How to remove specific function calls from source code...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • roman_tryk@gazeta.pl

    How to remove specific function calls from source code...

    Hi.
    I writing a lot of code that contains calls to my own Debug functions
    (like log).
    I want to produce a release from my code without this function calls,
    so I tried to write a program that reads a source code and removes this
    function calls with preg_replace...
    And here is a problem. I can't write a proper regexp for this use.

    There are some call that contains more that one argument or arguments
    are created dynamicaly, like:

    log($myVar1, $myVar2. " -". $myVar3, "(x:". $x .", y:". $y .")",
    $arg1.';('.$arg 2.');'.$arg3);

    Can anyone help me with it? I'm not good in Regular Expresions so maybe
    I can learn something from this group ;)

  • Kimmo Laine

    #2
    Re: How to remove specific function calls from source code...

    <roman_tryk@gaz eta.plwrote in message
    news:1157624198 .539861.83830@p 79g2000cwp.goog legroups.com...
    Hi.
    I writing a lot of code that contains calls to my own Debug functions
    (like log).
    I want to produce a release from my code without this function calls,
    so I tried to write a program that reads a source code and removes this
    function calls with preg_replace...
    And here is a problem. I can't write a proper regexp for this use.
    >
    There are some call that contains more that one argument or arguments
    are created dynamicaly, like:
    >
    log($myVar1, $myVar2. " -". $myVar3, "(x:". $x .", y:". $y .")",
    $arg1.';('.$arg 2.');'.$arg3);
    >
    Can anyone help me with it? I'm not good in Regular Expresions so maybe
    I can learn something from this group ;)

    Why not just change the debug function not to work?

    --
    "Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
    http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
    spam@outolempi. net || Gedoon-S @ IRCnet || rot13(xvzzb@bhg byrzcv.arg)


    Comment

    • davie

      #3
      Re: How to remove specific function calls from source code...


      Kimmo Laine wrote:
      <roman_tryk@gaz eta.plwrote in message
      news:1157624198 .539861.83830@p 79g2000cwp.goog legroups.com...
      Hi.
      I writing a lot of code that contains calls to my own Debug functions
      (like log).
      I want to produce a release from my code without this function calls,
      so I tried to write a program that reads a source code and removes this
      function calls with preg_replace...
      And here is a problem. I can't write a proper regexp for this use.

      There are some call that contains more that one argument or arguments
      are created dynamicaly, like:

      log($myVar1, $myVar2. " -". $myVar3, "(x:". $x .", y:". $y .")",
      $arg1.';('.$arg 2.');'.$arg3);

      Can anyone help me with it? I'm not good in Regular Expresions so maybe
      I can learn something from this group ;)
      >
      >
      Why not just change the debug function not to work?
      >
      --
      "Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
      http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
      spam@outolempi. net || Gedoon-S @ IRCnet || rot13(xvzzb@bhg byrzcv.arg)
      KISS
      Cut & Paste ???

      Comment

      • Petr Vileta

        #4
        Re: How to remove specific function calls from source code...

        <roman_tryk@gaz eta.plwrote in
        news:1157624198 .539861.83830@p 79g2000cwp.goog legroups.com...
        Hi.
        I writing a lot of code that contains calls to my own Debug functions
        (like log).
        I want to produce a release from my code without this function calls,
        so I tried to write a program that reads a source code and removes this
        function calls with preg_replace...
        And here is a problem. I can't write a proper regexp for this use.
        >
        There are some call that contains more that one argument or arguments
        are created dynamicaly, like:
        >
        log($myVar1, $myVar2. " -". $myVar3, "(x:". $x .", y:". $y .")",
        $arg1.';('.$arg 2.');'.$arg3);
        >
        Why you don't use some like this

        <?php
        global $DEBUG
        $DEBUG = 1;
        ?>
        .....
        <?php
        if($DEBUG) {
        log($myVar1, $myVar2. " -". $myVar3, "(x:". $x .", y:". $y .")",
        $arg1.';('.$arg 2.');'.$arg3); }
        ?>

        If you write code as I show you can disable your own debuging by change
        $DEBUG to 0 at the begin of all scripts.
        Or you can set $DEBUG value using some condition, for example
        if($_ENV["SERVER_NAM E"] == "Linux") {$DEBUG = 0;} else {$DEBUG = 1;}

        --

        Petr Vileta, Czech republic
        (My server rejects all messages from Yahoo and Hotmail. Send me your mail
        from another non-spammer site please.)


        Comment

        Working...