2002/css-validator/org/w3c/css/util Warning.java,1.13,1.14

Update of /sources/public/2002/css-validator/org/w3c/css/util
In directory hutz:/tmp/cvs-serv14416/css/util

Modified Files:
	Warning.java 
Log Message:
replaceFirst issue with $ 

Index: Warning.java
===================================================================
RCS file: /sources/public/2002/css-validator/org/w3c/css/util/Warning.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- Warning.java	12 Aug 2011 13:04:25 -0000	1.13
+++ Warning.java	29 Aug 2011 12:36:55 -0000	1.14
@@ -222,9 +222,26 @@
         } else {
             // replace all parameters.
             if (args != null) {
-                for (j = 0; j < args.length; j++) {
-                    str = str.replaceFirst("%s", args[j]);
+                StringBuilder sb = new StringBuilder();
+                int idx = 0;
+                int start = 0;
+                for (String subst : args) {
+                    idx = str.indexOf("%s", idx);
+                    if (idx < 0) {
+                        // TODO report error
+                        System.err.println("*** WARNING ISSUE: "+warning);
+                        System.err.println("*** WARNING ISSUE: "+ac.getMsg().getWarningString(warning));
+                        System.err.println("*** WARNING ISSUE: got "+args.length+" args entries");
+                        break;
+                    }
+                    sb.append(str.substring(start, idx));
+                    sb.append(subst);
+                    idx+=2;
+                    start=idx;
                 }
+                // and add the last part
+                sb.append(str.substring(start));
+                return sb.toString();
             }
             return str;
         }

Received on Monday, 29 August 2011 12:37:02 UTC