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,373 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
|
3
|
+
* Copyright (c) 2010-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 <stdio.h>
|
12
|
+
#include "util.h"
|
13
|
+
|
14
|
+
static void run_tests()
|
15
|
+
{
|
16
|
+
json_t *j, *j2;
|
17
|
+
int i1, i2, i3;
|
18
|
+
json_int_t I1;
|
19
|
+
int rv;
|
20
|
+
double f;
|
21
|
+
char *s;
|
22
|
+
|
23
|
+
json_error_t error;
|
24
|
+
|
25
|
+
/*
|
26
|
+
* Simple, valid json_pack cases
|
27
|
+
*/
|
28
|
+
|
29
|
+
/* true */
|
30
|
+
rv = json_unpack(json_true(), "b", &i1);
|
31
|
+
if(rv || !i1)
|
32
|
+
fail("json_unpack boolean failed");
|
33
|
+
|
34
|
+
/* false */
|
35
|
+
rv = json_unpack(json_false(), "b", &i1);
|
36
|
+
if(rv || i1)
|
37
|
+
fail("json_unpack boolean failed");
|
38
|
+
|
39
|
+
/* null */
|
40
|
+
if(json_unpack(json_null(), "n"))
|
41
|
+
fail("json_unpack null failed");
|
42
|
+
|
43
|
+
/* integer */
|
44
|
+
j = json_integer(42);
|
45
|
+
rv = json_unpack(j, "i", &i1);
|
46
|
+
if(rv || i1 != 42)
|
47
|
+
fail("json_unpack integer failed");
|
48
|
+
json_decref(j);
|
49
|
+
|
50
|
+
/* json_int_t */
|
51
|
+
j = json_integer(5555555);
|
52
|
+
rv = json_unpack(j, "I", &I1);
|
53
|
+
if(rv || I1 != 5555555)
|
54
|
+
fail("json_unpack json_int_t failed");
|
55
|
+
json_decref(j);
|
56
|
+
|
57
|
+
/* real */
|
58
|
+
j = json_real(1.7);
|
59
|
+
rv = json_unpack(j, "f", &f);
|
60
|
+
if(rv || f != 1.7)
|
61
|
+
fail("json_unpack real failed");
|
62
|
+
json_decref(j);
|
63
|
+
|
64
|
+
/* number */
|
65
|
+
j = json_integer(12345);
|
66
|
+
rv = json_unpack(j, "F", &f);
|
67
|
+
if(rv || f != 12345.0)
|
68
|
+
fail("json_unpack (real or) integer failed");
|
69
|
+
json_decref(j);
|
70
|
+
|
71
|
+
j = json_real(1.7);
|
72
|
+
rv = json_unpack(j, "F", &f);
|
73
|
+
if(rv || f != 1.7)
|
74
|
+
fail("json_unpack real (or integer) failed");
|
75
|
+
json_decref(j);
|
76
|
+
|
77
|
+
/* string */
|
78
|
+
j = json_string("foo");
|
79
|
+
rv = json_unpack(j, "s", &s);
|
80
|
+
if(rv || strcmp(s, "foo"))
|
81
|
+
fail("json_unpack string failed");
|
82
|
+
json_decref(j);
|
83
|
+
|
84
|
+
/* empty object */
|
85
|
+
j = json_object();
|
86
|
+
if(json_unpack(j, "{}"))
|
87
|
+
fail("json_unpack empty object failed");
|
88
|
+
json_decref(j);
|
89
|
+
|
90
|
+
/* empty list */
|
91
|
+
j = json_array();
|
92
|
+
if(json_unpack(j, "[]"))
|
93
|
+
fail("json_unpack empty list failed");
|
94
|
+
json_decref(j);
|
95
|
+
|
96
|
+
/* non-incref'd object */
|
97
|
+
j = json_object();
|
98
|
+
rv = json_unpack(j, "o", &j2);
|
99
|
+
if(rv || j2 != j || j->refcount != 1)
|
100
|
+
fail("json_unpack object failed");
|
101
|
+
json_decref(j);
|
102
|
+
|
103
|
+
/* incref'd object */
|
104
|
+
j = json_object();
|
105
|
+
rv = json_unpack(j, "O", &j2);
|
106
|
+
if(rv || j2 != j || j->refcount != 2)
|
107
|
+
fail("json_unpack object failed");
|
108
|
+
json_decref(j);
|
109
|
+
json_decref(j);
|
110
|
+
|
111
|
+
/* simple object */
|
112
|
+
j = json_pack("{s:i}", "foo", 42);
|
113
|
+
rv = json_unpack(j, "{s:i}", "foo", &i1);
|
114
|
+
if(rv || i1 != 42)
|
115
|
+
fail("json_unpack simple object failed");
|
116
|
+
json_decref(j);
|
117
|
+
|
118
|
+
/* simple array */
|
119
|
+
j = json_pack("[iii]", 1, 2, 3);
|
120
|
+
rv = json_unpack(j, "[i,i,i]", &i1, &i2, &i3);
|
121
|
+
if(rv || i1 != 1 || i2 != 2 || i3 != 3)
|
122
|
+
fail("json_unpack simple array failed");
|
123
|
+
json_decref(j);
|
124
|
+
|
125
|
+
/* object with many items & strict checking */
|
126
|
+
j = json_pack("{s:i, s:i, s:i}", "a", 1, "b", 2, "c", 3);
|
127
|
+
rv = json_unpack(j, "{s:i, s:i, s:i}", "a", &i1, "b", &i2, "c", &i3);
|
128
|
+
if(rv || i1 != 1 || i2 != 2 || i3 != 3)
|
129
|
+
fail("json_unpack object with many items failed");
|
130
|
+
json_decref(j);
|
131
|
+
|
132
|
+
/*
|
133
|
+
* Invalid cases
|
134
|
+
*/
|
135
|
+
|
136
|
+
j = json_integer(42);
|
137
|
+
if(!json_unpack_ex(j, &error, 0, "z"))
|
138
|
+
fail("json_unpack succeeded with invalid format character");
|
139
|
+
check_error("Unexpected format character 'z'", "<format>", 1, 1, 1);
|
140
|
+
|
141
|
+
if(!json_unpack_ex(NULL, &error, 0, "[i]"))
|
142
|
+
fail("json_unpack succeeded with NULL root");
|
143
|
+
check_error("NULL root value", "<root>", -1, -1, 0);
|
144
|
+
json_decref(j);
|
145
|
+
|
146
|
+
/* mismatched open/close array/object */
|
147
|
+
j = json_pack("[]");
|
148
|
+
if(!json_unpack_ex(j, &error, 0, "[}"))
|
149
|
+
fail("json_unpack failed to catch mismatched ']'");
|
150
|
+
check_error("Unexpected format character '}'", "<format>", 1, 2, 2);
|
151
|
+
json_decref(j);
|
152
|
+
|
153
|
+
j = json_pack("{}");
|
154
|
+
if(!json_unpack_ex(j, &error, 0, "{]"))
|
155
|
+
fail("json_unpack failed to catch mismatched '}'");
|
156
|
+
check_error("Expected format 's', got ']'", "<format>", 1, 2, 2);
|
157
|
+
json_decref(j);
|
158
|
+
|
159
|
+
/* missing close array */
|
160
|
+
j = json_pack("[]");
|
161
|
+
if(!json_unpack_ex(j, &error, 0, "["))
|
162
|
+
fail("json_unpack failed to catch missing ']'");
|
163
|
+
check_error("Unexpected end of format string", "<format>", 1, 2, 2);
|
164
|
+
json_decref(j);
|
165
|
+
|
166
|
+
/* missing close object */
|
167
|
+
j = json_pack("{}");
|
168
|
+
if(!json_unpack_ex(j, &error, 0, "{"))
|
169
|
+
fail("json_unpack failed to catch missing '}'");
|
170
|
+
check_error("Unexpected end of format string", "<format>", 1, 2, 2);
|
171
|
+
json_decref(j);
|
172
|
+
|
173
|
+
/* garbage after format string */
|
174
|
+
j = json_pack("[i]", 42);
|
175
|
+
if(!json_unpack_ex(j, &error, 0, "[i]a", &i1))
|
176
|
+
fail("json_unpack failed to catch garbage after format string");
|
177
|
+
check_error("Garbage after format string", "<format>", 1, 4, 4);
|
178
|
+
json_decref(j);
|
179
|
+
|
180
|
+
j = json_integer(12345);
|
181
|
+
if(!json_unpack_ex(j, &error, 0, "ia", &i1))
|
182
|
+
fail("json_unpack failed to catch garbage after format string");
|
183
|
+
check_error("Garbage after format string", "<format>", 1, 2, 2);
|
184
|
+
json_decref(j);
|
185
|
+
|
186
|
+
/* NULL format string */
|
187
|
+
j = json_pack("[]");
|
188
|
+
if(!json_unpack_ex(j, &error, 0, NULL))
|
189
|
+
fail("json_unpack failed to catch null format string");
|
190
|
+
check_error("NULL or empty format string", "<format>", -1, -1, 0);
|
191
|
+
json_decref(j);
|
192
|
+
|
193
|
+
/* NULL string pointer */
|
194
|
+
j = json_string("foobie");
|
195
|
+
if(!json_unpack_ex(j, &error, 0, "s", NULL))
|
196
|
+
fail("json_unpack failed to catch null string pointer");
|
197
|
+
check_error("NULL string argument", "<args>", 1, 1, 1);
|
198
|
+
json_decref(j);
|
199
|
+
|
200
|
+
/* invalid types */
|
201
|
+
j = json_integer(42);
|
202
|
+
j2 = json_string("foo");
|
203
|
+
if(!json_unpack_ex(j, &error, 0, "s"))
|
204
|
+
fail("json_unpack failed to catch invalid type");
|
205
|
+
check_error("Expected string, got integer", "<validation>", 1, 1, 1);
|
206
|
+
|
207
|
+
if(!json_unpack_ex(j, &error, 0, "n"))
|
208
|
+
fail("json_unpack failed to catch invalid type");
|
209
|
+
check_error("Expected null, got integer", "<validation>", 1, 1, 1);
|
210
|
+
|
211
|
+
if(!json_unpack_ex(j, &error, 0, "b"))
|
212
|
+
fail("json_unpack failed to catch invalid type");
|
213
|
+
check_error("Expected true or false, got integer", "<validation>", 1, 1, 1);
|
214
|
+
|
215
|
+
if(!json_unpack_ex(j2, &error, 0, "i"))
|
216
|
+
fail("json_unpack failed to catch invalid type");
|
217
|
+
check_error("Expected integer, got string", "<validation>", 1, 1, 1);
|
218
|
+
|
219
|
+
if(!json_unpack_ex(j2, &error, 0, "I"))
|
220
|
+
fail("json_unpack failed to catch invalid type");
|
221
|
+
check_error("Expected integer, got string", "<validation>", 1, 1, 1);
|
222
|
+
|
223
|
+
if(!json_unpack_ex(j, &error, 0, "f"))
|
224
|
+
fail("json_unpack failed to catch invalid type");
|
225
|
+
check_error("Expected real, got integer", "<validation>", 1, 1, 1);
|
226
|
+
|
227
|
+
if(!json_unpack_ex(j2, &error, 0, "F"))
|
228
|
+
fail("json_unpack failed to catch invalid type");
|
229
|
+
check_error("Expected real or integer, got string", "<validation>", 1, 1, 1);
|
230
|
+
|
231
|
+
if(!json_unpack_ex(j, &error, 0, "[i]"))
|
232
|
+
fail("json_unpack failed to catch invalid type");
|
233
|
+
check_error("Expected array, got integer", "<validation>", 1, 1, 1);
|
234
|
+
|
235
|
+
if(!json_unpack_ex(j, &error, 0, "{si}", "foo"))
|
236
|
+
fail("json_unpack failed to catch invalid type");
|
237
|
+
check_error("Expected object, got integer", "<validation>", 1, 1, 1);
|
238
|
+
|
239
|
+
json_decref(j);
|
240
|
+
json_decref(j2);
|
241
|
+
|
242
|
+
/* Array index out of range */
|
243
|
+
j = json_pack("[i]", 1);
|
244
|
+
if(!json_unpack_ex(j, &error, 0, "[ii]", &i1, &i2))
|
245
|
+
fail("json_unpack failed to catch index out of array bounds");
|
246
|
+
check_error("Array index 1 out of range", "<validation>", 1, 3, 3);
|
247
|
+
json_decref(j);
|
248
|
+
|
249
|
+
/* NULL object key */
|
250
|
+
j = json_pack("{si}", "foo", 42);
|
251
|
+
if(!json_unpack_ex(j, &error, 0, "{si}", NULL, &i1))
|
252
|
+
fail("json_unpack failed to catch null string pointer");
|
253
|
+
check_error("NULL object key", "<args>", 1, 2, 2);
|
254
|
+
json_decref(j);
|
255
|
+
|
256
|
+
/* Object key not found */
|
257
|
+
j = json_pack("{si}", "foo", 42);
|
258
|
+
if(!json_unpack_ex(j, &error, 0, "{si}", "baz", &i1))
|
259
|
+
fail("json_unpack failed to catch null string pointer");
|
260
|
+
check_error("Object item not found: baz", "<validation>", 1, 3, 3);
|
261
|
+
json_decref(j);
|
262
|
+
|
263
|
+
/*
|
264
|
+
* Strict validation
|
265
|
+
*/
|
266
|
+
|
267
|
+
j = json_pack("[iii]", 1, 2, 3);
|
268
|
+
rv = json_unpack(j, "[iii!]", &i1, &i2, &i3);
|
269
|
+
if(rv || i1 != 1 || i2 != 2 || i3 != 3)
|
270
|
+
fail("json_unpack array with strict validation failed");
|
271
|
+
json_decref(j);
|
272
|
+
|
273
|
+
j = json_pack("[iii]", 1, 2, 3);
|
274
|
+
if(!json_unpack_ex(j, &error, 0, "[ii!]", &i1, &i2))
|
275
|
+
fail("json_unpack array with strict validation failed");
|
276
|
+
check_error("1 array item(s) left unpacked", "<validation>", 1, 5, 5);
|
277
|
+
json_decref(j);
|
278
|
+
|
279
|
+
/* Like above, but with JSON_STRICT instead of '!' format */
|
280
|
+
j = json_pack("[iii]", 1, 2, 3);
|
281
|
+
if(!json_unpack_ex(j, &error, JSON_STRICT, "[ii]", &i1, &i2))
|
282
|
+
fail("json_unpack array with strict validation failed");
|
283
|
+
check_error("1 array item(s) left unpacked", "<validation>", 1, 4, 4);
|
284
|
+
json_decref(j);
|
285
|
+
|
286
|
+
j = json_pack("{s:s, s:i}", "foo", "bar", "baz", 42);
|
287
|
+
rv = json_unpack(j, "{sssi!}", "foo", &s, "baz", &i1);
|
288
|
+
if(rv || strcmp(s, "bar") != 0 || i1 != 42)
|
289
|
+
fail("json_unpack object with strict validation failed");
|
290
|
+
json_decref(j);
|
291
|
+
|
292
|
+
/* Unpack the same item twice */
|
293
|
+
j = json_pack("{s:s, s:i}", "foo", "bar", "baz", 42);
|
294
|
+
if(!json_unpack_ex(j, &error, 0, "{s:s,s:s!}", "foo", &s, "foo", &s))
|
295
|
+
fail("json_unpack object with strict validation failed");
|
296
|
+
check_error("1 object item(s) left unpacked", "<validation>", 1, 10, 10);
|
297
|
+
json_decref(j);
|
298
|
+
|
299
|
+
j = json_pack("[i,{s:i,s:n},[i,i]]", 1, "foo", 2, "bar", 3, 4);
|
300
|
+
if(json_unpack_ex(j, NULL, JSON_STRICT | JSON_VALIDATE_ONLY,
|
301
|
+
"[i{sisn}[ii]]", "foo", "bar"))
|
302
|
+
fail("json_unpack complex value with strict validation failed");
|
303
|
+
json_decref(j);
|
304
|
+
|
305
|
+
/* ! and * must be last */
|
306
|
+
j = json_pack("[ii]", 1, 2);
|
307
|
+
if(!json_unpack_ex(j, &error, 0, "[i!i]", &i1, &i2))
|
308
|
+
fail("json_unpack failed to catch ! in the middle of an array");
|
309
|
+
check_error("Expected ']' after '!', got 'i'", "<format>", 1, 4, 4);
|
310
|
+
|
311
|
+
if(!json_unpack_ex(j, &error, 0, "[i*i]", &i1, &i2))
|
312
|
+
fail("json_unpack failed to catch * in the middle of an array");
|
313
|
+
check_error("Expected ']' after '*', got 'i'", "<format>", 1, 4, 4);
|
314
|
+
json_decref(j);
|
315
|
+
|
316
|
+
j = json_pack("{sssi}", "foo", "bar", "baz", 42);
|
317
|
+
if(!json_unpack_ex(j, &error, 0, "{ss!si}", "foo", &s, "baz", &i1))
|
318
|
+
fail("json_unpack failed to catch ! in the middle of an object");
|
319
|
+
check_error("Expected '}' after '!', got 's'", "<format>", 1, 5, 5);
|
320
|
+
|
321
|
+
if(!json_unpack_ex(j, &error, 0, "{ss*si}", "foo", &s, "baz", &i1))
|
322
|
+
fail("json_unpack failed to catch ! in the middle of an object");
|
323
|
+
check_error("Expected '}' after '*', got 's'", "<format>", 1, 5, 5);
|
324
|
+
json_decref(j);
|
325
|
+
|
326
|
+
/* Error in nested object */
|
327
|
+
j = json_pack("{s{snsn}}", "foo", "bar", "baz");
|
328
|
+
if(!json_unpack_ex(j, &error, 0, "{s{sn!}}", "foo", "bar"))
|
329
|
+
fail("json_unpack nested object with strict validation failed");
|
330
|
+
check_error("1 object item(s) left unpacked", "<validation>", 1, 7, 7);
|
331
|
+
json_decref(j);
|
332
|
+
|
333
|
+
/* Error in nested array */
|
334
|
+
j = json_pack("[[ii]]", 1, 2);
|
335
|
+
if(!json_unpack_ex(j, &error, 0, "[[i!]]", &i1))
|
336
|
+
fail("json_unpack nested array with strict validation failed");
|
337
|
+
check_error("1 array item(s) left unpacked", "<validation>", 1, 5, 5);
|
338
|
+
json_decref(j);
|
339
|
+
|
340
|
+
/* Optional values */
|
341
|
+
j = json_object();
|
342
|
+
i1 = 0;
|
343
|
+
if(json_unpack(j, "{s?i}", "foo", &i1))
|
344
|
+
fail("json_unpack failed for optional key");
|
345
|
+
if(i1 != 0)
|
346
|
+
fail("json_unpack unpacked an optional key");
|
347
|
+
json_decref(j);
|
348
|
+
|
349
|
+
i1 = 0;
|
350
|
+
j = json_pack("{si}", "foo", 42);
|
351
|
+
if(json_unpack(j, "{s?i}", "foo", &i1))
|
352
|
+
fail("json_unpack failed for an optional value");
|
353
|
+
if(i1 != 42)
|
354
|
+
fail("json_unpack failed to unpack an optional value");
|
355
|
+
json_decref(j);
|
356
|
+
|
357
|
+
j = json_object();
|
358
|
+
i1 = i2 = i3 = 0;
|
359
|
+
if(json_unpack(j, "{s?[ii]s?{s{si}}}",
|
360
|
+
"foo", &i1, &i2,
|
361
|
+
"bar", "baz", "quux", &i3))
|
362
|
+
fail("json_unpack failed for complex optional values");
|
363
|
+
if(i1 != 0 || i2 != 0 || i3 != 0)
|
364
|
+
fail("json_unpack unexpectedly unpacked something");
|
365
|
+
json_decref(j);
|
366
|
+
|
367
|
+
j = json_pack("{s{si}}", "foo", "bar", 42);
|
368
|
+
if(json_unpack(j, "{s?{s?i}}", "foo", "bar", &i1))
|
369
|
+
fail("json_unpack failed for complex optional values");
|
370
|
+
if(i1 != 42)
|
371
|
+
fail("json_unpack failed to unpack");
|
372
|
+
json_decref(j);
|
373
|
+
}
|
@@ -0,0 +1,74 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
|
3
|
+
*
|
4
|
+
* Jansson is free software; you can redistribute it and/or modify
|
5
|
+
* it under the terms of the MIT license. See LICENSE for details.
|
6
|
+
*/
|
7
|
+
|
8
|
+
#ifndef UTIL_H
|
9
|
+
#define UTIL_H
|
10
|
+
|
11
|
+
#ifdef HAVE_CONFIG_H
|
12
|
+
#include <config.h>
|
13
|
+
#endif
|
14
|
+
|
15
|
+
#include <stdio.h>
|
16
|
+
#include <stdlib.h>
|
17
|
+
#if HAVE_LOCALE_H
|
18
|
+
#include <locale.h>
|
19
|
+
#endif
|
20
|
+
|
21
|
+
#include <jansson.h>
|
22
|
+
|
23
|
+
#define failhdr fprintf(stderr, "%s:%s:%d: ", __FILE__, __FUNCTION__, __LINE__)
|
24
|
+
|
25
|
+
#define fail(msg) \
|
26
|
+
do { \
|
27
|
+
failhdr; \
|
28
|
+
fprintf(stderr, "%s\n", msg); \
|
29
|
+
exit(1); \
|
30
|
+
} while(0)
|
31
|
+
|
32
|
+
/* Assumes json_error_t error */
|
33
|
+
#define check_error(text_, source_, line_, column_, position_) \
|
34
|
+
do { \
|
35
|
+
if(strcmp(error.text, text_) != 0) { \
|
36
|
+
failhdr; \
|
37
|
+
fprintf(stderr, "text: \"%s\" != \"%s\"\n", error.text, text_); \
|
38
|
+
exit(1); \
|
39
|
+
} \
|
40
|
+
if(strcmp(error.source, source_) != 0) { \
|
41
|
+
failhdr; \
|
42
|
+
\
|
43
|
+
fprintf(stderr, "source: \"%s\" != \"%s\"\n", error.source, source_); \
|
44
|
+
exit(1); \
|
45
|
+
} \
|
46
|
+
if(error.line != line_) { \
|
47
|
+
failhdr; \
|
48
|
+
fprintf(stderr, "line: %d != %d\n", error.line, line_); \
|
49
|
+
exit(1); \
|
50
|
+
} \
|
51
|
+
if(error.column != column_) { \
|
52
|
+
failhdr; \
|
53
|
+
fprintf(stderr, "column: %d != %d\n", error.column, column_); \
|
54
|
+
exit(1); \
|
55
|
+
} \
|
56
|
+
if(error.position != position_) { \
|
57
|
+
failhdr; \
|
58
|
+
fprintf(stderr, "position: %d != %d\n", error.position, position_); \
|
59
|
+
exit(1); \
|
60
|
+
} \
|
61
|
+
} while(0)
|
62
|
+
|
63
|
+
|
64
|
+
static void run_tests();
|
65
|
+
|
66
|
+
int main() {
|
67
|
+
#ifdef HAVE_SETLOCALE
|
68
|
+
setlocale(LC_ALL, "");
|
69
|
+
#endif
|
70
|
+
run_tests();
|
71
|
+
return 0;
|
72
|
+
}
|
73
|
+
|
74
|
+
#endif
|