vivkin / gason

Lightweight and fast JSON parser for C++
MIT License
338 stars 51 forks source link

Implicit fallthrough? #40

Open r-barnes opened 4 months ago

r-barnes commented 4 months ago

Is there supposed to be a fallthrough on this line?

        *endptr = s++;
        switch (**endptr) {
        case '-':
            if (!isdigit(*s) && *s != '.') {
                *endptr = s;
                return JSON_BAD_NUMBER;
            }
        // Should I fallthrough here?
        case '0':
        case '1':
        case '2':
        case '3':
vivkin commented 4 months ago

Yes. Then call to string2double(*endptr...) where '-' handled properly. This cases [-0-9] for parsing numbers

r-barnes commented 1 month ago

Thanks, @vivkin . I've put up #41 to make the fallthrough explicit (works for C++17 and up).