umagesh     2003/10/03 15:21:49

  Modified:    .        WHATSNEW
               src/etc/testcases/taskdefs/optional/i18n/translate/expected/de
                        template.txt
               src/etc/testcases/taskdefs/optional/i18n/translate/input
                        template.txt
               src/main/org/apache/tools/ant/taskdefs/optional/i18n
                        Translate.java
  Log:
  Translate task does not remove tokens when a key is not found.   It logs a 
verbose message.  Bugzilla Report 13936.
  
  Revision  Changes    Path
  1.506     +16 -2     ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.505
  retrieving revision 1.506
  diff -u -r1.505 -r1.506
  --- WHATSNEW  23 Sep 2003 14:33:43 -0000      1.505
  +++ WHATSNEW  3 Oct 2003 22:21:49 -0000       1.506
  @@ -1,5 +1,19 @@
  -Changes from Ant 1.5.4 to current CVS version
  -=============================================
  +Changes from Ant 1.6 to current cvs version
  +===========================================
  +
  +Changes that could break older environments:
  +--------------------------------------------
  +
  +Fixed bugs:
  +-----------
  +* Translate task does not remove tokens when a key is not found.  
  +  It logs a verbose message.  Bugzilla Report 13936.
  +
  +Other changes:
  +--------------
  +
  +Changes from Ant 1.5.4 to Ant 1.6Beta1
  +======================================
   
   Changes that could break older environments:
   --------------------------------------------
  
  
  
  1.3       +1 -1      
ant/src/etc/testcases/taskdefs/optional/i18n/translate/expected/de/template.txt
  
  Index: template.txt
  ===================================================================
  RCS file: 
/home/cvs/ant/src/etc/testcases/taskdefs/optional/i18n/translate/expected/de/template.txt,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- template.txt      30 Jun 2003 13:45:17 -0000      1.2
  +++ template.txt      3 Oct 2003 22:21:49 -0000       1.3
  @@ -1 +1 @@
  -Diese ist eine Demo Datei für die translate_Aufgabe.
  +Diese ist eine Demo Datei für die translate_Aufgabe @[EMAIL PROTECTED]
  
  
  
  1.3       +1 -1      
ant/src/etc/testcases/taskdefs/optional/i18n/translate/input/template.txt
  
  Index: template.txt
  ===================================================================
  RCS file: 
/home/cvs/ant/src/etc/testcases/taskdefs/optional/i18n/translate/input/template.txt,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- template.txt      19 Jul 2003 14:29:40 -0000      1.2
  +++ template.txt      3 Oct 2003 22:21:49 -0000       1.3
  @@ -1 +1 @@
  [EMAIL PROTECTED]@ @is@ @a@ @demo@ @file@ @for@ @the@ [EMAIL PROTECTED]@.
  [EMAIL PROTECTED]@ @is@ @a@ @demo@ @file@ @for@ @the@ [EMAIL PROTECTED]@ 
@[EMAIL PROTECTED]
  
  
  
  1.32      +53 -53    
ant/src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java
  
  Index: Translate.java
  ===================================================================
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/i18n/Translate.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- Translate.java    22 Aug 2003 15:25:44 -0000      1.31
  +++ Translate.java    3 Oct 2003 22:21:49 -0000       1.32
  @@ -577,66 +577,66 @@
                           lineTokenizer.setIncludeDelims(true);
                           line = lineTokenizer.getToken(in);
                           while ((line) != null) {
  -                        // 2003-02-21 new replace algorithm by tbee ([EMAIL 
PROTECTED])
  -                        // because it wasn't able to replace something like 
"@aaa;@bbb;"
  +                            // 2003-02-21 new replace algorithm by tbee 
([EMAIL PROTECTED])
  +                            // because it wasn't able to replace something 
like "@aaa;@bbb;"
   
  -                        // is there a startToken
  -                        // and there is still stuff following the startToken
  -                        int startIndex = line.indexOf(startToken);
  -                        while (startIndex >= 0
  -                            && (startIndex + startToken.length()) <= 
line.length()) {
  -                            // the new value, this needs to be here
  -                            // because it is required to calculate the next 
position to search from
  -                            // at the end of the loop
  -                            String replace = null;
  -
  -                            // we found a starttoken, is there an endtoken 
following?
  -                            // start at token+tokenlength because start and 
end
  -                            // token may be indentical
  -                            int endIndex = line.indexOf(endToken, startIndex 
+ startToken.length());
  -                            if (endIndex < 0) {
  -                                startIndex += 1;
  -                            } else {
  -                                // grab the token
  -                                String token
  -                                    = line.substring(startIndex + 
startToken.length(), endIndex);
  -
  -                                // If there is a white space or = or :, then
  -                                // it isn't to be treated as a valid key.
  -                                boolean validToken = true;
  -                                for (int k = 0; k < token.length() && 
validToken; k++) {
  -                                    char c = token.charAt(k);
  -                                    if (c == ':' || c == '='
  -                                        || Character.isSpaceChar(c)) {
  -                                        validToken = false;
  -                                    }
  -                                }
  -                                if (!validToken) {
  +                            // is there a startToken
  +                            // and there is still stuff following the 
startToken
  +                            int startIndex = line.indexOf(startToken);
  +                            while (startIndex >= 0
  +                                && (startIndex + startToken.length()) <= 
line.length()) {
  +                                // the new value, this needs to be here
  +                                // because it is required to calculate the 
next position to search from
  +                                // at the end of the loop
  +                                String replace = null;
  +
  +                                // we found a starttoken, is there an 
endtoken following?
  +                                // start at token+tokenlength because start 
and end
  +                                // token may be indentical
  +                                int endIndex = line.indexOf(endToken, 
startIndex + startToken.length());
  +                                if (endIndex < 0) {
                                       startIndex += 1;
                                   } else {
  -                                    // find the replace string
  -                                    if (resourceMap.containsKey(token)) {
  -                                        replace = (String) 
resourceMap.get(token);
  -                                    } else {
  -                                        replace = token;
  +                                    // grab the token
  +                                    String token
  +                                        = line.substring(startIndex + 
startToken.length(), endIndex);
  +
  +                                    // If there is a white space or = or :, 
then
  +                                    // it isn't to be treated as a valid key.
  +                                    boolean validToken = true;
  +                                    for (int k = 0; k < token.length() && 
validToken; k++) {
  +                                        char c = token.charAt(k);
  +                                        if (c == ':' || c == '='
  +                                            || Character.isSpaceChar(c)) {
  +                                            validToken = false;
  +                                        }
                                       }
  +                                    if (!validToken) {
  +                                        startIndex += 1;
  +                                    } else {
  +                                        // find the replace string
  +                                        if (resourceMap.containsKey(token)) {
  +                                            replace = (String) 
resourceMap.get(token);
  +                                        } else {
  +                                            log("Replacement string missing 
for: "
  +                                                + token, 
Project.MSG_VERBOSE);
  +                                            replace = startToken + token + 
endToken;
  +                                        }
  +
  +
  +                                        // generate the new line
  +                                        line = line.substring(0, startIndex)
  +                                             + replace
  +                                             + line.substring(endIndex + 
endToken.length());
   
  -
  -                                    // generate the new line
  -                                    line = line.substring(0, startIndex)
  -                                         + replace
  -                                         + line.substring(endIndex + 
endToken.length());
  -
  -                                    // set start position for next search
  -                                    startIndex += replace.length();
  +                                        // set start position for next search
  +                                        startIndex += replace.length();
  +                                    }
                                   }
  -                            }
  -
  -                            // find next starttoken
  -                            startIndex = line.indexOf(startToken, 
startIndex);
  -                        }
  -
   
  +                                // find next starttoken
  +                                startIndex = line.indexOf(startToken, 
startIndex);
  +                            }
                               out.write(line);
                               line = lineTokenizer.getToken(in);
                           }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to