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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +153 -2
- data/README.md +132 -240
- data/ext/zsv/ZSV_UPSTREAM +7 -0
- data/ext/zsv/common.h +0 -12
- data/ext/zsv/extconf.rb +70 -122
- data/ext/zsv/options.c +63 -62
- data/ext/zsv/options.h +8 -11
- data/ext/zsv/parser.c +390 -201
- data/ext/zsv/parser.h +35 -22
- data/ext/zsv/row.c +75 -28
- data/ext/zsv/row.h +15 -9
- data/ext/zsv/upstream.rb +55 -0
- data/ext/zsv/vendor/zsv/LICENSE +21 -0
- data/ext/zsv/vendor/zsv/VENDORED_FROM +2 -0
- data/ext/zsv/vendor/zsv/configure +1212 -0
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/api.h +39 -0
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/common.h +36 -0
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/ext/sheet.h +8 -1
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/ext.h +6 -2
- data/ext/zsv/vendor/zsv/include/zsv/utils/appname.h +51 -0
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/arg.h +50 -1
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/compiler.h +19 -8
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/dirs.h +2 -0
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/file-mem.h +1 -0
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/file.h +28 -2
- data/ext/zsv/vendor/zsv/include/zsv/utils/os.h +145 -0
- data/ext/zsv/vendor/zsv/include/zsv/utils/output.h +34 -0
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/overwrite_writer.h +1 -1
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/prop.h +16 -4
- data/ext/zsv/vendor/zsv/include/zsv/utils/rng.h +35 -0
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/signal.h +7 -0
- data/ext/zsv/vendor/zsv/include/zsv/utils/sql.h +13 -0
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/string.h +25 -0
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/writer.h +9 -1
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/zsv_export.h +1 -1
- data/ext/zsv/vendor/{zsv-1.3.0/include/zsv.h → zsv/include/zsv.h.in} +1 -3
- data/ext/zsv/vendor/zsv/src/Makefile +238 -0
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/src/zsv.c +152 -14
- data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/src/zsv_internal.c +108 -50
- data/ext/zsv/vendor/zsv/src/zsv_scan_delim_fast.c +741 -0
- data/ext/zsv/vendor/zsv/src/zsv_scan_simd_avx2.h +89 -0
- data/ext/zsv/vendor/zsv/src/zsv_scan_simd_neon.h +80 -0
- data/ext/zsv/vendor/zsv/src/zsv_scan_simd_sse2.h +93 -0
- data/ext/zsv/vendor/zsv/src/zsv_scan_simd_wasm.h +79 -0
- data/ext/zsv/vendor/zsv/src/zsv_strencode.c +84 -0
- data/ext/zsv/zsv_ext.c +176 -105
- data/lib/zsv/errors.rb +32 -0
- data/lib/zsv/input.rb +88 -0
- data/lib/zsv/options.rb +132 -0
- data/lib/zsv/strict_validator.rb +124 -0
- data/lib/zsv/version.rb +1 -1
- data/lib/zsv.rb +137 -35
- metadata +81 -230
- data/ext/zsv/vendor/zsv-1.3.0/app/2db.c +0 -756
- data/ext/zsv/vendor/zsv-1.3.0/app/2json.c +0 -381
- data/ext/zsv/vendor/zsv-1.3.0/app/2tsv.c +0 -228
- data/ext/zsv/vendor/zsv-1.3.0/app/builtin/help.c +0 -123
- data/ext/zsv/vendor/zsv-1.3.0/app/builtin/license.c +0 -39
- data/ext/zsv/vendor/zsv-1.3.0/app/builtin/register.c +0 -104
- data/ext/zsv/vendor/zsv-1.3.0/app/builtin/thirdparty.c +0 -41
- data/ext/zsv/vendor/zsv-1.3.0/app/builtin/unregister.c +0 -1
- data/ext/zsv/vendor/zsv-1.3.0/app/builtin/version.c +0 -14
- data/ext/zsv/vendor/zsv-1.3.0/app/check/simdutf_wrapper.h +0 -19
- data/ext/zsv/vendor/zsv-1.3.0/app/check/utf8.c +0 -116
- data/ext/zsv/vendor/zsv-1.3.0/app/check.c +0 -194
- data/ext/zsv/vendor/zsv-1.3.0/app/cli.c +0 -796
- data/ext/zsv/vendor/zsv-1.3.0/app/cli_const.h +0 -41
- data/ext/zsv/vendor/zsv-1.3.0/app/cli_export.h +0 -16
- data/ext/zsv/vendor/zsv-1.3.0/app/cli_ini.c +0 -280
- data/ext/zsv/vendor/zsv-1.3.0/app/cli_internal.h +0 -36
- data/ext/zsv/vendor/zsv-1.3.0/app/compare.c +0 -913
- data/ext/zsv/vendor/zsv-1.3.0/app/compare.h +0 -23
- data/ext/zsv/vendor/zsv-1.3.0/app/compare_added_column.c +0 -20
- data/ext/zsv/vendor/zsv-1.3.0/app/compare_internal.h +0 -140
- data/ext/zsv/vendor/zsv-1.3.0/app/compare_sort.c +0 -91
- data/ext/zsv/vendor/zsv-1.3.0/app/compare_unique_colname.c +0 -81
- data/ext/zsv/vendor/zsv-1.3.0/app/count-pull.c +0 -82
- data/ext/zsv/vendor/zsv-1.3.0/app/count.c +0 -404
- data/ext/zsv/vendor/zsv-1.3.0/app/desc.c +0 -569
- data/ext/zsv/vendor/zsv-1.3.0/app/echo.c +0 -365
- data/ext/zsv/vendor/zsv-1.3.0/app/ext_example/my_extension.c +0 -366
- data/ext/zsv/vendor/zsv-1.3.0/app/ext_example/mysheet_extension.c +0 -341
- data/ext/zsv/vendor/zsv-1.3.0/app/ext_template/YOUR_EXTENSION_zsvext.c +0 -263
- data/ext/zsv/vendor/zsv-1.3.0/app/external/inih/ini.c +0 -298
- data/ext/zsv/vendor/zsv-1.3.0/app/external/inih/ini.h +0 -157
- data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/json_numeric.c +0 -177
- data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/jsonwriter.c +0 -444
- data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/jsonwriter.h +0 -145
- data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/utils.c +0 -110
- data/ext/zsv/vendor/zsv-1.3.0/app/external/memfile-1.0/include/memfile.h +0 -15
- data/ext/zsv/vendor/zsv-1.3.0/app/external/memfile-1.0/src/memfile.c +0 -64
- data/ext/zsv/vendor/zsv-1.3.0/app/external/sglib/sglib.h +0 -1955
- data/ext/zsv/vendor/zsv-1.3.0/app/external/simdutf/simdutf.h +0 -6802
- data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3.c +0 -230517
- data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3.h +0 -12174
- data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_and_csv_vtab.c +0 -2
- data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab-mem.c +0 -142
- data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab-mem.h +0 -49
- data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab-zsv.c +0 -485
- data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab.c +0 -1015
- data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3ext.h +0 -663
- data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/vtab_helper.c +0 -85
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_common.h +0 -75
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_gen.h +0 -167
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_parse.h +0 -228
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_tree.h +0 -186
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_version.h +0 -23
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_common.h +0 -76
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_gen.h +0 -167
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_parse.h +0 -238
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_tree.h +0 -186
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl.c +0 -184
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_alloc.c +0 -52
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_alloc.h +0 -34
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_buf.c +0 -103
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_buf.h +0 -57
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_bytestack.h +0 -69
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_encode.c +0 -220
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_encode.h +0 -34
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_gen.c +0 -362
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_lex.c +0 -764
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_lex.h +0 -117
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_parser.c +0 -508
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_parser.h +0 -78
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_tree.c +0 -505
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_version.c +0 -7
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper/json_value.h +0 -59
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper/yajl_helper.h +0 -208
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper.c +0 -795
- data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper_internal.h +0 -28
- data/ext/zsv/vendor/zsv-1.3.0/app/flatten.c +0 -851
- data/ext/zsv/vendor/zsv-1.3.0/app/jq.c +0 -106
- data/ext/zsv/vendor/zsv-1.3.0/app/jq.h +0 -6
- data/ext/zsv/vendor/zsv-1.3.0/app/mv.c +0 -113
- data/ext/zsv/vendor/zsv-1.3.0/app/noop.c +0 -90
- data/ext/zsv/vendor/zsv-1.3.0/app/overwrite.c +0 -295
- data/ext/zsv/vendor/zsv-1.3.0/app/paste.c +0 -175
- data/ext/zsv/vendor/zsv-1.3.0/app/pretty.c +0 -693
- data/ext/zsv/vendor/zsv-1.3.0/app/prop.c +0 -980
- data/ext/zsv/vendor/zsv-1.3.0/app/rm.c +0 -131
- data/ext/zsv/vendor/zsv-1.3.0/app/select/fixed.c +0 -130
- data/ext/zsv/vendor/zsv-1.3.0/app/select/internal.h +0 -118
- data/ext/zsv/vendor/zsv-1.3.0/app/select/parallel.c +0 -45
- data/ext/zsv/vendor/zsv-1.3.0/app/select/parallel.h +0 -41
- data/ext/zsv/vendor/zsv-1.3.0/app/select/processing.c +0 -107
- data/ext/zsv/vendor/zsv-1.3.0/app/select/rand.c +0 -20
- data/ext/zsv/vendor/zsv-1.3.0/app/select/regex.c +0 -61
- data/ext/zsv/vendor/zsv-1.3.0/app/select/search.c +0 -14
- data/ext/zsv/vendor/zsv-1.3.0/app/select/selection.c +0 -192
- data/ext/zsv/vendor/zsv-1.3.0/app/select/usage.c +0 -72
- data/ext/zsv/vendor/zsv-1.3.0/app/select-pull.c +0 -812
- data/ext/zsv/vendor/zsv-1.3.0/app/select.c +0 -753
- data/ext/zsv/vendor/zsv-1.3.0/app/serialize.c +0 -372
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/curses.h +0 -15
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/cursor.c +0 -119
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/errors.c +0 -45
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/file.c +0 -63
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/file.h +0 -12
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/filter.c +0 -166
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/handlers.c +0 -214
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/handlers_internal.h +0 -128
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/help.c +0 -43
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/index.c +0 -81
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/index.h +0 -25
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/key-bindings.c +0 -325
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/key-bindings.h +0 -73
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/lexer.c +0 -203
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/newline_handler.c +0 -7
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/pivot.c +0 -318
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/procedure.c +0 -134
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/procedure.h +0 -119
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/read-data.c +0 -322
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/screen_buffer.c +0 -203
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/screen_buffer.h +0 -36
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/sheet-sql.c +0 -167
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/sheet_internal.h +0 -36
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/sqlfilter.c +0 -153
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/terminfo.c +0 -32
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/transformation.c +0 -312
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/transformation.h +0 -29
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/ui_buffer.c +0 -266
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/usage.c +0 -9
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet/utf8-width.c +0 -60
- data/ext/zsv/vendor/zsv-1.3.0/app/sheet.c +0 -1007
- data/ext/zsv/vendor/zsv-1.3.0/app/sql.c +0 -453
- data/ext/zsv/vendor/zsv-1.3.0/app/sql_internal.c +0 -101
- data/ext/zsv/vendor/zsv-1.3.0/app/sql_internal.h +0 -49
- data/ext/zsv/vendor/zsv-1.3.0/app/stack.c +0 -393
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/arg.c +0 -322
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/cache.c +0 -228
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/cat.c +0 -91
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/chunk.c +0 -240
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/chunk.h +0 -63
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/clock.c +0 -57
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/db.c +0 -148
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs-no-jq.c +0 -2
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs.c +0 -427
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs_from_json.c +0 -253
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs_to_json.c +0 -121
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/dl.c +0 -20
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/emcc/fs_api.c +0 -159
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/err.c +0 -24
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/file-mem.c +0 -180
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/file.c +0 -256
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/index.c +0 -197
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/index.h +0 -49
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/jq.c +0 -400
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/json.c +0 -120
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/mem.c +0 -18
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/memmem.c +0 -132
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/os.c +0 -178
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/overwrite.c +0 -258
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/overwrite_writer.c +0 -246
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/pcre2-8/pcre2-8-test.c +0 -123
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/pcre2-8/pcre2-8.c +0 -153
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/pcre2-8/pcre2-8.h +0 -54
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/prop.c +0 -267
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/signal.c +0 -53
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/string.c +0 -357
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/dir_exists_longpath.c +0 -83
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/dl.c +0 -33
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/fopen_longpath.c +0 -184
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/foreach_dirent_longpath.c +0 -292
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/io.c +0 -259
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/io.h +0 -13
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/mkdir_longpath.c +0 -255
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/remove_longpath.c +0 -96
- data/ext/zsv/vendor/zsv-1.3.0/app/utils/writer.c +0 -361
- data/ext/zsv/vendor/zsv-1.3.0/app/zsv_command.h +0 -40
- data/ext/zsv/vendor/zsv-1.3.0/app/zsv_command_standalone.c +0 -16
- data/ext/zsv/vendor/zsv-1.3.0/app/zsv_main.h +0 -44
- data/ext/zsv/vendor/zsv-1.3.0/examples/js/zsv_parser_api_dummy.c +0 -3
- data/ext/zsv/vendor/zsv-1.3.0/examples/lib/parse_by_chunk.c +0 -100
- data/ext/zsv/vendor/zsv-1.3.0/examples/lib/print_my_column.c +0 -143
- data/ext/zsv/vendor/zsv-1.3.0/examples/lib/pull.c +0 -89
- data/ext/zsv/vendor/zsv-1.3.0/examples/lib/simple.c +0 -123
- data/ext/zsv/vendor/zsv-1.3.0/fuzz/fuzz.c +0 -16
- data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/os.h +0 -54
- data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/sql.h +0 -11
- data/ext/zsv/vendor/zsv-1.3.0/src/zsv_strencode.c +0 -51
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/ext/implementation.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/ext/implementation_private.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/cache.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/clock.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/db.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/dl.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/emcc/fs_api.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/err.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/jq.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/json.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/mem.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/memmem.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/overwrite.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/utf8.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/win/dl.h +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/src/vector_delim.c +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/src/zsv_scan_delim.c +0 -0
- /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/src/zsv_scan_fixed.c +0 -0
|
@@ -121,6 +121,18 @@ struct zsv_scanner {
|
|
|
121
121
|
unsigned char have_cell : 1;
|
|
122
122
|
unsigned char started : 1;
|
|
123
123
|
|
|
124
|
+
unsigned char skip_cells : 1; // fast engine: skip cell storage, just count rows
|
|
125
|
+
unsigned char nonstandard : 1; // fast engine: set when input violates RFC 4180
|
|
126
|
+
// (e.g. quote mid-unquoted-cell). Cold-path falls back
|
|
127
|
+
// to COMPAT to match its byte-for-byte interpretation.
|
|
128
|
+
|
|
129
|
+
/* Column filter for the fast engine. When non-NULL, only columns
|
|
130
|
+
* with needed_cols[col_ix] != 0 get full processing (quote normalization,
|
|
131
|
+
* UTF-8 encoding, cell_handler). Other columns get a raw placeholder.
|
|
132
|
+
* Array length must be >= max_columns. */
|
|
133
|
+
unsigned char *needed_cols;
|
|
134
|
+
unsigned int needed_cols_count; // length of needed_cols array
|
|
135
|
+
|
|
124
136
|
size_t quote_close_position;
|
|
125
137
|
struct zsv_opts opts;
|
|
126
138
|
|
|
@@ -149,6 +161,8 @@ struct zsv_scanner {
|
|
|
149
161
|
#define ZSV_MODE_DELIM 0
|
|
150
162
|
#define ZSV_MODE_FIXED 1
|
|
151
163
|
#define ZSV_MODE_DELIM_PULL 2
|
|
164
|
+
#define ZSV_MODE_DELIM_FAST 3
|
|
165
|
+
#define ZSV_MODE_COMPAT 255
|
|
152
166
|
unsigned char mode;
|
|
153
167
|
struct {
|
|
154
168
|
unsigned *offsets; // 0-based position of each cell end. offset[0] = end of first cell
|
|
@@ -215,47 +229,50 @@ static int collate_header_append(struct zsv_scanner *scanner, struct collate_hea
|
|
|
215
229
|
this_row_size += c.len + 1; // +1: terminating null or delim
|
|
216
230
|
}
|
|
217
231
|
size_t new_row_size = ch->buff.used + this_row_size;
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
// now: splice the new row into the old row, starting with the last cell
|
|
225
|
-
// e.g. prior row = A1.B1.C1.
|
|
226
|
-
// this row = A2.B2.C2.
|
|
227
|
-
// new_row = A1.B1.C1..........
|
|
228
|
-
// starting with last cell in this row, move the old data, then splice new:
|
|
229
|
-
// new_row = A1.B1.C1.......C2.
|
|
230
|
-
// new_row = A1.B1.C1....C1 C2.
|
|
231
|
-
// new_row = A1.B1.C1.B2.C1 C2.
|
|
232
|
-
// new_row = A1.B1.B1 B2.C1 C2.
|
|
233
|
-
// new_row = A1.A2.B1 B2.C1 C2.
|
|
234
|
-
// new_row = A1 A2.B1 B2.C1 C2.
|
|
235
|
-
|
|
236
|
-
size_t new_row_end = ch->buff.used + this_row_size;
|
|
237
|
-
size_t old_row_end = ch->buff.used;
|
|
238
|
-
ch->buff.used += this_row_size;
|
|
239
|
-
ch->buff.buff = new_row;
|
|
240
|
-
for (size_t i = column_count; i > 0; i--) {
|
|
241
|
-
struct zsv_cell c = zsv_get_cell_1(scanner, i - 1);
|
|
242
|
-
// copy new row's cell value to end
|
|
243
|
-
if (c.len) {
|
|
244
|
-
memcpy(new_row + new_row_end - c.len - 1, c.str, c.len);
|
|
245
|
-
new_row[new_row_end - 1] = ' ';
|
|
246
|
-
new_row_end = new_row_end - c.len - 1;
|
|
232
|
+
if (new_row_size > 0) {
|
|
233
|
+
unsigned char *new_row = realloc(ch->buff.buff, new_row_size);
|
|
234
|
+
if (!new_row) {
|
|
235
|
+
scanner->errprintf(scanner->errf, "Out of memory!\n");
|
|
236
|
+
return -1;
|
|
247
237
|
}
|
|
248
238
|
|
|
249
|
-
//
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
239
|
+
// now: splice the new row into the old row, starting with the last cell
|
|
240
|
+
// e.g. prior row = A1.B1.C1.
|
|
241
|
+
// this row = A2.B2.C2.
|
|
242
|
+
// new_row = A1.B1.C1..........
|
|
243
|
+
// starting with last cell in this row, move the old data, then splice new:
|
|
244
|
+
// new_row = A1.B1.C1.......C2.
|
|
245
|
+
// new_row = A1.B1.C1....C1 C2.
|
|
246
|
+
// new_row = A1.B1.C1.B2.C1 C2.
|
|
247
|
+
// new_row = A1.B1.B1 B2.C1 C2.
|
|
248
|
+
// new_row = A1.A2.B1 B2.C1 C2.
|
|
249
|
+
// new_row = A1 A2.B1 B2.C1 C2.
|
|
250
|
+
|
|
251
|
+
size_t new_row_end = ch->buff.used + this_row_size;
|
|
252
|
+
size_t old_row_end = ch->buff.used;
|
|
253
|
+
ch->buff.used += this_row_size;
|
|
254
|
+
ch->buff.buff = new_row;
|
|
255
|
+
|
|
256
|
+
for (size_t i = column_count; i > 0; i--) {
|
|
257
|
+
struct zsv_cell c = zsv_get_cell_1(scanner, i - 1);
|
|
258
|
+
// copy new row's cell value to end
|
|
259
|
+
if (c.len) {
|
|
260
|
+
memcpy(new_row + new_row_end - c.len - 1, c.str, c.len);
|
|
261
|
+
new_row[new_row_end - 1] = ' ';
|
|
262
|
+
new_row_end = new_row_end - c.len - 1;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// move prior cell value
|
|
266
|
+
size_t old_cell_len = ch->lengths[i - 1]; // old_cell_len includes delim
|
|
267
|
+
if (old_cell_len) {
|
|
268
|
+
// need memmove, not memcpy
|
|
269
|
+
memmove(new_row + new_row_end - old_cell_len, new_row + old_row_end - old_cell_len, old_cell_len);
|
|
270
|
+
old_row_end -= old_cell_len;
|
|
271
|
+
new_row_end -= old_cell_len;
|
|
272
|
+
}
|
|
273
|
+
if (c.len)
|
|
274
|
+
ch->lengths[i - 1] += c.len + 1;
|
|
256
275
|
}
|
|
257
|
-
if (c.len)
|
|
258
|
-
ch->lengths[i - 1] += c.len + 1;
|
|
259
276
|
}
|
|
260
277
|
if (column_count > ch->column_count)
|
|
261
278
|
ch->column_count = column_count;
|
|
@@ -266,6 +283,33 @@ __attribute__((always_inline)) static inline void zsv_clear_cell(struct zsv_scan
|
|
|
266
283
|
scanner->quoted = 0;
|
|
267
284
|
}
|
|
268
285
|
|
|
286
|
+
static int zsv_count_malformed(void *ctx, const unsigned char *s, size_t n, size_t offset) {
|
|
287
|
+
(void)s;
|
|
288
|
+
(void)n;
|
|
289
|
+
(void)offset;
|
|
290
|
+
++*(size_t *)ctx;
|
|
291
|
+
return 0;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/* Apply the malformed-UTF8 policy to one cell and fire the per-cell handler.
|
|
295
|
+
* Callers gate on (malformed_utf8_replace || malformed_utf8_handler).
|
|
296
|
+
* malformed_utf8_replace holds negative sentinels in a plain char, which is
|
|
297
|
+
* unsigned on some targets (e.g. gcc/ARM Linux): compare via signed char.
|
|
298
|
+
* The handler is not fired for overflow cells (scanner->row.used is the index
|
|
299
|
+
* this cell is about to occupy), though replacement still applies to them. */
|
|
300
|
+
static inline size_t zsv_cell_encode_utf8(struct zsv_scanner *scanner, unsigned char *s, size_t n) {
|
|
301
|
+
signed char replace = (signed char)scanner->opts.malformed_utf8_replace;
|
|
302
|
+
char count_it = scanner->opts.malformed_utf8_handler != NULL && scanner->row.used < scanner->row.allocated;
|
|
303
|
+
size_t bad = 0;
|
|
304
|
+
if (replace) // a replacement char, or REMOVE (DO_NOT_REPLACE was normalized to 0 at init)
|
|
305
|
+
n = zsv_strencode(s, n, replace < 0 ? 0 : (unsigned char)replace, count_it ? zsv_count_malformed : NULL, &bad);
|
|
306
|
+
else if (count_it) // leave the bytes untouched, but still count
|
|
307
|
+
bad = zsv_strencode_validate(s, n, NULL, NULL);
|
|
308
|
+
if (bad && count_it)
|
|
309
|
+
scanner->opts.malformed_utf8_handler(scanner->opts.malformed_utf8_handler_ctx, scanner->row.used, bad);
|
|
310
|
+
return n;
|
|
311
|
+
}
|
|
312
|
+
|
|
269
313
|
// always_inline has a noticeable impact. do not remove without benchmarking!
|
|
270
314
|
__attribute__((always_inline)) static inline void cell_dl(struct zsv_scanner *scanner, unsigned char *s, size_t n) {
|
|
271
315
|
// handle quoting
|
|
@@ -273,8 +317,10 @@ __attribute__((always_inline)) static inline void cell_dl(struct zsv_scanner *sc
|
|
|
273
317
|
if (UNLIKELY(scanner->quoted > 0)) {
|
|
274
318
|
if (LIKELY(scanner->quote_close_position + 1 == n)) {
|
|
275
319
|
if (LIKELY((scanner->quoted & ZSV_PARSER_QUOTE_EMBEDDED) == 0)) {
|
|
276
|
-
//
|
|
277
|
-
// just remove surrounding quotes from content
|
|
320
|
+
// easy and usual case: no embedded double-quotes
|
|
321
|
+
// just remove surrounding quotes from content (n >= 2 enforced
|
|
322
|
+
// by EOF fix-up in zsv_finish, and by the parser state machine
|
|
323
|
+
// in scan-loop call sites)
|
|
278
324
|
s++;
|
|
279
325
|
n -= 2;
|
|
280
326
|
} else { // embedded dbl-quotes to remove
|
|
@@ -317,12 +363,8 @@ __attribute__((always_inline)) static inline void cell_dl(struct zsv_scanner *sc
|
|
|
317
363
|
}
|
|
318
364
|
// end quote handling
|
|
319
365
|
|
|
320
|
-
if (scanner->opts.malformed_utf8_replace)
|
|
321
|
-
|
|
322
|
-
n = zsv_strencode(s, n, 0, NULL, NULL);
|
|
323
|
-
else
|
|
324
|
-
n = zsv_strencode(s, n, scanner->opts.malformed_utf8_replace, NULL, NULL);
|
|
325
|
-
}
|
|
366
|
+
if (scanner->opts.malformed_utf8_replace || scanner->opts.malformed_utf8_handler)
|
|
367
|
+
n = zsv_cell_encode_utf8(scanner, s, n);
|
|
326
368
|
}
|
|
327
369
|
if (UNLIKELY(scanner->opts.cell_handler != NULL))
|
|
328
370
|
scanner->opts.cell_handler(scanner->opts.ctx, s, n);
|
|
@@ -410,8 +452,8 @@ __attribute__((always_inline)) static inline enum zsv_status cell_and_row_dl(str
|
|
|
410
452
|
#include <arm_neon.h>
|
|
411
453
|
static inline zsv_mask_t movemask_pseudo(zsv_uc_vector v) {
|
|
412
454
|
// see https://stackoverflow.com/questions/11870910/
|
|
413
|
-
static const uint8_t
|
|
414
|
-
|
|
455
|
+
static const uint8_t __attribute__((aligned(16)))
|
|
456
|
+
_powers[16] = {1, 2, 4, 8, 16, 32, 64, 128, 1, 2, 4, 8, 16, 32, 64, 128};
|
|
415
457
|
uint8x16_t mm_powers = vld1q_u8(_powers);
|
|
416
458
|
|
|
417
459
|
// compute the mask from the input
|
|
@@ -455,6 +497,7 @@ static inline zsv_mask_t movemask_pseudo(zsv_uc_vector v) {
|
|
|
455
497
|
#ifdef ZSV_SUPPORT_PULL_PARSER
|
|
456
498
|
#undef ZSV_SUPPORT_PULL_PARSER
|
|
457
499
|
#endif
|
|
500
|
+
|
|
458
501
|
#define ZSV_SCAN_DELIM zsv_scan_delim
|
|
459
502
|
#include "zsv_scan_delim.c"
|
|
460
503
|
#undef ZSV_SCAN_DELIM
|
|
@@ -465,6 +508,7 @@ static inline zsv_mask_t movemask_pseudo(zsv_uc_vector v) {
|
|
|
465
508
|
#include "zsv_scan_delim.c"
|
|
466
509
|
|
|
467
510
|
#include "zsv_scan_fixed.c"
|
|
511
|
+
#include "zsv_scan_delim_fast.c"
|
|
468
512
|
|
|
469
513
|
static enum zsv_status zsv_scan(struct zsv_scanner *scanner, unsigned char *buff, size_t bytes_read) {
|
|
470
514
|
switch (scanner->mode) {
|
|
@@ -473,6 +517,8 @@ static enum zsv_status zsv_scan(struct zsv_scanner *scanner, unsigned char *buff
|
|
|
473
517
|
case ZSV_MODE_DELIM_PULL:
|
|
474
518
|
// return zsv_status_row or zsv_status_ok (next call to parse_more)
|
|
475
519
|
return zsv_scan_delim_pull(scanner, buff, bytes_read);
|
|
520
|
+
case ZSV_MODE_DELIM_FAST:
|
|
521
|
+
return zsv_scan_delim_fast(scanner, buff, bytes_read);
|
|
476
522
|
default:
|
|
477
523
|
return zsv_scan_delim(scanner, buff, bytes_read);
|
|
478
524
|
}
|
|
@@ -601,6 +647,7 @@ static void set_callbacks(struct zsv_scanner *scanner) {
|
|
|
601
647
|
#endif
|
|
602
648
|
scanner->get_cell = zsv_get_cell_1;
|
|
603
649
|
scanner->data_row_count = 0;
|
|
650
|
+
scanner->skip_cells = 0;
|
|
604
651
|
scanner->opts.row_handler = scanner->opts_orig.row_handler;
|
|
605
652
|
scanner->opts.cell_handler = scanner->opts_orig.cell_handler;
|
|
606
653
|
scanner->opts.ctx = scanner->opts_orig.ctx;
|
|
@@ -650,7 +697,9 @@ static int zsv_scanner_init(struct zsv_scanner *scanner, struct zsv_opts *opts)
|
|
|
650
697
|
scanner->errprintf = opts->errprintf ? opts->errprintf : zsv_generic_fprintf;
|
|
651
698
|
scanner->errf = opts->errf ? opts->errf : stderr;
|
|
652
699
|
scanner->errclose = opts->errclose;
|
|
653
|
-
|
|
700
|
+
// via signed char: the sentinel is negative and plain char is unsigned on
|
|
701
|
+
// some targets (e.g. gcc/ARM Linux), where a bare == -2 never matches
|
|
702
|
+
if ((signed char)opts->malformed_utf8_replace == ZSV_MALFORMED_UTF8_DO_NOT_REPLACE)
|
|
654
703
|
opts->malformed_utf8_replace = 0;
|
|
655
704
|
if (opts->buffsize < opts->max_row_size * 2)
|
|
656
705
|
need_buff_size = opts->max_row_size * 2;
|
|
@@ -670,7 +719,7 @@ static int zsv_scanner_init(struct zsv_scanner *scanner, struct zsv_opts *opts)
|
|
|
670
719
|
if (need_buff_size == ZSV_MIN_SCANNER_BUFFSIZE)
|
|
671
720
|
scanner->errprintf(scanner->errf, "Increasing --buff-size to minimum %zu\n", need_buff_size);
|
|
672
721
|
else
|
|
673
|
-
scanner->errprintf(scanner->errf, "Increasing --buff-size to %zu to
|
|
722
|
+
scanner->errprintf(scanner->errf, "Increasing --buff-size to %zu to accommodate max-row-size of %u\n",
|
|
674
723
|
need_buff_size, opts->max_row_size);
|
|
675
724
|
}
|
|
676
725
|
opts->buffsize = need_buff_size;
|
|
@@ -680,6 +729,15 @@ static int zsv_scanner_init(struct zsv_scanner *scanner, struct zsv_opts *opts)
|
|
|
680
729
|
else if (opts->buffsize < ZSV_MIN_SCANNER_BUFFSIZE)
|
|
681
730
|
opts->buffsize = ZSV_MIN_SCANNER_BUFFSIZE;
|
|
682
731
|
|
|
732
|
+
if (opts->scan_engine == ZSV_MODE_COMPAT)
|
|
733
|
+
scanner->mode = ZSV_MODE_DELIM; /* force compat/standard engine */
|
|
734
|
+
else if (opts->scan_engine)
|
|
735
|
+
scanner->mode = opts->scan_engine;
|
|
736
|
+
#if defined(ZSV_FAST_PARSER_AVAILABLE) && defined(ZSV_DEFAULT_PARSER_FAST)
|
|
737
|
+
else
|
|
738
|
+
scanner->mode = ZSV_MODE_DELIM_FAST;
|
|
739
|
+
#endif
|
|
740
|
+
|
|
683
741
|
scanner->in = opts->stream;
|
|
684
742
|
if (!opts->read) {
|
|
685
743
|
scanner->read = (zsv_generic_read)fread;
|