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,106 +0,0 @@
1
- #include <stdio.h>
2
- #include <string.h>
3
-
4
- #define ZSV_COMMAND_NO_OPTIONS
5
- #define ZSV_COMMAND jq
6
- #include "zsv_command.h"
7
-
8
- #include <zsv/utils/jq.h>
9
-
10
- /**
11
- * This implementation is not intended to replicate the full functionality of the `jq`
12
- * utility available at https://github.com/stedolan/jq
13
- *
14
- * This `jq` implementation is included as a convenience so as not to require a
15
- * separate `jq` installation for basic JSON parsing and manipulation
16
- */
17
- int ZSV_MAIN_NO_OPTIONS_FUNC(ZSV_COMMAND)(int argc, const char *argv[]) {
18
- if (argc < 2 || !strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {
19
- printf("Usage: " APPNAME " <filter> filename [-o,--output filename] [--csv]\n");
20
- return 0;
21
- }
22
-
23
- char to_csv = 0;
24
- #ifdef NO_STDIN
25
- const int min_args = 3;
26
- #else
27
- const int min_args = 2;
28
- #endif
29
- if (argc < min_args) {
30
- fprintf(stderr, "Please provide a filter and an input file\n");
31
- return 1;
32
- }
33
-
34
- #ifdef NO_STDIN
35
- FILE *f_in = NULL;
36
- #else
37
- FILE *f_in = stdin;
38
- #endif
39
-
40
- FILE *f_out = stdout;
41
-
42
- int err = 0;
43
- const unsigned char *jqfilter = (const unsigned char *)argv[1];
44
- struct jv_to_json_ctx ctx = {0};
45
-
46
- for (int i = 2; !err && i < argc; i++) { // jq filter filename
47
- const char *arg = argv[i];
48
- if (i == 2 && *arg != '-') {
49
- if (!(f_in = fopen(arg, "rb"))) {
50
- err = 1;
51
- fprintf(stderr, "Unable to open for read: %s\n", arg);
52
- }
53
- } else if (!strcmp(arg, "--csv")) {
54
- to_csv = 1;
55
- } else if (!strcmp(arg, "--raw-output")) {
56
- ctx.raw_output = 1;
57
- } else if (!strcmp(arg, "-o") || !strcmp(arg, "--output")) {
58
- i++;
59
- if (!(i < argc)) {
60
- err = 1;
61
- fprintf(stderr, "Option %s requires a filename\n", arg);
62
- } else if (!(f_out = fopen(argv[i], "wb"))) {
63
- err = 1;
64
- fprintf(stderr, "Unable to open for write: %s\n", argv[i]);
65
- }
66
- } else {
67
- fprintf(stderr, "Unrecognized option: %s\n", arg);
68
- err = 1;
69
- }
70
- }
71
-
72
- if (!f_in) {
73
- fprintf(stderr, "Please specify an input file\n");
74
- err = 1;
75
- }
76
-
77
- if (!err) {
78
- void (*jqfunc)(jv, void *) = to_csv ? jv_to_csv : jv_to_json_func;
79
- ctx.write1 = zsv_jq_fwrite1;
80
- ctx.ctx = f_out;
81
- ctx.flags = JV_PRINT_PRETTY | JV_PRINT_SPACE1;
82
-
83
- void *jqctx = to_csv ? (void *)f_out : (void *)&ctx;
84
- enum zsv_jq_status jqstat;
85
- zsv_jq_handle zjq = zsv_jq_new(jqfilter, jqfunc, jqctx, &jqstat);
86
- if (jqstat != zsv_jq_status_ok) {
87
- fprintf(stderr, "Invalid filter: %s\n", jqfilter);
88
- err = 1;
89
- } else {
90
- if ((jqstat = zsv_jq_parse_file(zjq, f_in)))
91
- err = jqstat;
92
- if ((jqstat = zsv_jq_finish(zjq)) && !err)
93
- err = jqstat;
94
- if (!err && !to_csv)
95
- fprintf(f_out, "\n");
96
- }
97
- zsv_jq_delete(zjq);
98
- }
99
-
100
- if (f_out && f_out != stdout)
101
- fclose(f_out);
102
- if (f_in && f_in != stdin)
103
- fclose(f_in);
104
-
105
- return err;
106
- }
@@ -1,6 +0,0 @@
1
- #ifndef LQJQ_H
2
- #define LQJQ_H
3
-
4
- int lq_jq(int argc, const char *argv[]);
5
-
6
- #endif
@@ -1,113 +0,0 @@
1
- /* Copyright (C) 2022 Guarnerix Inc dba Liquidaty - All Rights Reserved
2
- * Unauthorized copying of this file, via any medium is strictly prohibited
3
- * Proprietary and confidential
4
- * Written by Matt Wong <matt@guarnerix.com>
5
- */
6
-
7
- /*
8
- * Move a given file and its cache as follows:
9
- * 1. check that the destination file doesn't exist. if it does, exit with an error
10
- * 2. if a cache exists, check that the destination file cache dir doesn't exist. if it does, exit with an error
11
- * 3. move the file. if it fails, exit with an error
12
- * 4. move the cache, if it exists. if it fails, attempt to move the file back to its original location, and exit with
13
- * an error
14
- */
15
-
16
- #include <stdlib.h>
17
- #include <stdio.h>
18
- #include <string.h>
19
- #include <unistd.h> // unlink()
20
- #include <errno.h>
21
-
22
- #define ZSV_COMMAND_NO_OPTIONS
23
- #define ZSV_COMMAND mv
24
- #include "zsv_command.h"
25
-
26
- #include <zsv/utils/dirs.h>
27
- #include <zsv/utils/file.h>
28
- #include <zsv/utils/cache.h>
29
- #include <zsv/utils/os.h>
30
-
31
- const char *zsv_mv_usage_msg[] = {
32
- APPNAME ": move a file and its related cache",
33
- "",
34
- "Usage: " APPNAME " [options] <source> <destination>",
35
- "",
36
- "Options:",
37
- " -v,--verbose : verbose output",
38
- " -C,--cache : only move related cache (not the file)",
39
- NULL,
40
- };
41
-
42
- static int zsv_mv_usage(FILE *target) {
43
- for (size_t j = 0; zsv_mv_usage_msg[j]; j++)
44
- fprintf(target, "%s\n", zsv_mv_usage_msg[j]);
45
- return target == stdout ? 0 : 1;
46
- }
47
-
48
- int ZSV_MAIN_NO_OPTIONS_FUNC(ZSV_COMMAND)(int argc, const char *argv[]) {
49
- int err = 0;
50
- if (argc > 1 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")))
51
- err = zsv_mv_usage(stdout);
52
- else if (argc < 2)
53
- err = zsv_mv_usage(stderr);
54
- else {
55
- const char *source = NULL;
56
- const char *dest = NULL;
57
-
58
- char move_file = 1;
59
- char verbose = 0;
60
- for (int i = 1; !err && i < argc; i++) {
61
- const char *arg = argv[i];
62
- if (*arg == '-') {
63
- if (!strcmp(arg, "-v") || !strcmp(arg, "--verbose"))
64
- verbose = 1;
65
- else if (!strcmp(arg, "-C") || !strcmp(arg, "--cache"))
66
- move_file = 0;
67
- else
68
- err = zsv_printerr(1, "Unrecognized option: %s", arg);
69
- } else if (!source)
70
- source = arg;
71
- else if (!dest)
72
- dest = arg;
73
- else
74
- err = zsv_printerr(1, "Unrecognized option: %s", arg);
75
- }
76
-
77
- if (!err) {
78
- unsigned char *source_cache_dir = zsv_cache_path((const unsigned char *)source, NULL, 0);
79
- unsigned char *dest_cache_dir = zsv_cache_path((const unsigned char *)dest, NULL, 0);
80
- if (!source || !dest) {
81
- err = zsv_mv_usage(stderr);
82
- } else if (move_file && !zsv_file_exists(source)) {
83
- err = errno = ENOENT;
84
- perror(source);
85
- } else if (move_file && zsv_file_exists(dest)) {
86
- err = errno = EEXIST;
87
- perror(dest);
88
- } else if (zsv_dir_exists((const char *)source_cache_dir) && zsv_dir_exists((const char *)dest_cache_dir)) {
89
- err = errno = EEXIST;
90
- perror((char *)dest_cache_dir);
91
- fprintf(stderr, "Use `mv --cache %s <destination>` to move or `rm --cache %s` to remove, then try again\n",
92
- dest, dest);
93
- } else if (move_file && (verbose ? fprintf(stderr, "Renaming files\n") : 1) && zsv_replace_file(source, dest)) {
94
- err = errno;
95
- fprintf(stderr, "%s -> %s: ", source, dest);
96
- zsv_perror(NULL);
97
- } else if (zsv_dir_exists((const char *)source_cache_dir) && (verbose ? fprintf(stderr, "Moving caches\n") : 1) &&
98
- rename( // rename(): not sure will work on Win with NFS dirs...
99
- (char *)source_cache_dir, (char *)dest_cache_dir)) {
100
- err = errno;
101
- fprintf(stderr, "%s -> %s: ", source_cache_dir, dest_cache_dir);
102
- perror(NULL);
103
- if (rename(dest, source)) { // try to revert the prior rename. see above re Win + NFS
104
- fprintf(stderr, "%s -> %s: ", dest, source);
105
- perror(NULL);
106
- }
107
- }
108
- free(source_cache_dir);
109
- free(dest_cache_dir);
110
- }
111
- }
112
- return err;
113
- }
@@ -1,90 +0,0 @@
1
- /*
2
- * Copyright (C) 2021 Liquidaty and zsv contributors. All rights reserved.
3
- *
4
- * This file is part of zsv/lib, distributed under the MIT license as defined at
5
- * https://opensource.org/licenses/MIT
6
- */
7
-
8
- #include <zsv.h>
9
- #include <zsv/utils/writer.h>
10
- #include <zsv/utils/signal.h>
11
- #include <zsv/utils/arg.h>
12
- #include <stdio.h>
13
- #include <string.h>
14
- #include <stdlib.h>
15
-
16
- struct data {
17
- int col_count;
18
- zsv_parser parser;
19
- };
20
-
21
- static void error(void *ctx, enum zsv_status status, const unsigned char *err_msg, size_t err_msg_len,
22
- unsigned char error_c, size_t cum_scanned_length) {
23
- (void)(ctx);
24
- (void)(status);
25
- (void)(err_msg);
26
- (void)(err_msg_len);
27
- (void)(error_c);
28
- (void)(cum_scanned_length);
29
- }
30
-
31
- static void cell(void *ctx, unsigned char *utf8_value, size_t len) {
32
- (void)(ctx);
33
- (void)(utf8_value);
34
- (void)(len);
35
- }
36
-
37
- static void overflow(void *ctx, unsigned char *utf8_value, size_t len) {
38
- (void)(ctx);
39
- (void)(utf8_value);
40
- (void)(len);
41
- }
42
-
43
- static void row(void *ctx) {
44
- (void)(ctx);
45
- }
46
-
47
- int main(int argc, const char *argv[]) {
48
- FILE *f = NULL;
49
- struct zsv_csv_writer_options writer_opts = zsv_writer_get_default_opts();
50
- struct data data = {0};
51
-
52
- for (int i = 1; i < argc; i++) {
53
- if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h")) {
54
- fprintf(stdout, "Usage: noop [filename]\n");
55
- fprintf(stdout, " Reads CSV input and does nothing. For performance testing\n\n");
56
- return 0;
57
- } else if (!f) {
58
- if (!(f = fopen(argv[i], "rb"))) {
59
- fprintf(stderr, "Unable to open %s for writing\n", argv[i]);
60
- return 1;
61
- }
62
- } else {
63
- fprintf(stderr, "Input file specified more than once (second was %s)\n", argv[i]);
64
- if (f)
65
- fclose(f);
66
- return 1;
67
- }
68
- }
69
-
70
- if (!f)
71
- f = stdin;
72
-
73
- struct zsv_opts opts = zsv_get_default_opts();
74
- opts.cell = cell;
75
- opts.row = row;
76
- opts.ctx = &data;
77
- opts.overflow = overflow;
78
- opts.error = error;
79
-
80
- opts.stream = f;
81
- if ((data.parser = zsv_new(&opts))) {
82
- zsv_handle_ctrl_c_signal();
83
- while (!zsv_signal_interrupted && zsv_parse_more(data.parser) == zsv_status_ok)
84
- ;
85
- zsv_finish(data.parser);
86
- zsv_delete(data.parser);
87
- }
88
- fclose(f);
89
- return 0;
90
- }
@@ -1,295 +0,0 @@
1
- /*
2
- * Copyright (C) 2021 Liquidaty and zsv contributors. All rights reserved.
3
- *
4
- * This file is part of zsv/lib, distributed under the MIT license as defined at
5
- * https://opensource.org/licenses/MIT
6
- */
7
-
8
- #include <stdio.h>
9
- #include <stdlib.h>
10
- #include <sqlite3.h>
11
- #include <errno.h>
12
- #include <limits.h>
13
-
14
- #define _GNU_SOURCE 1
15
- #include <string.h>
16
- #include <ctype.h>
17
-
18
- #include <zsv.h>
19
- #include <zsv/utils/writer.h>
20
- #include <zsv/utils/cache.h>
21
- #include <zsv/utils/overwrite.h>
22
- #include <zsv/utils/clock.h>
23
- #include <zsv/utils/overwrite_writer.h>
24
-
25
- #define ZSV_COMMAND overwrite
26
- #include "zsv_command.h"
27
-
28
- const char *zsv_overwrite_usage_msg[] = {
29
- APPNAME " - Manage overwrites associated with a CSV file",
30
- "",
31
- "Usage:",
32
- " " APPNAME " <file> <command> [arguments] [options]",
33
- "",
34
- "Commands (where <cell> can be <row>-<col> or an Excel-style address):",
35
- " list : Display all saved overwrite entries",
36
- " add <cell> <value> : Add an overwrite entry",
37
- " Example 1: overwrite the first column of the first",
38
- " non-header row",
39
- " overwrite mydata.csv add B2 \"new value\"",
40
- " - or -",
41
- " overwrite mydata.csv add 1-1 \"new value\"",
42
- " Example 2: change the header in the second column",
43
- " to \"ID #\"",
44
- " overwrite mydata.csv add B1 \"new value\"",
45
- " - or -",
46
- " overwrite mydata.csv add 0-1 \"ID #\"",
47
- " remove <cell> : Remove an overwrite entry",
48
- " clear : Remove any / all overwrites",
49
- " bulk-add <datafile> : Bulk add overwrite entries from a CSV or JSON file",
50
- " bulk-remove <datafile> : Bulk remove overwrite entries from a CSV or JSON file",
51
- "",
52
- "Options:",
53
- " -h,--help : Show this help message",
54
- " --old-value <value> : For `add` or `remove`, only proceed if the old value",
55
- " matches the given value",
56
- " --force. : For `add`, proceed even if an overwrite for the specified",
57
- " cell already exists",
58
- " For `remove`, exit without error even if no overwrite for",
59
- " the specified cell already exists",
60
- " --no-timestamp. : For `add`, don't save timestamp when adding an overwrite",
61
- " --all : For `remove`, remove all overwrites and delete sqlite file",
62
- " --A1 : For `list`, Display addresses in A1-notation",
63
- "",
64
- "Description:",
65
- " The `overwrite` utility allows you to manage a list of \"overwrites\" associated",
66
- " with a given CSV input file. Each overwrite entry is a tuple consisting of row,",
67
- " column, original value, and new value, along with optional timestamp and author",
68
- " metadata.",
69
- "",
70
- " Overwrite data for a given input file `/path/to/my-data.csv` is stored in the \"over‐",
71
- " writes\" table of `/path/to/.zsv/data/my-data.csv/overwrite.sqlite3`.",
72
- "",
73
- " For bulk operations, the data file must be a CSV with \"row\", \"col\" and \"value\" columns",
74
- " and may optionally include \"old value\", \"timestamp\" and/or \"author\"",
75
- NULL};
76
-
77
- static int zsv_overwrite_usage(void) {
78
- for (size_t i = 0; zsv_overwrite_usage_msg[i]; i++)
79
- fprintf(stdout, "%s\n", zsv_overwrite_usage_msg[i]);
80
- return 1;
81
- }
82
-
83
- static char *row_col_to_a1(size_t col, size_t row) {
84
- char buffer[64];
85
- int index = 63;
86
- buffer[index] = '\0';
87
-
88
- while (1) {
89
- if (index == 0)
90
- return NULL;
91
- col--;
92
- buffer[--index] = 'A' + (col % 26);
93
- col /= 26;
94
- if (col == 0)
95
- break;
96
- }
97
- // 20 extra bytes for row
98
- char *result = malloc(strlen(&buffer[index]) + 20 + 1);
99
- if (result)
100
- sprintf(result, "%s%zu", &buffer[index], row + 1);
101
- return result;
102
- }
103
-
104
- static int show_all_overwrites(struct zsv_overwrite *data, zsv_csv_writer writer) {
105
- zsv_writer_cell(writer, 0, (const unsigned char *)"row", 3, 0);
106
- zsv_writer_cell(writer, 0, (const unsigned char *)"column", 6, 0);
107
- zsv_writer_cell(writer, 0, (const unsigned char *)"value", 5, 0);
108
- zsv_writer_cell(writer, 0, (const unsigned char *)"timestamp", 9, 0);
109
- zsv_writer_cell(writer, 0, (const unsigned char *)"author", 6, 0);
110
- struct zsv_overwrite_data odata = {.have = 1};
111
- while ((data->ctx->next(data->ctx, &odata) == zsv_status_ok) && odata.have) {
112
- if (data->a1) {
113
- char *a1_ix = row_col_to_a1(odata.col_ix + 1, odata.row_ix);
114
- if (a1_ix)
115
- zsv_writer_cell(writer, 1, (unsigned char *)a1_ix, strlen(a1_ix), 0);
116
- free(a1_ix);
117
- } else {
118
- zsv_writer_cell_zu(writer, 1, odata.row_ix);
119
- zsv_writer_cell_zu(writer, 0, odata.col_ix);
120
- }
121
- zsv_writer_cell(writer, 0, odata.val.str, odata.val.len, 0);
122
- if (odata.timestamp)
123
- zsv_writer_cell_zu(writer, 0, odata.timestamp);
124
- else
125
- zsv_writer_cell(writer, 0, (unsigned char *)"", 0, 0);
126
- if (odata.author.len > 0 && odata.author.str)
127
- zsv_writer_cell(writer, 0, odata.author.str, odata.author.len, 0);
128
- else
129
- zsv_writer_cell(writer, 0, (unsigned char *)"", 0, 0);
130
- }
131
- return 0;
132
- }
133
-
134
- struct xl_address {
135
- size_t row, col;
136
- };
137
-
138
- static int parse_xl_address(const char *s, struct xl_address *address) {
139
- memset(address, 0, sizeof(*address));
140
- unsigned len = strlen(s);
141
- for (unsigned i = 0; i < len; i++) {
142
- char c = s[i];
143
- if (c >= '0' && c <= '9') {
144
- if (address->col == 0)
145
- return 1; // alpha should come before num
146
- if (address->row == 0 && c == '0')
147
- return 1; // first num should not be zero
148
- address->row = address->row * 10 + (c - '0');
149
- } else if (c >= 'A' && c <= 'Z') {
150
- if (address->row > 0)
151
- return 1; // alpha should come before num
152
- address->col = address->col * 26 + (c - 'A') + 1;
153
- } else if (c >= 'a' && c <= 'z') {
154
- if (address->row > 0)
155
- return 1; // alpha should come before num
156
- address->col = address->col * 26 + (c - 'a') + 1;
157
- } else
158
- break;
159
- }
160
- if (address->row > 0 && address->col > 0) {
161
- address->row--;
162
- address->col--;
163
- return 0;
164
- }
165
- return 1; // error
166
- }
167
-
168
- static int zsv_overwrite_parse_pos(struct zsv_overwrite_data *overwrite, const char *str) {
169
- // this means it's an excel-style cell, because it does not start with a number for the row
170
- if (!isdigit(*str)) {
171
- struct xl_address address;
172
- if (parse_xl_address(str, &address) != 0)
173
- return 1;
174
- overwrite->row_ix = address.row;
175
- overwrite->col_ix = address.col;
176
- return 0;
177
- }
178
- return sscanf(str, "%zu-%zu", &overwrite->row_ix, &overwrite->col_ix) != 2;
179
- }
180
-
181
- int ZSV_MAIN_FUNC(ZSV_COMMAND)(int argc, const char *argv[], struct zsv_opts *opts,
182
- struct zsv_prop_handler *custom_prop_handler) {
183
- int err = 0;
184
- if (argc < 3 || !strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {
185
- zsv_overwrite_usage();
186
- return err;
187
- }
188
-
189
- struct zsv_overwrite_opts ctx_opts = {0};
190
- (void)(opts);
191
- (void)(custom_prop_handler);
192
-
193
- struct zsv_overwrite_args args = {0};
194
- // By default, save timestamps
195
- struct zsv_overwrite_data overwrite = {0};
196
- overwrite.timestamp = (size_t)time(NULL);
197
-
198
- args.filepath = (char *)argv[1];
199
-
200
- for (int i = 2; !err && i < argc; i++) {
201
- const char *opt = argv[i];
202
- if (!strcmp(opt, "-f") || !strcmp(opt, "--force")) {
203
- args.force = 1;
204
- } else if (!strcmp(opt, "--old-value")) {
205
- overwrite.old_value.str = (unsigned char *)strdup(argv[++i]);
206
- overwrite.old_value.len = strlen((const char *)overwrite.old_value.str);
207
- } else if (!strcmp(opt, "--no-timestamp")) {
208
- overwrite.timestamp = 0;
209
- } else if (!strcmp(opt, "--A1")) {
210
- args.a1 = 1;
211
- } else if (!strcmp(opt, "list")) {
212
- args.mode = zsvsheet_mode_list;
213
- } else if (!strcmp(opt, "clear")) {
214
- args.mode = zsvsheet_mode_clear;
215
- } else if (!strcmp(opt, "add")) {
216
- if (argc - i > 2) {
217
- args.mode = zsvsheet_mode_add;
218
- err = zsv_overwrite_parse_pos(&overwrite, argv[++i]);
219
- overwrite.val.str = (unsigned char *)strdup(argv[++i]);
220
- overwrite.val.len = strlen((const char *)overwrite.val.str);
221
- if (err || !overwrite.val.str) {
222
- fprintf(stderr, "Expected row, column, and value\n");
223
- err = 1;
224
- }
225
- } else {
226
- fprintf(stderr, "Expected row, column, and value\n");
227
- err = 1;
228
- }
229
- } else if (!strcmp(opt, "remove")) {
230
- if (argc - i > 1) {
231
- args.mode = zsvsheet_mode_remove;
232
- if (!strcmp(argv[++i], "--all"))
233
- args.all = 1;
234
- else
235
- err = zsv_overwrite_parse_pos(&overwrite, argv[i]);
236
- if (err) {
237
- fprintf(stderr, "Expected row and column\n");
238
- }
239
- } else {
240
- fprintf(stderr, "Expected row and column\n");
241
- err = 1;
242
- }
243
- } else if (!strcmp(opt, "bulk-add")) {
244
- if (argc - i > 1) {
245
- args.mode = zsvsheet_mode_bulk;
246
- args.bulk_file = (unsigned char *)strdup(argv[++i]);
247
- args.next = zsv_overwrite_writer_add;
248
- } else {
249
- fprintf(stderr, "Expected overwrite filename\n");
250
- err = 1;
251
- }
252
- } else if (!strcmp(opt, "bulk-remove")) {
253
- if (argc - i > 1) {
254
- args.mode = zsvsheet_mode_bulk;
255
- args.bulk_file = (unsigned char *)strdup(argv[++i]);
256
- args.next = zsv_overwrite_writer_remove;
257
- } else {
258
- fprintf(stderr, "Expected overwrite filename\n");
259
- err = 1;
260
- }
261
- } else {
262
- err = 1;
263
- if (*opt == '-')
264
- fprintf(stderr, "Unrecognized option: %s\n", opt);
265
- else
266
- fprintf(stderr, "Unrecognized command or argument: %s\n", opt);
267
- }
268
- }
269
-
270
- args.overwrite = &overwrite;
271
-
272
- char *overwrites_fn =
273
- (char *)zsv_cache_filepath((const unsigned char *)args.filepath, zsv_cache_type_overwrite, 0, 0);
274
- ctx_opts.src = (char *)overwrites_fn;
275
- struct zsv_overwrite *data = zsv_overwrite_writer_new(&args, &ctx_opts);
276
- free(overwrites_fn);
277
-
278
- if (!err && data) {
279
- if (data->mode == zsvsheet_mode_list)
280
- err = show_all_overwrites(data, data->writer);
281
- else if (data->mode == zsvsheet_mode_clear)
282
- err = zsv_overwrite_writer_clear(data);
283
- else if (data->mode == zsvsheet_mode_add && data->ctx->sqlite3.db)
284
- err = zsv_overwrite_writer_add(data);
285
- else if (data->mode == zsvsheet_mode_remove && data->ctx->sqlite3.db)
286
- err = zsv_overwrite_writer_remove(data);
287
- else if (data->mode == zsvsheet_mode_bulk && data->ctx->sqlite3.db) {
288
- err = zsv_overwrite_writer_bulk(data);
289
- }
290
- }
291
-
292
- zsv_overwrite_writer_delete(data);
293
-
294
- return err;
295
- }