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/extconf.rb CHANGED
@@ -1,154 +1,102 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'mkmf'
4
- require 'net/http'
5
- require 'uri'
6
4
  require 'fileutils'
7
- require 'rubygems/package'
8
- require 'zlib'
9
- require 'openssl'
10
-
11
- # ZSV version to compile against
12
- ZSV_VERSION = '1.3.0' # zsv C library version (not gem version)
13
- ZSV_URL = "https://github.com/liquidaty/zsv/archive/refs/tags/v#{ZSV_VERSION}.tar.gz".freeze
14
- # Use absolute path relative to the original extconf.rb location
15
- EXTCONF_DIR = File.expand_path(__dir__)
16
- VENDOR_DIR = File.join(EXTCONF_DIR, 'vendor')
17
- ZSV_DIR = File.join(VENDOR_DIR, "zsv-#{ZSV_VERSION}")
18
-
19
- def download_file(url, destination, redirect_limit = 10, verify_ssl = true)
20
- abort('Too many redirects') if redirect_limit.zero?
21
-
22
- uri = URI.parse(url)
23
- http = Net::HTTP.new(uri.host, uri.port)
24
-
25
- if uri.scheme == 'https'
26
- http.use_ssl = true
27
- http.verify_mode = verify_ssl ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
28
- http.ca_file = ENV['SSL_CERT_FILE'] if ENV['SSL_CERT_FILE'] && verify_ssl
29
- end
30
-
31
- request = Net::HTTP::Get.new(uri.request_uri)
32
-
33
- begin
34
- response = http.request(request)
35
- rescue OpenSSL::SSL::SSLError => e
36
- if verify_ssl
37
- # Retry without SSL verification (GitHub is trusted)
38
- warn "SSL verification failed (#{e.message}), retrying without verification..."
39
- return download_file(url, destination, redirect_limit, false)
40
- end
41
- raise
42
- end
43
-
44
- case response
45
- when Net::HTTPRedirection
46
- download_file(response['location'], destination, redirect_limit - 1, verify_ssl)
47
- when Net::HTTPSuccess
48
- File.binwrite(destination, response.body)
49
- else
50
- abort("Failed to download: #{response.code} #{response.message}")
5
+ require 'shellwords'
6
+ require_relative 'upstream'
7
+
8
+ # Builds the zsv C library from the source vendored in ext/zsv/vendor/zsv (see
9
+ # ZSV_UPSTREAM and `rake zsv:vendor`), then links it statically into the
10
+ # extension. No network access happens here.
11
+ #
12
+ # The default build targets the baseline CPU of the architecture (SSE2 on
13
+ # x86_64, NEON on aarch64), so a binary built on one machine (a Docker image
14
+ # built in CI, say) runs on any other machine of that architecture instead of
15
+ # dying with SIGILL.
16
+ #
17
+ # Options (`gem install zsv -- --enable-native`, or ZSV_NATIVE=1):
18
+ # --enable-native build for the build machine's CPU (-march=native,
19
+ # AVX2 when it has it). Only for binaries that run
20
+ # where they were built.
21
+ # --enable-cross-build set by the Rakefile for rake-compiler-dock builds of
22
+ # precompiled gems; always baseline, ignores
23
+ # --enable-native.
24
+
25
+ def vendored_zsv_dir
26
+ unless ZSVUpstream.vendored_current?
27
+ abort <<~MSG
28
+ The zsv #{ZSVUpstream.version} C source is missing from #{ZSVUpstream::VENDOR_DIR}
29
+ (or was vendored from a different ZSV_UPSTREAM pin).
30
+ In a git checkout run `bundle exec rake zsv:vendor`; released gems always include it.
31
+ MSG
51
32
  end
33
+ ZSVUpstream::VENDOR_DIR
52
34
  end
53
35
 
54
- def extract_tar_gz(tarball, destination)
55
- Gem::Package::TarReader.new(Zlib::GzipReader.open(tarball)) do |tar|
56
- tar.each do |entry|
57
- dest_path = File.join(destination, entry.full_name)
58
-
59
- if entry.directory?
60
- FileUtils.mkdir_p(dest_path)
61
- elsif entry.file?
62
- FileUtils.mkdir_p(File.dirname(dest_path))
63
- File.binwrite(dest_path, entry.read)
64
- FileUtils.chmod(entry.header.mode, dest_path)
65
- end
66
- end
67
- end
36
+ def cross_compiling?
37
+ enable_config('cross-build', false)
68
38
  end
69
39
 
70
- def download_and_extract_zsv
71
- return if File.directory?(ZSV_DIR)
72
-
73
- puts "Downloading zsv #{ZSV_VERSION}..."
74
- FileUtils.mkdir_p(VENDOR_DIR)
75
-
76
- tarball = File.join(VENDOR_DIR, 'zsv.tar.gz')
77
- download_file(ZSV_URL, tarball)
78
-
79
- puts 'Extracting zsv...'
80
- extract_tar_gz(tarball, VENDOR_DIR)
81
- FileUtils.rm_f(tarball)
40
+ def native_build?
41
+ !cross_compiling? && enable_config('native', ENV['ZSV_NATIVE'] == '1')
42
+ end
82
43
 
83
- abort('zsv directory not found after extraction') unless File.directory?(ZSV_DIR)
84
- puts "zsv #{ZSV_VERSION} downloaded successfully"
44
+ def configure_args
45
+ # --minimal drops ZSV_EXTRAS (row limits, progress callbacks, sidecar
46
+ # overwrite files), which this gem does not use and which needs sqlite3.h
47
+ # from upstream's app/ tree, deliberately not vendored.
48
+ args = %w[--minimal=yes]
49
+ # SSE2 (x86_64) and NEON (aarch64) are part of the baseline ABI and still
50
+ # select zsv's SIMD scanner; only AVX/AVX2 and -march=native are dropped.
51
+ args += %w[--arch=none --force-avx2=no --force-avx=no] unless native_build?
52
+ args
85
53
  end
86
54
 
87
- def build_zsv
88
- puts 'Building zsv library...'
55
+ def build_env
56
+ env = { 'CC' => RbConfig::CONFIG['CC'], 'AR' => RbConfig::CONFIG['AR'] }
57
+ env['CROSS_COMPILING'] = 'yes' if cross_compiling?
58
+ env.compact
59
+ end
89
60
 
90
- # Build zsv static library
91
- Dir.chdir(ZSV_DIR) do
92
- # Configure zsv
93
- system('./configure') or abort('Failed to configure zsv') unless File.exist?('config.mk')
61
+ def run!(env, *cmd)
62
+ puts "#{env.map { |k, v| "#{k}=#{v.shellescape}" }.join(' ')} #{cmd.shelljoin}"
63
+ system(env, *cmd) or abort("zsv build failed: #{cmd.shelljoin}")
64
+ end
94
65
 
95
- # Build the library
96
- Dir.chdir('src') do
97
- system('make', 'build') or abort('Failed to build zsv library')
98
- end
66
+ # Builds a private copy so the vendored tree stays pristine and builds for
67
+ # several Rubies or platforms never share a config.mk.
68
+ def build_zsv(source_dir, build_dir)
69
+ FileUtils.rm_rf(build_dir)
70
+ FileUtils.cp_r(source_dir, build_dir)
71
+ env = build_env
72
+ Dir.chdir(build_dir) do
73
+ run!(env, './configure', *configure_args)
74
+ run!(env, find_executable('gmake') || 'make', '-C', 'src', 'build', "VERSION=#{ZSVUpstream.version}")
99
75
  end
100
-
101
- puts 'zsv library built successfully'
76
+ Dir.glob(File.join(build_dir, 'build', '*', 'rel', '*', 'lib', 'libzsv.a')).first or
77
+ abort("libzsv.a not found under #{build_dir}/build")
102
78
  end
103
79
 
104
- # Download and build zsv
105
- download_and_extract_zsv
106
- build_zsv
107
-
108
- # Determine build directory based on platform
109
- platform_dir = if RUBY_PLATFORM =~ /darwin/
110
- 'Darwin'
111
- elsif RUBY_PLATFORM =~ /linux/
112
- 'Linux'
113
- else
114
- 'generic'
115
- end
116
-
117
- # Find the built library - compiler name varies (gcc, gcc-14, clang, etc.)
118
- # Search for libzsv.a in the build directory
119
- build_rel_dir = File.join(ZSV_DIR, 'build', platform_dir, 'rel')
120
- zsv_lib = Dir.glob(File.join(build_rel_dir, '*', 'lib', 'libzsv.a')).first
80
+ zsv_build_dir = File.join(Dir.pwd, 'zsv-build')
81
+ puts "Building zsv #{ZSVUpstream.version} (#{native_build? ? 'native CPU' : 'portable baseline CPU'})"
82
+ zsv_lib = build_zsv(vendored_zsv_dir, zsv_build_dir)
83
+ include_dir = File.join(zsv_build_dir, 'include')
121
84
 
122
- abort("libzsv.a not found in #{build_rel_dir}/*/lib/") unless zsv_lib && File.exist?(zsv_lib)
123
-
124
- zsv_lib_dir = File.dirname(zsv_lib)
125
-
126
- # Add zsv include path
127
- include_dir = File.join(ZSV_DIR, 'include')
128
-
129
- # Add compiler and linker flags
130
85
  $INCFLAGS << " -I#{include_dir}"
131
86
  $CFLAGS << ' -std=c99 -Wall -Wextra'
132
- $CFLAGS << ' -O3' # Optimization level
133
-
134
- # Configure include and lib paths
135
- dir_config('zsv', include_dir, zsv_lib_dir)
87
+ $CFLAGS << ' -O3'
136
88
 
137
- # Find zsv header
138
89
  abort("zsv.h not found in #{include_dir}") unless have_header('zsv.h')
139
90
 
140
- # Link the static library
141
91
  $LOCAL_LIBS << " #{zsv_lib}"
142
92
 
143
- # Platform-specific adjustments
144
- if RUBY_PLATFORM =~ /darwin/
93
+ if RUBY_PLATFORM.include?('darwin')
145
94
  $LDFLAGS << ' -framework Foundation'
146
- elsif RUBY_PLATFORM =~ /linux/
95
+ elsif RUBY_PLATFORM.include?('linux')
147
96
  $LIBS << ' -lpthread -lm'
148
97
  end
149
98
 
150
- # Check for Ruby 3.2+ hash capacity preallocation
99
+ # Ruby 3.2+ hash capacity preallocation
151
100
  have_func('rb_hash_new_capa')
152
101
 
153
- # Create Makefile
154
102
  create_makefile('zsv/zsv')
data/ext/zsv/options.c CHANGED
@@ -1,5 +1,6 @@
1
1
  /* Options parsing and conversion implementation */
2
2
  #include "options.h"
3
+ #include "options_internal.h"
3
4
 
4
5
  /* Symbol constants for option keys */
5
6
  static ID id_headers;
@@ -7,45 +8,47 @@ static ID id_col_sep;
7
8
  static ID id_quote_char;
8
9
  static ID id_skip_lines;
9
10
  static ID id_encoding;
10
- static ID id_liberal_parsing;
11
11
  static ID id_buffer_size;
12
-
13
- void zsv_options_init_symbols(void)
14
- {
15
- id_headers = rb_intern("headers");
16
- id_col_sep = rb_intern("col_sep");
17
- id_quote_char = rb_intern("quote_char");
18
- id_skip_lines = rb_intern("skip_lines");
19
- id_encoding = rb_intern("encoding");
20
- id_liberal_parsing = rb_intern("liberal_parsing");
21
- id_buffer_size = rb_intern("buffer_size");
22
- }
12
+ static ID id_max_columns;
13
+ static ID id_max_row_size;
23
14
 
24
15
  void zsv_options_init(zsv_ruby_options_t *opts)
25
16
  {
26
17
  opts->delimiter = ',';
27
- opts->quote_char = '"';
28
18
  opts->headers = false;
29
19
  opts->header_array = Qnil;
30
20
  opts->skip_lines = 0;
31
- opts->liberal_parsing = false;
32
21
  opts->encoding = rb_utf8_encoding();
33
- opts->buffer_size = 256 * 1024; /* 256KB default */
22
+ opts->buffer_size = ZSV_DEFAULT_SCANNER_BUFFSIZE;
23
+ opts->max_columns = ZSV_MAX_COLS_DEFAULT;
24
+ opts->max_row_size = ZSV_RUBY_DEFAULT_MAX_ROW_SIZE;
34
25
  }
35
26
 
36
- static VALUE get_option(VALUE opts_hash, ID key, VALUE default_value)
27
+ static VALUE get_option(VALUE opts_hash, ID key)
37
28
  {
38
- if (NIL_P(opts_hash)) {
39
- return default_value;
29
+ return rb_hash_lookup(opts_hash, ID2SYM(key));
30
+ }
31
+
32
+ static char parse_single_char(VALUE value, const char *name)
33
+ {
34
+ StringValue(value);
35
+ if (RSTRING_LEN(value) != 1) {
36
+ rb_raise(rb_eArgError, "%s must be a single character", name);
40
37
  }
38
+ return RSTRING_PTR(value)[0];
39
+ }
41
40
 
42
- VALUE val = rb_hash_lookup(opts_hash, ID2SYM(key));
43
- return NIL_P(val) ? default_value : val;
41
+ static unsigned parse_positive_uint(VALUE value, const char *name)
42
+ {
43
+ unsigned long n = NUM2ULONG(value);
44
+ if (n == 0 || n > UINT_MAX) {
45
+ rb_raise(rb_eArgError, "%s must be between 1 and %u", name, UINT_MAX);
46
+ }
47
+ return (unsigned)n;
44
48
  }
45
49
 
46
50
  void zsv_options_parse(VALUE opts_hash, zsv_ruby_options_t *opts)
47
51
  {
48
- /* Initialize with defaults */
49
52
  zsv_options_init(opts);
50
53
 
51
54
  if (NIL_P(opts_hash)) {
@@ -54,72 +57,70 @@ void zsv_options_parse(VALUE opts_hash, zsv_ruby_options_t *opts)
54
57
 
55
58
  Check_Type(opts_hash, T_HASH);
56
59
 
57
- /* Parse col_sep */
58
- VALUE col_sep = get_option(opts_hash, id_col_sep, Qnil);
60
+ VALUE col_sep = get_option(opts_hash, id_col_sep);
59
61
  if (!NIL_P(col_sep)) {
60
- Check_Type(col_sep, T_STRING);
61
- if (RSTRING_LEN(col_sep) != 1) {
62
- rb_raise(rb_eArgError, "col_sep must be a single character");
62
+ opts->delimiter = parse_single_char(col_sep, "col_sep");
63
+ /* zsv silently replaces these delimiters with ',' */
64
+ if (opts->delimiter == '\n' || opts->delimiter == '\r' || opts->delimiter == '"') {
65
+ rb_raise(rb_eArgError, "col_sep cannot be a newline or a double quote");
63
66
  }
64
- opts->delimiter = RSTRING_PTR(col_sep)[0];
65
67
  }
66
68
 
67
- /* Parse quote_char */
68
- VALUE quote_char = get_option(opts_hash, id_quote_char, Qnil);
69
- if (!NIL_P(quote_char)) {
70
- Check_Type(quote_char, T_STRING);
71
- if (RSTRING_LEN(quote_char) != 1) {
72
- rb_raise(rb_eArgError, "quote_char must be a single character");
73
- }
74
- opts->quote_char = RSTRING_PTR(quote_char)[0];
69
+ /* zsv only supports '"' as the quote character */
70
+ VALUE quote_char = get_option(opts_hash, id_quote_char);
71
+ if (!NIL_P(quote_char) && parse_single_char(quote_char, "quote_char") != '"') {
72
+ rb_raise(rb_eArgError, "quote_char must be '\"' (zsv does not support other quotes)");
75
73
  }
76
74
 
77
- /* Parse headers */
78
- VALUE headers = get_option(opts_hash, id_headers, Qfalse);
79
- if (TYPE(headers) == T_ARRAY) {
75
+ VALUE headers = get_option(opts_hash, id_headers);
76
+ if (RB_TYPE_P(headers, T_ARRAY)) {
80
77
  opts->headers = true;
81
78
  opts->header_array = headers;
82
79
  } else {
83
80
  opts->headers = RTEST(headers);
84
81
  }
85
82
 
86
- /* Parse skip_lines */
87
- VALUE skip_lines = get_option(opts_hash, id_skip_lines, INT2FIX(0));
88
- opts->skip_lines = NUM2INT(skip_lines);
89
-
90
- /* Parse liberal_parsing */
91
- VALUE liberal = get_option(opts_hash, id_liberal_parsing, Qfalse);
92
- opts->liberal_parsing = RTEST(liberal);
83
+ VALUE skip_lines = get_option(opts_hash, id_skip_lines);
84
+ if (!NIL_P(skip_lines)) {
85
+ opts->skip_lines = NUM2INT(skip_lines);
86
+ if (opts->skip_lines < 0) {
87
+ rb_raise(rb_eArgError, "skip_lines must not be negative");
88
+ }
89
+ }
93
90
 
94
- /* Parse encoding */
95
- VALUE encoding = get_option(opts_hash, id_encoding, Qnil);
91
+ VALUE encoding = get_option(opts_hash, id_encoding);
96
92
  if (!NIL_P(encoding)) {
97
93
  opts->encoding = rb_to_encoding(encoding);
98
94
  }
99
95
 
100
- /* Parse buffer_size */
101
- VALUE buffer_size = get_option(opts_hash, id_buffer_size, Qnil);
96
+ VALUE buffer_size = get_option(opts_hash, id_buffer_size);
102
97
  if (!NIL_P(buffer_size)) {
103
98
  opts->buffer_size = NUM2SIZET(buffer_size);
99
+ if (opts->buffer_size == 0) {
100
+ rb_raise(rb_eArgError, "buffer_size must be positive");
101
+ }
104
102
  }
105
- }
106
103
 
107
- void zsv_options_free(zsv_ruby_options_t *opts)
108
- {
109
- (void)opts; /* Currently no dynamic allocations to free */
110
- }
104
+ VALUE max_columns = get_option(opts_hash, id_max_columns);
105
+ if (!NIL_P(max_columns)) {
106
+ opts->max_columns = parse_positive_uint(max_columns, "max_columns");
107
+ }
111
108
 
112
- void zsv_options_apply(zsv_parser parser, zsv_ruby_options_t *opts)
113
- {
114
- /* Note: zsv_set_delimiter doesn't exist in zsv API */
115
- /* The delimiter is set during parser creation via zsv_opts */
116
- /* Additional zsv-specific option application would go here */
117
- (void)parser; /* Suppress unused parameter warning */
118
- (void)opts;
109
+ VALUE max_row_size = get_option(opts_hash, id_max_row_size);
110
+ if (!NIL_P(max_row_size)) {
111
+ opts->max_row_size = parse_positive_uint(max_row_size, "max_row_size");
112
+ }
119
113
  }
120
114
 
121
115
  /* Initialize symbols (call from Init_zsv) */
122
116
  void Init_zsv_options(void)
123
117
  {
124
- zsv_options_init_symbols();
118
+ id_headers = rb_intern("headers");
119
+ id_col_sep = rb_intern("col_sep");
120
+ id_quote_char = rb_intern("quote_char");
121
+ id_skip_lines = rb_intern("skip_lines");
122
+ id_encoding = rb_intern("encoding");
123
+ id_buffer_size = rb_intern("buffer_size");
124
+ id_max_columns = rb_intern("max_columns");
125
+ id_max_row_size = rb_intern("max_row_size");
125
126
  }
data/ext/zsv/options.h CHANGED
@@ -4,28 +4,25 @@
4
4
 
5
5
  #include "common.h"
6
6
 
7
+ /* Longest row (bytes, without its line ending) parsed by default */
8
+ #define ZSV_RUBY_DEFAULT_MAX_ROW_SIZE (256 * 1024)
9
+
7
10
  /* Parser options structure */
8
11
  typedef struct {
9
12
  char delimiter;
10
- char quote_char;
11
13
  bool headers;
12
- VALUE header_array; /* Custom headers as Ruby array */
14
+ VALUE header_array; /* Custom headers as Ruby array (marked by the parser) */
13
15
  int skip_lines;
14
- bool liberal_parsing;
15
16
  rb_encoding *encoding;
16
- size_t buffer_size;
17
+ size_t buffer_size; /* Requested read size; the zsv buffer may be larger */
18
+ unsigned max_columns; /* Most fields in a row; a wider row raises */
19
+ unsigned max_row_size; /* Most bytes in a row; a longer row raises */
17
20
  } zsv_ruby_options_t;
18
21
 
19
22
  /* Initialize options with defaults */
20
23
  void zsv_options_init(zsv_ruby_options_t *opts);
21
24
 
22
- /* Parse Ruby hash into options structure */
25
+ /* Parse Ruby hash into options structure (raises on invalid options) */
23
26
  void zsv_options_parse(VALUE opts_hash, zsv_ruby_options_t *opts);
24
27
 
25
- /* Free any allocated option resources */
26
- void zsv_options_free(zsv_ruby_options_t *opts);
27
-
28
- /* Apply options to zsv parser */
29
- void zsv_options_apply(zsv_parser parser, zsv_ruby_options_t *opts);
30
-
31
28
  #endif /* ZSV_RUBY_OPTIONS_H */