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,63 @@
|
|
1
|
+
#include <string.h>
|
2
|
+
#include "jansson_private.h"
|
3
|
+
|
4
|
+
void jsonp_error_init(json_error_t *error, const char *source)
|
5
|
+
{
|
6
|
+
if(error)
|
7
|
+
{
|
8
|
+
error->text[0] = '\0';
|
9
|
+
error->line = -1;
|
10
|
+
error->column = -1;
|
11
|
+
error->position = 0;
|
12
|
+
if(source)
|
13
|
+
jsonp_error_set_source(error, source);
|
14
|
+
else
|
15
|
+
error->source[0] = '\0';
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
void jsonp_error_set_source(json_error_t *error, const char *source)
|
20
|
+
{
|
21
|
+
size_t length;
|
22
|
+
|
23
|
+
if(!error || !source)
|
24
|
+
return;
|
25
|
+
|
26
|
+
length = strlen(source);
|
27
|
+
if(length < JSON_ERROR_SOURCE_LENGTH)
|
28
|
+
strcpy(error->source, source);
|
29
|
+
else {
|
30
|
+
size_t extra = length - JSON_ERROR_SOURCE_LENGTH + 4;
|
31
|
+
strcpy(error->source, "...");
|
32
|
+
strcpy(error->source + 3, source + extra);
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
void jsonp_error_set(json_error_t *error, int line, int column,
|
37
|
+
size_t position, const char *msg, ...)
|
38
|
+
{
|
39
|
+
va_list ap;
|
40
|
+
|
41
|
+
va_start(ap, msg);
|
42
|
+
jsonp_error_vset(error, line, column, position, msg, ap);
|
43
|
+
va_end(ap);
|
44
|
+
}
|
45
|
+
|
46
|
+
void jsonp_error_vset(json_error_t *error, int line, int column,
|
47
|
+
size_t position, const char *msg, va_list ap)
|
48
|
+
{
|
49
|
+
if(!error)
|
50
|
+
return;
|
51
|
+
|
52
|
+
if(error->text[0] != '\0') {
|
53
|
+
/* error already set */
|
54
|
+
return;
|
55
|
+
}
|
56
|
+
|
57
|
+
error->line = line;
|
58
|
+
error->column = column;
|
59
|
+
error->position = position;
|
60
|
+
|
61
|
+
vsnprintf(error->text, JSON_ERROR_TEXT_LENGTH, msg, ap);
|
62
|
+
error->text[JSON_ERROR_TEXT_LENGTH - 1] = '\0';
|
63
|
+
}
|
@@ -0,0 +1,360 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
|
3
|
+
*
|
4
|
+
* This library 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
|
+
#include <stdlib.h>
|
9
|
+
#include <string.h>
|
10
|
+
#include <jansson_config.h> /* for JSON_INLINE */
|
11
|
+
#include "jansson_private.h" /* for container_of() */
|
12
|
+
#include "hashtable.h"
|
13
|
+
|
14
|
+
typedef struct hashtable_list list_t;
|
15
|
+
typedef struct hashtable_pair pair_t;
|
16
|
+
typedef struct hashtable_bucket bucket_t;
|
17
|
+
|
18
|
+
#define list_to_pair(list_) container_of(list_, pair_t, list)
|
19
|
+
|
20
|
+
/* From http://www.cse.yorku.ca/~oz/hash.html */
|
21
|
+
static size_t hash_str(const void *ptr)
|
22
|
+
{
|
23
|
+
const char *str = (const char *)ptr;
|
24
|
+
|
25
|
+
size_t hash = 5381;
|
26
|
+
size_t c;
|
27
|
+
|
28
|
+
while((c = (size_t)*str))
|
29
|
+
{
|
30
|
+
hash = ((hash << 5) + hash) + c;
|
31
|
+
str++;
|
32
|
+
}
|
33
|
+
|
34
|
+
return hash;
|
35
|
+
}
|
36
|
+
|
37
|
+
static JSON_INLINE void list_init(list_t *list)
|
38
|
+
{
|
39
|
+
list->next = list;
|
40
|
+
list->prev = list;
|
41
|
+
}
|
42
|
+
|
43
|
+
static JSON_INLINE void list_insert(list_t *list, list_t *node)
|
44
|
+
{
|
45
|
+
node->next = list;
|
46
|
+
node->prev = list->prev;
|
47
|
+
list->prev->next = node;
|
48
|
+
list->prev = node;
|
49
|
+
}
|
50
|
+
|
51
|
+
static JSON_INLINE void list_remove(list_t *list)
|
52
|
+
{
|
53
|
+
list->prev->next = list->next;
|
54
|
+
list->next->prev = list->prev;
|
55
|
+
}
|
56
|
+
|
57
|
+
static JSON_INLINE int bucket_is_empty(hashtable_t *hashtable, bucket_t *bucket)
|
58
|
+
{
|
59
|
+
return bucket->first == &hashtable->list && bucket->first == bucket->last;
|
60
|
+
}
|
61
|
+
|
62
|
+
static void insert_to_bucket(hashtable_t *hashtable, bucket_t *bucket,
|
63
|
+
list_t *list)
|
64
|
+
{
|
65
|
+
if(bucket_is_empty(hashtable, bucket))
|
66
|
+
{
|
67
|
+
list_insert(&hashtable->list, list);
|
68
|
+
bucket->first = bucket->last = list;
|
69
|
+
}
|
70
|
+
else
|
71
|
+
{
|
72
|
+
list_insert(bucket->first, list);
|
73
|
+
bucket->first = list;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
static const size_t primes[] = {
|
78
|
+
5, 13, 23, 53, 97, 193, 389, 769, 1543, 3079, 6151, 12289, 24593,
|
79
|
+
49157, 98317, 196613, 393241, 786433, 1572869, 3145739, 6291469,
|
80
|
+
12582917, 25165843, 50331653, 100663319, 201326611, 402653189,
|
81
|
+
805306457, 1610612741
|
82
|
+
};
|
83
|
+
|
84
|
+
static JSON_INLINE size_t num_buckets(hashtable_t *hashtable)
|
85
|
+
{
|
86
|
+
return primes[hashtable->num_buckets];
|
87
|
+
}
|
88
|
+
|
89
|
+
|
90
|
+
static pair_t *hashtable_find_pair(hashtable_t *hashtable, bucket_t *bucket,
|
91
|
+
const char *key, size_t hash)
|
92
|
+
{
|
93
|
+
list_t *list;
|
94
|
+
pair_t *pair;
|
95
|
+
|
96
|
+
if(bucket_is_empty(hashtable, bucket))
|
97
|
+
return NULL;
|
98
|
+
|
99
|
+
list = bucket->first;
|
100
|
+
while(1)
|
101
|
+
{
|
102
|
+
pair = list_to_pair(list);
|
103
|
+
if(pair->hash == hash && strcmp(pair->key, key) == 0)
|
104
|
+
return pair;
|
105
|
+
|
106
|
+
if(list == bucket->last)
|
107
|
+
break;
|
108
|
+
|
109
|
+
list = list->next;
|
110
|
+
}
|
111
|
+
|
112
|
+
return NULL;
|
113
|
+
}
|
114
|
+
|
115
|
+
/* returns 0 on success, -1 if key was not found */
|
116
|
+
static int hashtable_do_del(hashtable_t *hashtable,
|
117
|
+
const char *key, size_t hash)
|
118
|
+
{
|
119
|
+
pair_t *pair;
|
120
|
+
bucket_t *bucket;
|
121
|
+
size_t index;
|
122
|
+
|
123
|
+
index = hash % num_buckets(hashtable);
|
124
|
+
bucket = &hashtable->buckets[index];
|
125
|
+
|
126
|
+
pair = hashtable_find_pair(hashtable, bucket, key, hash);
|
127
|
+
if(!pair)
|
128
|
+
return -1;
|
129
|
+
|
130
|
+
if(&pair->list == bucket->first && &pair->list == bucket->last)
|
131
|
+
bucket->first = bucket->last = &hashtable->list;
|
132
|
+
|
133
|
+
else if(&pair->list == bucket->first)
|
134
|
+
bucket->first = pair->list.next;
|
135
|
+
|
136
|
+
else if(&pair->list == bucket->last)
|
137
|
+
bucket->last = pair->list.prev;
|
138
|
+
|
139
|
+
list_remove(&pair->list);
|
140
|
+
json_decref(pair->value);
|
141
|
+
|
142
|
+
jsonp_free(pair);
|
143
|
+
hashtable->size--;
|
144
|
+
|
145
|
+
return 0;
|
146
|
+
}
|
147
|
+
|
148
|
+
static void hashtable_do_clear(hashtable_t *hashtable)
|
149
|
+
{
|
150
|
+
list_t *list, *next;
|
151
|
+
pair_t *pair;
|
152
|
+
|
153
|
+
for(list = hashtable->list.next; list != &hashtable->list; list = next)
|
154
|
+
{
|
155
|
+
next = list->next;
|
156
|
+
pair = list_to_pair(list);
|
157
|
+
json_decref(pair->value);
|
158
|
+
jsonp_free(pair);
|
159
|
+
}
|
160
|
+
}
|
161
|
+
|
162
|
+
static int hashtable_do_rehash(hashtable_t *hashtable)
|
163
|
+
{
|
164
|
+
list_t *list, *next;
|
165
|
+
pair_t *pair;
|
166
|
+
size_t i, index, new_size;
|
167
|
+
|
168
|
+
jsonp_free(hashtable->buckets);
|
169
|
+
|
170
|
+
hashtable->num_buckets++;
|
171
|
+
new_size = num_buckets(hashtable);
|
172
|
+
|
173
|
+
hashtable->buckets = jsonp_malloc(new_size * sizeof(bucket_t));
|
174
|
+
if(!hashtable->buckets)
|
175
|
+
return -1;
|
176
|
+
|
177
|
+
for(i = 0; i < num_buckets(hashtable); i++)
|
178
|
+
{
|
179
|
+
hashtable->buckets[i].first = hashtable->buckets[i].last =
|
180
|
+
&hashtable->list;
|
181
|
+
}
|
182
|
+
|
183
|
+
list = hashtable->list.next;
|
184
|
+
list_init(&hashtable->list);
|
185
|
+
|
186
|
+
for(; list != &hashtable->list; list = next) {
|
187
|
+
next = list->next;
|
188
|
+
pair = list_to_pair(list);
|
189
|
+
index = pair->hash % new_size;
|
190
|
+
insert_to_bucket(hashtable, &hashtable->buckets[index], &pair->list);
|
191
|
+
}
|
192
|
+
|
193
|
+
return 0;
|
194
|
+
}
|
195
|
+
|
196
|
+
|
197
|
+
int hashtable_init(hashtable_t *hashtable)
|
198
|
+
{
|
199
|
+
size_t i;
|
200
|
+
|
201
|
+
hashtable->size = 0;
|
202
|
+
hashtable->num_buckets = 0; /* index to primes[] */
|
203
|
+
hashtable->buckets = jsonp_malloc(num_buckets(hashtable) * sizeof(bucket_t));
|
204
|
+
if(!hashtable->buckets)
|
205
|
+
return -1;
|
206
|
+
|
207
|
+
list_init(&hashtable->list);
|
208
|
+
|
209
|
+
for(i = 0; i < num_buckets(hashtable); i++)
|
210
|
+
{
|
211
|
+
hashtable->buckets[i].first = hashtable->buckets[i].last =
|
212
|
+
&hashtable->list;
|
213
|
+
}
|
214
|
+
|
215
|
+
return 0;
|
216
|
+
}
|
217
|
+
|
218
|
+
void hashtable_close(hashtable_t *hashtable)
|
219
|
+
{
|
220
|
+
hashtable_do_clear(hashtable);
|
221
|
+
jsonp_free(hashtable->buckets);
|
222
|
+
}
|
223
|
+
|
224
|
+
int hashtable_set(hashtable_t *hashtable,
|
225
|
+
const char *key, size_t serial,
|
226
|
+
json_t *value)
|
227
|
+
{
|
228
|
+
pair_t *pair;
|
229
|
+
bucket_t *bucket;
|
230
|
+
size_t hash, index;
|
231
|
+
|
232
|
+
/* rehash if the load ratio exceeds 1 */
|
233
|
+
if(hashtable->size >= num_buckets(hashtable))
|
234
|
+
if(hashtable_do_rehash(hashtable))
|
235
|
+
return -1;
|
236
|
+
|
237
|
+
hash = hash_str(key);
|
238
|
+
index = hash % num_buckets(hashtable);
|
239
|
+
bucket = &hashtable->buckets[index];
|
240
|
+
pair = hashtable_find_pair(hashtable, bucket, key, hash);
|
241
|
+
|
242
|
+
if(pair)
|
243
|
+
{
|
244
|
+
json_decref(pair->value);
|
245
|
+
pair->value = value;
|
246
|
+
}
|
247
|
+
else
|
248
|
+
{
|
249
|
+
/* offsetof(...) returns the size of pair_t without the last,
|
250
|
+
flexible member. This way, the correct amount is
|
251
|
+
allocated. */
|
252
|
+
pair = jsonp_malloc(offsetof(pair_t, key) + strlen(key) + 1);
|
253
|
+
if(!pair)
|
254
|
+
return -1;
|
255
|
+
|
256
|
+
pair->hash = hash;
|
257
|
+
pair->serial = serial;
|
258
|
+
strcpy(pair->key, key);
|
259
|
+
pair->value = value;
|
260
|
+
list_init(&pair->list);
|
261
|
+
|
262
|
+
insert_to_bucket(hashtable, bucket, &pair->list);
|
263
|
+
|
264
|
+
hashtable->size++;
|
265
|
+
}
|
266
|
+
return 0;
|
267
|
+
}
|
268
|
+
|
269
|
+
void *hashtable_get(hashtable_t *hashtable, const char *key)
|
270
|
+
{
|
271
|
+
pair_t *pair;
|
272
|
+
size_t hash;
|
273
|
+
bucket_t *bucket;
|
274
|
+
|
275
|
+
hash = hash_str(key);
|
276
|
+
bucket = &hashtable->buckets[hash % num_buckets(hashtable)];
|
277
|
+
|
278
|
+
pair = hashtable_find_pair(hashtable, bucket, key, hash);
|
279
|
+
if(!pair)
|
280
|
+
return NULL;
|
281
|
+
|
282
|
+
return pair->value;
|
283
|
+
}
|
284
|
+
|
285
|
+
int hashtable_del(hashtable_t *hashtable, const char *key)
|
286
|
+
{
|
287
|
+
size_t hash = hash_str(key);
|
288
|
+
return hashtable_do_del(hashtable, key, hash);
|
289
|
+
}
|
290
|
+
|
291
|
+
void hashtable_clear(hashtable_t *hashtable)
|
292
|
+
{
|
293
|
+
size_t i;
|
294
|
+
|
295
|
+
hashtable_do_clear(hashtable);
|
296
|
+
|
297
|
+
for(i = 0; i < num_buckets(hashtable); i++)
|
298
|
+
{
|
299
|
+
hashtable->buckets[i].first = hashtable->buckets[i].last =
|
300
|
+
&hashtable->list;
|
301
|
+
}
|
302
|
+
|
303
|
+
list_init(&hashtable->list);
|
304
|
+
hashtable->size = 0;
|
305
|
+
}
|
306
|
+
|
307
|
+
void *hashtable_iter(hashtable_t *hashtable)
|
308
|
+
{
|
309
|
+
return hashtable_iter_next(hashtable, &hashtable->list);
|
310
|
+
}
|
311
|
+
|
312
|
+
void *hashtable_iter_at(hashtable_t *hashtable, const char *key)
|
313
|
+
{
|
314
|
+
pair_t *pair;
|
315
|
+
size_t hash;
|
316
|
+
bucket_t *bucket;
|
317
|
+
|
318
|
+
hash = hash_str(key);
|
319
|
+
bucket = &hashtable->buckets[hash % num_buckets(hashtable)];
|
320
|
+
|
321
|
+
pair = hashtable_find_pair(hashtable, bucket, key, hash);
|
322
|
+
if(!pair)
|
323
|
+
return NULL;
|
324
|
+
|
325
|
+
return &pair->list;
|
326
|
+
}
|
327
|
+
|
328
|
+
void *hashtable_iter_next(hashtable_t *hashtable, void *iter)
|
329
|
+
{
|
330
|
+
list_t *list = (list_t *)iter;
|
331
|
+
if(list->next == &hashtable->list)
|
332
|
+
return NULL;
|
333
|
+
return list->next;
|
334
|
+
}
|
335
|
+
|
336
|
+
void *hashtable_iter_key(void *iter)
|
337
|
+
{
|
338
|
+
pair_t *pair = list_to_pair((list_t *)iter);
|
339
|
+
return pair->key;
|
340
|
+
}
|
341
|
+
|
342
|
+
size_t hashtable_iter_serial(void *iter)
|
343
|
+
{
|
344
|
+
pair_t *pair = list_to_pair((list_t *)iter);
|
345
|
+
return pair->serial;
|
346
|
+
}
|
347
|
+
|
348
|
+
void *hashtable_iter_value(void *iter)
|
349
|
+
{
|
350
|
+
pair_t *pair = list_to_pair((list_t *)iter);
|
351
|
+
return pair->value;
|
352
|
+
}
|
353
|
+
|
354
|
+
void hashtable_iter_set(void *iter, json_t *value)
|
355
|
+
{
|
356
|
+
pair_t *pair = list_to_pair((list_t *)iter);
|
357
|
+
|
358
|
+
json_decref(pair->value);
|
359
|
+
pair->value = value;
|
360
|
+
}
|
@@ -0,0 +1,180 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2009-2013 Petri Lehtinen <petri@digip.org>
|
3
|
+
*
|
4
|
+
* This library 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 HASHTABLE_H
|
9
|
+
#define HASHTABLE_H
|
10
|
+
|
11
|
+
struct hashtable_list {
|
12
|
+
struct hashtable_list *prev;
|
13
|
+
struct hashtable_list *next;
|
14
|
+
};
|
15
|
+
|
16
|
+
/* "pair" may be a bit confusing a name, but think of it as a
|
17
|
+
key-value pair. In this case, it just encodes some extra data,
|
18
|
+
too */
|
19
|
+
struct hashtable_pair {
|
20
|
+
size_t hash;
|
21
|
+
struct hashtable_list list;
|
22
|
+
json_t *value;
|
23
|
+
size_t serial;
|
24
|
+
char key[1];
|
25
|
+
};
|
26
|
+
|
27
|
+
struct hashtable_bucket {
|
28
|
+
struct hashtable_list *first;
|
29
|
+
struct hashtable_list *last;
|
30
|
+
};
|
31
|
+
|
32
|
+
typedef struct hashtable {
|
33
|
+
size_t size;
|
34
|
+
struct hashtable_bucket *buckets;
|
35
|
+
size_t num_buckets; /* index to primes[] */
|
36
|
+
struct hashtable_list list;
|
37
|
+
} hashtable_t;
|
38
|
+
|
39
|
+
|
40
|
+
#define hashtable_key_to_iter(key_) \
|
41
|
+
(&(container_of(key_, struct hashtable_pair, key)->list))
|
42
|
+
|
43
|
+
/**
|
44
|
+
* hashtable_init - Initialize a hashtable object
|
45
|
+
*
|
46
|
+
* @hashtable: The (statically allocated) hashtable object
|
47
|
+
*
|
48
|
+
* Initializes a statically allocated hashtable object. The object
|
49
|
+
* should be cleared with hashtable_close when it's no longer used.
|
50
|
+
*
|
51
|
+
* Returns 0 on success, -1 on error (out of memory).
|
52
|
+
*/
|
53
|
+
int hashtable_init(hashtable_t *hashtable);
|
54
|
+
|
55
|
+
/**
|
56
|
+
* hashtable_close - Release all resources used by a hashtable object
|
57
|
+
*
|
58
|
+
* @hashtable: The hashtable
|
59
|
+
*
|
60
|
+
* Destroys a statically allocated hashtable object.
|
61
|
+
*/
|
62
|
+
void hashtable_close(hashtable_t *hashtable);
|
63
|
+
|
64
|
+
/**
|
65
|
+
* hashtable_set - Add/modify value in hashtable
|
66
|
+
*
|
67
|
+
* @hashtable: The hashtable object
|
68
|
+
* @key: The key
|
69
|
+
* @serial: For addition order of keys
|
70
|
+
* @value: The value
|
71
|
+
*
|
72
|
+
* If a value with the given key already exists, its value is replaced
|
73
|
+
* with the new value. Value is "stealed" in the sense that hashtable
|
74
|
+
* doesn't increment its refcount but decreases the refcount when the
|
75
|
+
* value is no longer needed.
|
76
|
+
*
|
77
|
+
* Returns 0 on success, -1 on failure (out of memory).
|
78
|
+
*/
|
79
|
+
int hashtable_set(hashtable_t *hashtable,
|
80
|
+
const char *key, size_t serial,
|
81
|
+
json_t *value);
|
82
|
+
|
83
|
+
/**
|
84
|
+
* hashtable_get - Get a value associated with a key
|
85
|
+
*
|
86
|
+
* @hashtable: The hashtable object
|
87
|
+
* @key: The key
|
88
|
+
*
|
89
|
+
* Returns value if it is found, or NULL otherwise.
|
90
|
+
*/
|
91
|
+
void *hashtable_get(hashtable_t *hashtable, const char *key);
|
92
|
+
|
93
|
+
/**
|
94
|
+
* hashtable_del - Remove a value from the hashtable
|
95
|
+
*
|
96
|
+
* @hashtable: The hashtable object
|
97
|
+
* @key: The key
|
98
|
+
*
|
99
|
+
* Returns 0 on success, or -1 if the key was not found.
|
100
|
+
*/
|
101
|
+
int hashtable_del(hashtable_t *hashtable, const char *key);
|
102
|
+
|
103
|
+
/**
|
104
|
+
* hashtable_clear - Clear hashtable
|
105
|
+
*
|
106
|
+
* @hashtable: The hashtable object
|
107
|
+
*
|
108
|
+
* Removes all items from the hashtable.
|
109
|
+
*/
|
110
|
+
void hashtable_clear(hashtable_t *hashtable);
|
111
|
+
|
112
|
+
/**
|
113
|
+
* hashtable_iter - Iterate over hashtable
|
114
|
+
*
|
115
|
+
* @hashtable: The hashtable object
|
116
|
+
*
|
117
|
+
* Returns an opaque iterator to the first element in the hashtable.
|
118
|
+
* The iterator should be passed to hashtable_iter_* functions.
|
119
|
+
* The hashtable items are not iterated over in any particular order.
|
120
|
+
*
|
121
|
+
* There's no need to free the iterator in any way. The iterator is
|
122
|
+
* valid as long as the item that is referenced by the iterator is not
|
123
|
+
* deleted. Other values may be added or deleted. In particular,
|
124
|
+
* hashtable_iter_next() may be called on an iterator, and after that
|
125
|
+
* the key/value pair pointed by the old iterator may be deleted.
|
126
|
+
*/
|
127
|
+
void *hashtable_iter(hashtable_t *hashtable);
|
128
|
+
|
129
|
+
/**
|
130
|
+
* hashtable_iter_at - Return an iterator at a specific key
|
131
|
+
*
|
132
|
+
* @hashtable: The hashtable object
|
133
|
+
* @key: The key that the iterator should point to
|
134
|
+
*
|
135
|
+
* Like hashtable_iter() but returns an iterator pointing to a
|
136
|
+
* specific key.
|
137
|
+
*/
|
138
|
+
void *hashtable_iter_at(hashtable_t *hashtable, const char *key);
|
139
|
+
|
140
|
+
/**
|
141
|
+
* hashtable_iter_next - Advance an iterator
|
142
|
+
*
|
143
|
+
* @hashtable: The hashtable object
|
144
|
+
* @iter: The iterator
|
145
|
+
*
|
146
|
+
* Returns a new iterator pointing to the next element in the
|
147
|
+
* hashtable or NULL if the whole hastable has been iterated over.
|
148
|
+
*/
|
149
|
+
void *hashtable_iter_next(hashtable_t *hashtable, void *iter);
|
150
|
+
|
151
|
+
/**
|
152
|
+
* hashtable_iter_key - Retrieve the key pointed by an iterator
|
153
|
+
*
|
154
|
+
* @iter: The iterator
|
155
|
+
*/
|
156
|
+
void *hashtable_iter_key(void *iter);
|
157
|
+
|
158
|
+
/**
|
159
|
+
* hashtable_iter_serial - Retrieve the serial number pointed to by an iterator
|
160
|
+
*
|
161
|
+
* @iter: The iterator
|
162
|
+
*/
|
163
|
+
size_t hashtable_iter_serial(void *iter);
|
164
|
+
|
165
|
+
/**
|
166
|
+
* hashtable_iter_value - Retrieve the value pointed by an iterator
|
167
|
+
*
|
168
|
+
* @iter: The iterator
|
169
|
+
*/
|
170
|
+
void *hashtable_iter_value(void *iter);
|
171
|
+
|
172
|
+
/**
|
173
|
+
* hashtable_iter_set - Set the value pointed by an iterator
|
174
|
+
*
|
175
|
+
* @iter: The iterator
|
176
|
+
* @value: The value to set
|
177
|
+
*/
|
178
|
+
void hashtable_iter_set(void *iter, json_t *value);
|
179
|
+
|
180
|
+
#endif
|