Changeset 8377


Ignore:
Timestamp:
May 11, 2009, 4:29:12 PM (12 years ago)
Author:
charles
Message:

(1.5x libT) backport the fix for #2046 - JSON parser doesn't handle floating point numbers right in locales that don't use a period as the decimal point

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.5x/libtransmission/JSON_parser.c

    r7664 r8377  
    5555#include <ctype.h>
    5656#include <float.h>
     57#include <locale.h>
    5758#include <stddef.h>
    5859#include <stdio.h>
     
    477478                        value.vu.str.length = jc->parse_buffer_count;
    478479                    } else {
     480                        /* the json spec requires a '.' decimal point regardless of locale */
     481                        char numeric[128];
     482                        snprintf(numeric, sizeof(numeric), "%s", setlocale(LC_NUMERIC, NULL));
     483                        setlocale(LC_NUMERIC, "POSIX" );
    479484                        sscanf(jc->parse_buffer, "%Lf", &value.vu.float_value);
     485                        value.vu.float_value = strtod(jc->parse_buffer, NULL);
     486                        setlocale(LC_NUMERIC, numeric);
    480487                    }
    481488                    break;
Note: See TracChangeset for help on using the changeset viewer.