Ignore:
Timestamp:
May 9, 2009, 6:01:29 PM (13 years ago)
Author:
charles
Message:

(trunk libT) #2046: fix JSON bug when parsing floating point numbers in some locales

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/JSON_parser.c

    r7632 r8372  
    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.