ctags.rb 1.0.0 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/Gemfile +2 -1
- data/README.md +49 -0
- data/Rakefile +19 -0
- data/bench.rb +28 -0
- data/ctags.rb.gemspec +1 -1
- data/ext/.gitignore +1 -1
- data/ext/extconf.rb +30 -6
- data/ext/vendor/exuberant-ctags/entry.c +70 -1
- data/ext/vendor/exuberant-ctags/main.c +68 -7
- data/ext/vendor/exuberant-ctags/options.c +12 -12
- data/ext/vendor/exuberant-ctags/options.h +1 -1
- data/ext/vendor/exuberant-ctags/parse.c +2 -2
- data/ext/vendor/exuberant-ctags/read.c +8 -3
- data/ext/vendor/exuberant-ctags/read.h +4 -1
- data/ext/vendor/exuberant-ctags/routines.c +31 -8
- data/ext/vendor/exuberant-ctags/ruby.c +62 -7
- data/ext/vendor/fmemopen/README.md +49 -0
- data/ext/vendor/fmemopen/fmemopen.c +92 -0
- data/ext/vendor/fmemopen/fmemopen.h +52 -0
- data/ext/vendor/jansson-2.5/CHANGES +554 -0
- data/ext/vendor/jansson-2.5/LICENSE +19 -0
- data/ext/vendor/jansson-2.5/Makefile.am +15 -0
- data/ext/vendor/jansson-2.5/Makefile.in +825 -0
- data/ext/vendor/jansson-2.5/README.rst +63 -0
- data/ext/vendor/jansson-2.5/aclocal.m4 +9674 -0
- data/ext/vendor/jansson-2.5/config.guess +1530 -0
- data/ext/vendor/jansson-2.5/config.h.in +84 -0
- data/ext/vendor/jansson-2.5/config.sub +1782 -0
- data/ext/vendor/jansson-2.5/configure +13931 -0
- data/ext/vendor/jansson-2.5/configure.ac +57 -0
- data/ext/vendor/jansson-2.5/depcomp +708 -0
- data/ext/vendor/jansson-2.5/doc/Makefile.am +20 -0
- data/ext/vendor/jansson-2.5/doc/Makefile.in +401 -0
- data/ext/vendor/jansson-2.5/doc/README +5 -0
- data/ext/vendor/jansson-2.5/doc/apiref.rst +1487 -0
- data/ext/vendor/jansson-2.5/doc/changes.rst +5 -0
- data/ext/vendor/jansson-2.5/doc/conf.py +217 -0
- data/ext/vendor/jansson-2.5/doc/conformance.rst +114 -0
- data/ext/vendor/jansson-2.5/doc/ext/refcounting.py +59 -0
- data/ext/vendor/jansson-2.5/doc/gettingstarted.rst +237 -0
- data/ext/vendor/jansson-2.5/doc/github_commits.c +192 -0
- data/ext/vendor/jansson-2.5/doc/index.rst +53 -0
- data/ext/vendor/jansson-2.5/doc/portability.rst +52 -0
- data/ext/vendor/jansson-2.5/doc/tutorial.rst +286 -0
- data/ext/vendor/jansson-2.5/doc/upgrading.rst +76 -0
- data/ext/vendor/jansson-2.5/install-sh +527 -0
- data/ext/vendor/jansson-2.5/jansson.pc.in +10 -0
- data/ext/vendor/jansson-2.5/ltmain.sh +9661 -0
- data/ext/vendor/jansson-2.5/missing +331 -0
- data/ext/vendor/jansson-2.5/src/Makefile.am +24 -0
- data/ext/vendor/jansson-2.5/src/Makefile.in +613 -0
- data/ext/vendor/jansson-2.5/src/dump.c +456 -0
- data/ext/vendor/jansson-2.5/src/error.c +63 -0
- data/ext/vendor/jansson-2.5/src/hashtable.c +360 -0
- data/ext/vendor/jansson-2.5/src/hashtable.h +180 -0
- data/ext/vendor/jansson-2.5/src/jansson.def +63 -0
- data/ext/vendor/jansson-2.5/src/jansson.h +281 -0
- data/ext/vendor/jansson-2.5/src/jansson_config.h +39 -0
- data/ext/vendor/jansson-2.5/src/jansson_config.h.in +39 -0
- data/ext/vendor/jansson-2.5/src/jansson_private.h +93 -0
- data/ext/vendor/jansson-2.5/src/load.c +1077 -0
- data/ext/vendor/jansson-2.5/src/memory.c +56 -0
- data/ext/vendor/jansson-2.5/src/pack_unpack.c +762 -0
- data/ext/vendor/jansson-2.5/src/strbuffer.c +116 -0
- data/ext/vendor/jansson-2.5/src/strbuffer.h +33 -0
- data/ext/vendor/jansson-2.5/src/strconv.c +134 -0
- data/ext/vendor/jansson-2.5/src/utf.c +190 -0
- data/ext/vendor/jansson-2.5/src/utf.h +39 -0
- data/ext/vendor/jansson-2.5/src/value.c +950 -0
- data/ext/vendor/jansson-2.5/test/Makefile.am +10 -0
- data/ext/vendor/jansson-2.5/test/Makefile.in +684 -0
- data/ext/vendor/jansson-2.5/test/bin/Makefile.am +5 -0
- data/ext/vendor/jansson-2.5/test/bin/Makefile.in +498 -0
- data/ext/vendor/jansson-2.5/test/bin/json_process.c +349 -0
- data/ext/vendor/jansson-2.5/test/run-suites +50 -0
- data/ext/vendor/jansson-2.5/test/scripts/run-tests.sh +100 -0
- data/ext/vendor/jansson-2.5/test/scripts/valgrind.sh +35 -0
- data/ext/vendor/jansson-2.5/test/suites/Makefile.am +2 -0
- data/ext/vendor/jansson-2.5/test/suites/Makefile.in +580 -0
- data/ext/vendor/jansson-2.5/test/suites/api/Makefile.am +34 -0
- data/ext/vendor/jansson-2.5/test/suites/api/Makefile.in +632 -0
- data/ext/vendor/jansson-2.5/test/suites/api/check-exports +23 -0
- data/ext/vendor/jansson-2.5/test/suites/api/run +36 -0
- data/ext/vendor/jansson-2.5/test/suites/api/test_array.c +432 -0
- data/ext/vendor/jansson-2.5/test/suites/api/test_copy.c +318 -0
- data/ext/vendor/jansson-2.5/test/suites/api/test_dump.c +190 -0
- data/ext/vendor/jansson-2.5/test/suites/api/test_dump_callback.c +81 -0
- data/ext/vendor/jansson-2.5/test/suites/api/test_equal.c +189 -0
- data/ext/vendor/jansson-2.5/test/suites/api/test_load.c +166 -0
- data/ext/vendor/jansson-2.5/test/suites/api/test_load_callback.c +75 -0
- data/ext/vendor/jansson-2.5/test/suites/api/test_loadb.c +36 -0
- data/ext/vendor/jansson-2.5/test/suites/api/test_memory_funcs.c +82 -0
- data/ext/vendor/jansson-2.5/test/suites/api/test_number.c +73 -0
- data/ext/vendor/jansson-2.5/test/suites/api/test_object.c +511 -0
- data/ext/vendor/jansson-2.5/test/suites/api/test_pack.c +283 -0
- data/ext/vendor/jansson-2.5/test/suites/api/test_simple.c +199 -0
- data/ext/vendor/jansson-2.5/test/suites/api/test_unpack.c +373 -0
- data/ext/vendor/jansson-2.5/test/suites/api/util.h +74 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/encoded-surrogate-half/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/encoded-surrogate-half/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-after-backslash/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-after-backslash/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-array/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-array/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-bigger-int/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-bigger-int/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-escape/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-escape/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-exponent/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-exponent/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-identifier/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-identifier/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-int/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-int/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-real-after-e/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-real-after-e/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-string/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/invalid-utf-8-in-string/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/lone-invalid-utf-8/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/lone-invalid-utf-8/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/lone-utf-8-continuation-byte/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/lone-utf-8-continuation-byte/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/not-in-unicode-range/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/not-in-unicode-range/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/overlong-3-byte-encoding/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/overlong-3-byte-encoding/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/overlong-4-byte-encoding/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/overlong-4-byte-encoding/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/overlong-ascii-encoding/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/overlong-ascii-encoding/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/restricted-utf-8/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/restricted-utf-8/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/run +27 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/truncated-utf-8/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid-unicode/truncated-utf-8/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/apostrophe/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/apostrophe/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/ascii-unicode-identifier/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/ascii-unicode-identifier/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/brace-comma/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/brace-comma/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/bracket-comma/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/bracket-comma/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/bracket-one-comma/error.normal +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/bracket-one-comma/error.strip +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/bracket-one-comma/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/empty/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/empty/input +0 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/escaped-null-byte-in-string/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/escaped-null-byte-in-string/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/extra-comma-in-array/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/extra-comma-in-array/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/extra-comma-in-multiline-array/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/extra-comma-in-multiline-array/input +6 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/garbage-after-newline/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/garbage-after-newline/input +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/garbage-at-the-end/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/garbage-at-the-end/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/integer-starting-with-zero/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/integer-starting-with-zero/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/invalid-escape/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/invalid-escape/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/invalid-identifier/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/invalid-identifier/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/invalid-negative-integer/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/invalid-negative-integer/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/invalid-negative-real/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/invalid-negative-real/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/invalid-second-surrogate/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/invalid-second-surrogate/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/lone-open-brace/error.normal +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/lone-open-brace/error.strip +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/lone-open-brace/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/lone-open-bracket/error.normal +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/lone-open-bracket/error.strip +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/lone-open-bracket/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/lone-second-surrogate/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/lone-second-surrogate/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/minus-sign-without-number/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/minus-sign-without-number/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/negative-integer-starting-with-zero/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/negative-integer-starting-with-zero/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/null-byte-in-string/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/null-byte-in-string/input +0 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/null-byte-in-string/nostrip +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/null-byte-outside-string/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/null-byte-outside-string/input +0 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/null-byte-outside-string/nostrip +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/null/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/null/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/object-apostrophes/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/object-apostrophes/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/object-garbage-at-end/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/object-garbage-at-end/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/object-in-unterminated-array/error.normal +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/object-in-unterminated-array/error.strip +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/object-in-unterminated-array/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/object-no-colon/error.normal +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/object-no-colon/error.strip +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/object-no-colon/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/object-no-value/error.normal +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/object-no-value/error.strip +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/object-no-value/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/object-unterminated-value/error.normal +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/object-unterminated-value/error.strip +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/object-unterminated-value/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/real-garbage-after-e/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/real-garbage-after-e/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/real-negative-overflow/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/real-negative-overflow/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/real-positive-overflow/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/real-positive-overflow/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/real-truncated-at-e/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/real-truncated-at-e/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/real-truncated-at-point/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/real-truncated-at-point/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/run +57 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/tab-character-in-string/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/tab-character-in-string/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/too-big-negative-integer/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/too-big-negative-integer/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/too-big-positive-integer/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/too-big-positive-integer/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/truncated-unicode-surrogate/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/truncated-unicode-surrogate/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/unicode-identifier/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/unicode-identifier/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-array-and-object/error.normal +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-array-and-object/error.strip +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-array-and-object/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-array/error.normal +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-array/error.strip +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-array/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-empty-key/error.normal +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-empty-key/error.strip +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-empty-key/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-key/error.normal +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-key/error.strip +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-key/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-object-and-array/error +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-object-and-array/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-string/error.normal +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-string/error.strip +2 -0
- data/ext/vendor/jansson-2.5/test/suites/invalid/unterminated-string/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/complex-array/env +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/complex-array/input +5 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/complex-array/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/empty-array/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/empty-array/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/empty-object-in-array/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/empty-object-in-array/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/empty-object/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/empty-object/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/empty-string/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/empty-string/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/escaped-utf-control-char/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/escaped-utf-control-char/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/false/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/false/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/negative-int/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/negative-int/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/negative-one/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/negative-one/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/negative-zero/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/negative-zero/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/null/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/null/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/one-byte-utf-8/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/one-byte-utf-8/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/real-capital-e-negative-exponent/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/real-capital-e-negative-exponent/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/real-capital-e-positive-exponent/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/real-capital-e-positive-exponent/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/real-capital-e/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/real-capital-e/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/real-exponent/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/real-exponent/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/real-fraction-exponent/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/real-fraction-exponent/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/real-negative-exponent/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/real-negative-exponent/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/real-positive-exponent/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/real-positive-exponent/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/real-underflow/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/real-underflow/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/run +56 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/short-string/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/short-string/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/simple-ascii-string/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/simple-ascii-string/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/simple-int-0/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/simple-int-0/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/simple-int-1/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/simple-int-1/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/simple-int-123/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/simple-int-123/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/simple-object/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/simple-object/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/simple-real/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/simple-real/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/string-escapes/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/string-escapes/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/three-byte-utf-8/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/three-byte-utf-8/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/true/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/true/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/two-byte-utf-8/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/two-byte-utf-8/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/utf-8-string/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/utf-8-string/output +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/utf-surrogate-four-byte-encoding/input +1 -0
- data/ext/vendor/jansson-2.5/test/suites/valid/utf-surrogate-four-byte-encoding/output +1 -0
- data/ext/vendor/jansson-2.5/win32/jansson_config.h +39 -0
- data/ext/vendor/jansson-2.5/win32/vs2010/jansson.sln +20 -0
- data/ext/vendor/jansson-2.5/win32/vs2010/jansson.vcxproj +108 -0
- data/ext/vendor/jansson-2.5/win32/vs2010/jansson.vcxproj.filters +69 -0
- data/ext/vendor/jansson-2.5/win32/vs2010/jansson.vcxproj.user +3 -0
- data/lib/ctags.cnf +2 -0
- data/lib/ctags/exuberant.rb +129 -17
- data/lib/ctags/version.rb +1 -1
- data/test/test_ctags.rb +14 -7
- metadata +350 -69
@@ -0,0 +1,56 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
|
3
|
+
* Copyright (c) 2011-2012 Basile Starynkevitch <basile@starynkevitch.net>
|
4
|
+
*
|
5
|
+
* Jansson is free software; you can redistribute it and/or modify it
|
6
|
+
* under the terms of the MIT license. See LICENSE for details.
|
7
|
+
*/
|
8
|
+
|
9
|
+
#include <stdlib.h>
|
10
|
+
#include <string.h>
|
11
|
+
|
12
|
+
#include "jansson.h"
|
13
|
+
#include "jansson_private.h"
|
14
|
+
|
15
|
+
/* memory function pointers */
|
16
|
+
static json_malloc_t do_malloc = malloc;
|
17
|
+
static json_free_t do_free = free;
|
18
|
+
|
19
|
+
void *jsonp_malloc(size_t size)
|
20
|
+
{
|
21
|
+
if(!size)
|
22
|
+
return NULL;
|
23
|
+
|
24
|
+
return (*do_malloc)(size);
|
25
|
+
}
|
26
|
+
|
27
|
+
void jsonp_free(void *ptr)
|
28
|
+
{
|
29
|
+
if(!ptr)
|
30
|
+
return;
|
31
|
+
|
32
|
+
(*do_free)(ptr);
|
33
|
+
}
|
34
|
+
|
35
|
+
char *jsonp_strdup(const char *str)
|
36
|
+
{
|
37
|
+
char *new_str;
|
38
|
+
size_t len;
|
39
|
+
|
40
|
+
len = strlen(str);
|
41
|
+
if(len == (size_t)-1)
|
42
|
+
return NULL;
|
43
|
+
|
44
|
+
new_str = jsonp_malloc(len + 1);
|
45
|
+
if(!new_str)
|
46
|
+
return NULL;
|
47
|
+
|
48
|
+
memcpy(new_str, str, len + 1);
|
49
|
+
return new_str;
|
50
|
+
}
|
51
|
+
|
52
|
+
void json_set_alloc_funcs(json_malloc_t malloc_fn, json_free_t free_fn)
|
53
|
+
{
|
54
|
+
do_malloc = malloc_fn;
|
55
|
+
do_free = free_fn;
|
56
|
+
}
|
@@ -0,0 +1,762 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
|
3
|
+
* Copyright (c) 2011-2012 Graeme Smecher <graeme.smecher@mail.mcgill.ca>
|
4
|
+
*
|
5
|
+
* Jansson is free software; you can redistribute it and/or modify
|
6
|
+
* it under the terms of the MIT license. See LICENSE for details.
|
7
|
+
*/
|
8
|
+
|
9
|
+
#include <string.h>
|
10
|
+
#include "jansson.h"
|
11
|
+
#include "jansson_private.h"
|
12
|
+
#include "utf.h"
|
13
|
+
|
14
|
+
typedef struct {
|
15
|
+
int line;
|
16
|
+
int column;
|
17
|
+
size_t pos;
|
18
|
+
char token;
|
19
|
+
} token_t;
|
20
|
+
|
21
|
+
typedef struct {
|
22
|
+
const char *start;
|
23
|
+
const char *fmt;
|
24
|
+
token_t prev_token;
|
25
|
+
token_t token;
|
26
|
+
token_t next_token;
|
27
|
+
json_error_t *error;
|
28
|
+
size_t flags;
|
29
|
+
int line;
|
30
|
+
int column;
|
31
|
+
size_t pos;
|
32
|
+
} scanner_t;
|
33
|
+
|
34
|
+
#define token(scanner) ((scanner)->token.token)
|
35
|
+
|
36
|
+
static const char * const type_names[] = {
|
37
|
+
"object",
|
38
|
+
"array",
|
39
|
+
"string",
|
40
|
+
"integer",
|
41
|
+
"real",
|
42
|
+
"true",
|
43
|
+
"false",
|
44
|
+
"null"
|
45
|
+
};
|
46
|
+
|
47
|
+
#define type_name(x) type_names[json_typeof(x)]
|
48
|
+
|
49
|
+
static const char unpack_value_starters[] = "{[siIbfFOon";
|
50
|
+
|
51
|
+
|
52
|
+
static void scanner_init(scanner_t *s, json_error_t *error,
|
53
|
+
size_t flags, const char *fmt)
|
54
|
+
{
|
55
|
+
s->error = error;
|
56
|
+
s->flags = flags;
|
57
|
+
s->fmt = s->start = fmt;
|
58
|
+
memset(&s->prev_token, 0, sizeof(token_t));
|
59
|
+
memset(&s->token, 0, sizeof(token_t));
|
60
|
+
memset(&s->next_token, 0, sizeof(token_t));
|
61
|
+
s->line = 1;
|
62
|
+
s->column = 0;
|
63
|
+
s->pos = 0;
|
64
|
+
}
|
65
|
+
|
66
|
+
static void next_token(scanner_t *s)
|
67
|
+
{
|
68
|
+
const char *t;
|
69
|
+
s->prev_token = s->token;
|
70
|
+
|
71
|
+
if(s->next_token.line) {
|
72
|
+
s->token = s->next_token;
|
73
|
+
s->next_token.line = 0;
|
74
|
+
return;
|
75
|
+
}
|
76
|
+
|
77
|
+
t = s->fmt;
|
78
|
+
s->column++;
|
79
|
+
s->pos++;
|
80
|
+
|
81
|
+
/* skip space and ignored chars */
|
82
|
+
while(*t == ' ' || *t == '\t' || *t == '\n' || *t == ',' || *t == ':') {
|
83
|
+
if(*t == '\n') {
|
84
|
+
s->line++;
|
85
|
+
s->column = 1;
|
86
|
+
}
|
87
|
+
else
|
88
|
+
s->column++;
|
89
|
+
|
90
|
+
s->pos++;
|
91
|
+
t++;
|
92
|
+
}
|
93
|
+
|
94
|
+
s->token.token = *t;
|
95
|
+
s->token.line = s->line;
|
96
|
+
s->token.column = s->column;
|
97
|
+
s->token.pos = s->pos;
|
98
|
+
|
99
|
+
t++;
|
100
|
+
s->fmt = t;
|
101
|
+
}
|
102
|
+
|
103
|
+
static void prev_token(scanner_t *s)
|
104
|
+
{
|
105
|
+
s->next_token = s->token;
|
106
|
+
s->token = s->prev_token;
|
107
|
+
}
|
108
|
+
|
109
|
+
static void set_error(scanner_t *s, const char *source, const char *fmt, ...)
|
110
|
+
{
|
111
|
+
va_list ap;
|
112
|
+
va_start(ap, fmt);
|
113
|
+
|
114
|
+
jsonp_error_vset(s->error, s->token.line, s->token.column, s->token.pos,
|
115
|
+
fmt, ap);
|
116
|
+
|
117
|
+
jsonp_error_set_source(s->error, source);
|
118
|
+
|
119
|
+
va_end(ap);
|
120
|
+
}
|
121
|
+
|
122
|
+
static json_t *pack(scanner_t *s, va_list *ap);
|
123
|
+
|
124
|
+
|
125
|
+
/* ours will be set to 1 if jsonp_free() must be called for the result
|
126
|
+
afterwards */
|
127
|
+
static char *read_string(scanner_t *s, va_list *ap,
|
128
|
+
const char *purpose, int *ours)
|
129
|
+
{
|
130
|
+
char t;
|
131
|
+
strbuffer_t strbuff;
|
132
|
+
const char *str;
|
133
|
+
size_t length;
|
134
|
+
char *result;
|
135
|
+
|
136
|
+
next_token(s);
|
137
|
+
t = token(s);
|
138
|
+
prev_token(s);
|
139
|
+
|
140
|
+
if(t != '#' && t != '+') {
|
141
|
+
/* Optimize the simple case */
|
142
|
+
str = va_arg(*ap, const char *);
|
143
|
+
|
144
|
+
if(!str) {
|
145
|
+
set_error(s, "<args>", "NULL string argument");
|
146
|
+
return NULL;
|
147
|
+
}
|
148
|
+
|
149
|
+
if(!utf8_check_string(str, -1)) {
|
150
|
+
set_error(s, "<args>", "Invalid UTF-8 %s", purpose);
|
151
|
+
return NULL;
|
152
|
+
}
|
153
|
+
|
154
|
+
*ours = 0;
|
155
|
+
return (char *)str;
|
156
|
+
}
|
157
|
+
|
158
|
+
strbuffer_init(&strbuff);
|
159
|
+
|
160
|
+
while(1) {
|
161
|
+
str = va_arg(*ap, const char *);
|
162
|
+
if(!str) {
|
163
|
+
set_error(s, "<args>", "NULL string argument");
|
164
|
+
strbuffer_close(&strbuff);
|
165
|
+
return NULL;
|
166
|
+
}
|
167
|
+
|
168
|
+
next_token(s);
|
169
|
+
|
170
|
+
if(token(s) == '#') {
|
171
|
+
length = va_arg(*ap, int);
|
172
|
+
}
|
173
|
+
else {
|
174
|
+
prev_token(s);
|
175
|
+
length = strlen(str);
|
176
|
+
}
|
177
|
+
|
178
|
+
if(strbuffer_append_bytes(&strbuff, str, length) == -1) {
|
179
|
+
set_error(s, "<internal>", "Out of memory");
|
180
|
+
strbuffer_close(&strbuff);
|
181
|
+
return NULL;
|
182
|
+
}
|
183
|
+
|
184
|
+
next_token(s);
|
185
|
+
if(token(s) != '+') {
|
186
|
+
prev_token(s);
|
187
|
+
break;
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
191
|
+
result = strbuffer_steal_value(&strbuff);
|
192
|
+
|
193
|
+
if(!utf8_check_string(result, -1)) {
|
194
|
+
set_error(s, "<args>", "Invalid UTF-8 %s", purpose);
|
195
|
+
return NULL;
|
196
|
+
}
|
197
|
+
|
198
|
+
*ours = 1;
|
199
|
+
return result;
|
200
|
+
}
|
201
|
+
|
202
|
+
static json_t *pack_object(scanner_t *s, va_list *ap)
|
203
|
+
{
|
204
|
+
json_t *object = json_object();
|
205
|
+
next_token(s);
|
206
|
+
|
207
|
+
while(token(s) != '}') {
|
208
|
+
char *key;
|
209
|
+
int ours;
|
210
|
+
json_t *value;
|
211
|
+
|
212
|
+
if(!token(s)) {
|
213
|
+
set_error(s, "<format>", "Unexpected end of format string");
|
214
|
+
goto error;
|
215
|
+
}
|
216
|
+
|
217
|
+
if(token(s) != 's') {
|
218
|
+
set_error(s, "<format>", "Expected format 's', got '%c'", token(s));
|
219
|
+
goto error;
|
220
|
+
}
|
221
|
+
|
222
|
+
key = read_string(s, ap, "object key", &ours);
|
223
|
+
if(!key)
|
224
|
+
goto error;
|
225
|
+
|
226
|
+
next_token(s);
|
227
|
+
|
228
|
+
value = pack(s, ap);
|
229
|
+
if(!value)
|
230
|
+
goto error;
|
231
|
+
|
232
|
+
if(json_object_set_new_nocheck(object, key, value)) {
|
233
|
+
if(ours)
|
234
|
+
jsonp_free(key);
|
235
|
+
|
236
|
+
set_error(s, "<internal>", "Unable to add key \"%s\"", key);
|
237
|
+
goto error;
|
238
|
+
}
|
239
|
+
|
240
|
+
if(ours)
|
241
|
+
jsonp_free(key);
|
242
|
+
|
243
|
+
next_token(s);
|
244
|
+
}
|
245
|
+
|
246
|
+
return object;
|
247
|
+
|
248
|
+
error:
|
249
|
+
json_decref(object);
|
250
|
+
return NULL;
|
251
|
+
}
|
252
|
+
|
253
|
+
static json_t *pack_array(scanner_t *s, va_list *ap)
|
254
|
+
{
|
255
|
+
json_t *array = json_array();
|
256
|
+
next_token(s);
|
257
|
+
|
258
|
+
while(token(s) != ']') {
|
259
|
+
json_t *value;
|
260
|
+
|
261
|
+
if(!token(s)) {
|
262
|
+
set_error(s, "<format>", "Unexpected end of format string");
|
263
|
+
goto error;
|
264
|
+
}
|
265
|
+
|
266
|
+
value = pack(s, ap);
|
267
|
+
if(!value)
|
268
|
+
goto error;
|
269
|
+
|
270
|
+
if(json_array_append_new(array, value)) {
|
271
|
+
set_error(s, "<internal>", "Unable to append to array");
|
272
|
+
goto error;
|
273
|
+
}
|
274
|
+
|
275
|
+
next_token(s);
|
276
|
+
}
|
277
|
+
return array;
|
278
|
+
|
279
|
+
error:
|
280
|
+
json_decref(array);
|
281
|
+
return NULL;
|
282
|
+
}
|
283
|
+
|
284
|
+
static json_t *pack(scanner_t *s, va_list *ap)
|
285
|
+
{
|
286
|
+
switch(token(s)) {
|
287
|
+
case '{':
|
288
|
+
return pack_object(s, ap);
|
289
|
+
|
290
|
+
case '[':
|
291
|
+
return pack_array(s, ap);
|
292
|
+
|
293
|
+
case 's': { /* string */
|
294
|
+
char *str;
|
295
|
+
int ours;
|
296
|
+
json_t *result;
|
297
|
+
|
298
|
+
str = read_string(s, ap, "string", &ours);
|
299
|
+
if(!str)
|
300
|
+
return NULL;
|
301
|
+
|
302
|
+
result = json_string_nocheck(str);
|
303
|
+
if(ours)
|
304
|
+
jsonp_free(str);
|
305
|
+
|
306
|
+
return result;
|
307
|
+
}
|
308
|
+
|
309
|
+
case 'n': /* null */
|
310
|
+
return json_null();
|
311
|
+
|
312
|
+
case 'b': /* boolean */
|
313
|
+
return va_arg(*ap, int) ? json_true() : json_false();
|
314
|
+
|
315
|
+
case 'i': /* integer from int */
|
316
|
+
return json_integer(va_arg(*ap, int));
|
317
|
+
|
318
|
+
case 'I': /* integer from json_int_t */
|
319
|
+
return json_integer(va_arg(*ap, json_int_t));
|
320
|
+
|
321
|
+
case 'f': /* real */
|
322
|
+
return json_real(va_arg(*ap, double));
|
323
|
+
|
324
|
+
case 'O': /* a json_t object; increments refcount */
|
325
|
+
return json_incref(va_arg(*ap, json_t *));
|
326
|
+
|
327
|
+
case 'o': /* a json_t object; doesn't increment refcount */
|
328
|
+
return va_arg(*ap, json_t *);
|
329
|
+
|
330
|
+
default:
|
331
|
+
set_error(s, "<format>", "Unexpected format character '%c'",
|
332
|
+
token(s));
|
333
|
+
return NULL;
|
334
|
+
}
|
335
|
+
}
|
336
|
+
|
337
|
+
static int unpack(scanner_t *s, json_t *root, va_list *ap);
|
338
|
+
|
339
|
+
static int unpack_object(scanner_t *s, json_t *root, va_list *ap)
|
340
|
+
{
|
341
|
+
int ret = -1;
|
342
|
+
int strict = 0;
|
343
|
+
|
344
|
+
/* Use a set (emulated by a hashtable) to check that all object
|
345
|
+
keys are accessed. Checking that the correct number of keys
|
346
|
+
were accessed is not enough, as the same key can be unpacked
|
347
|
+
multiple times.
|
348
|
+
*/
|
349
|
+
hashtable_t key_set;
|
350
|
+
|
351
|
+
if(hashtable_init(&key_set)) {
|
352
|
+
set_error(s, "<internal>", "Out of memory");
|
353
|
+
return -1;
|
354
|
+
}
|
355
|
+
|
356
|
+
if(root && !json_is_object(root)) {
|
357
|
+
set_error(s, "<validation>", "Expected object, got %s",
|
358
|
+
type_name(root));
|
359
|
+
goto out;
|
360
|
+
}
|
361
|
+
next_token(s);
|
362
|
+
|
363
|
+
while(token(s) != '}') {
|
364
|
+
const char *key;
|
365
|
+
json_t *value;
|
366
|
+
int opt = 0;
|
367
|
+
|
368
|
+
if(strict != 0) {
|
369
|
+
set_error(s, "<format>", "Expected '}' after '%c', got '%c'",
|
370
|
+
(strict == 1 ? '!' : '*'), token(s));
|
371
|
+
goto out;
|
372
|
+
}
|
373
|
+
|
374
|
+
if(!token(s)) {
|
375
|
+
set_error(s, "<format>", "Unexpected end of format string");
|
376
|
+
goto out;
|
377
|
+
}
|
378
|
+
|
379
|
+
if(token(s) == '!' || token(s) == '*') {
|
380
|
+
strict = (token(s) == '!' ? 1 : -1);
|
381
|
+
next_token(s);
|
382
|
+
continue;
|
383
|
+
}
|
384
|
+
|
385
|
+
if(token(s) != 's') {
|
386
|
+
set_error(s, "<format>", "Expected format 's', got '%c'", token(s));
|
387
|
+
goto out;
|
388
|
+
}
|
389
|
+
|
390
|
+
key = va_arg(*ap, const char *);
|
391
|
+
if(!key) {
|
392
|
+
set_error(s, "<args>", "NULL object key");
|
393
|
+
goto out;
|
394
|
+
}
|
395
|
+
|
396
|
+
next_token(s);
|
397
|
+
|
398
|
+
if(token(s) == '?') {
|
399
|
+
opt = 1;
|
400
|
+
next_token(s);
|
401
|
+
}
|
402
|
+
|
403
|
+
if(!root) {
|
404
|
+
/* skipping */
|
405
|
+
value = NULL;
|
406
|
+
}
|
407
|
+
else {
|
408
|
+
value = json_object_get(root, key);
|
409
|
+
if(!value && !opt) {
|
410
|
+
set_error(s, "<validation>", "Object item not found: %s", key);
|
411
|
+
goto out;
|
412
|
+
}
|
413
|
+
}
|
414
|
+
|
415
|
+
if(unpack(s, value, ap))
|
416
|
+
goto out;
|
417
|
+
|
418
|
+
hashtable_set(&key_set, key, 0, json_null());
|
419
|
+
next_token(s);
|
420
|
+
}
|
421
|
+
|
422
|
+
if(strict == 0 && (s->flags & JSON_STRICT))
|
423
|
+
strict = 1;
|
424
|
+
|
425
|
+
if(root && strict == 1 && key_set.size != json_object_size(root)) {
|
426
|
+
long diff = (long)json_object_size(root) - (long)key_set.size;
|
427
|
+
set_error(s, "<validation>", "%li object item(s) left unpacked", diff);
|
428
|
+
goto out;
|
429
|
+
}
|
430
|
+
|
431
|
+
ret = 0;
|
432
|
+
|
433
|
+
out:
|
434
|
+
hashtable_close(&key_set);
|
435
|
+
return ret;
|
436
|
+
}
|
437
|
+
|
438
|
+
static int unpack_array(scanner_t *s, json_t *root, va_list *ap)
|
439
|
+
{
|
440
|
+
size_t i = 0;
|
441
|
+
int strict = 0;
|
442
|
+
|
443
|
+
if(root && !json_is_array(root)) {
|
444
|
+
set_error(s, "<validation>", "Expected array, got %s", type_name(root));
|
445
|
+
return -1;
|
446
|
+
}
|
447
|
+
next_token(s);
|
448
|
+
|
449
|
+
while(token(s) != ']') {
|
450
|
+
json_t *value;
|
451
|
+
|
452
|
+
if(strict != 0) {
|
453
|
+
set_error(s, "<format>", "Expected ']' after '%c', got '%c'",
|
454
|
+
(strict == 1 ? '!' : '*'),
|
455
|
+
token(s));
|
456
|
+
return -1;
|
457
|
+
}
|
458
|
+
|
459
|
+
if(!token(s)) {
|
460
|
+
set_error(s, "<format>", "Unexpected end of format string");
|
461
|
+
return -1;
|
462
|
+
}
|
463
|
+
|
464
|
+
if(token(s) == '!' || token(s) == '*') {
|
465
|
+
strict = (token(s) == '!' ? 1 : -1);
|
466
|
+
next_token(s);
|
467
|
+
continue;
|
468
|
+
}
|
469
|
+
|
470
|
+
if(!strchr(unpack_value_starters, token(s))) {
|
471
|
+
set_error(s, "<format>", "Unexpected format character '%c'",
|
472
|
+
token(s));
|
473
|
+
return -1;
|
474
|
+
}
|
475
|
+
|
476
|
+
if(!root) {
|
477
|
+
/* skipping */
|
478
|
+
value = NULL;
|
479
|
+
}
|
480
|
+
else {
|
481
|
+
value = json_array_get(root, i);
|
482
|
+
if(!value) {
|
483
|
+
set_error(s, "<validation>", "Array index %lu out of range",
|
484
|
+
(unsigned long)i);
|
485
|
+
return -1;
|
486
|
+
}
|
487
|
+
}
|
488
|
+
|
489
|
+
if(unpack(s, value, ap))
|
490
|
+
return -1;
|
491
|
+
|
492
|
+
next_token(s);
|
493
|
+
i++;
|
494
|
+
}
|
495
|
+
|
496
|
+
if(strict == 0 && (s->flags & JSON_STRICT))
|
497
|
+
strict = 1;
|
498
|
+
|
499
|
+
if(root && strict == 1 && i != json_array_size(root)) {
|
500
|
+
long diff = (long)json_array_size(root) - (long)i;
|
501
|
+
set_error(s, "<validation>", "%li array item(s) left unpacked", diff);
|
502
|
+
return -1;
|
503
|
+
}
|
504
|
+
|
505
|
+
return 0;
|
506
|
+
}
|
507
|
+
|
508
|
+
static int unpack(scanner_t *s, json_t *root, va_list *ap)
|
509
|
+
{
|
510
|
+
switch(token(s))
|
511
|
+
{
|
512
|
+
case '{':
|
513
|
+
return unpack_object(s, root, ap);
|
514
|
+
|
515
|
+
case '[':
|
516
|
+
return unpack_array(s, root, ap);
|
517
|
+
|
518
|
+
case 's':
|
519
|
+
if(root && !json_is_string(root)) {
|
520
|
+
set_error(s, "<validation>", "Expected string, got %s",
|
521
|
+
type_name(root));
|
522
|
+
return -1;
|
523
|
+
}
|
524
|
+
|
525
|
+
if(!(s->flags & JSON_VALIDATE_ONLY)) {
|
526
|
+
const char **target;
|
527
|
+
|
528
|
+
target = va_arg(*ap, const char **);
|
529
|
+
if(!target) {
|
530
|
+
set_error(s, "<args>", "NULL string argument");
|
531
|
+
return -1;
|
532
|
+
}
|
533
|
+
|
534
|
+
if(root)
|
535
|
+
*target = json_string_value(root);
|
536
|
+
}
|
537
|
+
return 0;
|
538
|
+
|
539
|
+
case 'i':
|
540
|
+
if(root && !json_is_integer(root)) {
|
541
|
+
set_error(s, "<validation>", "Expected integer, got %s",
|
542
|
+
type_name(root));
|
543
|
+
return -1;
|
544
|
+
}
|
545
|
+
|
546
|
+
if(!(s->flags & JSON_VALIDATE_ONLY)) {
|
547
|
+
int *target = va_arg(*ap, int*);
|
548
|
+
if(root)
|
549
|
+
*target = (int)json_integer_value(root);
|
550
|
+
}
|
551
|
+
|
552
|
+
return 0;
|
553
|
+
|
554
|
+
case 'I':
|
555
|
+
if(root && !json_is_integer(root)) {
|
556
|
+
set_error(s, "<validation>", "Expected integer, got %s",
|
557
|
+
type_name(root));
|
558
|
+
return -1;
|
559
|
+
}
|
560
|
+
|
561
|
+
if(!(s->flags & JSON_VALIDATE_ONLY)) {
|
562
|
+
json_int_t *target = va_arg(*ap, json_int_t*);
|
563
|
+
if(root)
|
564
|
+
*target = json_integer_value(root);
|
565
|
+
}
|
566
|
+
|
567
|
+
return 0;
|
568
|
+
|
569
|
+
case 'b':
|
570
|
+
if(root && !json_is_boolean(root)) {
|
571
|
+
set_error(s, "<validation>", "Expected true or false, got %s",
|
572
|
+
type_name(root));
|
573
|
+
return -1;
|
574
|
+
}
|
575
|
+
|
576
|
+
if(!(s->flags & JSON_VALIDATE_ONLY)) {
|
577
|
+
int *target = va_arg(*ap, int*);
|
578
|
+
if(root)
|
579
|
+
*target = json_is_true(root);
|
580
|
+
}
|
581
|
+
|
582
|
+
return 0;
|
583
|
+
|
584
|
+
case 'f':
|
585
|
+
if(root && !json_is_real(root)) {
|
586
|
+
set_error(s, "<validation>", "Expected real, got %s",
|
587
|
+
type_name(root));
|
588
|
+
return -1;
|
589
|
+
}
|
590
|
+
|
591
|
+
if(!(s->flags & JSON_VALIDATE_ONLY)) {
|
592
|
+
double *target = va_arg(*ap, double*);
|
593
|
+
if(root)
|
594
|
+
*target = json_real_value(root);
|
595
|
+
}
|
596
|
+
|
597
|
+
return 0;
|
598
|
+
|
599
|
+
case 'F':
|
600
|
+
if(root && !json_is_number(root)) {
|
601
|
+
set_error(s, "<validation>", "Expected real or integer, got %s",
|
602
|
+
type_name(root));
|
603
|
+
return -1;
|
604
|
+
}
|
605
|
+
|
606
|
+
if(!(s->flags & JSON_VALIDATE_ONLY)) {
|
607
|
+
double *target = va_arg(*ap, double*);
|
608
|
+
if(root)
|
609
|
+
*target = json_number_value(root);
|
610
|
+
}
|
611
|
+
|
612
|
+
return 0;
|
613
|
+
|
614
|
+
case 'O':
|
615
|
+
if(root && !(s->flags & JSON_VALIDATE_ONLY))
|
616
|
+
json_incref(root);
|
617
|
+
/* Fall through */
|
618
|
+
|
619
|
+
case 'o':
|
620
|
+
if(!(s->flags & JSON_VALIDATE_ONLY)) {
|
621
|
+
json_t **target = va_arg(*ap, json_t**);
|
622
|
+
if(root)
|
623
|
+
*target = root;
|
624
|
+
}
|
625
|
+
|
626
|
+
return 0;
|
627
|
+
|
628
|
+
case 'n':
|
629
|
+
/* Never assign, just validate */
|
630
|
+
if(root && !json_is_null(root)) {
|
631
|
+
set_error(s, "<validation>", "Expected null, got %s",
|
632
|
+
type_name(root));
|
633
|
+
return -1;
|
634
|
+
}
|
635
|
+
return 0;
|
636
|
+
|
637
|
+
default:
|
638
|
+
set_error(s, "<format>", "Unexpected format character '%c'",
|
639
|
+
token(s));
|
640
|
+
return -1;
|
641
|
+
}
|
642
|
+
}
|
643
|
+
|
644
|
+
json_t *json_vpack_ex(json_error_t *error, size_t flags,
|
645
|
+
const char *fmt, va_list ap)
|
646
|
+
{
|
647
|
+
scanner_t s;
|
648
|
+
va_list ap_copy;
|
649
|
+
json_t *value;
|
650
|
+
|
651
|
+
if(!fmt || !*fmt) {
|
652
|
+
jsonp_error_init(error, "<format>");
|
653
|
+
jsonp_error_set(error, -1, -1, 0, "NULL or empty format string");
|
654
|
+
return NULL;
|
655
|
+
}
|
656
|
+
jsonp_error_init(error, NULL);
|
657
|
+
|
658
|
+
scanner_init(&s, error, flags, fmt);
|
659
|
+
next_token(&s);
|
660
|
+
|
661
|
+
va_copy(ap_copy, ap);
|
662
|
+
value = pack(&s, &ap_copy);
|
663
|
+
va_end(ap_copy);
|
664
|
+
|
665
|
+
if(!value)
|
666
|
+
return NULL;
|
667
|
+
|
668
|
+
next_token(&s);
|
669
|
+
if(token(&s)) {
|
670
|
+
json_decref(value);
|
671
|
+
set_error(&s, "<format>", "Garbage after format string");
|
672
|
+
return NULL;
|
673
|
+
}
|
674
|
+
|
675
|
+
return value;
|
676
|
+
}
|
677
|
+
|
678
|
+
json_t *json_pack_ex(json_error_t *error, size_t flags, const char *fmt, ...)
|
679
|
+
{
|
680
|
+
json_t *value;
|
681
|
+
va_list ap;
|
682
|
+
|
683
|
+
va_start(ap, fmt);
|
684
|
+
value = json_vpack_ex(error, flags, fmt, ap);
|
685
|
+
va_end(ap);
|
686
|
+
|
687
|
+
return value;
|
688
|
+
}
|
689
|
+
|
690
|
+
json_t *json_pack(const char *fmt, ...)
|
691
|
+
{
|
692
|
+
json_t *value;
|
693
|
+
va_list ap;
|
694
|
+
|
695
|
+
va_start(ap, fmt);
|
696
|
+
value = json_vpack_ex(NULL, 0, fmt, ap);
|
697
|
+
va_end(ap);
|
698
|
+
|
699
|
+
return value;
|
700
|
+
}
|
701
|
+
|
702
|
+
int json_vunpack_ex(json_t *root, json_error_t *error, size_t flags,
|
703
|
+
const char *fmt, va_list ap)
|
704
|
+
{
|
705
|
+
scanner_t s;
|
706
|
+
va_list ap_copy;
|
707
|
+
|
708
|
+
if(!root) {
|
709
|
+
jsonp_error_init(error, "<root>");
|
710
|
+
jsonp_error_set(error, -1, -1, 0, "NULL root value");
|
711
|
+
return -1;
|
712
|
+
}
|
713
|
+
|
714
|
+
if(!fmt || !*fmt) {
|
715
|
+
jsonp_error_init(error, "<format>");
|
716
|
+
jsonp_error_set(error, -1, -1, 0, "NULL or empty format string");
|
717
|
+
return -1;
|
718
|
+
}
|
719
|
+
jsonp_error_init(error, NULL);
|
720
|
+
|
721
|
+
scanner_init(&s, error, flags, fmt);
|
722
|
+
next_token(&s);
|
723
|
+
|
724
|
+
va_copy(ap_copy, ap);
|
725
|
+
if(unpack(&s, root, &ap_copy)) {
|
726
|
+
va_end(ap_copy);
|
727
|
+
return -1;
|
728
|
+
}
|
729
|
+
va_end(ap_copy);
|
730
|
+
|
731
|
+
next_token(&s);
|
732
|
+
if(token(&s)) {
|
733
|
+
set_error(&s, "<format>", "Garbage after format string");
|
734
|
+
return -1;
|
735
|
+
}
|
736
|
+
|
737
|
+
return 0;
|
738
|
+
}
|
739
|
+
|
740
|
+
int json_unpack_ex(json_t *root, json_error_t *error, size_t flags, const char *fmt, ...)
|
741
|
+
{
|
742
|
+
int ret;
|
743
|
+
va_list ap;
|
744
|
+
|
745
|
+
va_start(ap, fmt);
|
746
|
+
ret = json_vunpack_ex(root, error, flags, fmt, ap);
|
747
|
+
va_end(ap);
|
748
|
+
|
749
|
+
return ret;
|
750
|
+
}
|
751
|
+
|
752
|
+
int json_unpack(json_t *root, const char *fmt, ...)
|
753
|
+
{
|
754
|
+
int ret;
|
755
|
+
va_list ap;
|
756
|
+
|
757
|
+
va_start(ap, fmt);
|
758
|
+
ret = json_vunpack_ex(root, NULL, 0, fmt, ap);
|
759
|
+
va_end(ap);
|
760
|
+
|
761
|
+
return ret;
|
762
|
+
}
|