zsv 1.3.1 → 1.4.4

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 (259) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +153 -2
  3. data/README.md +132 -240
  4. data/ext/zsv/ZSV_UPSTREAM +7 -0
  5. data/ext/zsv/common.h +0 -12
  6. data/ext/zsv/extconf.rb +70 -122
  7. data/ext/zsv/options.c +63 -62
  8. data/ext/zsv/options.h +8 -11
  9. data/ext/zsv/parser.c +390 -201
  10. data/ext/zsv/parser.h +35 -22
  11. data/ext/zsv/row.c +75 -28
  12. data/ext/zsv/row.h +15 -9
  13. data/ext/zsv/upstream.rb +55 -0
  14. data/ext/zsv/vendor/zsv/LICENSE +21 -0
  15. data/ext/zsv/vendor/zsv/VENDORED_FROM +2 -0
  16. data/ext/zsv/vendor/zsv/configure +1212 -0
  17. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/api.h +39 -0
  18. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/common.h +36 -0
  19. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/ext/sheet.h +8 -1
  20. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/ext.h +6 -2
  21. data/ext/zsv/vendor/zsv/include/zsv/utils/appname.h +51 -0
  22. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/arg.h +50 -1
  23. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/compiler.h +19 -8
  24. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/dirs.h +2 -0
  25. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/file-mem.h +1 -0
  26. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/file.h +28 -2
  27. data/ext/zsv/vendor/zsv/include/zsv/utils/os.h +145 -0
  28. data/ext/zsv/vendor/zsv/include/zsv/utils/output.h +34 -0
  29. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/overwrite_writer.h +1 -1
  30. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/prop.h +16 -4
  31. data/ext/zsv/vendor/zsv/include/zsv/utils/rng.h +35 -0
  32. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/signal.h +7 -0
  33. data/ext/zsv/vendor/zsv/include/zsv/utils/sql.h +13 -0
  34. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/string.h +25 -0
  35. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/writer.h +9 -1
  36. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/zsv_export.h +1 -1
  37. data/ext/zsv/vendor/{zsv-1.3.0/include/zsv.h → zsv/include/zsv.h.in} +1 -3
  38. data/ext/zsv/vendor/zsv/src/Makefile +238 -0
  39. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/src/zsv.c +152 -14
  40. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/src/zsv_internal.c +108 -50
  41. data/ext/zsv/vendor/zsv/src/zsv_scan_delim_fast.c +741 -0
  42. data/ext/zsv/vendor/zsv/src/zsv_scan_simd_avx2.h +89 -0
  43. data/ext/zsv/vendor/zsv/src/zsv_scan_simd_neon.h +80 -0
  44. data/ext/zsv/vendor/zsv/src/zsv_scan_simd_sse2.h +93 -0
  45. data/ext/zsv/vendor/zsv/src/zsv_scan_simd_wasm.h +79 -0
  46. data/ext/zsv/vendor/zsv/src/zsv_strencode.c +84 -0
  47. data/ext/zsv/zsv_ext.c +176 -105
  48. data/lib/zsv/errors.rb +32 -0
  49. data/lib/zsv/input.rb +88 -0
  50. data/lib/zsv/options.rb +132 -0
  51. data/lib/zsv/strict_validator.rb +124 -0
  52. data/lib/zsv/version.rb +1 -1
  53. data/lib/zsv.rb +137 -35
  54. metadata +81 -230
  55. data/ext/zsv/vendor/zsv-1.3.0/app/2db.c +0 -756
  56. data/ext/zsv/vendor/zsv-1.3.0/app/2json.c +0 -381
  57. data/ext/zsv/vendor/zsv-1.3.0/app/2tsv.c +0 -228
  58. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/help.c +0 -123
  59. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/license.c +0 -39
  60. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/register.c +0 -104
  61. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/thirdparty.c +0 -41
  62. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/unregister.c +0 -1
  63. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/version.c +0 -14
  64. data/ext/zsv/vendor/zsv-1.3.0/app/check/simdutf_wrapper.h +0 -19
  65. data/ext/zsv/vendor/zsv-1.3.0/app/check/utf8.c +0 -116
  66. data/ext/zsv/vendor/zsv-1.3.0/app/check.c +0 -194
  67. data/ext/zsv/vendor/zsv-1.3.0/app/cli.c +0 -796
  68. data/ext/zsv/vendor/zsv-1.3.0/app/cli_const.h +0 -41
  69. data/ext/zsv/vendor/zsv-1.3.0/app/cli_export.h +0 -16
  70. data/ext/zsv/vendor/zsv-1.3.0/app/cli_ini.c +0 -280
  71. data/ext/zsv/vendor/zsv-1.3.0/app/cli_internal.h +0 -36
  72. data/ext/zsv/vendor/zsv-1.3.0/app/compare.c +0 -913
  73. data/ext/zsv/vendor/zsv-1.3.0/app/compare.h +0 -23
  74. data/ext/zsv/vendor/zsv-1.3.0/app/compare_added_column.c +0 -20
  75. data/ext/zsv/vendor/zsv-1.3.0/app/compare_internal.h +0 -140
  76. data/ext/zsv/vendor/zsv-1.3.0/app/compare_sort.c +0 -91
  77. data/ext/zsv/vendor/zsv-1.3.0/app/compare_unique_colname.c +0 -81
  78. data/ext/zsv/vendor/zsv-1.3.0/app/count-pull.c +0 -82
  79. data/ext/zsv/vendor/zsv-1.3.0/app/count.c +0 -404
  80. data/ext/zsv/vendor/zsv-1.3.0/app/desc.c +0 -569
  81. data/ext/zsv/vendor/zsv-1.3.0/app/echo.c +0 -365
  82. data/ext/zsv/vendor/zsv-1.3.0/app/ext_example/my_extension.c +0 -366
  83. data/ext/zsv/vendor/zsv-1.3.0/app/ext_example/mysheet_extension.c +0 -341
  84. data/ext/zsv/vendor/zsv-1.3.0/app/ext_template/YOUR_EXTENSION_zsvext.c +0 -263
  85. data/ext/zsv/vendor/zsv-1.3.0/app/external/inih/ini.c +0 -298
  86. data/ext/zsv/vendor/zsv-1.3.0/app/external/inih/ini.h +0 -157
  87. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/json_numeric.c +0 -177
  88. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/jsonwriter.c +0 -444
  89. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/jsonwriter.h +0 -145
  90. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/utils.c +0 -110
  91. data/ext/zsv/vendor/zsv-1.3.0/app/external/memfile-1.0/include/memfile.h +0 -15
  92. data/ext/zsv/vendor/zsv-1.3.0/app/external/memfile-1.0/src/memfile.c +0 -64
  93. data/ext/zsv/vendor/zsv-1.3.0/app/external/sglib/sglib.h +0 -1955
  94. data/ext/zsv/vendor/zsv-1.3.0/app/external/simdutf/simdutf.h +0 -6802
  95. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3.c +0 -230517
  96. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3.h +0 -12174
  97. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_and_csv_vtab.c +0 -2
  98. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab-mem.c +0 -142
  99. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab-mem.h +0 -49
  100. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab-zsv.c +0 -485
  101. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab.c +0 -1015
  102. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3ext.h +0 -663
  103. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/vtab_helper.c +0 -85
  104. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_common.h +0 -75
  105. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_gen.h +0 -167
  106. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_parse.h +0 -228
  107. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_tree.h +0 -186
  108. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_version.h +0 -23
  109. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_common.h +0 -76
  110. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_gen.h +0 -167
  111. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_parse.h +0 -238
  112. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_tree.h +0 -186
  113. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl.c +0 -184
  114. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_alloc.c +0 -52
  115. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_alloc.h +0 -34
  116. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_buf.c +0 -103
  117. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_buf.h +0 -57
  118. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_bytestack.h +0 -69
  119. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_encode.c +0 -220
  120. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_encode.h +0 -34
  121. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_gen.c +0 -362
  122. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_lex.c +0 -764
  123. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_lex.h +0 -117
  124. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_parser.c +0 -508
  125. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_parser.h +0 -78
  126. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_tree.c +0 -505
  127. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_version.c +0 -7
  128. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper/json_value.h +0 -59
  129. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper/yajl_helper.h +0 -208
  130. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper.c +0 -795
  131. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper_internal.h +0 -28
  132. data/ext/zsv/vendor/zsv-1.3.0/app/flatten.c +0 -851
  133. data/ext/zsv/vendor/zsv-1.3.0/app/jq.c +0 -106
  134. data/ext/zsv/vendor/zsv-1.3.0/app/jq.h +0 -6
  135. data/ext/zsv/vendor/zsv-1.3.0/app/mv.c +0 -113
  136. data/ext/zsv/vendor/zsv-1.3.0/app/noop.c +0 -90
  137. data/ext/zsv/vendor/zsv-1.3.0/app/overwrite.c +0 -295
  138. data/ext/zsv/vendor/zsv-1.3.0/app/paste.c +0 -175
  139. data/ext/zsv/vendor/zsv-1.3.0/app/pretty.c +0 -693
  140. data/ext/zsv/vendor/zsv-1.3.0/app/prop.c +0 -980
  141. data/ext/zsv/vendor/zsv-1.3.0/app/rm.c +0 -131
  142. data/ext/zsv/vendor/zsv-1.3.0/app/select/fixed.c +0 -130
  143. data/ext/zsv/vendor/zsv-1.3.0/app/select/internal.h +0 -118
  144. data/ext/zsv/vendor/zsv-1.3.0/app/select/parallel.c +0 -45
  145. data/ext/zsv/vendor/zsv-1.3.0/app/select/parallel.h +0 -41
  146. data/ext/zsv/vendor/zsv-1.3.0/app/select/processing.c +0 -107
  147. data/ext/zsv/vendor/zsv-1.3.0/app/select/rand.c +0 -20
  148. data/ext/zsv/vendor/zsv-1.3.0/app/select/regex.c +0 -61
  149. data/ext/zsv/vendor/zsv-1.3.0/app/select/search.c +0 -14
  150. data/ext/zsv/vendor/zsv-1.3.0/app/select/selection.c +0 -192
  151. data/ext/zsv/vendor/zsv-1.3.0/app/select/usage.c +0 -72
  152. data/ext/zsv/vendor/zsv-1.3.0/app/select-pull.c +0 -812
  153. data/ext/zsv/vendor/zsv-1.3.0/app/select.c +0 -753
  154. data/ext/zsv/vendor/zsv-1.3.0/app/serialize.c +0 -372
  155. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/curses.h +0 -15
  156. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/cursor.c +0 -119
  157. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/errors.c +0 -45
  158. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/file.c +0 -63
  159. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/file.h +0 -12
  160. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/filter.c +0 -166
  161. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/handlers.c +0 -214
  162. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/handlers_internal.h +0 -128
  163. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/help.c +0 -43
  164. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/index.c +0 -81
  165. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/index.h +0 -25
  166. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/key-bindings.c +0 -325
  167. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/key-bindings.h +0 -73
  168. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/lexer.c +0 -203
  169. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/newline_handler.c +0 -7
  170. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/pivot.c +0 -318
  171. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/procedure.c +0 -134
  172. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/procedure.h +0 -119
  173. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/read-data.c +0 -322
  174. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/screen_buffer.c +0 -203
  175. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/screen_buffer.h +0 -36
  176. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/sheet-sql.c +0 -167
  177. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/sheet_internal.h +0 -36
  178. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/sqlfilter.c +0 -153
  179. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/terminfo.c +0 -32
  180. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/transformation.c +0 -312
  181. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/transformation.h +0 -29
  182. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/ui_buffer.c +0 -266
  183. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/usage.c +0 -9
  184. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/utf8-width.c +0 -60
  185. data/ext/zsv/vendor/zsv-1.3.0/app/sheet.c +0 -1007
  186. data/ext/zsv/vendor/zsv-1.3.0/app/sql.c +0 -453
  187. data/ext/zsv/vendor/zsv-1.3.0/app/sql_internal.c +0 -101
  188. data/ext/zsv/vendor/zsv-1.3.0/app/sql_internal.h +0 -49
  189. data/ext/zsv/vendor/zsv-1.3.0/app/stack.c +0 -393
  190. data/ext/zsv/vendor/zsv-1.3.0/app/utils/arg.c +0 -322
  191. data/ext/zsv/vendor/zsv-1.3.0/app/utils/cache.c +0 -228
  192. data/ext/zsv/vendor/zsv-1.3.0/app/utils/cat.c +0 -91
  193. data/ext/zsv/vendor/zsv-1.3.0/app/utils/chunk.c +0 -240
  194. data/ext/zsv/vendor/zsv-1.3.0/app/utils/chunk.h +0 -63
  195. data/ext/zsv/vendor/zsv-1.3.0/app/utils/clock.c +0 -57
  196. data/ext/zsv/vendor/zsv-1.3.0/app/utils/db.c +0 -148
  197. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs-no-jq.c +0 -2
  198. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs.c +0 -427
  199. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs_from_json.c +0 -253
  200. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs_to_json.c +0 -121
  201. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dl.c +0 -20
  202. data/ext/zsv/vendor/zsv-1.3.0/app/utils/emcc/fs_api.c +0 -159
  203. data/ext/zsv/vendor/zsv-1.3.0/app/utils/err.c +0 -24
  204. data/ext/zsv/vendor/zsv-1.3.0/app/utils/file-mem.c +0 -180
  205. data/ext/zsv/vendor/zsv-1.3.0/app/utils/file.c +0 -256
  206. data/ext/zsv/vendor/zsv-1.3.0/app/utils/index.c +0 -197
  207. data/ext/zsv/vendor/zsv-1.3.0/app/utils/index.h +0 -49
  208. data/ext/zsv/vendor/zsv-1.3.0/app/utils/jq.c +0 -400
  209. data/ext/zsv/vendor/zsv-1.3.0/app/utils/json.c +0 -120
  210. data/ext/zsv/vendor/zsv-1.3.0/app/utils/mem.c +0 -18
  211. data/ext/zsv/vendor/zsv-1.3.0/app/utils/memmem.c +0 -132
  212. data/ext/zsv/vendor/zsv-1.3.0/app/utils/os.c +0 -178
  213. data/ext/zsv/vendor/zsv-1.3.0/app/utils/overwrite.c +0 -258
  214. data/ext/zsv/vendor/zsv-1.3.0/app/utils/overwrite_writer.c +0 -246
  215. data/ext/zsv/vendor/zsv-1.3.0/app/utils/pcre2-8/pcre2-8-test.c +0 -123
  216. data/ext/zsv/vendor/zsv-1.3.0/app/utils/pcre2-8/pcre2-8.c +0 -153
  217. data/ext/zsv/vendor/zsv-1.3.0/app/utils/pcre2-8/pcre2-8.h +0 -54
  218. data/ext/zsv/vendor/zsv-1.3.0/app/utils/prop.c +0 -267
  219. data/ext/zsv/vendor/zsv-1.3.0/app/utils/signal.c +0 -53
  220. data/ext/zsv/vendor/zsv-1.3.0/app/utils/string.c +0 -357
  221. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/dir_exists_longpath.c +0 -83
  222. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/dl.c +0 -33
  223. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/fopen_longpath.c +0 -184
  224. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/foreach_dirent_longpath.c +0 -292
  225. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/io.c +0 -259
  226. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/io.h +0 -13
  227. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/mkdir_longpath.c +0 -255
  228. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/remove_longpath.c +0 -96
  229. data/ext/zsv/vendor/zsv-1.3.0/app/utils/writer.c +0 -361
  230. data/ext/zsv/vendor/zsv-1.3.0/app/zsv_command.h +0 -40
  231. data/ext/zsv/vendor/zsv-1.3.0/app/zsv_command_standalone.c +0 -16
  232. data/ext/zsv/vendor/zsv-1.3.0/app/zsv_main.h +0 -44
  233. data/ext/zsv/vendor/zsv-1.3.0/examples/js/zsv_parser_api_dummy.c +0 -3
  234. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/parse_by_chunk.c +0 -100
  235. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/print_my_column.c +0 -143
  236. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/pull.c +0 -89
  237. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/simple.c +0 -123
  238. data/ext/zsv/vendor/zsv-1.3.0/fuzz/fuzz.c +0 -16
  239. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/os.h +0 -54
  240. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/sql.h +0 -11
  241. data/ext/zsv/vendor/zsv-1.3.0/src/zsv_strencode.c +0 -51
  242. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/ext/implementation.h +0 -0
  243. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/ext/implementation_private.h +0 -0
  244. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/cache.h +0 -0
  245. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/clock.h +0 -0
  246. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/db.h +0 -0
  247. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/dl.h +0 -0
  248. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/emcc/fs_api.h +0 -0
  249. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/err.h +0 -0
  250. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/jq.h +0 -0
  251. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/json.h +0 -0
  252. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/mem.h +0 -0
  253. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/memmem.h +0 -0
  254. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/overwrite.h +0 -0
  255. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/utf8.h +0 -0
  256. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/win/dl.h +0 -0
  257. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/src/vector_delim.c +0 -0
  258. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/src/zsv_scan_delim.c +0 -0
  259. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/src/zsv_scan_fixed.c +0 -0
@@ -1,186 +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
- /**
18
- * \file yajl_tree.h
19
- *
20
- * Parses JSON data and returns the data in tree form.
21
- *
22
- * \author Florian Forster
23
- * \date August 2010
24
- *
25
- * This interface makes quick parsing and extraction of
26
- * smallish JSON docs trivial:
27
- *
28
- * \include example/parse_config.c
29
- */
30
-
31
- #ifndef YAJL_TREE_H
32
- #define YAJL_TREE_H 1
33
-
34
- #include <yajl/yajl_common.h>
35
-
36
- #ifdef __cplusplus
37
- extern "C" {
38
- #endif
39
-
40
- /** possible data types that a yajl_val_s can hold */
41
- typedef enum {
42
- yajl_t_string = 1,
43
- yajl_t_number = 2,
44
- yajl_t_object = 3,
45
- yajl_t_array = 4,
46
- yajl_t_true = 5,
47
- yajl_t_false = 6,
48
- yajl_t_null = 7,
49
- /** The any type isn't valid for yajl_val_s.type, but can be
50
- * used as an argument to routines like yajl_tree_get().
51
- */
52
- yajl_t_any = 8
53
- } yajl_type;
54
-
55
- #define YAJL_NUMBER_INT_VALID 0x01
56
- #define YAJL_NUMBER_DOUBLE_VALID 0x02
57
-
58
- /** A pointer to a node in the parse tree */
59
- typedef struct yajl_val_s * yajl_val;
60
-
61
- /**
62
- * A JSON value representation capable of holding one of the seven
63
- * types above. For "string", "number", "object", and "array"
64
- * additional data is available in the union. The "YAJL_IS_*"
65
- * and "YAJL_GET_*" macros below allow type checking and convenient
66
- * value extraction.
67
- */
68
- struct yajl_val_s
69
- {
70
- /** Type of the value contained. Use the "YAJL_IS_*" macros to check for a
71
- * specific type. */
72
- yajl_type type;
73
- /** Type-specific data. You may use the "YAJL_GET_*" macros to access these
74
- * members. */
75
- union
76
- {
77
- char * string;
78
- struct {
79
- long long i; /*< integer value, if representable. */
80
- double d; /*< double value, if representable. */
81
- char *r; /*< unparsed number in string form. */
82
- /** Signals whether the \em i and \em d members are
83
- * valid. See \c YAJL_NUMBER_INT_VALID and
84
- * \c YAJL_NUMBER_DOUBLE_VALID. */
85
- unsigned int flags;
86
- } number;
87
- struct {
88
- const char **keys; /*< Array of keys */
89
- yajl_val *values; /*< Array of values. */
90
- size_t len; /*< Number of key-value-pairs. */
91
- } object;
92
- struct {
93
- yajl_val *values; /*< Array of elements. */
94
- size_t len; /*< Number of elements. */
95
- } array;
96
- } u;
97
- };
98
-
99
- /**
100
- * Parse a string.
101
- *
102
- * Parses an null-terminated string containing JSON data and returns a pointer
103
- * to the top-level value (root of the parse tree).
104
- *
105
- * \param input Pointer to a null-terminated utf8 string containing
106
- * JSON data.
107
- * \param error_buffer Pointer to a buffer in which an error message will
108
- * be stored if \em yajl_tree_parse fails, or
109
- * \c NULL. The buffer will be initialized before
110
- * parsing, so its content will be destroyed even if
111
- * \em yajl_tree_parse succeeds.
112
- * \param error_buffer_size Size of the memory area pointed to by
113
- * \em error_buffer_size. If \em error_buffer_size is
114
- * \c NULL, this argument is ignored.
115
- *
116
- * \returns Pointer to the top-level value or \c NULL on error. The memory
117
- * pointed to must be freed using \em yajl_tree_free. In case of an error, a
118
- * null terminated message describing the error in more detail is stored in
119
- * \em error_buffer if it is not \c NULL.
120
- */
121
- YAJL_API yajl_val yajl_tree_parse (const char *input,
122
- char *error_buffer, size_t error_buffer_size);
123
-
124
-
125
- /**
126
- * Free a parse tree returned by "yajl_tree_parse".
127
- *
128
- * \param v Pointer to a JSON value returned by "yajl_tree_parse". Passing NULL
129
- * is valid and results in a no-op.
130
- */
131
- YAJL_API void yajl_tree_free (yajl_val v);
132
-
133
- /**
134
- * Access a nested value inside a tree.
135
- *
136
- * \param parent the node under which you'd like to extract values.
137
- * \param path A null terminated array of strings, each the name of an object key
138
- * \param type the yajl_type of the object you seek, or yajl_t_any if any will do.
139
- *
140
- * \returns a pointer to the found value, or NULL if we came up empty.
141
- *
142
- * Future Ideas: it'd be nice to move path to a string and implement support for
143
- * a teeny tiny micro language here, so you can extract array elements, do things
144
- * like .first and .last, even .length. Inspiration from JSONPath and css selectors?
145
- * No it wouldn't be fast, but that's not what this API is about.
146
- */
147
- YAJL_API yajl_val yajl_tree_get(yajl_val parent, const char ** path, yajl_type type);
148
-
149
- /* Various convenience macros to check the type of a `yajl_val` */
150
- #define YAJL_IS_STRING(v) (((v) != NULL) && ((v)->type == yajl_t_string))
151
- #define YAJL_IS_NUMBER(v) (((v) != NULL) && ((v)->type == yajl_t_number))
152
- #define YAJL_IS_INTEGER(v) (YAJL_IS_NUMBER(v) && ((v)->u.number.flags & YAJL_NUMBER_INT_VALID))
153
- #define YAJL_IS_DOUBLE(v) (YAJL_IS_NUMBER(v) && ((v)->u.number.flags & YAJL_NUMBER_DOUBLE_VALID))
154
- #define YAJL_IS_OBJECT(v) (((v) != NULL) && ((v)->type == yajl_t_object))
155
- #define YAJL_IS_ARRAY(v) (((v) != NULL) && ((v)->type == yajl_t_array ))
156
- #define YAJL_IS_TRUE(v) (((v) != NULL) && ((v)->type == yajl_t_true ))
157
- #define YAJL_IS_FALSE(v) (((v) != NULL) && ((v)->type == yajl_t_false ))
158
- #define YAJL_IS_NULL(v) (((v) != NULL) && ((v)->type == yajl_t_null ))
159
-
160
- /** Given a yajl_val_string return a ptr to the bare string it contains,
161
- * or NULL if the value is not a string. */
162
- #define YAJL_GET_STRING(v) (YAJL_IS_STRING(v) ? (v)->u.string : NULL)
163
-
164
- /** Get the string representation of a number. You should check type first,
165
- * perhaps using YAJL_IS_NUMBER */
166
- #define YAJL_GET_NUMBER(v) ((v)->u.number.r)
167
-
168
- /** Get the double representation of a number. You should check type first,
169
- * perhaps using YAJL_IS_DOUBLE */
170
- #define YAJL_GET_DOUBLE(v) ((v)->u.number.d)
171
-
172
- /** Get the 64bit (long long) integer representation of a number. You should
173
- * check type first, perhaps using YAJL_IS_INTEGER */
174
- #define YAJL_GET_INTEGER(v) ((v)->u.number.i)
175
-
176
- /** Get a pointer to a yajl_val_object or NULL if the value is not an object. */
177
- #define YAJL_GET_OBJECT(v) (YAJL_IS_OBJECT(v) ? &(v)->u.object : NULL)
178
-
179
- /** Get a pointer to a yajl_val_array or NULL if the value is not an object. */
180
- #define YAJL_GET_ARRAY(v) (YAJL_IS_ARRAY(v) ? &(v)->u.array : NULL)
181
-
182
- #ifdef __cplusplus
183
- }
184
- #endif
185
-
186
- #endif /* YAJL_TREE_H */
@@ -1,184 +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
- #include "api/yajl_parse.h"
18
- #include "yajl_lex.h"
19
- #include "yajl_parser.h"
20
- #include "yajl_alloc.h"
21
-
22
- #include <stdlib.h>
23
- #include <string.h>
24
- #include <stdarg.h>
25
- #include <assert.h>
26
-
27
- const char *
28
- yajl_status_to_string(yajl_status stat)
29
- {
30
- const char * statStr = "unknown";
31
- switch (stat) {
32
- case yajl_status_ok:
33
- statStr = "ok, no error";
34
- break;
35
- case yajl_status_client_canceled:
36
- statStr = "client canceled parse";
37
- break;
38
- case yajl_status_error:
39
- statStr = "parse error";
40
- break;
41
- }
42
- return statStr;
43
- }
44
-
45
-
46
- yajl_handle
47
- yajl_alloc(const yajl_callbacks * callbacks,
48
- yajl_alloc_funcs * afs,
49
- void * ctx)
50
- {
51
- yajl_handle hand = NULL;
52
- yajl_alloc_funcs afsBuffer;
53
-
54
- /* first order of business is to set up memory allocation routines */
55
- if (afs != NULL) {
56
- if (afs->malloc == NULL || afs->realloc == NULL || afs->free == NULL)
57
- {
58
- return NULL;
59
- }
60
- } else {
61
- yajl_set_default_alloc_funcs(&afsBuffer);
62
- afs = &afsBuffer;
63
- }
64
-
65
- hand = (yajl_handle) YA_MALLOC(afs, sizeof(struct yajl_handle_t));
66
-
67
- /* copy in pointers to allocation routines */
68
- memcpy((void *) &(hand->alloc), (void *) afs, sizeof(yajl_alloc_funcs));
69
-
70
- hand->callbacks = callbacks;
71
- hand->ctx = ctx;
72
- hand->lexer = NULL;
73
- hand->bytesConsumed = 0;
74
- hand->decodeBuf = yajl_buf_alloc(&(hand->alloc));
75
- hand->flags = 0;
76
- yajl_bs_init(hand->stateStack, &(hand->alloc));
77
- yajl_bs_push(hand->stateStack, yajl_state_start);
78
-
79
- return hand;
80
- }
81
-
82
- const yajl_callbacks *
83
- yajl_swap_callbacks(yajl_handle h, const yajl_callbacks * callbacks, void *new_ctx) {
84
- const yajl_callbacks *old_callbacks = h->callbacks;
85
- h->callbacks = callbacks;
86
- h->ctx = new_ctx;
87
- return old_callbacks;
88
- }
89
-
90
- int
91
- yajl_config(yajl_handle h, yajl_option opt, ...)
92
- {
93
- int rv = 1;
94
- va_list ap;
95
- va_start(ap, opt);
96
-
97
- switch(opt) {
98
- case yajl_allow_comments:
99
- case yajl_dont_validate_strings:
100
- case yajl_allow_trailing_garbage:
101
- case yajl_allow_multiple_values:
102
- case yajl_allow_partial_values:
103
- if (va_arg(ap, int)) h->flags |= opt;
104
- else h->flags &= ~opt;
105
- break;
106
- default:
107
- rv = 0;
108
- }
109
- va_end(ap);
110
-
111
- return rv;
112
- }
113
-
114
- void
115
- yajl_free(yajl_handle handle)
116
- {
117
- yajl_bs_free(handle->stateStack);
118
- yajl_buf_free(handle->decodeBuf);
119
- if (handle->lexer) {
120
- yajl_lex_free(handle->lexer);
121
- handle->lexer = NULL;
122
- }
123
- YA_FREE(&(handle->alloc), handle);
124
- }
125
-
126
- yajl_status
127
- yajl_parse(yajl_handle hand, const unsigned char * jsonText,
128
- size_t jsonTextLen)
129
- {
130
- yajl_status status;
131
-
132
- /* lazy allocation of the lexer */
133
- if (hand->lexer == NULL) {
134
- hand->lexer = yajl_lex_alloc(&(hand->alloc),
135
- hand->flags & yajl_allow_comments,
136
- !(hand->flags & yajl_dont_validate_strings));
137
- }
138
-
139
- status = yajl_do_parse(hand, jsonText, jsonTextLen);
140
- return status;
141
- }
142
-
143
-
144
- yajl_status
145
- yajl_complete_parse(yajl_handle hand)
146
- {
147
- /* The lexer is lazy allocated in the first call to parse. if parse is
148
- * never called, then no data was provided to parse at all. This is a
149
- * "premature EOF" error unless yajl_allow_partial_values is specified.
150
- * allocating the lexer now is the simplest possible way to handle this
151
- * case while preserving all the other semantics of the parser
152
- * (multiple values, partial values, etc). */
153
- if (hand->lexer == NULL) {
154
- hand->lexer = yajl_lex_alloc(&(hand->alloc),
155
- hand->flags & yajl_allow_comments,
156
- !(hand->flags & yajl_dont_validate_strings));
157
- }
158
-
159
- return yajl_do_finish(hand);
160
- }
161
-
162
- unsigned char *
163
- yajl_get_error(yajl_handle hand, int verbose,
164
- const unsigned char * jsonText, size_t jsonTextLen)
165
- {
166
- return yajl_render_error_string(hand, jsonText, jsonTextLen, verbose);
167
- }
168
-
169
- size_t
170
- yajl_get_bytes_consumed(yajl_handle hand)
171
- {
172
- if (!hand) return 0;
173
- else return hand->bytesConsumed;
174
- }
175
-
176
-
177
- void
178
- yajl_free_error(yajl_handle hand, unsigned char * str)
179
- {
180
- /* use memory allocation functions if set */
181
- YA_FREE(&(hand->alloc), str);
182
- }
183
-
184
- /* XXX: add utility routines to parse from file */
@@ -1,52 +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
- /**
18
- * \file yajl_alloc.h
19
- * default memory allocation routines for yajl which use malloc/realloc and
20
- * free
21
- */
22
-
23
- #include "yajl_alloc.h"
24
- #include <stdlib.h>
25
-
26
- static void * yajl_internal_malloc(void *ctx, size_t sz)
27
- {
28
- (void)ctx;
29
- return malloc(sz);
30
- }
31
-
32
- static void * yajl_internal_realloc(void *ctx, void * previous,
33
- size_t sz)
34
- {
35
- (void)ctx;
36
- return realloc(previous, sz);
37
- }
38
-
39
- static void yajl_internal_free(void *ctx, void * ptr)
40
- {
41
- (void)ctx;
42
- free(ptr);
43
- }
44
-
45
- void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf)
46
- {
47
- yaf->malloc = yajl_internal_malloc;
48
- yaf->free = yajl_internal_free;
49
- yaf->realloc = yajl_internal_realloc;
50
- yaf->ctx = NULL;
51
- }
52
-
@@ -1,34 +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
- /**
18
- * \file yajl_alloc.h
19
- * default memory allocation routines for yajl which use malloc/realloc and
20
- * free
21
- */
22
-
23
- #ifndef __YAJL_ALLOC_H__
24
- #define __YAJL_ALLOC_H__
25
-
26
- #include "api/yajl_common.h"
27
-
28
- #define YA_MALLOC(afs, sz) (afs)->malloc((afs)->ctx, (sz))
29
- #define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
30
- #define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
31
-
32
- void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
33
-
34
- #endif
@@ -1,103 +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
- #include "yajl_buf.h"
18
-
19
- #include <assert.h>
20
- #include <stdlib.h>
21
- #include <string.h>
22
-
23
- #define YAJL_BUF_INIT_SIZE 2048
24
-
25
- struct yajl_buf_t {
26
- size_t len;
27
- size_t used;
28
- unsigned char * data;
29
- yajl_alloc_funcs * alloc;
30
- };
31
-
32
- static
33
- void yajl_buf_ensure_available(yajl_buf buf, size_t want)
34
- {
35
- size_t need;
36
-
37
- assert(buf != NULL);
38
-
39
- /* first call */
40
- if (buf->data == NULL) {
41
- buf->len = YAJL_BUF_INIT_SIZE;
42
- buf->data = (unsigned char *) YA_MALLOC(buf->alloc, buf->len);
43
- buf->data[0] = 0;
44
- }
45
-
46
- need = buf->len;
47
-
48
- while (want >= (need - buf->used)) need <<= 1;
49
-
50
- if (need != buf->len) {
51
- buf->data = (unsigned char *) YA_REALLOC(buf->alloc, buf->data, need);
52
- buf->len = need;
53
- }
54
- }
55
-
56
- yajl_buf yajl_buf_alloc(yajl_alloc_funcs * alloc)
57
- {
58
- yajl_buf b = YA_MALLOC(alloc, sizeof(struct yajl_buf_t));
59
- memset((void *) b, 0, sizeof(struct yajl_buf_t));
60
- b->alloc = alloc;
61
- return b;
62
- }
63
-
64
- void yajl_buf_free(yajl_buf buf)
65
- {
66
- assert(buf != NULL);
67
- if (buf->data) YA_FREE(buf->alloc, buf->data);
68
- YA_FREE(buf->alloc, buf);
69
- }
70
-
71
- void yajl_buf_append(yajl_buf buf, const void * data, size_t len)
72
- {
73
- yajl_buf_ensure_available(buf, len);
74
- if (len > 0) {
75
- assert(data != NULL);
76
- memcpy(buf->data + buf->used, data, len);
77
- buf->used += len;
78
- buf->data[buf->used] = 0;
79
- }
80
- }
81
-
82
- void yajl_buf_clear(yajl_buf buf)
83
- {
84
- buf->used = 0;
85
- if (buf->data) buf->data[buf->used] = 0;
86
- }
87
-
88
- const unsigned char * yajl_buf_data(yajl_buf buf)
89
- {
90
- return buf->data;
91
- }
92
-
93
- size_t yajl_buf_len(yajl_buf buf)
94
- {
95
- return buf->used;
96
- }
97
-
98
- void
99
- yajl_buf_truncate(yajl_buf buf, size_t len)
100
- {
101
- assert(len <= buf->used);
102
- buf->used = len;
103
- }
@@ -1,57 +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_BUF_H__
18
- #define __YAJL_BUF_H__
19
-
20
- #include "api/yajl_common.h"
21
- #include "yajl_alloc.h"
22
-
23
- /*
24
- * Implementation/performance notes. If this were moved to a header
25
- * only implementation using #define's where possible we might be
26
- * able to sqeeze a little performance out of the guy by killing function
27
- * call overhead. YMMV.
28
- */
29
-
30
- /**
31
- * yajl_buf is a buffer with exponential growth. the buffer ensures that
32
- * you are always null padded.
33
- */
34
- typedef struct yajl_buf_t * yajl_buf;
35
-
36
- /* allocate a new buffer */
37
- yajl_buf yajl_buf_alloc(yajl_alloc_funcs * alloc);
38
-
39
- /* free the buffer */
40
- void yajl_buf_free(yajl_buf buf);
41
-
42
- /* append a number of bytes to the buffer */
43
- void yajl_buf_append(yajl_buf buf, const void * data, size_t len);
44
-
45
- /* empty the buffer */
46
- void yajl_buf_clear(yajl_buf buf);
47
-
48
- /* get a pointer to the beginning of the buffer */
49
- const unsigned char * yajl_buf_data(yajl_buf buf);
50
-
51
- /* get the length of the buffer */
52
- size_t yajl_buf_len(yajl_buf buf);
53
-
54
- /* truncate the buffer */
55
- void yajl_buf_truncate(yajl_buf buf, size_t len);
56
-
57
- #endif
@@ -1,69 +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
- /*
18
- * A header only implementation of a simple stack of bytes, used in YAJL
19
- * to maintain parse state.
20
- */
21
-
22
- #ifndef __YAJL_BYTESTACK_H__
23
- #define __YAJL_BYTESTACK_H__
24
-
25
- #include "api/yajl_common.h"
26
-
27
- #define YAJL_BS_INC 128
28
-
29
- typedef struct yajl_bytestack_t
30
- {
31
- unsigned char * stack;
32
- size_t size;
33
- size_t used;
34
- yajl_alloc_funcs * yaf;
35
- } yajl_bytestack;
36
-
37
- /* initialize a bytestack */
38
- #define yajl_bs_init(obs, _yaf) { \
39
- (obs).stack = NULL; \
40
- (obs).size = 0; \
41
- (obs).used = 0; \
42
- (obs).yaf = (_yaf); \
43
- } \
44
-
45
-
46
- /* initialize a bytestack */
47
- #define yajl_bs_free(obs) \
48
- if ((obs).stack) (obs).yaf->free((obs).yaf->ctx, (obs).stack);
49
-
50
- #define yajl_bs_current(obs) \
51
- (assert((obs).used > 0), (obs).stack[(obs).used - 1])
52
-
53
- #define yajl_bs_push(obs, byte) { \
54
- if (((obs).size - (obs).used) == 0) { \
55
- (obs).size += YAJL_BS_INC; \
56
- (obs).stack = (obs).yaf->realloc((obs).yaf->ctx,\
57
- (void *) (obs).stack, (obs).size);\
58
- } \
59
- (obs).stack[((obs).used)++] = (byte); \
60
- }
61
-
62
- /* removes the top item of the stack, returns nothing */
63
- #define yajl_bs_pop(obs) { ((obs).used)--; }
64
-
65
- #define yajl_bs_set(obs, byte) \
66
- (obs).stack[((obs).used) - 1] = (byte);
67
-
68
-
69
- #endif