stephan     2003/01/13 02:27:59

  Modified:    src/java/org/apache/cocoon/util IOUtils.java
  Log:
  Code rewritten to compile with java 1.3.
  
  Revision  Changes    Path
  1.9       +26 -19    xml-cocoon2/src/java/org/apache/cocoon/util/IOUtils.java
  
  Index: IOUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/util/IOUtils.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- IOUtils.java      11 Jan 2003 20:19:54 -0000      1.8
  +++ IOUtils.java      13 Jan 2003 10:27:57 -0000      1.9
  @@ -227,34 +227,41 @@
       StringBuffer buffer = new StringBuffer();
       for (int i = start; i < path.length; i++) {
   
  -      if(path[i].equals("..")) {
  -        int lio = buffer.lastIndexOf(File.separator);
  -        if(lio != -1) {
  -          buffer.setLength(lio);
  -          continue;
  -        }
  -      }
  -
         if (i > start) {
           buffer.append(File.separator);
         }
   
  -      boolean isJavaKeyword = isJavaKeyword(path[i]);
  +      if(path[i].equals("..")) {
  +        int lio = buffer.length()-2;
  +        while (lio>=0) {
  +          if (buffer.substring(lio).startsWith(File.separator))
  +            break;
  +
  +          lio--;
  +        }
  +
  +        if (lio>=0)
  +          buffer.setLength(lio);
   
  -      char[] chars = path[i].toCharArray();
  -      if (chars.length < 1 || !Character.isLetter(chars[0])) buffer.append('_');
  +      } else {
  +        char[] chars = path[i].toCharArray();
   
  -      for (int j = 0; j < chars.length; j++) {
  -        if (StringUtils.isAlphaNumeric(chars[j])) {
  -          buffer.append(chars[j]);
  -        } else {
  +        if (chars.length < 1 || !Character.isLetter(chars[0])) 
             buffer.append('_');
  +
  +        for (int j = 0; j < chars.length; j++) {
  +          if (StringUtils.isAlphaNumeric(chars[j])) {
  +            buffer.append(chars[j]);
  +          } else {
  +            buffer.append('_');
  +          }
           }
  -      }
   
  -      // Append the suffix if necessary.
  -      if(isJavaKeyword)
  +        // Append the suffix if necessary.
  +        if(isJavaKeyword(path[i]))
             buffer.append(keywordSuffix);
  +      }
  +
       }
       return buffer.toString();
     }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to