]> thyrsus.com Git - microjson.git/commitdiff
Rsync with GPSD version.
authorEric S. Raymond <esr@thyrsus.com>
Sun, 28 Sep 2014 12:42:00 +0000 (08:42 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Sun, 28 Sep 2014 12:42:00 +0000 (08:42 -0400)
mjson.c

diff --git a/mjson.c b/mjson.c
index 515770766411c79f6f934e2dc6c6f0ba6569b10c..c8d32641d2b97b74a627e26e67c34d7906a58bc6 100644 (file)
--- a/mjson.c
+++ b/mjson.c
@@ -289,10 +289,9 @@ static int json_internal_read_object(const char *cp,
            }
            break;
        case in_attr:
-           if (pattr == NULL) {
+           if (pattr == NULL)
                /* don't update end here, leave at attribute start */
                return JSON_ERR_NULLPTR;
-           }
            if (*cp == '"') {
                *pattr++ = '\0';
                json_debug_trace((1, "Collected attribute name %s\n",
@@ -360,10 +359,9 @@ static int json_internal_read_object(const char *cp,
            }
            break;
        case in_val_string:
-           if (pval == NULL) {
+           if (pval == NULL)
                /* don't update end here, leave at value start */
                return JSON_ERR_NULLPTR;
-           }
            if (*cp == '\\')
                state = in_escape;
            else if (*cp == '"') {
@@ -379,11 +377,9 @@ static int json_internal_read_object(const char *cp,
                *pval++ = *cp;
            break;
        case in_escape:
-           if (pval == NULL) {
-               if (end != NULL)
-                   *end = cp;
+           if (pval == NULL)
+               /* don't update end here, leave at value start */
                return JSON_ERR_NULLPTR;
-           }
            switch (*cp) {
            case 'b':
                *pval++ = '\b';
@@ -414,10 +410,9 @@ static int json_internal_read_object(const char *cp,
            state = in_val_string;
            break;
        case in_val_token:
-           if (pval == NULL) {
+           if (pval == NULL)
                /* don't update end here, leave at value start */
                return JSON_ERR_NULLPTR;
-           }
            if (isspace((unsigned char) *cp) || *cp == ',' || *cp == '}') {
                *pval = '\0';
                json_debug_trace((1, "Collected token value %s.\n", valbuf));
@@ -530,11 +525,9 @@ static int json_internal_read_object(const char *cp,
                    }
                    break;
                case t_character:
-                   if (strlen(valbuf) > 1) {
-                       if (end != NULL)
-                           *end = cp;
+                   if (strlen(valbuf) > 1)
+                       /* don't update end here, leave at value start */
                        return JSON_ERR_STRLONG;
-                   }
                    else
                        lptr[0] = valbuf[0];
                    break;