ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant/taskdefs/optional ReplaceRegExp.java
Date Thu, 24 Apr 2003 09:27:02 GMT
bodewig     2003/04/24 02:27:02

  Modified:    src/main/org/apache/tools/ant/taskdefs Replace.java
               src/main/org/apache/tools/ant/taskdefs/optional
                        ReplaceRegExp.java
  Log:
  More code reuse
  
  Revision  Changes    Path
  1.39      +3 -17     ant/src/main/org/apache/tools/ant/taskdefs/Replace.java
  
  Index: Replace.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Replace.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- Replace.java	4 Apr 2003 13:51:11 -0000	1.38
  +++ Replace.java	24 Apr 2003 09:27:02 -0000	1.39
  @@ -402,24 +402,10 @@
               BufferedReader br = new BufferedReader(reader);
               BufferedWriter bw = new BufferedWriter(writer);
   
  -            // read the entire file into a StringBuffer
  -            //   size of work buffer may be bigger than needed
  -            //   when multibyte characters exist in the source file
  -            //   but then again, it might be smaller than needed on
  -            //   platforms like Windows where length can't be trusted
  -            int fileLengthInBytes = (int) src.length();
  -            StringBuffer tmpBuf = new StringBuffer(fileLengthInBytes);
  -            int readChar = 0;
  -            int totread = 0;
  -            while (true) {
  -                readChar = br.read();
  -                if (readChar < 0) { break; }
  -                tmpBuf.append((char) readChar);
  -                totread++;
  +            String buf = fileUtils.readFully(br);
  +            if (buf == null) {
  +                buf = "";
               }
  -
  -            // create a String so we can use indexOf
  -            String buf = tmpBuf.toString();
   
               //Preserve original string (buf) so we can compare the result
               String newString = new String(buf);
  
  
  
  1.20      +3 -0      ant/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java
  
  Index: ReplaceRegExp.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- ReplaceRegExp.java	24 Apr 2003 09:11:38 -0000	1.19
  +++ ReplaceRegExp.java	24 Apr 2003 09:27:02 -0000	1.20
  @@ -417,6 +417,9 @@
                   pw.flush();
               } else {
                   String buf = fileUtils.readFully(br);
  +                if (buf == null) {
  +                    buf = "";
  +                }
   
                   String res = doReplace(regex, subs, buf, options);
   
  
  
  

Mime
View raw message