ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sbaill...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce P4Change.java
Date Wed, 14 Nov 2001 22:18:18 GMT
sbailliez    01/11/14 14:18:18

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/perforce
                        P4Change.java
  Log:
  Fixed the description bug reported by Gerhard Langs <glangs@eunet.at>
  Description is now backslashed so that delimiters are backslashed correctly and do not confuse
Oro.
  Based on a patch from Magesh Umasankar <umagesh@rediffmail.com>
  Added basic test case to ensure fix.
  
  Revision  Changes    Path
  1.5       +23 -2     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Change.java
  
  Index: P4Change.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Change.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- P4Change.java	2001/10/28 21:30:22	1.4
  +++ P4Change.java	2001/11/14 22:18:18	1.5
  @@ -58,8 +58,6 @@
   
   package org.apache.tools.ant.taskdefs.optional.perforce;
   
  -
  -
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.Project;
   
  @@ -120,6 +118,8 @@
                                       
                           } else if(util.match("/<enter description here>/",line))
{
   
  +                            // we need to escape the description in case there are /
  +                            description = backslash(description);
                               line = util.substitute("s/<enter description here>/"
+ description + "/", line);
                                           
                           } else if(util.match("/\\/\\//", line)) {
  @@ -134,6 +134,27 @@
                   }});
                   
           return stringbuf.toString();
  +    }
  +
  +    /**
  +     * Ensure that a string is backslashing slashes so that  it does not
  +     * confuse them with Perl substitution delimiter in Oro. Backslashes are
  +     * always backslashes in a string unless they escape the delimiter.
  +     * @param value the string to backslash for slashes
  +     * @return the backslashed string
  +     * @see < a href="http://jakarta.apache.org/oro/api/org/apache/oro/text/perl/Perl5Util.html#substitute(java.lang.String,%20java.lang.String)">Oro</a>
  +     */
  +    protected String backslash(String value){
  +        final StringBuffer buf = new StringBuffer(value.length());
  +        final int len = value.length();
  +        for (int i = 0; i < len; i++){
  +            char c = value.charAt(i);
  +            if (c == '/'){
  +                buf.append('\\');
  +            }
  +            buf.append(c);
  +        }
  +        return buf.toString();
       }
   
       /* Set Description Variable. */
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message