Hey,

This patch adds a new private method in
tools.gnu.classpath.tools.appletviewer.TagParser.  This method is called
by the parseParams and its purpose is to unescape the given string,
that is, to replace all escaped strings with their one byte equivalent.
This method does the same thing as the glib's g_strcompress function.
This patch fixes also fixes the following Bugzilla Bug:

https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=216038

Cheers,
Tania

2006-11-29  Tania Bento  <[EMAIL PROTECTED]>

        * tools/gnu/classpath/tools/appletviewer/TagParser.java:
        (parseParams): Unescape 'val' before putting it into the Map.
        (unescapeString): New private method.

Index: tools/gnu/classpath/tools/appletviewer/TagParser.java
===================================================================
RCS file: /cvsroot/classpath/classpath/tools/gnu/classpath/tools/appletviewer/TagParser.java,v
retrieving revision 1.1
diff -u -r1.1 TagParser.java
--- tools/gnu/classpath/tools/appletviewer/TagParser.java	8 May 2006 20:36:46 -0000	1.1
+++ tools/gnu/classpath/tools/appletviewer/TagParser.java	29 Nov 2006 20:37:38 -0000
@@ -230,12 +230,66 @@
               t.archives = parseArchives(val, t);
               val = t.archives.toString();
             }
-
+          val = unescapeString(val);
           t.parameters.put(key.toLowerCase(), val);
         }
   }
   
   /**
+   * This method does the same thing as the g_strcompress function in glib.
+   * 
+   * @param value
+   * @return value in its original one-byte equivalence.
+   */
+  private static String unescapeString(String value)
+  {
+    String unescVal = "";
+    for (int i = 0; i < value.length(); i++)
+      {
+        if (i == value.length() - 1)
+          {
+            unescVal = unescVal.concat(value.substring(i));
+            break;
+          }
+        if (value.charAt(i) == '\\')
+          {
+            switch (value.charAt(i + 1))
+              {
+              case 'b':
+                unescVal = unescVal.concat("\b");
+                break;
+              case 'f':
+                unescVal = unescVal.concat("\f");
+                break;
+              case 'n':
+                unescVal = unescVal.concat("\n");
+                break;
+              case 'r':
+                unescVal = unescVal.concat("\r");
+                break;
+              case 't':
+                unescVal = unescVal.concat("\t");
+                break;
+              case '\\':
+                unescVal = unescVal.concat("\\");
+                break;
+              case '\"':
+                unescVal = unescVal.concat("\"");
+                break;
+              default:
+                unescVal = unescVal.concat("\\");
+                unescVal = unescVal.concat(value.substring(i + 1, i + 2));
+                break;
+              }
+            i++;
+          }
+        else
+          unescVal = unescVal.concat(value.substring(i, i + 1));
+      }
+    return unescVal;
+  }
+  
+  /**
    * Parses the archive string and returns a list.
    * 
    * @param the list of archives (comma-separated) in a String.

Reply via email to