Backout fix for bug 365345 due to regressions. a=bsmedberg on IRC
authorsmontagu@smontagu.org
Thu, 26 Apr 2007 11:56:30 -0700
changeset 844 a39fcc86115d533010cac63304e385e6156c09a0
parent 843 5ccae52bf036f1ae7d6364e0c985be893ceccb10
child 845 df7a3c8ffeeaba229067efee5a20e21dae0dd877
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs365345
milestone1.9a4pre
Backout fix for bug 365345 due to regressions. a=bsmedberg on IRC
xpcom/ds/nsPersistentProperties.cpp
--- a/xpcom/ds/nsPersistentProperties.cpp
+++ b/xpcom/ds/nsPersistentProperties.cpp
@@ -171,109 +171,91 @@ nsPersistentProperties::Load(nsIInputStr
         c = Read();
       }
       if (c < 0) {
         break;
       }
       static const char trimThese[] = " \t";
       key.Trim(trimThese, PR_FALSE, PR_TRUE);
       c = Read();
-      nsAutoString value, tempValue;
-      while ((c >= 0) && (c != '\r') && (c != '\n')) {
-        if (c == '\\') {
-          c = Read();
-          switch(c) {
-            case '\r':
-            case '\n':
-              // Only skip first EOL characters and then next line's
-              // whitespace characters. Skipping all EOL characters
-              // and all upcoming whitespace is too agressive.
-              if (c == '\r')
-                c = Read();
-              if (c == '\n')
-                c = Read();
-              while (c == ' ' || c == '\t')
-                c = Read();
-              continue;
-            default:
-              tempValue.Append((PRUnichar) '\\');
-              tempValue.Append((PRUnichar) c);
-          } // switch(c)
-        } else {
-          tempValue.Append((PRUnichar) c);
-        }
-        c = Read();
-      }
-      tempValue.Trim(trimThese, PR_TRUE, PR_TRUE);
-
+      nsAutoString value;
       PRUint32 state  = 0;
       PRUnichar uchar = 0;
-      for (PRUint32 i = 0; i < tempValue.Length(); ++i) {
-        PRUnichar ch = tempValue[i];
+      while ((c >= 0) && (c != '\r') && (c != '\n')) {
         switch(state) {
           case 0:
-           if (ch == '\\') {
-             ++i;
-             if (i == tempValue.Length())
-               break;
-             ch = tempValue[i];
-             switch(ch) {
+           if (c == '\\') {
+             c = Read();
+             switch(c) {
+               case '\r':
+               case '\n':
+                 // Only skip first EOL characters and then next line's
+                 // whitespace characters. Skipping all EOL characters
+                 // and all upcoming whitespace is too agressive.
+                 if (c == '\r')
+                    c = Read();
+                 if (c == '\n')
+                    c = Read();
+                 while (c == ' ' || c == '\t')
+                    c = Read();
+                 continue;
                case 'u':
                case 'U':
                  state = 1;
                  uchar=0;
                  break;
                case 't':
                  value.Append(PRUnichar('\t'));
                  break;
                case 'n':
                  value.Append(PRUnichar('\n'));
                  break;
                case 'r':
                  value.Append(PRUnichar('\r'));
                  break;
                default:
-                 value.Append(ch);
-             } // switch(ch)
+                 value.Append((PRUnichar) c);
+             } // switch(c)
            } else {
-             value.Append(ch);
+             value.Append((PRUnichar) c);
            }
-           continue;
+           c = Read();
+           break;
          case 1:
          case 2:
          case 3:
          case 4:
-           if (('0' <= ch) && (ch <= '9')) {
-               uchar = (uchar << 4) | (ch - '0');
+           if (('0' <= c) && (c <= '9')) {
+              uchar = (uchar << 4) | (c - '0');
               state++;
-              continue;
-           }
-           if (('a' <= ch) && (ch <= 'f')) {
-              uchar = (uchar << 4) | (ch - 'a' + 0x0a);
+              c = Read();
+           } else if (('a' <= c) && (c <= 'f')) {
+              uchar = (uchar << 4) | (c - 'a' + 0x0a);
               state++;
-              continue;
-           }
-           if (('A' <= ch) && (ch <= 'F')) {
-              uchar = (uchar << 4) | (ch - 'A' + 0x0a);
+              c = Read();
+           } else if (('A' <= c) && (c <= 'F')) {
+              uchar = (uchar << 4) | (c - 'A' + 0x0a);
               state++;
-              continue;
+              c = Read();
+           } else {
+             value.Append((PRUnichar) uchar);
+             state = 0;
            }
-           value.Append((PRUnichar) uchar);
-           state = 0;
            break;
          case 5:
            value.Append((PRUnichar) uchar);
            state = 0;
         }
       }
       if (state != 0) {
         value.Append((PRUnichar) uchar);
         state = 0;
       }
-      
+
+      value.Trim(trimThese, PR_TRUE, PR_TRUE);
       nsAutoString oldValue;
       mSubclass->SetStringProperty(NS_ConvertUTF16toUTF8(key), value, oldValue);
     }
   }
   mIn->Close();
   NS_RELEASE(mIn);
 
   return NS_OK;