zsv 1.3.0 → 1.4.3

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 (232) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/README.md +41 -3
  4. data/ext/zsv/extconf.rb +66 -49
  5. data/ext/zsv/options.c +1 -2
  6. data/ext/zsv/parser.c +14 -0
  7. data/ext/zsv/zsv_ext.c +3 -0
  8. data/lib/zsv/version.rb +1 -1
  9. metadata +6 -226
  10. data/ext/zsv/vendor/zsv-1.3.0/app/2db.c +0 -756
  11. data/ext/zsv/vendor/zsv-1.3.0/app/2json.c +0 -381
  12. data/ext/zsv/vendor/zsv-1.3.0/app/2tsv.c +0 -228
  13. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/help.c +0 -123
  14. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/license.c +0 -39
  15. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/register.c +0 -104
  16. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/thirdparty.c +0 -41
  17. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/unregister.c +0 -1
  18. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/version.c +0 -14
  19. data/ext/zsv/vendor/zsv-1.3.0/app/check/simdutf_wrapper.h +0 -19
  20. data/ext/zsv/vendor/zsv-1.3.0/app/check/utf8.c +0 -116
  21. data/ext/zsv/vendor/zsv-1.3.0/app/check.c +0 -194
  22. data/ext/zsv/vendor/zsv-1.3.0/app/cli.c +0 -796
  23. data/ext/zsv/vendor/zsv-1.3.0/app/cli_const.h +0 -41
  24. data/ext/zsv/vendor/zsv-1.3.0/app/cli_export.h +0 -16
  25. data/ext/zsv/vendor/zsv-1.3.0/app/cli_ini.c +0 -280
  26. data/ext/zsv/vendor/zsv-1.3.0/app/cli_internal.h +0 -36
  27. data/ext/zsv/vendor/zsv-1.3.0/app/compare.c +0 -913
  28. data/ext/zsv/vendor/zsv-1.3.0/app/compare.h +0 -23
  29. data/ext/zsv/vendor/zsv-1.3.0/app/compare_added_column.c +0 -20
  30. data/ext/zsv/vendor/zsv-1.3.0/app/compare_internal.h +0 -140
  31. data/ext/zsv/vendor/zsv-1.3.0/app/compare_sort.c +0 -91
  32. data/ext/zsv/vendor/zsv-1.3.0/app/compare_unique_colname.c +0 -81
  33. data/ext/zsv/vendor/zsv-1.3.0/app/count-pull.c +0 -82
  34. data/ext/zsv/vendor/zsv-1.3.0/app/count.c +0 -404
  35. data/ext/zsv/vendor/zsv-1.3.0/app/desc.c +0 -569
  36. data/ext/zsv/vendor/zsv-1.3.0/app/echo.c +0 -365
  37. data/ext/zsv/vendor/zsv-1.3.0/app/ext_example/my_extension.c +0 -366
  38. data/ext/zsv/vendor/zsv-1.3.0/app/ext_example/mysheet_extension.c +0 -341
  39. data/ext/zsv/vendor/zsv-1.3.0/app/ext_template/YOUR_EXTENSION_zsvext.c +0 -263
  40. data/ext/zsv/vendor/zsv-1.3.0/app/external/inih/ini.c +0 -298
  41. data/ext/zsv/vendor/zsv-1.3.0/app/external/inih/ini.h +0 -157
  42. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/json_numeric.c +0 -177
  43. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/jsonwriter.c +0 -444
  44. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/jsonwriter.h +0 -145
  45. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/utils.c +0 -110
  46. data/ext/zsv/vendor/zsv-1.3.0/app/external/memfile-1.0/include/memfile.h +0 -15
  47. data/ext/zsv/vendor/zsv-1.3.0/app/external/memfile-1.0/src/memfile.c +0 -64
  48. data/ext/zsv/vendor/zsv-1.3.0/app/external/sglib/sglib.h +0 -1955
  49. data/ext/zsv/vendor/zsv-1.3.0/app/external/simdutf/simdutf.h +0 -6802
  50. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3.c +0 -230517
  51. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3.h +0 -12174
  52. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_and_csv_vtab.c +0 -2
  53. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab-mem.c +0 -142
  54. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab-mem.h +0 -49
  55. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab-zsv.c +0 -485
  56. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab.c +0 -1015
  57. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3ext.h +0 -663
  58. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/vtab_helper.c +0 -85
  59. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_common.h +0 -75
  60. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_gen.h +0 -167
  61. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_parse.h +0 -228
  62. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_tree.h +0 -186
  63. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_version.h +0 -23
  64. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_common.h +0 -76
  65. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_gen.h +0 -167
  66. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_parse.h +0 -238
  67. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_tree.h +0 -186
  68. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl.c +0 -184
  69. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_alloc.c +0 -52
  70. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_alloc.h +0 -34
  71. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_buf.c +0 -103
  72. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_buf.h +0 -57
  73. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_bytestack.h +0 -69
  74. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_encode.c +0 -220
  75. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_encode.h +0 -34
  76. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_gen.c +0 -362
  77. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_lex.c +0 -764
  78. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_lex.h +0 -117
  79. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_parser.c +0 -508
  80. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_parser.h +0 -78
  81. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_tree.c +0 -505
  82. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_version.c +0 -7
  83. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper/json_value.h +0 -59
  84. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper/yajl_helper.h +0 -208
  85. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper.c +0 -795
  86. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper_internal.h +0 -28
  87. data/ext/zsv/vendor/zsv-1.3.0/app/flatten.c +0 -851
  88. data/ext/zsv/vendor/zsv-1.3.0/app/jq.c +0 -106
  89. data/ext/zsv/vendor/zsv-1.3.0/app/jq.h +0 -6
  90. data/ext/zsv/vendor/zsv-1.3.0/app/mv.c +0 -113
  91. data/ext/zsv/vendor/zsv-1.3.0/app/noop.c +0 -90
  92. data/ext/zsv/vendor/zsv-1.3.0/app/overwrite.c +0 -295
  93. data/ext/zsv/vendor/zsv-1.3.0/app/paste.c +0 -175
  94. data/ext/zsv/vendor/zsv-1.3.0/app/pretty.c +0 -693
  95. data/ext/zsv/vendor/zsv-1.3.0/app/prop.c +0 -980
  96. data/ext/zsv/vendor/zsv-1.3.0/app/rm.c +0 -131
  97. data/ext/zsv/vendor/zsv-1.3.0/app/select/fixed.c +0 -130
  98. data/ext/zsv/vendor/zsv-1.3.0/app/select/internal.h +0 -118
  99. data/ext/zsv/vendor/zsv-1.3.0/app/select/parallel.c +0 -45
  100. data/ext/zsv/vendor/zsv-1.3.0/app/select/parallel.h +0 -41
  101. data/ext/zsv/vendor/zsv-1.3.0/app/select/processing.c +0 -107
  102. data/ext/zsv/vendor/zsv-1.3.0/app/select/rand.c +0 -20
  103. data/ext/zsv/vendor/zsv-1.3.0/app/select/regex.c +0 -61
  104. data/ext/zsv/vendor/zsv-1.3.0/app/select/search.c +0 -14
  105. data/ext/zsv/vendor/zsv-1.3.0/app/select/selection.c +0 -192
  106. data/ext/zsv/vendor/zsv-1.3.0/app/select/usage.c +0 -72
  107. data/ext/zsv/vendor/zsv-1.3.0/app/select-pull.c +0 -812
  108. data/ext/zsv/vendor/zsv-1.3.0/app/select.c +0 -753
  109. data/ext/zsv/vendor/zsv-1.3.0/app/serialize.c +0 -372
  110. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/curses.h +0 -15
  111. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/cursor.c +0 -119
  112. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/errors.c +0 -45
  113. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/file.c +0 -63
  114. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/file.h +0 -12
  115. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/filter.c +0 -166
  116. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/handlers.c +0 -214
  117. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/handlers_internal.h +0 -128
  118. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/help.c +0 -43
  119. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/index.c +0 -81
  120. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/index.h +0 -25
  121. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/key-bindings.c +0 -325
  122. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/key-bindings.h +0 -73
  123. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/lexer.c +0 -203
  124. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/newline_handler.c +0 -7
  125. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/pivot.c +0 -318
  126. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/procedure.c +0 -134
  127. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/procedure.h +0 -119
  128. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/read-data.c +0 -322
  129. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/screen_buffer.c +0 -203
  130. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/screen_buffer.h +0 -36
  131. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/sheet-sql.c +0 -167
  132. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/sheet_internal.h +0 -36
  133. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/sqlfilter.c +0 -153
  134. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/terminfo.c +0 -32
  135. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/transformation.c +0 -312
  136. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/transformation.h +0 -29
  137. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/ui_buffer.c +0 -266
  138. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/usage.c +0 -9
  139. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/utf8-width.c +0 -60
  140. data/ext/zsv/vendor/zsv-1.3.0/app/sheet.c +0 -1007
  141. data/ext/zsv/vendor/zsv-1.3.0/app/sql.c +0 -453
  142. data/ext/zsv/vendor/zsv-1.3.0/app/sql_internal.c +0 -101
  143. data/ext/zsv/vendor/zsv-1.3.0/app/sql_internal.h +0 -49
  144. data/ext/zsv/vendor/zsv-1.3.0/app/stack.c +0 -393
  145. data/ext/zsv/vendor/zsv-1.3.0/app/utils/arg.c +0 -322
  146. data/ext/zsv/vendor/zsv-1.3.0/app/utils/cache.c +0 -228
  147. data/ext/zsv/vendor/zsv-1.3.0/app/utils/cat.c +0 -91
  148. data/ext/zsv/vendor/zsv-1.3.0/app/utils/chunk.c +0 -240
  149. data/ext/zsv/vendor/zsv-1.3.0/app/utils/chunk.h +0 -63
  150. data/ext/zsv/vendor/zsv-1.3.0/app/utils/clock.c +0 -57
  151. data/ext/zsv/vendor/zsv-1.3.0/app/utils/db.c +0 -148
  152. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs-no-jq.c +0 -2
  153. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs.c +0 -427
  154. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs_from_json.c +0 -253
  155. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs_to_json.c +0 -121
  156. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dl.c +0 -20
  157. data/ext/zsv/vendor/zsv-1.3.0/app/utils/emcc/fs_api.c +0 -159
  158. data/ext/zsv/vendor/zsv-1.3.0/app/utils/err.c +0 -24
  159. data/ext/zsv/vendor/zsv-1.3.0/app/utils/file-mem.c +0 -180
  160. data/ext/zsv/vendor/zsv-1.3.0/app/utils/file.c +0 -256
  161. data/ext/zsv/vendor/zsv-1.3.0/app/utils/index.c +0 -197
  162. data/ext/zsv/vendor/zsv-1.3.0/app/utils/index.h +0 -49
  163. data/ext/zsv/vendor/zsv-1.3.0/app/utils/jq.c +0 -400
  164. data/ext/zsv/vendor/zsv-1.3.0/app/utils/json.c +0 -120
  165. data/ext/zsv/vendor/zsv-1.3.0/app/utils/mem.c +0 -18
  166. data/ext/zsv/vendor/zsv-1.3.0/app/utils/memmem.c +0 -132
  167. data/ext/zsv/vendor/zsv-1.3.0/app/utils/os.c +0 -178
  168. data/ext/zsv/vendor/zsv-1.3.0/app/utils/overwrite.c +0 -258
  169. data/ext/zsv/vendor/zsv-1.3.0/app/utils/overwrite_writer.c +0 -246
  170. data/ext/zsv/vendor/zsv-1.3.0/app/utils/pcre2-8/pcre2-8-test.c +0 -123
  171. data/ext/zsv/vendor/zsv-1.3.0/app/utils/pcre2-8/pcre2-8.c +0 -153
  172. data/ext/zsv/vendor/zsv-1.3.0/app/utils/pcre2-8/pcre2-8.h +0 -54
  173. data/ext/zsv/vendor/zsv-1.3.0/app/utils/prop.c +0 -267
  174. data/ext/zsv/vendor/zsv-1.3.0/app/utils/signal.c +0 -53
  175. data/ext/zsv/vendor/zsv-1.3.0/app/utils/string.c +0 -357
  176. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/dir_exists_longpath.c +0 -83
  177. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/dl.c +0 -33
  178. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/fopen_longpath.c +0 -184
  179. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/foreach_dirent_longpath.c +0 -292
  180. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/io.c +0 -259
  181. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/io.h +0 -13
  182. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/mkdir_longpath.c +0 -255
  183. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/remove_longpath.c +0 -96
  184. data/ext/zsv/vendor/zsv-1.3.0/app/utils/writer.c +0 -361
  185. data/ext/zsv/vendor/zsv-1.3.0/app/zsv_command.h +0 -40
  186. data/ext/zsv/vendor/zsv-1.3.0/app/zsv_command_standalone.c +0 -16
  187. data/ext/zsv/vendor/zsv-1.3.0/app/zsv_main.h +0 -44
  188. data/ext/zsv/vendor/zsv-1.3.0/examples/js/zsv_parser_api_dummy.c +0 -3
  189. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/parse_by_chunk.c +0 -100
  190. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/print_my_column.c +0 -143
  191. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/pull.c +0 -89
  192. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/simple.c +0 -123
  193. data/ext/zsv/vendor/zsv-1.3.0/fuzz/fuzz.c +0 -16
  194. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/api.h +0 -336
  195. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/common.h +0 -361
  196. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/ext/implementation.h +0 -62
  197. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/ext/implementation_private.h +0 -113
  198. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/ext/sheet.h +0 -73
  199. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/ext.h +0 -329
  200. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/arg.h +0 -90
  201. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/cache.h +0 -49
  202. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/clock.h +0 -36
  203. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/compiler.h +0 -58
  204. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/db.h +0 -19
  205. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/dirs.h +0 -147
  206. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/dl.h +0 -22
  207. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/emcc/fs_api.h +0 -28
  208. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/err.h +0 -22
  209. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/file-mem.h +0 -17
  210. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/file.h +0 -99
  211. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/jq.h +0 -65
  212. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/json.h +0 -19
  213. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/mem.h +0 -19
  214. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/memmem.h +0 -13
  215. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/os.h +0 -54
  216. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/overwrite.h +0 -71
  217. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/overwrite_writer.h +0 -53
  218. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/prop.h +0 -107
  219. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/signal.h +0 -18
  220. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/sql.h +0 -11
  221. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/string.h +0 -148
  222. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/utf8.h +0 -41
  223. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/win/dl.h +0 -25
  224. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/writer.h +0 -101
  225. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/zsv_export.h +0 -33
  226. data/ext/zsv/vendor/zsv-1.3.0/include/zsv.h +0 -20
  227. data/ext/zsv/vendor/zsv-1.3.0/src/vector_delim.c +0 -60
  228. data/ext/zsv/vendor/zsv-1.3.0/src/zsv.c +0 -484
  229. data/ext/zsv/vendor/zsv-1.3.0/src/zsv_internal.c +0 -731
  230. data/ext/zsv/vendor/zsv-1.3.0/src/zsv_scan_delim.c +0 -285
  231. data/ext/zsv/vendor/zsv-1.3.0/src/zsv_scan_fixed.c +0 -88
  232. data/ext/zsv/vendor/zsv-1.3.0/src/zsv_strencode.c +0 -51
@@ -1,192 +0,0 @@
1
- static enum zsv_select_column_index_selection_type zsv_select_column_index_selection(const unsigned char *arg,
2
- unsigned *lo, unsigned *hi);
3
-
4
- static inline void zsv_select_add_exclusion(struct zsv_select_data *data, const char *name) {
5
- if (data->exclusion_count < MAX_EXCLUSIONS)
6
- data->exclusions[data->exclusion_count++] = (const unsigned char *)name;
7
- }
8
-
9
- static inline unsigned char *zsv_select_get_header_name(struct zsv_select_data *data, unsigned in_ix) {
10
- if (in_ix < data->header_name_count)
11
- return data->header_names[in_ix];
12
- return NULL;
13
- }
14
-
15
- static inline char zsv_select_excluded_current_header_name(struct zsv_select_data *data, unsigned in_ix) {
16
- if (data->exclusion_count) {
17
- if (data->use_header_indexes) {
18
- for (unsigned int ix = 0; ix < data->exclusion_count; ix++) {
19
- unsigned i, j;
20
- switch (zsv_select_column_index_selection(data->exclusions[ix], &i, &j)) {
21
- case zsv_select_column_index_selection_type_none:
22
- // not expected!
23
- break;
24
- case zsv_select_column_index_selection_type_single:
25
- if (in_ix + 1 == i)
26
- return 1;
27
- break;
28
- case zsv_select_column_index_selection_type_range:
29
- if (i <= in_ix + 1 && in_ix + 1 <= j)
30
- return 1;
31
- break;
32
- case zsv_select_column_index_selection_type_lower_bounded:
33
- if (i <= in_ix + 1)
34
- return 1;
35
- break;
36
- }
37
- }
38
- } else {
39
- unsigned char *header_name = zsv_select_get_header_name(data, in_ix);
40
- if (header_name) {
41
- for (unsigned int i = 0; i < data->exclusion_count; i++)
42
- if (!zsv_stricmp(header_name, data->exclusions[i]))
43
- return 1;
44
- }
45
- }
46
- }
47
- return 0;
48
- }
49
-
50
- // zsv_select_find_header(): return 1-based index, or 0 if not found
51
- static int zsv_select_find_header(struct zsv_select_data *data, const unsigned char *header_name) {
52
- if (header_name) {
53
- for (unsigned int i = 0; i < data->output_cols_count; i++) {
54
- unsigned char *prior_header_name = zsv_select_get_header_name(data, data->out2in[i].ix);
55
- if (prior_header_name && !zsv_stricmp(header_name, prior_header_name))
56
- return i + 1;
57
- }
58
- }
59
- return 0;
60
- }
61
-
62
- static int zsv_select_add_output_col(struct zsv_select_data *data, unsigned in_ix) {
63
- int err = 0;
64
- if (data->output_cols_count < data->opts->max_columns) {
65
- int found = zsv_select_find_header(data, zsv_select_get_header_name(data, in_ix));
66
- if (data->distinct && found) {
67
- if (data->distinct == ZSV_SELECT_DISTINCT_MERGE) {
68
- // add this index
69
- struct zsv_select_uint_list *ix = calloc(1, sizeof(*ix));
70
- if (!ix)
71
- err = zsv_printerr(1, "Out of memory!\n");
72
- else {
73
- ix->value = in_ix;
74
- if (!data->out2in[found - 1].merge.indexes)
75
- data->out2in[found - 1].merge.indexes = ix;
76
- else
77
- *data->out2in[found - 1].merge.last_index = ix;
78
- data->out2in[found - 1].merge.last_index = &ix->next;
79
- }
80
- }
81
- return err;
82
- }
83
- if (zsv_select_excluded_current_header_name(data, in_ix))
84
- return err;
85
- data->out2in[data->output_cols_count++].ix = in_ix;
86
- }
87
- return err;
88
- }
89
-
90
- // not very fast, but we don't need it to be
91
- static inline unsigned int str_array_ifind(const unsigned char *needle, unsigned char *haystack[], unsigned hay_count) {
92
- for (unsigned int i = 0; i < hay_count; i++) {
93
- if (!(needle && *needle) && !(haystack[i] && *haystack[i]))
94
- return i + 1;
95
- if (!(needle && *needle && haystack[i] && *haystack[i]))
96
- continue;
97
- if (!zsv_stricmp(needle, haystack[i]))
98
- return i + 1;
99
- }
100
- return 0;
101
- }
102
-
103
- static int zsv_select_set_output_columns(struct zsv_select_data *data) {
104
- int err = 0;
105
- unsigned int header_name_count = data->header_name_count;
106
- if (!data->col_argc) {
107
- for (unsigned int i = 0; !err && i < header_name_count; i++)
108
- err = zsv_select_add_output_col(data, i);
109
- } else if (data->use_header_indexes) {
110
- for (int arg_i = 0; !err && arg_i < data->col_argc; arg_i++) {
111
- const char *arg = data->col_argv[arg_i];
112
- unsigned i, j;
113
- switch (zsv_select_column_index_selection((const unsigned char *)arg, &i, &j)) {
114
- case zsv_select_column_index_selection_type_none:
115
- zsv_printerr(1, "Invalid column index: %s", arg);
116
- err = -1;
117
- break;
118
- case zsv_select_column_index_selection_type_single:
119
- err = zsv_select_add_output_col(data, i - 1);
120
- break;
121
- case zsv_select_column_index_selection_type_range:
122
- while (i <= j && i < data->opts->max_columns) {
123
- err = zsv_select_add_output_col(data, i - 1);
124
- i++;
125
- }
126
- break;
127
- case zsv_select_column_index_selection_type_lower_bounded:
128
- if (i) {
129
- for (unsigned int k = i - 1; !err && k < header_name_count; k++)
130
- err = zsv_select_add_output_col(data, k);
131
- }
132
- break;
133
- }
134
- }
135
- } else { // using header names
136
- for (int arg_i = 0; !err && arg_i < data->col_argc; arg_i++) {
137
- // find the location of the matching header name, if any
138
- unsigned int in_pos =
139
- str_array_ifind((const unsigned char *)data->col_argv[arg_i], data->header_names, header_name_count);
140
- if (!in_pos) {
141
- fprintf(stderr, "Column %s not found\n", data->col_argv[arg_i]);
142
- err = -1;
143
- } else
144
- err = zsv_select_add_output_col(data, in_pos - 1);
145
- }
146
- }
147
- return err;
148
- }
149
-
150
- static enum zsv_select_column_index_selection_type zsv_select_column_index_selection(const unsigned char *arg,
151
- unsigned *lo, unsigned *hi) {
152
- enum zsv_select_column_index_selection_type result = zsv_select_column_index_selection_type_none;
153
-
154
- unsigned int i = 0;
155
- unsigned int j = 0;
156
- int n = 0;
157
- int k = sscanf((const char *)arg, "%u-%u%n", &i, &j, &n);
158
- if (k == 2) {
159
- if (n >= 0 && (size_t)n == strlen((const char *)arg) && i > 0 && j >= i)
160
- result = zsv_select_column_index_selection_type_range;
161
- } else {
162
- k = sscanf((const char *)arg, "%u%n", &i, &n);
163
- if (k == 1 && n >= 0 && (size_t)n == strlen((const char *)arg)) {
164
- if (i > 0)
165
- result = zsv_select_column_index_selection_type_single;
166
- } else {
167
- k = sscanf((const char *)arg, "%u-%n", &i, &n);
168
- if (k == 1 && n >= 0 && (size_t)n == strlen((const char *)arg)) {
169
- if (i > 0) {
170
- result = zsv_select_column_index_selection_type_lower_bounded;
171
- j = 0;
172
- }
173
- }
174
- }
175
- }
176
- if (lo)
177
- *lo = i;
178
- if (hi)
179
- *hi = j;
180
- return result;
181
- }
182
-
183
- // zsv_select_check_exclusions_are_indexes(): return err
184
- static int zsv_select_check_exclusions_are_indexes(struct zsv_select_data *data) {
185
- int err = 0;
186
- for (unsigned int e = 0; e < data->exclusion_count; e++) {
187
- const unsigned char *arg = data->exclusions[e];
188
- if (zsv_select_column_index_selection(arg, NULL, NULL) == zsv_select_column_index_selection_type_none)
189
- err = zsv_printerr(1, "Invalid column index: %s", arg);
190
- }
191
- return err;
192
- }
@@ -1,72 +0,0 @@
1
- const char *zsv_select_usage_msg[] = {
2
- APPNAME ": extracts and outputs specified columns",
3
- "",
4
- "Usage: " APPNAME " [filename] [options] [-- col_specifier [... col_specifier]]",
5
- " where col_specifier is a column name or, if the -n option is used,",
6
- " a column index (starting at 1) or index range in the form of n-m",
7
- " e.g. " APPNAME " -n file.csv -- 1 4-6 50 10",
8
- " " APPNAME " file.csv -- first_col fiftieth_column \"Tenth Column\"",
9
- "",
10
- "Note: Outputs the columns specified after '--' separator, or all columns if omitted.",
11
- "",
12
- "Options:",
13
- " -b,--with-bom : output with BOM",
14
- " --fixed <offset1,offset2,..> : parse as fixed-width text; use given CSV list of positive integers for",
15
- " cell and indexes",
16
- " --fixed-auto : parse as fixed-width text; derive widths from first row in input data (max 256k)",
17
- " assumes ASCII whitespace; multi-byte whitespace is not counted as whitespace",
18
- " --fixed-auto-max-lines : maximum number of lines to use in calculating fixed widths",
19
- #ifndef ZSV_CLI
20
- " -v,--verbose : verbose output",
21
- #endif
22
- " -H,--head <n> : (head) only process the first n rows of input data (including header)",
23
- " --skip-data <n> : skip the specified number of data rows",
24
- " --no-header : do not output header row",
25
- " --prepend-header <value> : prepend each column header with the given text <value>",
26
- " -s,--search <value> : only output rows with at least one cell containing <value>",
27
- #ifdef HAVE_PCRE2_8
28
- " --regex-search <pattern> : only output rows with at least one cell matching the given regex pattern",
29
- #endif
30
- // TO DO: " -s,--search /<pattern>/modifiers: search on regex pattern; modifiers include 'g' (global) and 'i'
31
- // (case-insensitive)",
32
- " --sample-every <num_of_rows> : output a sample consisting of the first row, then every nth row",
33
- " --sample-pct <percentage> : output a randomly-selected sample (32 bits of randomness) of n%% of input rows",
34
- " --distinct : skip subsequent occurrences of columns with the same name",
35
- " --merge : merge subsequent occurrences of columns with the same name",
36
- " outputting first non-null value",
37
- // --rename: like distinct, but instead of removing cols with dupe names, renames them, trying _<n> for n up to max
38
- // cols
39
- " -e <embedded_lineend_char> : char to replace embedded lineend. If left empty, embedded lineends are preserved.",
40
- " If the provided string begins with 0x, it will be interpreted as the hex",
41
- " representation of a string.",
42
- " -x <column> : exclude the indicated column. can be specified more than once",
43
- " -N,--line-number : prefix each row with the row number",
44
- " -n : provided column indexes are numbers corresponding to column positions",
45
- " (starting with 1), instead of names",
46
- #ifndef ZSV_CLI
47
- " -T : input is tab-delimited, instead of comma-delimited",
48
- " -O,--other-delim <delim> : input is delimited with the given char",
49
- " Note: This option does not support quoted values with embedded delimiters.",
50
- #endif
51
- " --unescape : escape any backslash-escaped input e.g. \\t, \\n, \\r such as output from `2tsv`",
52
- " -w,--whitespace-clean : normalize all whitespace to space or newline, single-char (non-consecutive)",
53
- " occurrences",
54
- " --whitespace-clean-no-newline: clean whitespace and remove embedded newlines",
55
- " -W,--no-trim : do not trim whitespace",
56
- #ifndef ZSV_CLI
57
- " -C <max_num_of_columns> : defaults to " ZSV_SELECT_MAX_COLS_DEFAULT_S,
58
- " -L,--max-row-size <n> : set the maximum memory used for a single row",
59
- " Default: " ZSV_ROW_MAX_SIZE_MIN_S " (min), " ZSV_ROW_MAX_SIZE_DEFAULT_S " (max)",
60
- #endif
61
- #ifndef ZSV_NO_PARALLEL
62
- " -j,--jobs <N> : parallelize using N threads",
63
- " --parallel : parallelize using a number of threads equal to the number of cores",
64
- #endif
65
- " -o <filename> : filename to save output to",
66
- NULL,
67
- };
68
-
69
- static void zsv_select_usage(void) {
70
- for (size_t i = 0; zsv_select_usage_msg[i]; i++)
71
- fprintf(stdout, "%s\n", zsv_select_usage_msg[i]);
72
- }