loader: GH362 - Fix json output of escape chars
authorMark Young <marky@lunarg.com>
Tue, 14 Jun 2016 20:59:44 +0000 (14:59 -0600)
committerMark Young <marky@lunarg.com>
Tue, 14 Jun 2016 21:02:53 +0000 (15:02 -0600)
The strings from the JSON file already add escape characters.
So, \ becomes \\ in the JSON file strings.  However, the cJSON
library was adding \\ for ever encountered \ when converting
to a string.  This became messy as C:\\vulkanSDK\\layerfile.json
became C:\\\\vulkanSDK\\\\layerfile.json.

Change-Id: I006252e33d6e91e2bef704dd5dee0777105388a7

loader/cJSON.c

index f28eadb..fc3ba04 100644 (file)
@@ -423,7 +423,6 @@ static char *print_string_ptr(const char *str, printbuffer *p) {
         if ((unsigned char)*ptr > 31 && *ptr != '\"' && *ptr != '\\')
             *ptr2++ = *ptr++;
         else {
-            *ptr2++ = '\\';
             switch (token = *ptr++) {
             case '\\':
                 *ptr2++ = '\\';
@@ -432,19 +431,19 @@ static char *print_string_ptr(const char *str, printbuffer *p) {
                 *ptr2++ = '\"';
                 break;
             case '\b':
-                *ptr2++ = 'b';
+                *ptr2++ = '\b';
                 break;
             case '\f':
-                *ptr2++ = 'f';
+                *ptr2++ = '\f';
                 break;
             case '\n':
-                *ptr2++ = 'n';
+                *ptr2++ = '\n';
                 break;
             case '\r':
-                *ptr2++ = 'r';
+                *ptr2++ = '\r';
                 break;
             case '\t':
-                *ptr2++ = 't';
+                *ptr2++ = '\t';
                 break;
             default:
                 sprintf(ptr2, "u%04x", token);