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
data/ext/zsv/parser.h CHANGED
@@ -6,44 +6,60 @@
6
6
  #include "options.h"
7
7
  #include "row.h"
8
8
 
9
- /* Parser state structure */
9
+ /* Where the parser reads its input from */
10
+ typedef enum {
11
+ ZSV_SOURCE_NONE = 0, /* not initialized yet */
12
+ ZSV_SOURCE_FILE, /* FILE* opened from a path */
13
+ ZSV_SOURCE_STRING, /* frozen Ruby String held in `source` */
14
+ ZSV_SOURCE_IO, /* Ruby object responding to #read held in `source` */
15
+ } zsv_source_kind_t;
16
+
17
+ /* Parser state, owned by a ZSV::Parser TypedData object. Every VALUE here is
18
+ * marked by zsv_parser_mark(); the struct is freed by zsv_parser_free(). */
10
19
  typedef struct {
11
20
  zsv_parser zsv; /* zsv parser instance */
12
- FILE *file; /* File handle (if parsing file) */
13
- VALUE io; /* Ruby IO object (if parsing IO) */
21
+ zsv_source_kind_t source_kind; /* Input kind */
22
+ FILE *file; /* File handle (ZSV_SOURCE_FILE) */
23
+ VALUE source; /* String or IO object (pinned: zsv reads from it) */
24
+ size_t source_offset; /* Read position in a String source */
14
25
  zsv_ruby_options_t options; /* Parser options */
15
26
  zsv_row_builder_t *row_builder; /* Row builder */
16
- VALUE current_row; /* Current row being built */
17
27
  VALUE row_buffer; /* Buffer of parsed rows (Ruby array) */
18
28
  VALUE headers; /* Parsed headers (if header mode) */
19
- size_t row_count; /* Number of rows parsed */
29
+ size_t record_count; /* Records zsv has emitted: the 1-based line in errors */
20
30
  size_t lines_skipped; /* Number of lines skipped */
21
31
  bool header_row_processed; /* Whether header row was processed */
22
32
  bool closed; /* Whether parser is closed */
23
- bool eof_reached; /* Whether EOF was reached */
24
- bool in_cleanup; /* True during zsv_finish cleanup */
25
- int error_code; /* Last error code */
26
- char *error_message; /* Last error message */
33
+ bool eof_reached; /* Whether EOF (and zsv_finish) was reached */
34
+ bool parsing; /* True while inside zsv (reentrancy guard) */
35
+ bool column_overflow; /* zsv reported a row wider than max_columns */
36
+ bool row_truncated; /* zsv reported a row that did not fit in its buffer */
37
+ int exception_state; /* rb_protect state of an exception raised in a callback */
27
38
  } zsv_ruby_parser_t;
28
39
 
29
- /* Create new parser from file path */
30
- zsv_ruby_parser_t *zsv_parser_new_from_path(const char *path, VALUE opts_hash);
40
+ /* Initialize symbols (called from Init_zsv) */
41
+ void Init_zsv_parser(void);
42
+
43
+ /* Reset a freshly allocated struct to the uninitialized state */
44
+ void zsv_parser_init_struct(zsv_ruby_parser_t *parser);
31
45
 
32
- /* Create new parser from Ruby IO object */
33
- zsv_ruby_parser_t *zsv_parser_new_from_io(VALUE io, VALUE opts_hash);
46
+ /* Initialize an allocated parser from a file path, String or IO object.
47
+ * May raise; the parser is then left for zsv_parser_free() to clean up. */
48
+ void zsv_parser_init_path(zsv_ruby_parser_t *parser, VALUE path, VALUE opts_hash);
49
+ void zsv_parser_init_string(zsv_ruby_parser_t *parser, VALUE string, VALUE opts_hash);
50
+ void zsv_parser_init_io(zsv_ruby_parser_t *parser, VALUE io, VALUE opts_hash);
34
51
 
35
- /* Create new parser from string */
36
- zsv_ruby_parser_t *zsv_parser_new_from_string(VALUE string, VALUE opts_hash);
52
+ /* GC support */
53
+ void zsv_parser_mark(zsv_ruby_parser_t *parser);
54
+ void zsv_parser_compact(zsv_ruby_parser_t *parser);
55
+ size_t zsv_parser_memsize(const zsv_ruby_parser_t *parser);
37
56
 
38
57
  /* Free parser and associated resources */
39
58
  void zsv_parser_free(zsv_ruby_parser_t *parser);
40
59
 
41
- /* Parse next row, returns Ruby array or hash */
60
+ /* Parse next row, returns Ruby array or hash, or nil at EOF */
42
61
  VALUE zsv_parser_shift(zsv_ruby_parser_t *parser);
43
62
 
44
- /* Parse all rows, yielding to block */
45
- void zsv_parser_each(zsv_ruby_parser_t *parser);
46
-
47
63
  /* Rewind parser to beginning */
48
64
  void zsv_parser_rewind(zsv_ruby_parser_t *parser);
49
65
 
@@ -56,7 +72,4 @@ VALUE zsv_parser_headers(zsv_ruby_parser_t *parser);
56
72
  /* Check if parser is closed */
57
73
  bool zsv_parser_closed(zsv_ruby_parser_t *parser);
58
74
 
59
- /* Get row count */
60
- size_t zsv_parser_row_count(zsv_ruby_parser_t *parser);
61
-
62
75
  #endif /* ZSV_RUBY_PARSER_H */
data/ext/zsv/row.c CHANGED
@@ -11,8 +11,7 @@ zsv_row_builder_t *zsv_row_builder_new(rb_encoding *encoding)
11
11
  builder->cells = ZSV_ALLOC_N(VALUE, builder->capacity);
12
12
  builder->count = 0;
13
13
  builder->headers = Qnil;
14
- builder->header_cache = NULL;
15
- builder->header_count = 0;
14
+ builder->has_duplicate_headers = false;
16
15
  builder->encoding = encoding;
17
16
 
18
17
  return builder;
@@ -22,13 +21,31 @@ void zsv_row_builder_free(zsv_row_builder_t *builder)
22
21
  {
23
22
  if (builder) {
24
23
  xfree(builder->cells);
25
- if (builder->header_cache) {
26
- xfree(builder->header_cache);
27
- }
28
24
  xfree(builder);
29
25
  }
30
26
  }
31
27
 
28
+ void zsv_row_builder_mark(zsv_row_builder_t *builder)
29
+ {
30
+ rb_gc_mark_movable(builder->headers);
31
+ for (size_t i = 0; i < builder->count; i++) {
32
+ rb_gc_mark_movable(builder->cells[i]);
33
+ }
34
+ }
35
+
36
+ void zsv_row_builder_compact(zsv_row_builder_t *builder)
37
+ {
38
+ builder->headers = rb_gc_location(builder->headers);
39
+ for (size_t i = 0; i < builder->count; i++) {
40
+ builder->cells[i] = rb_gc_location(builder->cells[i]);
41
+ }
42
+ }
43
+
44
+ size_t zsv_row_builder_memsize(const zsv_row_builder_t *builder)
45
+ {
46
+ return sizeof(*builder) + builder->capacity * sizeof(VALUE);
47
+ }
48
+
32
49
  void zsv_row_builder_reset(zsv_row_builder_t *builder)
33
50
  {
34
51
  builder->count = 0;
@@ -54,7 +71,8 @@ void zsv_row_builder_add_cell(zsv_row_builder_t *builder, const unsigned char *d
54
71
  {
55
72
  zsv_row_builder_ensure_capacity(builder, builder->count + 1);
56
73
 
57
- /* Create Ruby string with proper encoding */
74
+ /* Create Ruby string with proper encoding. The allocation may run GC,
75
+ * which is why the cells collected so far are marked by the parser. */
58
76
  VALUE str = rb_enc_str_new((const char *)data, length, builder->encoding);
59
77
 
60
78
  /* Freeze string for memory efficiency (shared strings) */
@@ -65,8 +83,7 @@ void zsv_row_builder_add_cell(zsv_row_builder_t *builder, const unsigned char *d
65
83
 
66
84
  VALUE zsv_row_builder_to_array(zsv_row_builder_t *builder)
67
85
  {
68
- VALUE row = rb_ary_new_from_values(builder->count, builder->cells);
69
- return row;
86
+ return rb_ary_new_from_values(builder->count, builder->cells);
70
87
  }
71
88
 
72
89
  VALUE zsv_row_builder_to_hash(zsv_row_builder_t *builder)
@@ -75,21 +92,26 @@ VALUE zsv_row_builder_to_hash(zsv_row_builder_t *builder)
75
92
  rb_raise(rb_eRuntimeError, "Headers not set for hash conversion");
76
93
  }
77
94
 
78
- /* Use cached header count for efficiency */
79
- size_t header_count = builder->header_count;
95
+ /* RARRAY_AREF, not a cached RARRAY_CONST_PTR: rb_hash_aset can trigger
96
+ * GC with auto-compaction, which may move an embedded array's storage */
97
+ VALUE headers = builder->headers;
98
+ size_t header_count = RARRAY_LEN(builder->headers);
80
99
  size_t cell_count = builder->count;
81
100
 
82
101
  /* Pre-allocate hash with expected size (Ruby 3.2+) */
83
102
  #ifdef HAVE_RB_HASH_NEW_CAPA
84
- VALUE hash = rb_hash_new_capa(cell_count);
103
+ VALUE hash = rb_hash_new_capa(header_count > cell_count ? header_count : cell_count);
85
104
  #else
86
105
  VALUE hash = rb_hash_new();
87
106
  #endif
88
107
 
89
- /* Fast path: use cached header pointers (no rb_ary_entry calls) */
90
- size_t matched = (cell_count < header_count) ? cell_count : header_count;
91
- for (size_t i = 0; i < matched; i++) {
92
- rb_hash_aset(hash, builder->header_cache[i], builder->cells[i]);
108
+ /* Like CSV, every header is a key; missing trailing fields are nil */
109
+ for (size_t i = 0; i < header_count; i++) {
110
+ VALUE header = RARRAY_AREF(headers, i);
111
+ if (builder->has_duplicate_headers && rb_hash_lookup2(hash, header, Qundef) != Qundef) {
112
+ continue;
113
+ }
114
+ rb_hash_aset(hash, header, i < cell_count ? builder->cells[i] : Qnil);
93
115
  }
94
116
 
95
117
  /* Rare case: more cells than headers, add with numeric keys */
@@ -100,23 +122,48 @@ VALUE zsv_row_builder_to_hash(zsv_row_builder_t *builder)
100
122
  return hash;
101
123
  }
102
124
 
103
- void zsv_row_builder_set_headers(zsv_row_builder_t *builder, VALUE headers)
125
+ /* Header strings are copied and frozen so that the caller mutating its
126
+ * header array (or the strings in it) cannot change the keys mid-parse, and
127
+ * so rb_hash_aset does not have to dup an unfrozen String key on every row. */
128
+ static VALUE zsv_row_builder_freeze_headers(VALUE headers)
104
129
  {
105
- Check_Type(headers, T_ARRAY);
106
- builder->headers = headers;
130
+ long count = RARRAY_LEN(headers);
131
+ VALUE copy = rb_ary_new_capa(count);
132
+
133
+ for (long i = 0; i < count; i++) {
134
+ VALUE header = RARRAY_AREF(headers, i);
135
+ rb_ary_push(copy, RB_TYPE_P(header, T_STRING) ? rb_str_new_frozen(header) : header);
136
+ }
107
137
 
108
- /* Cache header count and pointers for fast access in to_hash */
109
- builder->header_count = RARRAY_LEN(headers);
138
+ return rb_ary_freeze(copy);
139
+ }
110
140
 
111
- /* Free old cache if exists */
112
- if (builder->header_cache) {
113
- xfree(builder->header_cache);
141
+ static bool zsv_row_builder_has_duplicates(VALUE headers)
142
+ {
143
+ long count = RARRAY_LEN(headers);
144
+ VALUE seen = rb_hash_new();
145
+
146
+ for (long i = 0; i < count; i++) {
147
+ VALUE header = RARRAY_AREF(headers, i);
148
+ if (rb_hash_lookup2(seen, header, Qundef) != Qundef) {
149
+ return true;
150
+ }
151
+ rb_hash_aset(seen, header, Qtrue);
114
152
  }
115
153
 
116
- /* Allocate and populate header cache */
117
- builder->header_cache = ZSV_ALLOC_N(VALUE, builder->header_count);
118
- const VALUE *header_ptr = RARRAY_CONST_PTR(headers);
119
- for (size_t i = 0; i < builder->header_count; i++) {
120
- builder->header_cache[i] = header_ptr[i];
154
+ return false;
155
+ }
156
+
157
+ void zsv_row_builder_set_headers(zsv_row_builder_t *builder, VALUE headers)
158
+ {
159
+ if (NIL_P(headers)) {
160
+ builder->headers = Qnil;
161
+ builder->has_duplicate_headers = false;
162
+ return;
121
163
  }
164
+
165
+ Check_Type(headers, T_ARRAY);
166
+ VALUE frozen = zsv_row_builder_freeze_headers(headers);
167
+ builder->has_duplicate_headers = zsv_row_builder_has_duplicates(frozen);
168
+ builder->headers = frozen;
122
169
  }
data/ext/zsv/row.h CHANGED
@@ -4,15 +4,16 @@
4
4
 
5
5
  #include "common.h"
6
6
 
7
- /* Row builder for efficient conversion from zsv cells to Ruby arrays/hashes */
7
+ /* Row builder for efficient conversion from zsv cells to Ruby arrays/hashes.
8
+ * Every VALUE held here is reachable only through the C struct, so the owning
9
+ * parser must call zsv_row_builder_mark() and zsv_row_builder_compact(). */
8
10
  typedef struct {
9
- VALUE *cells; /* Array of Ruby string cells */
10
- size_t count; /* Number of cells in current row */
11
- size_t capacity; /* Allocated capacity */
12
- VALUE headers; /* Header array (for hash mode) */
13
- VALUE *header_cache; /* Cached header VALUE pointers for fast access */
14
- size_t header_count; /* Number of headers (cached) */
15
- rb_encoding *encoding; /* String encoding */
11
+ VALUE *cells; /* Ruby string cells of the current row */
12
+ size_t count; /* Number of cells in current row */
13
+ size_t capacity; /* Allocated capacity */
14
+ VALUE headers; /* Private frozen copy of the headers (hash mode) */
15
+ bool has_duplicate_headers; /* First occurrence wins, as in CSV::Row#to_h */
16
+ rb_encoding *encoding; /* String encoding */
16
17
  } zsv_row_builder_t;
17
18
 
18
19
  /* Initialize row builder */
@@ -21,6 +22,11 @@ zsv_row_builder_t *zsv_row_builder_new(rb_encoding *encoding);
21
22
  /* Free row builder */
22
23
  void zsv_row_builder_free(zsv_row_builder_t *builder);
23
24
 
25
+ /* GC support */
26
+ void zsv_row_builder_mark(zsv_row_builder_t *builder);
27
+ void zsv_row_builder_compact(zsv_row_builder_t *builder);
28
+ size_t zsv_row_builder_memsize(const zsv_row_builder_t *builder);
29
+
24
30
  /* Reset row builder for next row */
25
31
  void zsv_row_builder_reset(zsv_row_builder_t *builder);
26
32
 
@@ -33,7 +39,7 @@ VALUE zsv_row_builder_to_array(zsv_row_builder_t *builder);
33
39
  /* Build Ruby hash from current row (requires headers) */
34
40
  VALUE zsv_row_builder_to_hash(zsv_row_builder_t *builder);
35
41
 
36
- /* Set headers for hash mode */
42
+ /* Set headers for hash mode (Qnil clears them) */
37
43
  void zsv_row_builder_set_headers(zsv_row_builder_t *builder, VALUE headers);
38
44
 
39
45
  #endif /* ZSV_RUBY_ROW_H */
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The pinned upstream zsv release, shared by the Rakefile (which vendors it)
4
+ # and extconf.rb (which builds it). The pin itself lives in ZSV_UPSTREAM.
5
+ module ZSVUpstream
6
+ PIN_FILE = File.expand_path('ZSV_UPSTREAM', __dir__)
7
+ VENDOR_DIR = File.expand_path('vendor/zsv', __dir__)
8
+ # Written into VENDOR_DIR by `rake zsv:vendor`; records which pin it came from.
9
+ MARKER_FILE = File.join(VENDOR_DIR, 'VENDORED_FROM')
10
+ # The only parts of the upstream tarball needed to build libzsv.
11
+ VENDORED_PATHS = %w[LICENSE configure include src].freeze
12
+
13
+ module_function
14
+
15
+ # @return [Hash{String => String}] the pin, e.g. {'version' => '1.4.4', 'sha256' => '...'}
16
+ def pin(path = PIN_FILE)
17
+ entries = File.readlines(path, chomp: true).reject { |line| line.strip.empty? || line.start_with?('#') }
18
+ pin = entries.to_h { |line| line.split('=', 2).map(&:strip) }
19
+ validate!(pin, path)
20
+ end
21
+
22
+ def version
23
+ pin.fetch('version')
24
+ end
25
+
26
+ def sha256
27
+ pin.fetch('sha256')
28
+ end
29
+
30
+ def tarball_url(version = self.version)
31
+ "https://github.com/liquidaty/zsv/archive/refs/tags/v#{version}.tar.gz"
32
+ end
33
+
34
+ # @return [String, nil] contents of the marker, nil when nothing is vendored
35
+ def vendored_marker
36
+ File.read(MARKER_FILE) if File.file?(MARKER_FILE)
37
+ end
38
+
39
+ def marker_for(pin)
40
+ "version=#{pin.fetch('version')}\nsha256=#{pin.fetch('sha256')}\n"
41
+ end
42
+
43
+ def vendored_current?
44
+ vendored_marker == marker_for(pin)
45
+ end
46
+
47
+ def validate!(pin, path)
48
+ raise ArgumentError, "#{path}: version must look like 1.2.3, got #{pin['version'].inspect}" \
49
+ unless pin['version'].to_s.match?(/\A\d+(\.\d+){2}\z/)
50
+ raise ArgumentError, "#{path}: sha256 must be 64 hex characters, got #{pin['sha256'].inspect}" \
51
+ unless pin['sha256'].to_s.match?(/\A\h{64}\z/)
52
+
53
+ pin
54
+ end
55
+ end
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Guarnerix Inc dba Liquidaty
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ version=1.4.4
2
+ sha256=99486b6901d6b576bf15afceb0bcc888ceeb3f555a6d489547eefe67eff52079