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
@@ -0,0 +1,89 @@
1
+ /*
2
+ * SIMD abstraction for the fast CSV scanner — x86_64 AVX2 (256-bit).
3
+ *
4
+ * Provides the platform-specific primitives used by zsv_scan_delim_fast.c:
5
+ * fast_vec_t — broadcast vector type
6
+ * fast_vec_set1() — broadcast a byte to all lanes
7
+ * fast_cmpeq_64() — compare 64 bytes against one value → 64-bit mask
8
+ * fast_scan_block() — load 64 bytes once, compare against 4 values
9
+ * fast_prefix_xor() — cumulative XOR (quote state propagation)
10
+ * fast_clear_lowest() — clear lowest set bit
11
+ *
12
+ * AVX2 processes 64 bytes as 2 × 32-byte loads (half the loads of SSE2).
13
+ */
14
+
15
+ #ifndef ZSV_SCAN_SIMD_AVX2_H
16
+ #define ZSV_SCAN_SIMD_AVX2_H
17
+
18
+ #include <immintrin.h>
19
+ #include <stdint.h>
20
+
21
+ #ifdef __PCLMUL__
22
+ #include <wmmintrin.h> /* PCLMULQDQ */
23
+ #endif
24
+
25
+ typedef __m256i fast_vec_t;
26
+
27
+ static inline fast_vec_t fast_vec_set1(unsigned char c) {
28
+ return _mm256_set1_epi8((char)c);
29
+ }
30
+
31
+ /* Compare 64 bytes against broadcast vector, return 64-bit bitmask. */
32
+ __attribute__((always_inline)) static inline uint64_t fast_cmpeq_64(const unsigned char *p, fast_vec_t v) {
33
+ __m256i b0 = _mm256_loadu_si256((const __m256i *)p);
34
+ __m256i b1 = _mm256_loadu_si256((const __m256i *)(p + 32));
35
+ uint64_t m0 = (uint32_t)_mm256_movemask_epi8(_mm256_cmpeq_epi8(b0, v));
36
+ uint64_t m1 = (uint32_t)_mm256_movemask_epi8(_mm256_cmpeq_epi8(b1, v));
37
+ return m0 | (m1 << 32);
38
+ }
39
+
40
+ /*
41
+ * Load 64 bytes once, compare against 4 broadcast vectors, produce 4 masks.
42
+ * Halves the number of loads vs calling fast_cmpeq_64 four times.
43
+ */
44
+ __attribute__((always_inline)) static inline void fast_scan_block(const unsigned char *p, fast_vec_t v0, fast_vec_t v1,
45
+ fast_vec_t v2, fast_vec_t v3, uint64_t *m0,
46
+ uint64_t *m1, uint64_t *m2, uint64_t *m3) {
47
+ __m256i lo = _mm256_loadu_si256((const __m256i *)p);
48
+ __m256i hi = _mm256_loadu_si256((const __m256i *)(p + 32));
49
+ *m0 = (uint32_t)_mm256_movemask_epi8(_mm256_cmpeq_epi8(lo, v0)) |
50
+ ((uint64_t)(uint32_t)_mm256_movemask_epi8(_mm256_cmpeq_epi8(hi, v0)) << 32);
51
+ *m1 = (uint32_t)_mm256_movemask_epi8(_mm256_cmpeq_epi8(lo, v1)) |
52
+ ((uint64_t)(uint32_t)_mm256_movemask_epi8(_mm256_cmpeq_epi8(hi, v1)) << 32);
53
+ *m2 = (uint32_t)_mm256_movemask_epi8(_mm256_cmpeq_epi8(lo, v2)) |
54
+ ((uint64_t)(uint32_t)_mm256_movemask_epi8(_mm256_cmpeq_epi8(hi, v2)) << 32);
55
+ *m3 = (uint32_t)_mm256_movemask_epi8(_mm256_cmpeq_epi8(lo, v3)) |
56
+ ((uint64_t)(uint32_t)_mm256_movemask_epi8(_mm256_cmpeq_epi8(hi, v3)) << 32);
57
+ }
58
+
59
+ /*
60
+ * Cumulative XOR (prefix XOR) — propagates quote toggle state across 64 bits.
61
+ * With PCLMULQDQ this is a single carry-less multiply instruction;
62
+ * without it, falls back to the 6-round shift-XOR cascade.
63
+ */
64
+ __attribute__((always_inline)) static inline uint64_t fast_prefix_xor(uint64_t x) {
65
+ #ifdef __PCLMUL__
66
+ __m128i v = _mm_set_epi64x(0, (long long)x);
67
+ __m128i ones = _mm_set_epi64x(0, (long long)~0ULL);
68
+ return (uint64_t)_mm_cvtsi128_si64(_mm_clmulepi64_si128(v, ones, 0));
69
+ #else
70
+ x ^= x << 1;
71
+ x ^= x << 2;
72
+ x ^= x << 4;
73
+ x ^= x << 8;
74
+ x ^= x << 16;
75
+ x ^= x << 32;
76
+ return x;
77
+ #endif
78
+ }
79
+
80
+ /* Clear lowest set bit — BMI1 blsr or portable fallback. */
81
+ __attribute__((always_inline)) static inline uint64_t fast_clear_lowest(uint64_t x) {
82
+ #ifdef __BMI__
83
+ return _blsr_u64(x);
84
+ #else
85
+ return x & (x - 1);
86
+ #endif
87
+ }
88
+
89
+ #endif /* ZSV_SCAN_SIMD_AVX2_H */
@@ -0,0 +1,80 @@
1
+ /*
2
+ * SIMD abstraction for the fast CSV scanner — aarch64 NEON.
3
+ *
4
+ * Provides the platform-specific primitives used by zsv_scan_delim_fast.c:
5
+ * fast_vec_t — broadcast vector type
6
+ * fast_vec_set1() — broadcast a byte to all lanes
7
+ * fast_cmpeq_64() — compare 64 bytes against one value → 64-bit mask
8
+ * fast_scan_block() — load 64 bytes once, compare against 4 values
9
+ * fast_prefix_xor() — cumulative XOR (quote state propagation)
10
+ * fast_clear_lowest() — clear lowest set bit
11
+ */
12
+
13
+ #ifndef ZSV_SCAN_SIMD_NEON_H
14
+ #define ZSV_SCAN_SIMD_NEON_H
15
+
16
+ #include <arm_neon.h>
17
+ #include <stdint.h>
18
+
19
+ typedef uint8x16_t fast_vec_t;
20
+
21
+ static inline fast_vec_t fast_vec_set1(unsigned char c) {
22
+ return vdupq_n_u8(c);
23
+ }
24
+
25
+ /* NEON has no native movemask — emulate with weighted horizontal add. */
26
+ __attribute__((always_inline)) static inline uint16_t fast_neon_movemask(uint8x16_t input) {
27
+ static const uint8_t weights[16] = {1, 2, 4, 8, 16, 32, 64, 128, 1, 2, 4, 8, 16, 32, 64, 128};
28
+ const uint8x16_t bit_weights = vld1q_u8(weights);
29
+ uint8x16_t masked = vandq_u8(input, bit_weights);
30
+ return (uint16_t)vaddv_u8(vget_low_u8(masked)) | ((uint16_t)vaddv_u8(vget_high_u8(masked)) << 8);
31
+ }
32
+
33
+ /* Compare 64 bytes against broadcast vector, return 64-bit bitmask. */
34
+ __attribute__((always_inline)) static inline uint64_t fast_cmpeq_64(const unsigned char *p, fast_vec_t v) {
35
+ uint64_t mask = 0;
36
+ for (int i = 0; i < 4; i++) {
37
+ uint8x16_t b = vld1q_u8(p + i * 16);
38
+ mask |= (uint64_t)fast_neon_movemask(vceqq_u8(b, v)) << (i * 16);
39
+ }
40
+ return mask;
41
+ }
42
+
43
+ /*
44
+ * Load 64 bytes once, compare against 4 broadcast vectors, produce 4 masks.
45
+ * Avoids redundant loads vs calling fast_cmpeq_64 four times.
46
+ */
47
+ __attribute__((always_inline)) static inline void fast_scan_block(const unsigned char *p, fast_vec_t v0, fast_vec_t v1,
48
+ fast_vec_t v2, fast_vec_t v3, uint64_t *m0,
49
+ uint64_t *m1, uint64_t *m2, uint64_t *m3) {
50
+ *m0 = 0;
51
+ *m1 = 0;
52
+ *m2 = 0;
53
+ *m3 = 0;
54
+ for (int i = 0; i < 4; i++) {
55
+ uint8x16_t b = vld1q_u8(p + i * 16);
56
+ unsigned shift = i * 16;
57
+ *m0 |= (uint64_t)fast_neon_movemask(vceqq_u8(b, v0)) << shift;
58
+ *m1 |= (uint64_t)fast_neon_movemask(vceqq_u8(b, v1)) << shift;
59
+ *m2 |= (uint64_t)fast_neon_movemask(vceqq_u8(b, v2)) << shift;
60
+ *m3 |= (uint64_t)fast_neon_movemask(vceqq_u8(b, v3)) << shift;
61
+ }
62
+ }
63
+
64
+ /* Cumulative XOR (prefix XOR) — portable 6-round shift-XOR cascade. */
65
+ __attribute__((always_inline)) static inline uint64_t fast_prefix_xor(uint64_t x) {
66
+ x ^= x << 1;
67
+ x ^= x << 2;
68
+ x ^= x << 4;
69
+ x ^= x << 8;
70
+ x ^= x << 16;
71
+ x ^= x << 32;
72
+ return x;
73
+ }
74
+
75
+ /* Clear lowest set bit — portable fallback. */
76
+ __attribute__((always_inline)) static inline uint64_t fast_clear_lowest(uint64_t x) {
77
+ return x & (x - 1);
78
+ }
79
+
80
+ #endif /* ZSV_SCAN_SIMD_NEON_H */
@@ -0,0 +1,93 @@
1
+ /*
2
+ * SIMD abstraction for the fast CSV scanner — x86_64 SSE2 (128-bit).
3
+ *
4
+ * Provides the platform-specific primitives used by zsv_scan_delim_fast.c:
5
+ * fast_vec_t — broadcast vector type
6
+ * fast_vec_set1() — broadcast a byte to all lanes
7
+ * fast_cmpeq_64() — compare 64 bytes against one value → 64-bit mask
8
+ * fast_scan_block() — load 64 bytes once, compare against 4 values
9
+ * fast_prefix_xor() — cumulative XOR (quote state propagation)
10
+ * fast_clear_lowest() — clear lowest set bit
11
+ *
12
+ * SSE2 is baseline for all x86_64. Uses 4 × 16-byte loads per 64 bytes.
13
+ * The native _mm_movemask_epi8 compiles to a single instruction.
14
+ */
15
+
16
+ #ifndef ZSV_SCAN_SIMD_SSE2_H
17
+ #define ZSV_SCAN_SIMD_SSE2_H
18
+
19
+ #include <emmintrin.h>
20
+ #include <stdint.h>
21
+
22
+ #ifdef __PCLMUL__
23
+ #include <wmmintrin.h> /* PCLMULQDQ */
24
+ #endif
25
+
26
+ typedef __m128i fast_vec_t;
27
+
28
+ static inline fast_vec_t fast_vec_set1(unsigned char c) {
29
+ return _mm_set1_epi8((char)c);
30
+ }
31
+
32
+ /* Compare 64 bytes against broadcast vector, return 64-bit bitmask. */
33
+ __attribute__((always_inline)) static inline uint64_t fast_cmpeq_64(const unsigned char *p, fast_vec_t v) {
34
+ uint64_t mask = 0;
35
+ for (int i = 0; i < 4; i++) {
36
+ __m128i b = _mm_loadu_si128((const __m128i *)(p + i * 16));
37
+ mask |= (uint64_t)(uint16_t)_mm_movemask_epi8(_mm_cmpeq_epi8(b, v)) << (i * 16);
38
+ }
39
+ return mask;
40
+ }
41
+
42
+ /*
43
+ * Load 64 bytes once, compare against 4 broadcast vectors, produce 4 masks.
44
+ * Avoids redundant loads vs calling fast_cmpeq_64 four times.
45
+ */
46
+ __attribute__((always_inline)) static inline void fast_scan_block(const unsigned char *p, fast_vec_t v0, fast_vec_t v1,
47
+ fast_vec_t v2, fast_vec_t v3, uint64_t *m0,
48
+ uint64_t *m1, uint64_t *m2, uint64_t *m3) {
49
+ *m0 = 0;
50
+ *m1 = 0;
51
+ *m2 = 0;
52
+ *m3 = 0;
53
+ for (int i = 0; i < 4; i++) {
54
+ __m128i b = _mm_loadu_si128((const __m128i *)(p + i * 16));
55
+ unsigned shift = i * 16;
56
+ *m0 |= (uint64_t)(uint16_t)_mm_movemask_epi8(_mm_cmpeq_epi8(b, v0)) << shift;
57
+ *m1 |= (uint64_t)(uint16_t)_mm_movemask_epi8(_mm_cmpeq_epi8(b, v1)) << shift;
58
+ *m2 |= (uint64_t)(uint16_t)_mm_movemask_epi8(_mm_cmpeq_epi8(b, v2)) << shift;
59
+ *m3 |= (uint64_t)(uint16_t)_mm_movemask_epi8(_mm_cmpeq_epi8(b, v3)) << shift;
60
+ }
61
+ }
62
+
63
+ /*
64
+ * Cumulative XOR (prefix XOR) — propagates quote toggle state across 64 bits.
65
+ * With PCLMULQDQ this is a single carry-less multiply instruction;
66
+ * without it, falls back to the 6-round shift-XOR cascade.
67
+ */
68
+ __attribute__((always_inline)) static inline uint64_t fast_prefix_xor(uint64_t x) {
69
+ #ifdef __PCLMUL__
70
+ __m128i v = _mm_set_epi64x(0, (long long)x);
71
+ __m128i ones = _mm_set_epi64x(0, (long long)~0ULL);
72
+ return (uint64_t)_mm_cvtsi128_si64(_mm_clmulepi64_si128(v, ones, 0));
73
+ #else
74
+ x ^= x << 1;
75
+ x ^= x << 2;
76
+ x ^= x << 4;
77
+ x ^= x << 8;
78
+ x ^= x << 16;
79
+ x ^= x << 32;
80
+ return x;
81
+ #endif
82
+ }
83
+
84
+ /* Clear lowest set bit — BMI1 blsr or portable fallback. */
85
+ __attribute__((always_inline)) static inline uint64_t fast_clear_lowest(uint64_t x) {
86
+ #ifdef __BMI__
87
+ return _blsr_u64(x);
88
+ #else
89
+ return x & (x - 1);
90
+ #endif
91
+ }
92
+
93
+ #endif /* ZSV_SCAN_SIMD_SSE2_H */
@@ -0,0 +1,79 @@
1
+ /*
2
+ * SIMD abstraction for the fast CSV scanner — WebAssembly SIMD128.
3
+ *
4
+ * Provides the platform-specific primitives used by zsv_scan_delim_fast.c:
5
+ * fast_vec_t — broadcast vector type
6
+ * fast_vec_set1() — broadcast a byte to all lanes
7
+ * fast_cmpeq_64() — compare 64 bytes against one value → 64-bit mask
8
+ * fast_scan_block() — load 64 bytes once, compare against 4 values
9
+ * fast_prefix_xor() — cumulative XOR (quote state propagation)
10
+ * fast_clear_lowest() — clear lowest set bit
11
+ *
12
+ * This implementation uses WebAssembly SIMD (128-bit) via <wasm_simd128.h>.
13
+ * WebAssembly SIMD currently supports 128-bit vectors maximum.
14
+ * Requires the -msimd128 compiler flag.
15
+ */
16
+
17
+ #ifndef ZSV_SCAN_SIMD_WASM_H
18
+ #define ZSV_SCAN_SIMD_WASM_H
19
+
20
+ #include <wasm_simd128.h>
21
+ #include <stdint.h>
22
+
23
+ typedef v128_t fast_vec_t;
24
+
25
+ static inline fast_vec_t fast_vec_set1(unsigned char c) {
26
+ return wasm_i8x16_splat((char)c);
27
+ }
28
+
29
+ /* Compare 64 bytes against broadcast vector, return 64-bit bitmask. */
30
+ __attribute__((always_inline)) static inline uint64_t fast_cmpeq_64(const unsigned char *p, fast_vec_t v) {
31
+ uint64_t mask = 0;
32
+ for (int i = 0; i < 4; i++) {
33
+ v128_t b = wasm_v128_load((const v128_t *)(p + i * 16));
34
+ mask |= ((uint64_t)(uint16_t)wasm_i8x16_bitmask(wasm_i8x16_eq(b, v))) << (i * 16);
35
+ }
36
+ return mask;
37
+ }
38
+
39
+ /*
40
+ * Load 64 bytes once, compare against 4 broadcast vectors, produce 4 masks.
41
+ * Minimizes loads by reusing the 128-bit registers for multiple comparisons.
42
+ */
43
+ __attribute__((always_inline)) static inline void fast_scan_block(const unsigned char *p, fast_vec_t v0, fast_vec_t v1,
44
+ fast_vec_t v2, fast_vec_t v3, uint64_t *m0,
45
+ uint64_t *m1, uint64_t *m2, uint64_t *m3) {
46
+ *m0 = 0;
47
+ *m1 = 0;
48
+ *m2 = 0;
49
+ *m3 = 0;
50
+ for (int i = 0; i < 4; i++) {
51
+ v128_t b = wasm_v128_load((const v128_t *)(p + i * 16));
52
+ *m0 |= ((uint64_t)(uint16_t)wasm_i8x16_bitmask(wasm_i8x16_eq(b, v0))) << (i * 16);
53
+ *m1 |= ((uint64_t)(uint16_t)wasm_i8x16_bitmask(wasm_i8x16_eq(b, v1))) << (i * 16);
54
+ *m2 |= ((uint64_t)(uint16_t)wasm_i8x16_bitmask(wasm_i8x16_eq(b, v2))) << (i * 16);
55
+ *m3 |= ((uint64_t)(uint16_t)wasm_i8x16_bitmask(wasm_i8x16_eq(b, v3))) << (i * 16);
56
+ }
57
+ }
58
+
59
+ /*
60
+ * Cumulative XOR (prefix XOR) — propagates quote toggle state across 64 bits.
61
+ * WebAssembly lacks a native carry-less multiply (PCLMULQDQ);
62
+ * using the 6-round shift-XOR cascade.
63
+ */
64
+ __attribute__((always_inline)) static inline uint64_t fast_prefix_xor(uint64_t x) {
65
+ x ^= x << 1;
66
+ x ^= x << 2;
67
+ x ^= x << 4;
68
+ x ^= x << 8;
69
+ x ^= x << 16;
70
+ x ^= x << 32;
71
+ return x;
72
+ }
73
+
74
+ /* Clear lowest set bit. */
75
+ __attribute__((always_inline)) static inline uint64_t fast_clear_lowest(uint64_t x) {
76
+ return x & (x - 1);
77
+ }
78
+
79
+ #endif /* ZSV_SCAN_SIMD_WASM_H */
@@ -0,0 +1,84 @@
1
+ /*
2
+ * zsv_strencode(): standalone file to allow zsv utilities that use this
3
+ * to be used on a standalone basis without the zsv parser
4
+ *
5
+ * This file is part of zsv/lib, distributed under the license defined at
6
+ * https://opensource.org/licenses/MIT
7
+ */
8
+
9
+ #include <zsv/utils/utf8.h>
10
+ #include <zsv/utils/compiler.h>
11
+
12
+ /* Single scan loop shared by zsv_strencode (encode in place) and
13
+ * zsv_strencode_validate (read-only). validate_only is a compile-time
14
+ * constant at each entry point, so each instantiation constant-folds; with
15
+ * validate_only set the loop provably never writes through s. Returns the
16
+ * encoded length (with validate_only, the length removal would leave);
17
+ * *malformed_count, if given, receives the number of malformed sequences. */
18
+ static inline size_t zsv_strencode_aux(unsigned char *s, size_t n, unsigned char replace,
19
+ int (*malformed_handler)(void *, const unsigned char *s, size_t n,
20
+ size_t offset),
21
+ void *handler_ctx, char validate_only, size_t *malformed_count) {
22
+ size_t new_len = 0, bad = 0;
23
+ int clen;
24
+ for (size_t i2 = 0; i2 < n; i2 += (size_t)clen) {
25
+ clen = ZSV_UTF8_CHARLEN(s[i2]);
26
+ if (LIKELY(clen == 1)) {
27
+ if (!validate_only)
28
+ s[new_len] = s[i2];
29
+ new_len++;
30
+ } else if (UNLIKELY(clen < 0) || UNLIKELY(i2 + clen > n)) {
31
+ bad++;
32
+ if (malformed_handler)
33
+ malformed_handler(handler_ctx, s, n, new_len);
34
+ if (!validate_only && replace)
35
+ s[new_len++] = replace;
36
+ clen = 1;
37
+ } else { /* might be valid multi-byte utf8; check */
38
+ unsigned char valid_n;
39
+ for (valid_n = 1; valid_n < clen; valid_n++)
40
+ if (!ZSV_UTF8_SUBSEQUENT_CHAR_OK(s[i2 + valid_n]))
41
+ break;
42
+ if (valid_n == clen) { /* valid_n utf8; copy it */
43
+ if (!validate_only)
44
+ memmove(s + new_len, s + i2, clen);
45
+ new_len += clen;
46
+ } else { /* invalid; valid_n smaller than expected */
47
+ bad++;
48
+ if (malformed_handler)
49
+ malformed_handler(handler_ctx, s, n, new_len);
50
+ if (!validate_only && replace) {
51
+ memset(s + new_len, replace, valid_n);
52
+ new_len += valid_n;
53
+ }
54
+ clen = valid_n;
55
+ }
56
+ }
57
+ }
58
+ if (malformed_count)
59
+ *malformed_count = bad;
60
+ return new_len;
61
+ }
62
+
63
+ /**
64
+ * Ensure valid UTF8 encoding by, if needed, replacing malformed bytes
65
+ */
66
+ ZSV_EXPORT
67
+ size_t zsv_strencode(unsigned char *s, size_t n, unsigned char replace,
68
+ int (*malformed_handler)(void *, const unsigned char *s, size_t n, size_t offset),
69
+ void *handler_ctx) {
70
+ return zsv_strencode_aux(s, n, replace, malformed_handler, handler_ctx, 0, NULL);
71
+ }
72
+
73
+ /**
74
+ * Scan for malformed UTF8 without modifying the input
75
+ */
76
+ ZSV_EXPORT
77
+ size_t zsv_strencode_validate(const unsigned char *s, size_t n,
78
+ int (*malformed_handler)(void *, const unsigned char *s, size_t n, size_t offset),
79
+ void *handler_ctx) {
80
+ size_t bad;
81
+ /* validate_only is compile-time 1: the core never writes through s */
82
+ zsv_strencode_aux((unsigned char *)s, n, 0, malformed_handler, handler_ctx, 1, &bad);
83
+ return bad;
84
+ }