zsv 1.3.0 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/README.md +41 -3
  4. data/ext/zsv/extconf.rb +66 -49
  5. data/ext/zsv/options.c +1 -2
  6. data/ext/zsv/parser.c +14 -0
  7. data/ext/zsv/zsv_ext.c +3 -0
  8. data/lib/zsv/version.rb +1 -1
  9. metadata +6 -226
  10. data/ext/zsv/vendor/zsv-1.3.0/app/2db.c +0 -756
  11. data/ext/zsv/vendor/zsv-1.3.0/app/2json.c +0 -381
  12. data/ext/zsv/vendor/zsv-1.3.0/app/2tsv.c +0 -228
  13. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/help.c +0 -123
  14. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/license.c +0 -39
  15. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/register.c +0 -104
  16. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/thirdparty.c +0 -41
  17. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/unregister.c +0 -1
  18. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/version.c +0 -14
  19. data/ext/zsv/vendor/zsv-1.3.0/app/check/simdutf_wrapper.h +0 -19
  20. data/ext/zsv/vendor/zsv-1.3.0/app/check/utf8.c +0 -116
  21. data/ext/zsv/vendor/zsv-1.3.0/app/check.c +0 -194
  22. data/ext/zsv/vendor/zsv-1.3.0/app/cli.c +0 -796
  23. data/ext/zsv/vendor/zsv-1.3.0/app/cli_const.h +0 -41
  24. data/ext/zsv/vendor/zsv-1.3.0/app/cli_export.h +0 -16
  25. data/ext/zsv/vendor/zsv-1.3.0/app/cli_ini.c +0 -280
  26. data/ext/zsv/vendor/zsv-1.3.0/app/cli_internal.h +0 -36
  27. data/ext/zsv/vendor/zsv-1.3.0/app/compare.c +0 -913
  28. data/ext/zsv/vendor/zsv-1.3.0/app/compare.h +0 -23
  29. data/ext/zsv/vendor/zsv-1.3.0/app/compare_added_column.c +0 -20
  30. data/ext/zsv/vendor/zsv-1.3.0/app/compare_internal.h +0 -140
  31. data/ext/zsv/vendor/zsv-1.3.0/app/compare_sort.c +0 -91
  32. data/ext/zsv/vendor/zsv-1.3.0/app/compare_unique_colname.c +0 -81
  33. data/ext/zsv/vendor/zsv-1.3.0/app/count-pull.c +0 -82
  34. data/ext/zsv/vendor/zsv-1.3.0/app/count.c +0 -404
  35. data/ext/zsv/vendor/zsv-1.3.0/app/desc.c +0 -569
  36. data/ext/zsv/vendor/zsv-1.3.0/app/echo.c +0 -365
  37. data/ext/zsv/vendor/zsv-1.3.0/app/ext_example/my_extension.c +0 -366
  38. data/ext/zsv/vendor/zsv-1.3.0/app/ext_example/mysheet_extension.c +0 -341
  39. data/ext/zsv/vendor/zsv-1.3.0/app/ext_template/YOUR_EXTENSION_zsvext.c +0 -263
  40. data/ext/zsv/vendor/zsv-1.3.0/app/external/inih/ini.c +0 -298
  41. data/ext/zsv/vendor/zsv-1.3.0/app/external/inih/ini.h +0 -157
  42. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/json_numeric.c +0 -177
  43. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/jsonwriter.c +0 -444
  44. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/jsonwriter.h +0 -145
  45. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/utils.c +0 -110
  46. data/ext/zsv/vendor/zsv-1.3.0/app/external/memfile-1.0/include/memfile.h +0 -15
  47. data/ext/zsv/vendor/zsv-1.3.0/app/external/memfile-1.0/src/memfile.c +0 -64
  48. data/ext/zsv/vendor/zsv-1.3.0/app/external/sglib/sglib.h +0 -1955
  49. data/ext/zsv/vendor/zsv-1.3.0/app/external/simdutf/simdutf.h +0 -6802
  50. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3.c +0 -230517
  51. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3.h +0 -12174
  52. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_and_csv_vtab.c +0 -2
  53. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab-mem.c +0 -142
  54. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab-mem.h +0 -49
  55. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab-zsv.c +0 -485
  56. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab.c +0 -1015
  57. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3ext.h +0 -663
  58. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/vtab_helper.c +0 -85
  59. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_common.h +0 -75
  60. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_gen.h +0 -167
  61. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_parse.h +0 -228
  62. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_tree.h +0 -186
  63. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_version.h +0 -23
  64. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_common.h +0 -76
  65. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_gen.h +0 -167
  66. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_parse.h +0 -238
  67. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_tree.h +0 -186
  68. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl.c +0 -184
  69. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_alloc.c +0 -52
  70. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_alloc.h +0 -34
  71. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_buf.c +0 -103
  72. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_buf.h +0 -57
  73. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_bytestack.h +0 -69
  74. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_encode.c +0 -220
  75. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_encode.h +0 -34
  76. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_gen.c +0 -362
  77. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_lex.c +0 -764
  78. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_lex.h +0 -117
  79. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_parser.c +0 -508
  80. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_parser.h +0 -78
  81. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_tree.c +0 -505
  82. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_version.c +0 -7
  83. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper/json_value.h +0 -59
  84. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper/yajl_helper.h +0 -208
  85. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper.c +0 -795
  86. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper_internal.h +0 -28
  87. data/ext/zsv/vendor/zsv-1.3.0/app/flatten.c +0 -851
  88. data/ext/zsv/vendor/zsv-1.3.0/app/jq.c +0 -106
  89. data/ext/zsv/vendor/zsv-1.3.0/app/jq.h +0 -6
  90. data/ext/zsv/vendor/zsv-1.3.0/app/mv.c +0 -113
  91. data/ext/zsv/vendor/zsv-1.3.0/app/noop.c +0 -90
  92. data/ext/zsv/vendor/zsv-1.3.0/app/overwrite.c +0 -295
  93. data/ext/zsv/vendor/zsv-1.3.0/app/paste.c +0 -175
  94. data/ext/zsv/vendor/zsv-1.3.0/app/pretty.c +0 -693
  95. data/ext/zsv/vendor/zsv-1.3.0/app/prop.c +0 -980
  96. data/ext/zsv/vendor/zsv-1.3.0/app/rm.c +0 -131
  97. data/ext/zsv/vendor/zsv-1.3.0/app/select/fixed.c +0 -130
  98. data/ext/zsv/vendor/zsv-1.3.0/app/select/internal.h +0 -118
  99. data/ext/zsv/vendor/zsv-1.3.0/app/select/parallel.c +0 -45
  100. data/ext/zsv/vendor/zsv-1.3.0/app/select/parallel.h +0 -41
  101. data/ext/zsv/vendor/zsv-1.3.0/app/select/processing.c +0 -107
  102. data/ext/zsv/vendor/zsv-1.3.0/app/select/rand.c +0 -20
  103. data/ext/zsv/vendor/zsv-1.3.0/app/select/regex.c +0 -61
  104. data/ext/zsv/vendor/zsv-1.3.0/app/select/search.c +0 -14
  105. data/ext/zsv/vendor/zsv-1.3.0/app/select/selection.c +0 -192
  106. data/ext/zsv/vendor/zsv-1.3.0/app/select/usage.c +0 -72
  107. data/ext/zsv/vendor/zsv-1.3.0/app/select-pull.c +0 -812
  108. data/ext/zsv/vendor/zsv-1.3.0/app/select.c +0 -753
  109. data/ext/zsv/vendor/zsv-1.3.0/app/serialize.c +0 -372
  110. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/curses.h +0 -15
  111. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/cursor.c +0 -119
  112. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/errors.c +0 -45
  113. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/file.c +0 -63
  114. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/file.h +0 -12
  115. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/filter.c +0 -166
  116. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/handlers.c +0 -214
  117. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/handlers_internal.h +0 -128
  118. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/help.c +0 -43
  119. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/index.c +0 -81
  120. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/index.h +0 -25
  121. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/key-bindings.c +0 -325
  122. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/key-bindings.h +0 -73
  123. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/lexer.c +0 -203
  124. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/newline_handler.c +0 -7
  125. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/pivot.c +0 -318
  126. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/procedure.c +0 -134
  127. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/procedure.h +0 -119
  128. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/read-data.c +0 -322
  129. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/screen_buffer.c +0 -203
  130. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/screen_buffer.h +0 -36
  131. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/sheet-sql.c +0 -167
  132. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/sheet_internal.h +0 -36
  133. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/sqlfilter.c +0 -153
  134. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/terminfo.c +0 -32
  135. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/transformation.c +0 -312
  136. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/transformation.h +0 -29
  137. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/ui_buffer.c +0 -266
  138. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/usage.c +0 -9
  139. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/utf8-width.c +0 -60
  140. data/ext/zsv/vendor/zsv-1.3.0/app/sheet.c +0 -1007
  141. data/ext/zsv/vendor/zsv-1.3.0/app/sql.c +0 -453
  142. data/ext/zsv/vendor/zsv-1.3.0/app/sql_internal.c +0 -101
  143. data/ext/zsv/vendor/zsv-1.3.0/app/sql_internal.h +0 -49
  144. data/ext/zsv/vendor/zsv-1.3.0/app/stack.c +0 -393
  145. data/ext/zsv/vendor/zsv-1.3.0/app/utils/arg.c +0 -322
  146. data/ext/zsv/vendor/zsv-1.3.0/app/utils/cache.c +0 -228
  147. data/ext/zsv/vendor/zsv-1.3.0/app/utils/cat.c +0 -91
  148. data/ext/zsv/vendor/zsv-1.3.0/app/utils/chunk.c +0 -240
  149. data/ext/zsv/vendor/zsv-1.3.0/app/utils/chunk.h +0 -63
  150. data/ext/zsv/vendor/zsv-1.3.0/app/utils/clock.c +0 -57
  151. data/ext/zsv/vendor/zsv-1.3.0/app/utils/db.c +0 -148
  152. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs-no-jq.c +0 -2
  153. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs.c +0 -427
  154. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs_from_json.c +0 -253
  155. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs_to_json.c +0 -121
  156. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dl.c +0 -20
  157. data/ext/zsv/vendor/zsv-1.3.0/app/utils/emcc/fs_api.c +0 -159
  158. data/ext/zsv/vendor/zsv-1.3.0/app/utils/err.c +0 -24
  159. data/ext/zsv/vendor/zsv-1.3.0/app/utils/file-mem.c +0 -180
  160. data/ext/zsv/vendor/zsv-1.3.0/app/utils/file.c +0 -256
  161. data/ext/zsv/vendor/zsv-1.3.0/app/utils/index.c +0 -197
  162. data/ext/zsv/vendor/zsv-1.3.0/app/utils/index.h +0 -49
  163. data/ext/zsv/vendor/zsv-1.3.0/app/utils/jq.c +0 -400
  164. data/ext/zsv/vendor/zsv-1.3.0/app/utils/json.c +0 -120
  165. data/ext/zsv/vendor/zsv-1.3.0/app/utils/mem.c +0 -18
  166. data/ext/zsv/vendor/zsv-1.3.0/app/utils/memmem.c +0 -132
  167. data/ext/zsv/vendor/zsv-1.3.0/app/utils/os.c +0 -178
  168. data/ext/zsv/vendor/zsv-1.3.0/app/utils/overwrite.c +0 -258
  169. data/ext/zsv/vendor/zsv-1.3.0/app/utils/overwrite_writer.c +0 -246
  170. data/ext/zsv/vendor/zsv-1.3.0/app/utils/pcre2-8/pcre2-8-test.c +0 -123
  171. data/ext/zsv/vendor/zsv-1.3.0/app/utils/pcre2-8/pcre2-8.c +0 -153
  172. data/ext/zsv/vendor/zsv-1.3.0/app/utils/pcre2-8/pcre2-8.h +0 -54
  173. data/ext/zsv/vendor/zsv-1.3.0/app/utils/prop.c +0 -267
  174. data/ext/zsv/vendor/zsv-1.3.0/app/utils/signal.c +0 -53
  175. data/ext/zsv/vendor/zsv-1.3.0/app/utils/string.c +0 -357
  176. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/dir_exists_longpath.c +0 -83
  177. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/dl.c +0 -33
  178. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/fopen_longpath.c +0 -184
  179. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/foreach_dirent_longpath.c +0 -292
  180. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/io.c +0 -259
  181. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/io.h +0 -13
  182. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/mkdir_longpath.c +0 -255
  183. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/remove_longpath.c +0 -96
  184. data/ext/zsv/vendor/zsv-1.3.0/app/utils/writer.c +0 -361
  185. data/ext/zsv/vendor/zsv-1.3.0/app/zsv_command.h +0 -40
  186. data/ext/zsv/vendor/zsv-1.3.0/app/zsv_command_standalone.c +0 -16
  187. data/ext/zsv/vendor/zsv-1.3.0/app/zsv_main.h +0 -44
  188. data/ext/zsv/vendor/zsv-1.3.0/examples/js/zsv_parser_api_dummy.c +0 -3
  189. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/parse_by_chunk.c +0 -100
  190. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/print_my_column.c +0 -143
  191. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/pull.c +0 -89
  192. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/simple.c +0 -123
  193. data/ext/zsv/vendor/zsv-1.3.0/fuzz/fuzz.c +0 -16
  194. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/api.h +0 -336
  195. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/common.h +0 -361
  196. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/ext/implementation.h +0 -62
  197. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/ext/implementation_private.h +0 -113
  198. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/ext/sheet.h +0 -73
  199. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/ext.h +0 -329
  200. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/arg.h +0 -90
  201. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/cache.h +0 -49
  202. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/clock.h +0 -36
  203. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/compiler.h +0 -58
  204. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/db.h +0 -19
  205. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/dirs.h +0 -147
  206. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/dl.h +0 -22
  207. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/emcc/fs_api.h +0 -28
  208. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/err.h +0 -22
  209. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/file-mem.h +0 -17
  210. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/file.h +0 -99
  211. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/jq.h +0 -65
  212. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/json.h +0 -19
  213. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/mem.h +0 -19
  214. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/memmem.h +0 -13
  215. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/os.h +0 -54
  216. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/overwrite.h +0 -71
  217. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/overwrite_writer.h +0 -53
  218. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/prop.h +0 -107
  219. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/signal.h +0 -18
  220. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/sql.h +0 -11
  221. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/string.h +0 -148
  222. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/utf8.h +0 -41
  223. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/win/dl.h +0 -25
  224. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/writer.h +0 -101
  225. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/zsv_export.h +0 -33
  226. data/ext/zsv/vendor/zsv-1.3.0/include/zsv.h +0 -20
  227. data/ext/zsv/vendor/zsv-1.3.0/src/vector_delim.c +0 -60
  228. data/ext/zsv/vendor/zsv-1.3.0/src/zsv.c +0 -484
  229. data/ext/zsv/vendor/zsv-1.3.0/src/zsv_internal.c +0 -731
  230. data/ext/zsv/vendor/zsv-1.3.0/src/zsv_scan_delim.c +0 -285
  231. data/ext/zsv/vendor/zsv-1.3.0/src/zsv_scan_fixed.c +0 -88
  232. data/ext/zsv/vendor/zsv-1.3.0/src/zsv_strencode.c +0 -51
@@ -1,78 +0,0 @@
1
- /*
2
- * Copyright (c) 2007-2014, Lloyd Hilaiel <me@lloyd.io>
3
- *
4
- * Permission to use, copy, modify, and/or distribute this software for any
5
- * purpose with or without fee is hereby granted, provided that the above
6
- * copyright notice and this permission notice appear in all copies.
7
- *
8
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
- */
16
-
17
- #ifndef __YAJL_PARSER_H__
18
- #define __YAJL_PARSER_H__
19
-
20
- #include "api/yajl_parse.h"
21
- #include "yajl_bytestack.h"
22
- #include "yajl_buf.h"
23
- #include "yajl_lex.h"
24
-
25
-
26
- typedef enum {
27
- yajl_state_start = 0,
28
- yajl_state_parse_complete,
29
- yajl_state_parse_error,
30
- yajl_state_lexical_error,
31
- yajl_state_map_start,
32
- yajl_state_map_sep,
33
- yajl_state_map_need_val,
34
- yajl_state_map_got_val,
35
- yajl_state_map_need_key,
36
- yajl_state_array_start,
37
- yajl_state_array_got_val,
38
- yajl_state_array_need_val,
39
- yajl_state_got_value,
40
- } yajl_state;
41
-
42
- struct yajl_handle_t {
43
- const yajl_callbacks * callbacks;
44
- void * ctx;
45
- yajl_lexer lexer;
46
- const char * parseError;
47
- /* the number of bytes consumed from the last client buffer,
48
- * in the case of an error this will be an error offset, in the
49
- * case of an error this can be used as the error offset */
50
- size_t bytesConsumed;
51
- /* temporary storage for decoded strings */
52
- yajl_buf decodeBuf;
53
- /* a stack of states. access with yajl_state_XXX routines */
54
- yajl_bytestack stateStack;
55
- /* memory allocation routines */
56
- yajl_alloc_funcs alloc;
57
- /* bitfield */
58
- unsigned int flags;
59
- };
60
-
61
- yajl_status
62
- yajl_do_parse(yajl_handle handle, const unsigned char * jsonText,
63
- size_t jsonTextLen);
64
-
65
- yajl_status
66
- yajl_do_finish(yajl_handle handle);
67
-
68
- unsigned char *
69
- yajl_render_error_string(yajl_handle hand, const unsigned char * jsonText,
70
- size_t jsonTextLen, int verbose);
71
-
72
- /* A little built in integer parsing routine with the same semantics as strtol
73
- * that's unaffected by LOCALE. */
74
- long long
75
- yajl_parse_integer(const unsigned char *number, unsigned int length);
76
-
77
-
78
- #endif
@@ -1,505 +0,0 @@
1
- /*
2
- * Copyright (c) 2010-2011 Florian Forster <ff at octo.it>
3
- *
4
- * Permission to use, copy, modify, and/or distribute this software for any
5
- * purpose with or without fee is hereby granted, provided that the above
6
- * copyright notice and this permission notice appear in all copies.
7
- *
8
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
- */
16
-
17
- #include <stdlib.h>
18
- #include <stdio.h>
19
- #include <string.h>
20
- #include <errno.h>
21
- #include <assert.h>
22
-
23
- #include "api/yajl_tree.h"
24
- #include "api/yajl_parse.h"
25
-
26
- #include "yajl_parser.h"
27
-
28
- #if defined(_WIN32) || defined(WIN32)
29
- #define snprintf sprintf_s
30
- #endif
31
-
32
- #define STATUS_CONTINUE 1
33
- #define STATUS_ABORT 0
34
-
35
- struct stack_elem_s;
36
- typedef struct stack_elem_s stack_elem_t;
37
- struct stack_elem_s
38
- {
39
- char * key;
40
- yajl_val value;
41
- stack_elem_t *next;
42
- };
43
-
44
- struct context_s
45
- {
46
- stack_elem_t *stack;
47
- yajl_val root;
48
- char *errbuf;
49
- size_t errbuf_size;
50
- };
51
- typedef struct context_s context_t;
52
-
53
-
54
- #define RETURN_ERROR(ctx,retval,...) { \
55
- if ((ctx)->errbuf != NULL) \
56
- snprintf ((ctx)->errbuf, (ctx)->errbuf_size, __VA_ARGS__); \
57
- /*sprintf ((ctx)->errbuf, "%.*s", (int)(ctx)->errbuf_size, __VA_ARGS__); */ \
58
- return (retval); \
59
- }
60
-
61
- static yajl_val value_alloc (yajl_type type)
62
- {
63
- yajl_val v;
64
-
65
- v = malloc (sizeof (*v));
66
- if (v == NULL) return (NULL);
67
- memset (v, 0, sizeof (*v));
68
- v->type = type;
69
-
70
- return (v);
71
- }
72
-
73
- static void yajl_object_free (yajl_val v)
74
- {
75
- size_t i;
76
-
77
- if (!YAJL_IS_OBJECT(v)) return;
78
-
79
- for (i = 0; i < v->u.object.len; i++)
80
- {
81
- free((char *) v->u.object.keys[i]);
82
- v->u.object.keys[i] = NULL;
83
- yajl_tree_free (v->u.object.values[i]);
84
- v->u.object.values[i] = NULL;
85
- }
86
-
87
- free((void*) v->u.object.keys);
88
- free(v->u.object.values);
89
- free(v);
90
- }
91
-
92
- static void yajl_array_free (yajl_val v)
93
- {
94
- size_t i;
95
-
96
- if (!YAJL_IS_ARRAY(v)) return;
97
-
98
- for (i = 0; i < v->u.array.len; i++)
99
- {
100
- yajl_tree_free (v->u.array.values[i]);
101
- v->u.array.values[i] = NULL;
102
- }
103
-
104
- free(v->u.array.values);
105
- free(v);
106
- }
107
-
108
- /*
109
- * Parsing nested objects and arrays is implemented using a stack. When a new
110
- * object or array starts (a curly or a square opening bracket is read), an
111
- * appropriate value is pushed on the stack. When the end of the object is
112
- * reached (an appropriate closing bracket has been read), the value is popped
113
- * off the stack and added to the enclosing object using "context_add_value".
114
- */
115
- static int context_push(context_t *ctx, yajl_val v)
116
- {
117
- stack_elem_t *stack;
118
-
119
- stack = malloc (sizeof (*stack));
120
- if (stack == NULL)
121
- RETURN_ERROR (ctx, ENOMEM, "Out of memory");
122
- memset (stack, 0, sizeof (*stack));
123
-
124
- assert ((ctx->stack == NULL)
125
- || YAJL_IS_OBJECT (v)
126
- || YAJL_IS_ARRAY (v));
127
-
128
- stack->value = v;
129
- stack->next = ctx->stack;
130
- ctx->stack = stack;
131
-
132
- return (0);
133
- }
134
-
135
- static yajl_val context_pop(context_t *ctx)
136
- {
137
- stack_elem_t *stack;
138
- yajl_val v;
139
-
140
- if (ctx->stack == NULL)
141
- RETURN_ERROR (ctx, NULL, "context_pop: "
142
- "Bottom of stack reached prematurely");
143
-
144
- stack = ctx->stack;
145
- ctx->stack = stack->next;
146
-
147
- v = stack->value;
148
-
149
- free (stack);
150
-
151
- return (v);
152
- }
153
-
154
- static int object_add_keyval(context_t *ctx,
155
- yajl_val obj, char *key, yajl_val value)
156
- {
157
- const char **tmpk;
158
- yajl_val *tmpv;
159
-
160
- /* We're checking for NULL in "context_add_value" or its callers. */
161
- assert (ctx != NULL);
162
- assert (obj != NULL);
163
- assert (key != NULL);
164
- assert (value != NULL);
165
-
166
- /* We're assuring that "obj" is an object in "context_add_value". */
167
- assert(YAJL_IS_OBJECT(obj));
168
-
169
- tmpk = realloc((void *) obj->u.object.keys, sizeof(*(obj->u.object.keys)) * (obj->u.object.len + 1));
170
- if (tmpk == NULL)
171
- RETURN_ERROR(ctx, ENOMEM, "Out of memory");
172
- obj->u.object.keys = tmpk;
173
-
174
- tmpv = realloc(obj->u.object.values, sizeof (*obj->u.object.values) * (obj->u.object.len + 1));
175
- if (tmpv == NULL)
176
- RETURN_ERROR(ctx, ENOMEM, "Out of memory");
177
- obj->u.object.values = tmpv;
178
-
179
- obj->u.object.keys[obj->u.object.len] = key;
180
- obj->u.object.values[obj->u.object.len] = value;
181
- obj->u.object.len++;
182
-
183
- return (0);
184
- }
185
-
186
- static int array_add_value (context_t *ctx,
187
- yajl_val array, yajl_val value)
188
- {
189
- yajl_val *tmp;
190
-
191
- /* We're checking for NULL pointers in "context_add_value" or its
192
- * callers. */
193
- assert (ctx != NULL);
194
- assert (array != NULL);
195
- assert (value != NULL);
196
-
197
- /* "context_add_value" will only call us with array values. */
198
- assert(YAJL_IS_ARRAY(array));
199
-
200
- tmp = realloc(array->u.array.values,
201
- sizeof(*(array->u.array.values)) * (array->u.array.len + 1));
202
- if (tmp == NULL)
203
- RETURN_ERROR(ctx, ENOMEM, "Out of memory");
204
- array->u.array.values = tmp;
205
- array->u.array.values[array->u.array.len] = value;
206
- array->u.array.len++;
207
-
208
- return 0;
209
- }
210
-
211
- /*
212
- * Add a value to the value on top of the stack or the "root" member in the
213
- * context if the end of the parsing process is reached.
214
- */
215
- static int context_add_value (context_t *ctx, yajl_val v)
216
- {
217
- /* We're checking for NULL values in all the calling functions. */
218
- assert (ctx != NULL);
219
- assert (v != NULL);
220
-
221
- /*
222
- * There are three valid states in which this function may be called:
223
- * - There is no value on the stack => This is the only value. This is the
224
- * last step done when parsing a document. We assign the value to the
225
- * "root" member and return.
226
- * - The value on the stack is an object. In this case store the key on the
227
- * stack or, if the key has already been read, add key and value to the
228
- * object.
229
- * - The value on the stack is an array. In this case simply add the value
230
- * and return.
231
- */
232
- if (ctx->stack == NULL)
233
- {
234
- assert (ctx->root == NULL);
235
- ctx->root = v;
236
- return (0);
237
- }
238
- else if (YAJL_IS_OBJECT (ctx->stack->value))
239
- {
240
- if (ctx->stack->key == NULL)
241
- {
242
- if (!YAJL_IS_STRING (v))
243
- RETURN_ERROR (ctx, EINVAL, "context_add_value: "
244
- "Object key is not a string (%#04x)",
245
- v->type);
246
- ctx->stack->key = v->u.string;
247
- v->u.string = NULL;
248
- free(v);
249
- return (0);
250
- }
251
- else /* if (ctx->key != NULL) */
252
- {
253
- char * key;
254
-
255
- key = ctx->stack->key;
256
- ctx->stack->key = NULL;
257
- return (object_add_keyval (ctx, ctx->stack->value, key, v));
258
- }
259
- }
260
- else if (YAJL_IS_ARRAY (ctx->stack->value))
261
- {
262
- return (array_add_value (ctx, ctx->stack->value, v));
263
- }
264
- else
265
- {
266
- RETURN_ERROR (ctx, EINVAL, "context_add_value: Cannot add value to "
267
- "a value of type %#04x (not a composite type)",
268
- ctx->stack->value->type);
269
- }
270
- }
271
-
272
- static int handle_string (void *ctx,
273
- const unsigned char *string, size_t string_length)
274
- {
275
- yajl_val v;
276
-
277
- v = value_alloc (yajl_t_string);
278
- if (v == NULL)
279
- RETURN_ERROR ((context_t *) ctx, STATUS_ABORT, "Out of memory");
280
-
281
- v->u.string = malloc (string_length + 1);
282
- if (v->u.string == NULL)
283
- {
284
- free (v);
285
- RETURN_ERROR ((context_t *) ctx, STATUS_ABORT, "Out of memory");
286
- }
287
- memcpy(v->u.string, string, string_length);
288
- v->u.string[string_length] = 0;
289
-
290
- return ((context_add_value (ctx, v) == 0) ? STATUS_CONTINUE : STATUS_ABORT);
291
- }
292
-
293
- static int handle_number (void *ctx, const char *string, size_t string_length)
294
- {
295
- yajl_val v;
296
- char *endptr;
297
-
298
- v = value_alloc(yajl_t_number);
299
- if (v == NULL)
300
- RETURN_ERROR((context_t *) ctx, STATUS_ABORT, "Out of memory");
301
-
302
- v->u.number.r = malloc(string_length + 1);
303
- if (v->u.number.r == NULL)
304
- {
305
- free(v);
306
- RETURN_ERROR((context_t *) ctx, STATUS_ABORT, "Out of memory");
307
- }
308
- memcpy(v->u.number.r, string, string_length);
309
- v->u.number.r[string_length] = 0;
310
-
311
- v->u.number.flags = 0;
312
-
313
- errno = 0;
314
- v->u.number.i = yajl_parse_integer((const unsigned char *) v->u.number.r,
315
- strlen(v->u.number.r));
316
- if (errno == 0)
317
- v->u.number.flags |= YAJL_NUMBER_INT_VALID;
318
-
319
- endptr = NULL;
320
- errno = 0;
321
- v->u.number.d = strtod(v->u.number.r, &endptr);
322
- if ((errno == 0) && (endptr != NULL) && (*endptr == 0))
323
- v->u.number.flags |= YAJL_NUMBER_DOUBLE_VALID;
324
-
325
- return ((context_add_value(ctx, v) == 0) ? STATUS_CONTINUE : STATUS_ABORT);
326
- }
327
-
328
- static int handle_start_map (void *ctx)
329
- {
330
- yajl_val v;
331
-
332
- v = value_alloc(yajl_t_object);
333
- if (v == NULL)
334
- RETURN_ERROR ((context_t *) ctx, STATUS_ABORT, "Out of memory");
335
-
336
- v->u.object.keys = NULL;
337
- v->u.object.values = NULL;
338
- v->u.object.len = 0;
339
-
340
- return ((context_push (ctx, v) == 0) ? STATUS_CONTINUE : STATUS_ABORT);
341
- }
342
-
343
- static int handle_end_map (void *ctx)
344
- {
345
- yajl_val v;
346
-
347
- v = context_pop (ctx);
348
- if (v == NULL)
349
- return (STATUS_ABORT);
350
-
351
- return ((context_add_value (ctx, v) == 0) ? STATUS_CONTINUE : STATUS_ABORT);
352
- }
353
-
354
- static int handle_start_array (void *ctx)
355
- {
356
- yajl_val v;
357
-
358
- v = value_alloc(yajl_t_array);
359
- if (v == NULL)
360
- RETURN_ERROR ((context_t *) ctx, STATUS_ABORT, "Out of memory");
361
-
362
- v->u.array.values = NULL;
363
- v->u.array.len = 0;
364
-
365
- return ((context_push (ctx, v) == 0) ? STATUS_CONTINUE : STATUS_ABORT);
366
- }
367
-
368
- static int handle_end_array (void *ctx)
369
- {
370
- yajl_val v;
371
-
372
- v = context_pop (ctx);
373
- if (v == NULL)
374
- return (STATUS_ABORT);
375
-
376
- return ((context_add_value (ctx, v) == 0) ? STATUS_CONTINUE : STATUS_ABORT);
377
- }
378
-
379
- static int handle_boolean (void *ctx, int boolean_value)
380
- {
381
- yajl_val v;
382
-
383
- v = value_alloc (boolean_value ? yajl_t_true : yajl_t_false);
384
- if (v == NULL)
385
- RETURN_ERROR ((context_t *) ctx, STATUS_ABORT, "Out of memory");
386
-
387
- return ((context_add_value (ctx, v) == 0) ? STATUS_CONTINUE : STATUS_ABORT);
388
- }
389
-
390
- static int handle_null (void *ctx)
391
- {
392
- yajl_val v;
393
-
394
- v = value_alloc (yajl_t_null);
395
- if (v == NULL)
396
- RETURN_ERROR ((context_t *) ctx, STATUS_ABORT, "Out of memory");
397
-
398
- return ((context_add_value (ctx, v) == 0) ? STATUS_CONTINUE : STATUS_ABORT);
399
- }
400
-
401
- /*
402
- * Public functions
403
- */
404
- yajl_val yajl_tree_parse (const char *input,
405
- char *error_buffer, size_t error_buffer_size)
406
- {
407
- static const yajl_callbacks callbacks =
408
- {
409
- /* null = */ handle_null,
410
- /* boolean = */ handle_boolean,
411
- /* integer = */ NULL,
412
- /* double = */ NULL,
413
- /* number = */ handle_number,
414
- /* string = */ handle_string,
415
- /* start map = */ handle_start_map,
416
- /* map key = */ handle_string,
417
- /* end map = */ handle_end_map,
418
- /* start array = */ handle_start_array,
419
- /* end array = */ handle_end_array,
420
- /* error = */ NULL
421
- };
422
-
423
- yajl_handle handle;
424
- yajl_status status;
425
- char * internal_err_str;
426
- context_t ctx = { NULL, NULL, NULL, 0 };
427
-
428
- ctx.errbuf = error_buffer;
429
- ctx.errbuf_size = error_buffer_size;
430
-
431
- if (error_buffer != NULL)
432
- memset (error_buffer, 0, error_buffer_size);
433
-
434
- handle = yajl_alloc (&callbacks, NULL, &ctx);
435
- yajl_config(handle, yajl_allow_comments, 1);
436
-
437
- status = yajl_parse(handle, // compiler msg: Value stored to 'status' is never read
438
- (unsigned char *) input,
439
- strlen (input));
440
- status = yajl_complete_parse (handle);
441
- if (status != yajl_status_ok) {
442
- if (error_buffer != NULL && error_buffer_size > 0) {
443
- internal_err_str = (char *) yajl_get_error(handle, 1,
444
- (const unsigned char *) input,
445
- strlen(input));
446
- snprintf(error_buffer, error_buffer_size, "%s", internal_err_str);
447
- YA_FREE(&(handle->alloc), internal_err_str);
448
- }
449
- yajl_free (handle);
450
- return NULL;
451
- }
452
-
453
- yajl_free (handle);
454
- return (ctx.root);
455
- }
456
-
457
- yajl_val yajl_tree_get(yajl_val n, const char ** path, yajl_type type)
458
- {
459
- if (!path) return NULL;
460
- while (n && *path) {
461
- size_t i;
462
- size_t len;
463
-
464
- if (n->type != yajl_t_object) return NULL;
465
- len = n->u.object.len;
466
- for (i = 0; i < len; i++) {
467
- if (!strcmp(*path, n->u.object.keys[i])) {
468
- n = n->u.object.values[i];
469
- break;
470
- }
471
- }
472
- if (i == len) return NULL;
473
- path++;
474
- }
475
- if (n && type != yajl_t_any && type != n->type) n = NULL;
476
- return n;
477
- }
478
-
479
- void yajl_tree_free (yajl_val v)
480
- {
481
- if (v == NULL) return;
482
-
483
- if (YAJL_IS_STRING(v))
484
- {
485
- free(v->u.string);
486
- free(v);
487
- }
488
- else if (YAJL_IS_NUMBER(v))
489
- {
490
- free(v->u.number.r);
491
- free(v);
492
- }
493
- else if (YAJL_GET_OBJECT(v))
494
- {
495
- yajl_object_free(v);
496
- }
497
- else if (YAJL_GET_ARRAY(v))
498
- {
499
- yajl_array_free(v);
500
- }
501
- else /* if (yajl_t_true or yajl_t_false or yajl_t_null) */
502
- {
503
- free(v);
504
- }
505
- }
@@ -1,7 +0,0 @@
1
- #include <yajl/yajl_version.h>
2
-
3
- int yajl_version(void)
4
- {
5
- return YAJL_VERSION;
6
- }
7
-
@@ -1,59 +0,0 @@
1
- #ifndef JSON_VALUE_H
2
- #define JSON_VALUE_H
3
-
4
- struct json_value {
5
- enum {
6
- json_value_null = 1,
7
- json_value_bool,
8
- json_value_int,
9
- json_value_string,
10
- json_value_double,
11
- json_value_number_string,
12
- json_value_error
13
- } type;
14
-
15
- union {
16
- unsigned char *s;
17
- char *cs;
18
- long long i;
19
- double dbl;
20
- } val;
21
-
22
- size_t strlen;
23
- };
24
-
25
- #define json_value_free(value) do { \
26
- if((value)->type == json_value_string && (value)->val.s) free((value)->val.s), (value)->type = json_value_null; \
27
- } while(0)
28
-
29
- #define json_value_dup(dest, src) do { \
30
- memcpy(dest, src, sizeof(*dest)); \
31
- if((src)->type == json_value_string && (src)->val.cs) { \
32
- size_t sz = strlen((src)->val.cs); \
33
- if(((dest)->val.cs = malloc(sz + 2))) { \
34
- memcpy((dest)->val.cs, (src)->val.cs, sz); \
35
- (dest)->val.cs[sz] = (dest)->val.cs[sz+1] = '\0'; \
36
- } \
37
- } \
38
- } while(0)
39
-
40
- #define json_value_to_str(value) do { \
41
- if((value)->type != json_value_string) { \
42
- char *s; \
43
- if((value)->type == json_value_null) { \
44
- s = calloc(1, 3); \
45
- } else if((value)->type == json_value_double) { \
46
- asprintf(&s, "%lf", (value)->val.dbl); \
47
- } else { \
48
- asprintf(&s, "%lli", (value)->val.i); \
49
- } \
50
- (value)->val.cs = s; \
51
- (value)->strlen = strlen(s); \
52
- (value)->type = json_value_string; \
53
- } \
54
- } while(0)
55
-
56
- void json_value_delete(struct json_value **valuep);
57
- struct json_value *json_value_copy(struct json_value *value);
58
-
59
- #endif