~james-page/ubuntu/saucy/openvswitch/1.12-snapshot

« back to all changes in this revision

Viewing changes to lib/json.c

  • Committer: James Page
  • Date: 2013-08-21 10:16:57 UTC
  • mfrom: (1.1.20)
  • Revision ID: james.page@canonical.com-20130821101657-3o0z0qeiv5zkwlzi
New upstream snapshot

Show diffs side-by-side

added added

removed removed

Lines of Context:
620
620
    significand = 0;
621
621
    if (*cp == '0') {
622
622
        cp++;
623
 
        if (isdigit(*cp)) {
 
623
        if (isdigit((unsigned char) *cp)) {
624
624
            json_error(p, "leading zeros not allowed");
625
625
            return;
626
626
        }
627
 
    } else if (isdigit(*cp)) {
 
627
    } else if (isdigit((unsigned char) *cp)) {
628
628
        do {
629
629
            if (significand <= ULLONG_MAX / 10) {
630
630
                significand = significand * 10 + (*cp - '0');
635
635
                }
636
636
            }
637
637
            cp++;
638
 
        } while (isdigit(*cp));
 
638
        } while (isdigit((unsigned char) *cp));
639
639
    } else {
640
640
        json_error(p, "'-' must be followed by digit");
641
641
        return;
644
644
    /* Optional fraction. */
645
645
    if (*cp == '.') {
646
646
        cp++;
647
 
        if (!isdigit(*cp)) {
 
647
        if (!isdigit((unsigned char) *cp)) {
648
648
            json_error(p, "decimal point must be followed by digit");
649
649
            return;
650
650
        }
656
656
                imprecise = true;
657
657
            }
658
658
            cp++;
659
 
        } while (isdigit(*cp));
 
659
        } while (isdigit((unsigned char) *cp));
660
660
    }
661
661
 
662
662
    /* Optional exponent. */
672
672
            cp++;
673
673
        }
674
674
 
675
 
        if (!isdigit(*cp)) {
 
675
        if (!isdigit((unsigned char) *cp)) {
676
676
            json_error(p, "exponent must contain at least one digit");
677
677
            return;
678
678
        }
685
685
            }
686
686
            exponent = exponent * 10 + (*cp - '0');
687
687
            cp++;
688
 
        } while (isdigit(*cp));
 
688
        } while (isdigit((unsigned char) *cp));
689
689
 
690
690
        if (negative_exponent) {
691
691
            pow10 -= exponent;
1026
1026
    stream = fopen(file_name, "r");
1027
1027
    if (!stream) {
1028
1028
        return json_string_create_nocopy(
1029
 
            xasprintf("error opening \"%s\": %s", file_name, strerror(errno)));
 
1029
            xasprintf("error opening \"%s\": %s", file_name,
 
1030
                      ovs_strerror(errno)));
1030
1031
    }
1031
1032
    json = json_from_stream(stream);
1032
1033
    fclose(stream);
1063
1064
    if (ferror(stream)) {
1064
1065
        json_destroy(json);
1065
1066
        json = json_string_create_nocopy(
1066
 
            xasprintf("error reading JSON stream: %s", strerror(errno)));
 
1067
            xasprintf("error reading JSON stream: %s", ovs_strerror(errno)));
1067
1068
    }
1068
1069
 
1069
1070
    return json;