summaryrefslogtreecommitdiff
path: root/json.c
Commit message (Collapse)AuthorAgeFilesLines
* json.c: Add t_byte and t_ubyte decodes.Gary E. Miller2019-05-171-0/+39
| | | | No changes to existing decodes.
* Replace gnu-ism: __attribute__ ((fallthrough));Gary E. Miller2018-12-271-1/+1
| | | | | | | | __attribute__ ((fallthrough)); is only in GCC after version 7. Not supported by other cc, and in fact throws warnings on other cc. The comment "/* FALLTHOUGH */" has the same effect when -Wimplicit-fallthrough=X is used, with X being 1, 2, 3, or 4.
* LICENSE: Update licenses for consistency. No functional changes.Gary E. Miller2018-11-191-1/+1
|
* Reconverge with microjson version..Eric S. Raymond2018-08-091-4/+5
|
* Abandon JSON_MINIMAL. The small amount of code it saves is not worth the ↵Eric S. Raymond2018-08-081-34/+1
| | | | clutter.
* json.c: ECMA-404 says JSON \u must have 4 hex digitsGary E. Miller2018-06-151-2/+3
| | | | | ECMA-404 says \u generates UNICODE, but json.c limits it to latin1 (0 to 0xff).
* Add bounds check in in_escape state of JSON parser.Eric S. Raymond2018-06-151-1/+7
|
* Suppress GCC 7.3.0 fallthrough warnings in intentional cases.Eric S. Raymond2018-06-151-0/+1
|
* json.c Allow for \u escapes with fewer than 4 digits.Gary E. Miller2018-06-141-3/+5
| | | | \u0, \u00, \u000 and \u000. The next charbetter be non-hex.
* json.c: Fail on bad escape string.Gary E. Miller2018-06-141-2/+3
|
* json.c be sure a string is NUL terminated.Gary E. Miller2018-06-141-0/+1
|
* json.c: fix overlong lines. No functional changes.Gary E. Miller2018-06-141-13/+18
|
* SPDXify the licerse references.Eric S. Raymond2018-03-081-1/+1
|
* JSON: note failure to handle doubles that are NaNs.Gary E. Miller2018-02-131-1/+1
|
* Initial creation of os_compat.h.Fred Wright2017-01-221-2/+1
| | | | | | | | | | | | | | | | | This creates a header for os_compat.c, and moves the related prototypes into it from gpsd_config.h (as created by SConstruct), after adding references to it to gpsd.h (via gpsd.h-tail) and a few other sources that need it but don't include gpsd.h. It also removes includes of <time.h> in the places where they were only needed for the code now removed from gpsd_config.h. TESTED: Ran "scons build-all check" on OSX 10.9 (with strlcat/strlcpy but no clock_gettime), OSX 10.12 (with strlcat/strlcpy and clock_gettime), and Ubuntu 14 (with clock_gettime but no strlcat/strlcpy). Also verified that fallback versions were not being included where unnecessary.
* Add Coverity suppressions for new invariant checks.Eric S. Raymond2016-01-291-0/+1
|
* Address Savannah bug #46804: JSON satellite view parsing is somewhat broken.Fred Wright2016-01-041-0/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fred Wright <fhgwright> writes: While trying the regression tests on a MacBook (PowerPC), I ran across some failures in the JSON unit test. Although this is ostensibly an endian issue, it turns out that the code for parsing satellite view data is actually incorrect for all processors, albeit more so for big-endian processors. The problem is that the three "integer" fields in struct satellite_t are defined as shorts, but parsed as ints by the JSON parser. On a big-endian processor, this causes the values to be misaddressed and hence have incorrect values, but even on a little-endian processor this is incorrect since it's storing four-byte values into two-byte fields. The unit tests don't catch this aspect, since the fields are favorably ordered such that the clobbered fields are clobbered before being written pseudo-correctly. I was able to demonstrate the "buffer overflow" misbehavior by modifying the test data for the last satellite to provide the fields in the reverse order from their order in the structure. The simple fix for this would be just to change the shorts to ints in the definition of struct satellite_t. On most processors, this doesn't even cost any memory, since the presence of the double forces eight-bye alignment, so the padded structure is 24 bytes regardless of whether the three fields in question are shorts or ints. However, there might be some processors with less strict alignment requirements where using shorts would actually be helpful. With the existing layout, the only possible fix is to add support for shorts to the JSON parser, and adjust the satellite-view parsing accordingly. The attached patch does that, as well as adding u_short support for completeness (though it's not currently used). It also provides the aforementioned change in the test data, in keeping with the philosophy of "create a test for what just failed, so it doesn't happen again". Note that using shorts for these fields would be more effective if the "used" field were also reduced to a short, instead of inheriting "int" from "bool". That would shrink the structure to 16 bytes. It could be further reduced to 12 bytes by using a float instead of a double for the "ss" field (and even a float is gross overkill for this purpose). This could all be more significant when MAXCHANNELS needs to be increased (again) to accommodate the deployment of the newer GNSSes.
* json_trace improvementJon Schlueter2015-10-061-2/+2
| | | | | guard on FILE * not being NULL initialize the buffer for easier debugging
* Still more whitespace fixupsGary E. Miller2015-04-301-2/+2
|
* Retire splint from our set of static analyzers.Eric S. Raymond2015-03-301-22/+5
| | | | | | | | | | | | | | | | | | | The proximate cause was that we've been seing emission of error messages that were randomly and disturbingly variable across different environments - notably Raspbian and Gentoo splint gave nontrivially different results than Ubuntu 14.10 splint. And this was *not* due to Ubuntu patches! A pristine splint built from the 3.1.2 tarball on Ubuntu didn't match the Raspbian and Gentoo results either. But this has been coming for a while. Easy access to more modern static analyzers such as coverity, scan-build and cppcheck has been decreasing the utility of splint, which is unmaintained and somewhat buggy and not easy to use. Only file not cleaned is ppsthread.c, because Gary has been working on it during this cleanup. All regression tests pass. PPS observed live on GR601-W.
* Fix erroneous comment.Eric S. Raymond2015-03-091-1/+1
|
* OS X needs a lot of time.hGary E. Miller2015-03-081-0/+1
| | | | | | gpsd_config.h needs time_t which is in time.h OS X builds now. Untested.
* Add str_{,v}appendf, use it everywhere.Zbigniew Chyla2015-01-211-2/+2
| | | | This change doesn't affect generated binary code.
* Add str_starts_with macro, use it instead of strncmp.Zbigniew Chyla2015-01-211-2/+2
| | | | This change doesn't affect generated binary code.
* Always use sizeof to get array sizeZbigniew Chyla2015-01-131-1/+1
| | | | | | Don't use constant/expression from an array's definition when referring to its size. Eliminates redundancy and avoids problems when array size changes. The change doesn't affect generated code.
* Note for anyone wo might want to re-use this.Eric S. Raymond2014-09-281-1/+5
|
* More microjson resync. All regression tests pass.Eric S. Raymond2014-09-281-64/+14
|
* Resynchronize with microjson.Eric S. Raymond2014-09-281-4/+21
|
* Cosmetic cleanup. All regression tests pass.Eric S. Raymond2014-09-271-22/+24
|
* Remove some unnecessary copies, All regression tests pass.Eric S. Raymond2014-09-271-23/+19
|
* Appease splint. All regression tests pass.Eric S. Raymond2014-09-271-22/+22
|
* Reconcile json.c with microjson's copy. All regression tests pass.Eric S. Raymond2014-09-271-8/+102
|
* Condition out extended JSON features.Eric S. Raymond2014-09-221-0/+2
| | | | All regression tests pass.
* Implement and test extended JSON array parsing.Eric S. Raymond2014-09-221-6/+44
| | | | | | Now supported: JSON arrays with int, unit, bool, and real elements. All regressiion tests pass.
* Typo fixes. All regression tests pass.Eric S. Raymond2014-09-171-4/+4
|
* Typo fixes.Eric S. Raymond2014-09-171-2/+2
|
* Silence compiler warnings about array subscripts of type 'char'Matt2014-09-101-11/+11
| | | | | | | | | | | | | | | | | | | | Cygwin GCC complains about code like isprint(c), where c is of type char. The isX() and toX() functions/macros (ISO C allows either) all accept an int, whose value should be either that of an unsigned char, or the special value EOF (== -1). So cast to unsigned char each argument to isprint, tolower, etc. Silences several warnings of the form: gpsutils.c: In function 'safe_atof': gpsutils.c:90:5: warning: array subscript has type 'char' [-Wchar-subscripts] while (isspace(*p)) { ^ gpsutils.c:188:2: warning: array subscript has type 'char' [-Wchar-subscripts] while (isdigit(*p)) { ^
* splint cleanup.Eric S. Raymond2013-10-011-0/+1
|
* The JSON parser now has an "ignore" type...Eric S. Raymond2013-10-011-2/+7
| | | | ...and it's used for the new dependent _text attributes.
* Nuke trailing whitespace in C source.Eric S. Raymond2012-09-071-3/+3
|
* Comply strictly with strict-aliasing rules by using memcpy...ukyg9e5r6k7gubiekd62012-09-071-9/+24
| | | | | | | | ...rather than using type-punning pointer casts. With optimization this will generate similarly-performing or even identical code on most architectures/compilers. Signed-off-by: Eric S. Raymond <esr@thyrsus.com>
* json parser: fix empty array bugChristian Gagneraud2012-06-201-0/+7
|
* Get rid of nullbool default - not used, and it causes a bad smell to Coverity.Eric S. Raymond2012-05-111-5/+1
|
* Armor the JSON code against zeroed value or attribute pointers.Eric S. Raymond2012-05-101-0/+9
| | | | | Should never happen, but having the bailout logic in plavce creates static invariants that should banish a bunch of Coverity warnings.
* Avoid locale problems in the NMEA driver, too.Eric S. Raymond2011-08-271-208/+2
|
* Optimize a bit. All regression tests pass.Eric S. Raymond2011-08-271-39/+30
|
* Avoid locale problems by inlining an old BSD version of strtod().Eric S. Raymond2011-08-271-6/+216
| | | | | This solves Berlios tracker bug #18328: Wrong/bad locale handling in json_read_object. All regression tests (including the JSON unit test) pass.
* Add an explanatory note.Eric S. Raymond2011-08-101-0/+1
|
* Use t_time consistently for timestamps.Eric S. Raymond2011-04-161-0/+2
| | | | All regression tests pass. Livetesting with cgps looks good.
* Cosmetic tweak: t_timestamp -> t_time.Eric S. Raymond2011-04-161-7/+7
|