zsv 1.3.0

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 (240) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +36 -0
  3. data/LICENSE +21 -0
  4. data/README.md +311 -0
  5. data/ext/zsv/common.h +34 -0
  6. data/ext/zsv/extconf.rb +137 -0
  7. data/ext/zsv/options.c +126 -0
  8. data/ext/zsv/options.h +31 -0
  9. data/ext/zsv/options_internal.h +8 -0
  10. data/ext/zsv/parser.c +300 -0
  11. data/ext/zsv/parser.h +62 -0
  12. data/ext/zsv/row.c +122 -0
  13. data/ext/zsv/row.h +39 -0
  14. data/ext/zsv/vendor/zsv-1.3.0/app/2db.c +756 -0
  15. data/ext/zsv/vendor/zsv-1.3.0/app/2json.c +381 -0
  16. data/ext/zsv/vendor/zsv-1.3.0/app/2tsv.c +228 -0
  17. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/help.c +123 -0
  18. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/license.c +39 -0
  19. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/register.c +104 -0
  20. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/thirdparty.c +41 -0
  21. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/unregister.c +1 -0
  22. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/version.c +14 -0
  23. data/ext/zsv/vendor/zsv-1.3.0/app/check/simdutf_wrapper.h +19 -0
  24. data/ext/zsv/vendor/zsv-1.3.0/app/check/utf8.c +116 -0
  25. data/ext/zsv/vendor/zsv-1.3.0/app/check.c +194 -0
  26. data/ext/zsv/vendor/zsv-1.3.0/app/cli.c +796 -0
  27. data/ext/zsv/vendor/zsv-1.3.0/app/cli_const.h +41 -0
  28. data/ext/zsv/vendor/zsv-1.3.0/app/cli_export.h +16 -0
  29. data/ext/zsv/vendor/zsv-1.3.0/app/cli_ini.c +280 -0
  30. data/ext/zsv/vendor/zsv-1.3.0/app/cli_internal.h +36 -0
  31. data/ext/zsv/vendor/zsv-1.3.0/app/compare.c +913 -0
  32. data/ext/zsv/vendor/zsv-1.3.0/app/compare.h +23 -0
  33. data/ext/zsv/vendor/zsv-1.3.0/app/compare_added_column.c +20 -0
  34. data/ext/zsv/vendor/zsv-1.3.0/app/compare_internal.h +140 -0
  35. data/ext/zsv/vendor/zsv-1.3.0/app/compare_sort.c +91 -0
  36. data/ext/zsv/vendor/zsv-1.3.0/app/compare_unique_colname.c +81 -0
  37. data/ext/zsv/vendor/zsv-1.3.0/app/count-pull.c +82 -0
  38. data/ext/zsv/vendor/zsv-1.3.0/app/count.c +404 -0
  39. data/ext/zsv/vendor/zsv-1.3.0/app/desc.c +569 -0
  40. data/ext/zsv/vendor/zsv-1.3.0/app/echo.c +365 -0
  41. data/ext/zsv/vendor/zsv-1.3.0/app/ext_example/my_extension.c +366 -0
  42. data/ext/zsv/vendor/zsv-1.3.0/app/ext_example/mysheet_extension.c +341 -0
  43. data/ext/zsv/vendor/zsv-1.3.0/app/ext_template/YOUR_EXTENSION_zsvext.c +263 -0
  44. data/ext/zsv/vendor/zsv-1.3.0/app/external/inih/ini.c +298 -0
  45. data/ext/zsv/vendor/zsv-1.3.0/app/external/inih/ini.h +157 -0
  46. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/json_numeric.c +177 -0
  47. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/jsonwriter.c +444 -0
  48. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/jsonwriter.h +145 -0
  49. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/utils.c +110 -0
  50. data/ext/zsv/vendor/zsv-1.3.0/app/external/memfile-1.0/include/memfile.h +15 -0
  51. data/ext/zsv/vendor/zsv-1.3.0/app/external/memfile-1.0/src/memfile.c +64 -0
  52. data/ext/zsv/vendor/zsv-1.3.0/app/external/sglib/sglib.h +1955 -0
  53. data/ext/zsv/vendor/zsv-1.3.0/app/external/simdutf/simdutf.h +6802 -0
  54. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3.c +230517 -0
  55. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3.h +12174 -0
  56. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_and_csv_vtab.c +2 -0
  57. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab-mem.c +142 -0
  58. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab-mem.h +49 -0
  59. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab-zsv.c +485 -0
  60. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab.c +1015 -0
  61. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3ext.h +663 -0
  62. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/vtab_helper.c +85 -0
  63. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_common.h +75 -0
  64. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_gen.h +167 -0
  65. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_parse.h +228 -0
  66. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_tree.h +186 -0
  67. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_version.h +23 -0
  68. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_common.h +76 -0
  69. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_gen.h +167 -0
  70. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_parse.h +238 -0
  71. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_tree.h +186 -0
  72. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl.c +184 -0
  73. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_alloc.c +52 -0
  74. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_alloc.h +34 -0
  75. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_buf.c +103 -0
  76. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_buf.h +57 -0
  77. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_bytestack.h +69 -0
  78. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_encode.c +220 -0
  79. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_encode.h +34 -0
  80. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_gen.c +362 -0
  81. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_lex.c +764 -0
  82. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_lex.h +117 -0
  83. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_parser.c +508 -0
  84. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_parser.h +78 -0
  85. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_tree.c +505 -0
  86. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_version.c +7 -0
  87. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper/json_value.h +59 -0
  88. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper/yajl_helper.h +208 -0
  89. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper.c +795 -0
  90. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper_internal.h +28 -0
  91. data/ext/zsv/vendor/zsv-1.3.0/app/flatten.c +851 -0
  92. data/ext/zsv/vendor/zsv-1.3.0/app/jq.c +106 -0
  93. data/ext/zsv/vendor/zsv-1.3.0/app/jq.h +6 -0
  94. data/ext/zsv/vendor/zsv-1.3.0/app/mv.c +113 -0
  95. data/ext/zsv/vendor/zsv-1.3.0/app/noop.c +90 -0
  96. data/ext/zsv/vendor/zsv-1.3.0/app/overwrite.c +295 -0
  97. data/ext/zsv/vendor/zsv-1.3.0/app/paste.c +175 -0
  98. data/ext/zsv/vendor/zsv-1.3.0/app/pretty.c +693 -0
  99. data/ext/zsv/vendor/zsv-1.3.0/app/prop.c +980 -0
  100. data/ext/zsv/vendor/zsv-1.3.0/app/rm.c +131 -0
  101. data/ext/zsv/vendor/zsv-1.3.0/app/select/fixed.c +130 -0
  102. data/ext/zsv/vendor/zsv-1.3.0/app/select/internal.h +118 -0
  103. data/ext/zsv/vendor/zsv-1.3.0/app/select/parallel.c +45 -0
  104. data/ext/zsv/vendor/zsv-1.3.0/app/select/parallel.h +41 -0
  105. data/ext/zsv/vendor/zsv-1.3.0/app/select/processing.c +107 -0
  106. data/ext/zsv/vendor/zsv-1.3.0/app/select/rand.c +20 -0
  107. data/ext/zsv/vendor/zsv-1.3.0/app/select/regex.c +61 -0
  108. data/ext/zsv/vendor/zsv-1.3.0/app/select/search.c +14 -0
  109. data/ext/zsv/vendor/zsv-1.3.0/app/select/selection.c +192 -0
  110. data/ext/zsv/vendor/zsv-1.3.0/app/select/usage.c +72 -0
  111. data/ext/zsv/vendor/zsv-1.3.0/app/select-pull.c +812 -0
  112. data/ext/zsv/vendor/zsv-1.3.0/app/select.c +753 -0
  113. data/ext/zsv/vendor/zsv-1.3.0/app/serialize.c +372 -0
  114. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/curses.h +15 -0
  115. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/cursor.c +119 -0
  116. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/errors.c +45 -0
  117. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/file.c +63 -0
  118. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/file.h +12 -0
  119. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/filter.c +166 -0
  120. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/handlers.c +214 -0
  121. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/handlers_internal.h +128 -0
  122. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/help.c +43 -0
  123. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/index.c +81 -0
  124. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/index.h +25 -0
  125. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/key-bindings.c +325 -0
  126. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/key-bindings.h +73 -0
  127. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/lexer.c +203 -0
  128. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/newline_handler.c +7 -0
  129. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/pivot.c +318 -0
  130. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/procedure.c +134 -0
  131. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/procedure.h +119 -0
  132. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/read-data.c +322 -0
  133. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/screen_buffer.c +203 -0
  134. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/screen_buffer.h +36 -0
  135. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/sheet-sql.c +167 -0
  136. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/sheet_internal.h +36 -0
  137. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/sqlfilter.c +153 -0
  138. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/terminfo.c +32 -0
  139. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/transformation.c +312 -0
  140. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/transformation.h +29 -0
  141. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/ui_buffer.c +266 -0
  142. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/usage.c +9 -0
  143. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/utf8-width.c +60 -0
  144. data/ext/zsv/vendor/zsv-1.3.0/app/sheet.c +1007 -0
  145. data/ext/zsv/vendor/zsv-1.3.0/app/sql.c +453 -0
  146. data/ext/zsv/vendor/zsv-1.3.0/app/sql_internal.c +101 -0
  147. data/ext/zsv/vendor/zsv-1.3.0/app/sql_internal.h +49 -0
  148. data/ext/zsv/vendor/zsv-1.3.0/app/stack.c +393 -0
  149. data/ext/zsv/vendor/zsv-1.3.0/app/utils/arg.c +322 -0
  150. data/ext/zsv/vendor/zsv-1.3.0/app/utils/cache.c +228 -0
  151. data/ext/zsv/vendor/zsv-1.3.0/app/utils/cat.c +91 -0
  152. data/ext/zsv/vendor/zsv-1.3.0/app/utils/chunk.c +240 -0
  153. data/ext/zsv/vendor/zsv-1.3.0/app/utils/chunk.h +63 -0
  154. data/ext/zsv/vendor/zsv-1.3.0/app/utils/clock.c +57 -0
  155. data/ext/zsv/vendor/zsv-1.3.0/app/utils/db.c +148 -0
  156. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs-no-jq.c +2 -0
  157. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs.c +427 -0
  158. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs_from_json.c +253 -0
  159. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs_to_json.c +121 -0
  160. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dl.c +20 -0
  161. data/ext/zsv/vendor/zsv-1.3.0/app/utils/emcc/fs_api.c +159 -0
  162. data/ext/zsv/vendor/zsv-1.3.0/app/utils/err.c +24 -0
  163. data/ext/zsv/vendor/zsv-1.3.0/app/utils/file-mem.c +180 -0
  164. data/ext/zsv/vendor/zsv-1.3.0/app/utils/file.c +256 -0
  165. data/ext/zsv/vendor/zsv-1.3.0/app/utils/index.c +197 -0
  166. data/ext/zsv/vendor/zsv-1.3.0/app/utils/index.h +49 -0
  167. data/ext/zsv/vendor/zsv-1.3.0/app/utils/jq.c +400 -0
  168. data/ext/zsv/vendor/zsv-1.3.0/app/utils/json.c +120 -0
  169. data/ext/zsv/vendor/zsv-1.3.0/app/utils/mem.c +18 -0
  170. data/ext/zsv/vendor/zsv-1.3.0/app/utils/memmem.c +132 -0
  171. data/ext/zsv/vendor/zsv-1.3.0/app/utils/os.c +178 -0
  172. data/ext/zsv/vendor/zsv-1.3.0/app/utils/overwrite.c +258 -0
  173. data/ext/zsv/vendor/zsv-1.3.0/app/utils/overwrite_writer.c +246 -0
  174. data/ext/zsv/vendor/zsv-1.3.0/app/utils/pcre2-8/pcre2-8-test.c +123 -0
  175. data/ext/zsv/vendor/zsv-1.3.0/app/utils/pcre2-8/pcre2-8.c +153 -0
  176. data/ext/zsv/vendor/zsv-1.3.0/app/utils/pcre2-8/pcre2-8.h +54 -0
  177. data/ext/zsv/vendor/zsv-1.3.0/app/utils/prop.c +267 -0
  178. data/ext/zsv/vendor/zsv-1.3.0/app/utils/signal.c +53 -0
  179. data/ext/zsv/vendor/zsv-1.3.0/app/utils/string.c +357 -0
  180. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/dir_exists_longpath.c +83 -0
  181. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/dl.c +33 -0
  182. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/fopen_longpath.c +184 -0
  183. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/foreach_dirent_longpath.c +292 -0
  184. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/io.c +259 -0
  185. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/io.h +13 -0
  186. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/mkdir_longpath.c +255 -0
  187. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/remove_longpath.c +96 -0
  188. data/ext/zsv/vendor/zsv-1.3.0/app/utils/writer.c +361 -0
  189. data/ext/zsv/vendor/zsv-1.3.0/app/zsv_command.h +40 -0
  190. data/ext/zsv/vendor/zsv-1.3.0/app/zsv_command_standalone.c +16 -0
  191. data/ext/zsv/vendor/zsv-1.3.0/app/zsv_main.h +44 -0
  192. data/ext/zsv/vendor/zsv-1.3.0/examples/js/zsv_parser_api_dummy.c +3 -0
  193. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/parse_by_chunk.c +100 -0
  194. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/print_my_column.c +143 -0
  195. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/pull.c +89 -0
  196. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/simple.c +123 -0
  197. data/ext/zsv/vendor/zsv-1.3.0/fuzz/fuzz.c +16 -0
  198. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/api.h +336 -0
  199. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/common.h +361 -0
  200. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/ext/implementation.h +62 -0
  201. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/ext/implementation_private.h +113 -0
  202. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/ext/sheet.h +73 -0
  203. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/ext.h +329 -0
  204. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/arg.h +90 -0
  205. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/cache.h +49 -0
  206. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/clock.h +36 -0
  207. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/compiler.h +58 -0
  208. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/db.h +19 -0
  209. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/dirs.h +147 -0
  210. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/dl.h +22 -0
  211. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/emcc/fs_api.h +28 -0
  212. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/err.h +22 -0
  213. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/file-mem.h +17 -0
  214. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/file.h +99 -0
  215. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/jq.h +65 -0
  216. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/json.h +19 -0
  217. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/mem.h +19 -0
  218. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/memmem.h +13 -0
  219. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/os.h +54 -0
  220. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/overwrite.h +71 -0
  221. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/overwrite_writer.h +53 -0
  222. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/prop.h +107 -0
  223. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/signal.h +18 -0
  224. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/sql.h +11 -0
  225. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/string.h +148 -0
  226. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/utf8.h +41 -0
  227. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/win/dl.h +25 -0
  228. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/writer.h +101 -0
  229. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/zsv_export.h +33 -0
  230. data/ext/zsv/vendor/zsv-1.3.0/include/zsv.h +20 -0
  231. data/ext/zsv/vendor/zsv-1.3.0/src/vector_delim.c +60 -0
  232. data/ext/zsv/vendor/zsv-1.3.0/src/zsv.c +484 -0
  233. data/ext/zsv/vendor/zsv-1.3.0/src/zsv_internal.c +731 -0
  234. data/ext/zsv/vendor/zsv-1.3.0/src/zsv_scan_delim.c +285 -0
  235. data/ext/zsv/vendor/zsv-1.3.0/src/zsv_scan_fixed.c +88 -0
  236. data/ext/zsv/vendor/zsv-1.3.0/src/zsv_strencode.c +51 -0
  237. data/ext/zsv/zsv_ext.c +343 -0
  238. data/lib/zsv/version.rb +5 -0
  239. data/lib/zsv.rb +81 -0
  240. metadata +340 -0
@@ -0,0 +1,71 @@
1
+ #ifndef ZSV_OVERWRITE_H
2
+ #define ZSV_OVERWRITE_H
3
+
4
+ #include <sqlite3.h>
5
+
6
+ struct zsv_overwrite_ctx {
7
+ char *src;
8
+ size_t author_ix;
9
+ size_t timestamp_ix;
10
+ size_t old_value_ix;
11
+ // enum zsv_overwrite_type type;
12
+ enum zsv_status (*next)(void *ctx, struct zsv_overwrite_data *odata);
13
+ struct {
14
+ FILE *f;
15
+ zsv_parser parser;
16
+ } csv;
17
+ struct {
18
+ char *filename;
19
+ sqlite3 *db;
20
+ sqlite3_stmt *stmt; // select row, column, overwrite
21
+ const char *sql;
22
+ } sqlite3;
23
+ size_t row_ix;
24
+ };
25
+
26
+ /**
27
+ * The easiest way to enable overwrite support is to use zsv_overwrite_auto()
28
+ * which, given an input located at /path/to/my-data.csv, will assume an overwrite source
29
+ * located at /path/to/.zsv/data/my-data.csv/overwrite.sqlite3
30
+ * in a table named 'overwrites'
31
+ *
32
+ * zsv_overwrite_auto() returns:
33
+ * - zsv_status_done if a valid overwrite file was found
34
+ * - zsv_status_no_more_input if no overwrite file was found
35
+ * - a different status code on error
36
+ *
37
+ * This function is used in app/cli.c via the --apply-overwrites option
38
+ */
39
+ enum zsv_status zsv_overwrite_auto(struct zsv_opts *opts, const char *csv_filename);
40
+
41
+ /**
42
+ * As an alternative to zsv_overwrite_auto(), you can specify your own
43
+ * source from which to fetch overwrite data.
44
+ * The specified source can be a sqlite3 file or a CSV file
45
+ *
46
+ * This approach is used by app/echo.c
47
+ */
48
+ struct zsv_overwrite_opts {
49
+ /* src may be either:
50
+ *
51
+ * 1. sqlite3 file source:
52
+ * sqlite3://<filename>[?sql=<query>]",
53
+ *
54
+ * e.g. sqlite3:///path/to/my-overwritedb.sqlite3?sql=select row, column, value from overwrites order by row, column",
55
+ *
56
+ * or
57
+ *
58
+ * 2. CSV file source
59
+ * /path/to/file.csv",
60
+ * where the CSV columns are row,col,val (in that order, with a header row),
61
+ * and rows already-sorted by row and column",
62
+ */
63
+ const char *src;
64
+ };
65
+
66
+ void *zsv_overwrite_context_new(struct zsv_overwrite_opts *);
67
+ enum zsv_status zsv_overwrite_next(void *h, struct zsv_overwrite_data *odata);
68
+ enum zsv_status zsv_overwrite_open(void *h);
69
+ enum zsv_status zsv_overwrite_context_delete(void *h);
70
+
71
+ #endif
@@ -0,0 +1,53 @@
1
+ #include <zsv.h>
2
+
3
+ enum zsvsheet_mode {
4
+ zsvsheet_mode_add,
5
+ zsvsheet_mode_remove,
6
+ zsvsheet_mode_clear,
7
+ zsvsheet_mode_list,
8
+ zsvsheet_mode_bulk,
9
+ };
10
+
11
+ struct zsv_overwrite {
12
+ struct zsv_overwrite_ctx *ctx;
13
+ struct zsv_overwrite_data *overwrite;
14
+ zsv_csv_writer writer;
15
+ enum zsv_status (*next)(struct zsv_overwrite *data);
16
+ enum zsvsheet_mode mode;
17
+ unsigned char force : 1;
18
+ unsigned char a1 : 1;
19
+ unsigned char all : 1;
20
+ unsigned char *bulk_file;
21
+ // bulk indexes
22
+ size_t row_ix;
23
+ size_t col_ix;
24
+ size_t val_ix;
25
+ size_t old_value_ix;
26
+ size_t timestamp_ix;
27
+ size_t author_ix;
28
+ };
29
+
30
+ struct zsv_overwrite_args {
31
+ char *filepath;
32
+ enum zsv_status (*next)(struct zsv_overwrite *data);
33
+ // options
34
+ unsigned char force : 1;
35
+ unsigned char a1 : 1;
36
+ unsigned char all : 1;
37
+ unsigned char *bulk_file;
38
+ struct zsv_overwrite_data *overwrite;
39
+ // commands
40
+ enum zsvsheet_mode mode;
41
+ };
42
+
43
+ struct zsv_overwrite *zsv_overwrite_writer_new(struct zsv_overwrite_args *args, struct zsv_overwrite_opts *ctx_opts);
44
+
45
+ void zsv_overwrite_writer_delete();
46
+
47
+ enum zsv_status zsv_overwrite_writer_add(struct zsv_overwrite *data);
48
+
49
+ enum zsv_status zsv_overwrite_writer_remove(struct zsv_overwrite *data);
50
+
51
+ enum zsv_status zsv_overwrite_writer_bulk(struct zsv_overwrite *data);
52
+
53
+ enum zsv_status zsv_overwrite_writer_clear(struct zsv_overwrite *data);
@@ -0,0 +1,107 @@
1
+ #ifndef ZSV_PROP_H
2
+ #define ZSV_PROP_H
3
+
4
+ #include <zsv/common.h>
5
+ #include <yajl_helper/yajl_helper.h>
6
+
7
+ struct zsv_file_properties {
8
+ enum zsv_status stat;
9
+ unsigned int skip;
10
+ unsigned int header_span;
11
+
12
+ // flags used by parser only to indicate whether property was specified
13
+ unsigned int skip_specified : 1;
14
+ unsigned int header_span_specified : 1;
15
+ unsigned int _ : 6;
16
+ };
17
+
18
+ struct zsv_prop_handler {
19
+ // handler should return 0 on success or non-zero on error. a non-zero return code will abort the property processing
20
+ int (*handler)(void *property_parser, const char *property_name, struct json_value *value);
21
+ void *ctx;
22
+ };
23
+
24
+ void *zsv_properties_parser_get_custom_ctx(void *property_parser);
25
+ const unsigned char *zsv_properties_parser_get_filepath(void *property_parser);
26
+ struct zsv_opts *zsv_properties_parser_get_opts(void *property_parser_);
27
+
28
+ /**
29
+ * set or get default custom property handler
30
+ */
31
+ void zsv_set_default_custom_prop_handler(struct zsv_prop_handler custom_prop_handler);
32
+
33
+ struct zsv_prop_handler zsv_get_default_custom_prop_handler(void);
34
+
35
+ void zsv_clear_default_custom_prop_handler(void);
36
+
37
+ /**
38
+ * Load cached file properties into a zsp_opts and/or zsv_file_properties struct
39
+ *
40
+ * @param data_filepath required file path
41
+ * @param opts (optional) parser options to load
42
+ * @param custom_prop custom property handler
43
+ * @return struct zsv_file_properties, with .stat set to zsv_status_ok on success
44
+ */
45
+ struct zsv_file_properties zsv_cache_load_props(const char *data_filepath, struct zsv_opts *opts,
46
+ struct zsv_prop_handler *custom_prop);
47
+
48
+ /**
49
+ * Create a new properties parser
50
+ */
51
+ struct zsv_properties_parser;
52
+ struct zsv_properties_parser *zsv_properties_parser_new(const unsigned char *path,
53
+ struct zsv_prop_handler *custom_prop_handler,
54
+ struct zsv_file_properties *fp, struct zsv_opts *opts);
55
+
56
+ /**
57
+ * Finished parsing
58
+ */
59
+ enum zsv_status zsv_properties_parse_complete(struct zsv_properties_parser *parser);
60
+
61
+ /**
62
+ * Clean up
63
+ */
64
+ enum zsv_status zsv_properties_parser_destroy(struct zsv_properties_parser *parser);
65
+
66
+ /**
67
+ * zsv_new_with_properties(): use in lieu of zsv_new() to also merge zsv options
68
+ * with any saved properties (such as rows_to_ignore or header_span) for the
69
+ * specified input file. In the event that saved properties conflict with a
70
+ * command-line option, the command-line option "wins" (the property value is
71
+ * ignored), but a warning is printed
72
+ *
73
+ * @param opts parser options. see `zsv_new()`
74
+ * @param cust_prop optional custom file property handler
75
+ * @param input_path path of file whose zsv properties should be loaded. this
76
+ * param is used solely for loading properties and has no
77
+ * impact on the data that is actually parsed, which is
78
+ * determined by opts->stream
79
+ * @param handle_out returns zsv parser handle, or NULL on fail
80
+ */
81
+ enum zsv_status zsv_new_with_properties(struct zsv_opts *opts, struct zsv_prop_handler *custom_prop,
82
+ const char *input_path, zsv_parser *handle_out);
83
+
84
+ /**
85
+ * If you are building your own CLI and incorporating zsv CLI commands into it,
86
+ * the `prop` command can be customized by providing your own function
87
+ * for determining whether a file in the property cache is a property file,
88
+ * which can be set using zsv_prop_get_or_set_is_prop_file()
89
+ *
90
+ * @param is_prop_file: your function, that returns non-zero if the given file entry
91
+ * is a property file. If NULL, is set to zsv_is_prop_file
92
+ * @param max_depth : maximum depth of any property file. if is_prop_file was NULL,
93
+ * max_depth is set to 1
94
+ */
95
+
96
+ #include "dirs.h"
97
+
98
+ struct zsv_dir_filter; /* opaque structure for internal use */
99
+ struct zsv_dir_filter *zsv_prop_get_or_set_is_prop_file(int (*is_prop_file)(struct zsv_foreach_dirent_handle *, size_t),
100
+ int max_depth, char set);
101
+
102
+ /**
103
+ * If you provide your own is_prop_file() function and you also want to include any
104
+ * zsv property file, your is_prop_file() can call zsv_is_prop_file()
105
+ */
106
+ int zsv_is_prop_file(struct zsv_foreach_dirent_handle *h, size_t depth);
107
+ #endif
@@ -0,0 +1,18 @@
1
+ /*
2
+ * Copyright (C) 2021 Liquidaty and the zsv/lib contributors
3
+ * All rights reserved
4
+ *
5
+ * This file is part of zsv/lib, distributed under the license defined at
6
+ * https://opensource.org/licenses/MIT
7
+ */
8
+
9
+ #ifndef ZSV_SIGNAL_H
10
+ #define ZSV_SIGNAL_H
11
+
12
+ #include <signal.h>
13
+
14
+ extern volatile sig_atomic_t zsv_signal_interrupted;
15
+
16
+ void zsv_handle_ctrl_c_signal(void);
17
+
18
+ #endif
@@ -0,0 +1,11 @@
1
+ #ifndef ZSV_UTILS_SQL_H
2
+ #define ZSV_UTILS_SQL_H
3
+
4
+ typedef struct zsv_sqlite3_db *zsv_sqlite3_db_t;
5
+
6
+ struct zsv_sqlite3_dbopts {
7
+ unsigned char in_memory : 1;
8
+ unsigned char _ : 7;
9
+ };
10
+
11
+ #endif
@@ -0,0 +1,148 @@
1
+ /*
2
+ * Copyright (C) 2021 Liquidaty and the zsv/lib contributors
3
+ * All rights reserved
4
+ *
5
+ * This file is part of zsv/lib, distributed under the license defined at
6
+ * https://opensource.org/licenses/MIT
7
+ */
8
+
9
+ #ifndef ASCII_STRING_H
10
+ #define ASCII_STRING_H
11
+
12
+ #include "../zsv_export.h"
13
+ #include <stddef.h>
14
+ #include <stdint.h>
15
+
16
+ /*
17
+ * zsv_strtolowercase(): convert to lower case. if built with utf8proc, converts unicode points
18
+ * on malformed UTF8, prints to stderr
19
+ *
20
+ * @param s string to convert
21
+ * @param lenp pointer to length of input string; will be set to length of output string
22
+ *
23
+ * @returns newly-allocated string; caller must free()
24
+ */
25
+ unsigned char *zsv_strtolowercase(const unsigned char *s, size_t *lenp);
26
+
27
+ /*
28
+ * zsv_strtolowercase_w_err(): convert to lower case. if built with utf8proc, converts unicode points
29
+ * on malformed UTF8, sets *err to non-zero
30
+ *
31
+ */
32
+ unsigned char *zsv_strtolowercase_w_err(const unsigned char *s, size_t *lenp, int *err);
33
+
34
+ const unsigned char *zsv_strstr(const unsigned char *hay, const unsigned char *needle);
35
+
36
+ /*
37
+ * zsv_stricmp, zsv_strincmp(): case-insensitive comparison (unicode-compatible if built with utf8proc)
38
+ * zsv_strincmp_ascii: ascii case-insensitive comparison
39
+ *
40
+ * @param s1 string to convert
41
+ * @param len1 length of s1
42
+ * @param s2 string to convert
43
+ * @param len2 length of s2
44
+ *
45
+ * @returns 0 if the strings are equal, -1 if s1 < s2, else 1
46
+ */
47
+ int zsv_stricmp(const unsigned char *s1, const unsigned char *s2);
48
+ int zsv_strincmp(const unsigned char *s1, size_t len1, const unsigned char *s2, size_t len2);
49
+ int zsv_strincmp_ascii(const unsigned char *s1, size_t len1, const unsigned char *s2, size_t len2);
50
+
51
+ #define ZSV_STRWHITE_FLAG_NO_EMBEDDED_NEWLINE 1
52
+ /**
53
+ * zsv_strwhite(): convert consecutive white to single space
54
+ *
55
+ * @param s string to convert
56
+ * @param len length of input string
57
+ * @param flags bitfield of any of the following flags:
58
+ * ZSV_STRWHITE_FLAG_NO_EMBEDDED_NEWLINE
59
+ */
60
+ size_t zsv_strwhite(unsigned char *s, size_t len, unsigned int flags);
61
+
62
+ /**
63
+ * Force a string to conform to UTF8 encoding. Replaces any non-conforming utf8
64
+ * with the specified char, or removes from the string (and shortens the string)
65
+ * if replace = 0
66
+ * @param s input string. invalid UTF8 bytes will be overwritten
67
+ * @param n length (in bytes) of input
68
+ * @param replace the character to replace any malformed UTF8 bytes with, or 0
69
+ * to remove and shorten the result
70
+ * @param callback optional callback invoked upon scanning malformed UTF8
71
+ * @param ctx context pointer passed to callback
72
+ * @return length of the valid string
73
+ */
74
+ ZSV_EXPORT
75
+ size_t zsv_strencode(unsigned char *s, size_t n, unsigned char replace,
76
+ int (*malformed_handler)(void *, const unsigned char *s, size_t n, size_t offset),
77
+ void *handler_ctx);
78
+
79
+ size_t zsv_strip_trailing_zeros(const char *s, size_t len);
80
+
81
+ /**
82
+ * Trim trailing whitespace
83
+ * Returns the input string and new length
84
+ */
85
+ const unsigned char *zsv_strtrim_right(const char unsigned *restrict s, size_t *lenp);
86
+
87
+ /**
88
+ * Trim leading whitespace
89
+ * Returns the pointer to the new string start and new length
90
+ */
91
+ const unsigned char *zsv_strtrim_left(const char unsigned *restrict s, size_t *lenp);
92
+
93
+ /**
94
+ * Trim leading and trailing whitespace
95
+ Returns the pointer to the new string start and new length
96
+ */
97
+ const unsigned char *zsv_strtrim(const char unsigned *restrict s, size_t *lenp);
98
+
99
+ /**
100
+ * zsv_strunescape_backslash(): convert consecutive white to single space
101
+ *
102
+ * @param s string to convert
103
+ * @param len length of input string
104
+ * @param flags bitfield of ZSV_STRWHITE_FLAG_XXX values
105
+ */
106
+ size_t zsv_strunescape_backslash(unsigned char *s, size_t len);
107
+
108
+ /**
109
+ * Get the next UTF8 codepoint in a string
110
+ * Return: length of next character (in bytes), or 0 on error or end of string
111
+ */
112
+ size_t zsv_strnext(const unsigned char *s, size_t len, int32_t *codepoint);
113
+
114
+ /**
115
+ * Get the last UTF8 codepoint in a string
116
+ * Return: length of last character (in bytes), or 0 on error or end of string
117
+ */
118
+ size_t zsv_strlast(const unsigned char *s, size_t len, int32_t *codepoint);
119
+
120
+ /**
121
+ * Check if the next char is a plus or minus. If so, return its length, else return 0
122
+ */
123
+ size_t zsv_strnext_is_sign(const unsigned char *s, size_t len);
124
+
125
+ /**
126
+ * Check if the next char is a currency char. If so, return its length, else return 0
127
+ */
128
+ size_t zsv_strnext_is_currency(const unsigned char *s, size_t len);
129
+
130
+ /*
131
+ * Convert a string to a double. must convert entire string, else returns error
132
+ * @param s string to convert
133
+ * @param d pointer to converted value, on success
134
+ *
135
+ * @returns 0 on success, non-zero on error
136
+ */
137
+ int zsv_strtod_exact(const char *s, double *d);
138
+
139
+ /*
140
+ * `zsv_get_cell_trimmed` is equivalent to `zsv_get_cell`, except that it
141
+ * @param s string to convert
142
+ * @param len length of input string
143
+ * returns a value with leading and trailing whitespace removed
144
+ */
145
+ #include <zsv.h>
146
+ struct zsv_cell zsv_get_cell_trimmed(zsv_parser parser, size_t index);
147
+
148
+ #endif
@@ -0,0 +1,41 @@
1
+ /*
2
+ * Copyright (C) 2021 Liquidaty and the zsv/lib contributors
3
+ * All rights reserved
4
+ *
5
+ * This file is part of zsv/lib, distributed under the license defined at
6
+ * https://opensource.org/licenses/MIT
7
+ */
8
+
9
+ // clang-format off
10
+
11
+ #ifndef ZSV_UTF8_CHARLEN_NOERR
12
+ // ZSV_UTF8_CHARLEN_NOERR: return > 0 if valid utf8, +1 on error
13
+ #define ZSV_UTF8_CHARLEN_NOERR(c) \
14
+ (!(c & 128) ? 1 : \
15
+ (c & 224) == 192 ? 2 : /* 110xxxxx */ \
16
+ (c & 240) == 224 ? 3 : /* 1110xxxx */ \
17
+ (c & 248) == 240 ? 4 : /* 11110xxx */ \
18
+ (c & 252) == 248 ? 5 : /* 111110xx */ \
19
+ (c & 254) == 252 ? 6 : /* 1111110x */ \
20
+ 1 /* error */ \
21
+ )
22
+ #endif
23
+
24
+ #ifndef ZSV_UTF8_CHARLEN
25
+ // ZSV_UTF8_CHARLEN: return > 0 if valid utf8, -1 on error
26
+ #define ZSV_UTF8_CHARLEN(c) \
27
+ (!(c & 128) ? 1 : \
28
+ (c & 224) == 192 ? 2 : /* 110xxxxx */ \
29
+ (c & 240) == 224 ? 3 : /* 1110xxxx */ \
30
+ (c & 248) == 240 ? 4 : /* 11110xxx */ \
31
+ (c & 252) == 248 ? 5 : /* 111110xx */ \
32
+ (c & 254) == 252 ? 6 : /* 1111110x */ \
33
+ -1 /* error */ \
34
+ )
35
+ #endif
36
+
37
+ // clang-format on
38
+
39
+ #ifndef ZSV_UTF8_SUBSEQUENT_CHAR_OK
40
+ #define ZSV_UTF8_SUBSEQUENT_CHAR_OK(c) ((c & 192) == 128)
41
+ #endif
@@ -0,0 +1,25 @@
1
+ /*
2
+ * Copyright (C) 2021 Liquidaty and the zsv/lib contributors
3
+ * All rights reserved
4
+ *
5
+ * This file is part of zsv/lib, distributed under the license defined at
6
+ * https://opensource.org/licenses/MIT
7
+ */
8
+
9
+ #ifndef ZSV_DL_WIN_H
10
+ #define ZSV_DL_WIN_H
11
+
12
+ #ifdef _WIN32
13
+
14
+ #include <windows.h>
15
+
16
+ #define RTLD_LAZY 0
17
+ void *dlopen(const char *dll_name, int flags);
18
+
19
+ void *dlsym(void *handle, const char *symbol);
20
+
21
+ int dlclose(void *handle);
22
+
23
+ #endif
24
+
25
+ #endif
@@ -0,0 +1,101 @@
1
+ /*
2
+ * Copyright (C) 2021 Liquidaty and the zsv/lib contributors
3
+ * All rights reserved
4
+ *
5
+ * This file is part of zsv/lib, distributed under the license defined at
6
+ * https://opensource.org/licenses/MIT
7
+ */
8
+
9
+ #ifndef ZSV_WRITER_H
10
+ #define ZSV_WRITER_H
11
+
12
+ #include <stdio.h>
13
+ #include <stdint.h> // uint64_t
14
+
15
+ #define ZSV_WRITER_NEW_ROW 1
16
+ #define ZSV_WRITER_SAME_ROW 0
17
+
18
+ /**
19
+ * csv writer options
20
+ *
21
+ * If `output_path` is non-NULL, `stream` must be NULL or stdout and `write` must be NULL or fwrite
22
+ ***/
23
+ struct zsv_csv_writer_options {
24
+ char with_bom;
25
+ size_t (*write)(const void *restrict, size_t size, size_t nitems, void *restrict stream);
26
+ void *stream;
27
+ void (*table_init)(void *);
28
+ void *table_init_ctx;
29
+ const char *output_path; // if provided, will be created by zsv_writer_new() and closed by zsv_writer_delete()
30
+ void (*on_row)(void *);
31
+ void *on_row_ctx;
32
+
33
+ void (*on_delete)(void *);
34
+ void *on_delete_ctx;
35
+ };
36
+
37
+ void zsv_writer_set_default_opts(struct zsv_csv_writer_options opts);
38
+ struct zsv_csv_writer_options zsv_writer_get_default_opts(void);
39
+
40
+ enum zsv_writer_status {
41
+ zsv_writer_status_ok = 0,
42
+ zsv_writer_status_error,
43
+ zsv_writer_status_missing_handle,
44
+ zsv_writer_status_unknown = 999
45
+ };
46
+
47
+ struct zsv_writer_data;
48
+ typedef struct zsv_writer_data *zsv_csv_writer;
49
+
50
+ /**
51
+ * Get a new CSV writer
52
+ *
53
+ * @returns handle, or NULL on error, in which case errno will be set
54
+ */
55
+ zsv_csv_writer zsv_writer_new(struct zsv_csv_writer_options *opts);
56
+ enum zsv_writer_status zsv_writer_delete(zsv_csv_writer w);
57
+
58
+ enum zsv_writer_status zsv_writer_flush(zsv_csv_writer w);
59
+
60
+ void zsv_writer_set_temp_buff(zsv_csv_writer w, unsigned char *buff, size_t buffsize);
61
+
62
+ enum zsv_writer_status zsv_writer_cell(zsv_csv_writer,
63
+ char new_row, // ZSV_WRITER_NEW_ROW or ZSV_WRITER_SAME_ROW
64
+ const unsigned char *s, size_t len, char check_if_needs_quoting);
65
+
66
+ /*
67
+ * Get total bytes that have been written (to disk and buffer)
68
+ */
69
+ uint64_t zsv_writer_cum_bytes_written(zsv_csv_writer);
70
+
71
+ unsigned char *zsv_writer_str_to_csv(const unsigned char *s, size_t len);
72
+
73
+ /*
74
+ * quote a CSV string, if needed
75
+ * @return NULL if no quoting required, `buff` if quoted value written to buff,
76
+ * or newly-allocated memory if buff not large enough (caller must free)
77
+ */
78
+ unsigned char *zsv_csv_quote(const unsigned char *utf8_value, size_t len, unsigned char *buff, size_t buffsize);
79
+
80
+ // zsv_writer_cell convenience funcs: zsv_writer_cell_XX where XX = printf specifier
81
+ enum zsv_writer_status zsv_writer_cell_zu(zsv_csv_writer w, char new_row, size_t zu);
82
+
83
+ enum zsv_writer_status zsv_writer_cell_s(zsv_csv_writer w, char new_row, const unsigned char *s,
84
+ char check_if_needs_quoting);
85
+
86
+ enum zsv_writer_status zsv_writer_cell_Lf(zsv_csv_writer w, char new_row,
87
+ const char *fmt_spec, // provide X in %XLf e.g. ".2" or ""
88
+ long double ldbl);
89
+
90
+ // write a blank cell
91
+ enum zsv_writer_status zsv_writer_cell_blank(zsv_csv_writer w, char new_row);
92
+
93
+ /**
94
+ * set a value to be prepended to the next cell value that is written
95
+ *
96
+ * @param w handle to the writer
97
+ * @param s text value to write (can be NULL)
98
+ */
99
+ void zsv_writer_cell_prepend(zsv_csv_writer w, const unsigned char *s);
100
+
101
+ #endif
@@ -0,0 +1,33 @@
1
+ #ifndef ZSV_EXPORT_H
2
+ #define ZSV_EXPORT_H
3
+
4
+ // clang-format off
5
+ #ifdef __EMSCRIPTEN__
6
+ # include <emscripten.h>
7
+ # define ZSV_EXPORT EMSCRIPTEN_KEEPALIVE
8
+ #else
9
+ # ifdef ZSV_BUILD_SHARED
10
+ # if defined(_WIN32) || defined(__CYGWIN__)
11
+ # ifdef __GNUC__
12
+ # define ZSV_EXPORT __attribute__((dllexport))
13
+ # else
14
+ # define ZSV_EXPORT __declspec(dllexport)
15
+ # endif
16
+ # else
17
+ # ifdef __GNUC__
18
+ # define ZSV_EXPORT __attribute__((dllimport))
19
+ # else
20
+ # define ZSV_EXPORT __declspec(dllimport)
21
+ # endif
22
+ # endif
23
+ # else
24
+ # if __GNUC__ >= 4
25
+ # define ZSV_EXPORT __attribute__((visibility("default")))
26
+ # else
27
+ # define ZSV_EXPORT
28
+ # endif
29
+ # endif
30
+ #endif
31
+ // clang-format on
32
+
33
+ #endif
@@ -0,0 +1,20 @@
1
+ /*
2
+ * Copyright (C) 2021 Liquidaty and the zsv/lib contributors
3
+ * All rights reserved
4
+ *
5
+ * This file is part of zsv/lib, distributed under the license defined at
6
+ * https://opensource.org/licenses/MIT
7
+ */
8
+
9
+ #ifndef ZSV_H
10
+ #define ZSV_H
11
+
12
+ #ifndef ZSV_EXTRAS
13
+ #define ZSV_EXTRAS
14
+ #endif
15
+
16
+ #include <stddef.h>
17
+ #include "zsv/common.h"
18
+ #include "zsv/api.h"
19
+
20
+ #endif
@@ -0,0 +1,60 @@
1
+ /*
2
+ * Copyright (C) 2021 Tai Chi Minh Ralph Eastwood (self), Matt Wong (Guarnerix Inc dba Liquidaty)
3
+ * All rights reserved
4
+ *
5
+ * This file is part of zsv/lib, distributed under the license defined at
6
+ * https://opensource.org/licenses/MIT
7
+ */
8
+
9
+ #include <stdio.h>
10
+ #include <time.h>
11
+ #include <stdint.h>
12
+ #include <stdbool.h>
13
+ #include <string.h>
14
+
15
+ #if VECTOR_BYTES == 64 && (defined(HAVE__BLSR_U64) || defined(HAVE___BLSR_U64))
16
+ #if defined(HAVE__BLSR_U64)
17
+ #define clear_lowest_bit(n) _blsr_u64(n)
18
+ #else
19
+ #define clear_lowest_bit(n) __blsr_u64(n)
20
+ #endif
21
+ #elif VECTOR_BYTES == 32 && (defined(HAVE__BLSR_U32) || defined(HAVE___BLSR_U32))
22
+ #if defined(HAVE__BLSR_U32)
23
+ #define clear_lowest_bit(n) _blsr_u32(n)
24
+ #else
25
+ #define clear_lowest_bit(n) __blsr_u32(n)
26
+ #endif
27
+ #else
28
+ #define clear_lowest_bit(n) (n & (n - 1))
29
+ #endif
30
+
31
+ // vec_delims: return bitfield of next 32 bytes that contain at least 1 token
32
+ __attribute__((always_inline)) static inline int vec_delims(const unsigned char *s, size_t n,
33
+ zsv_uc_vector *char_match1, zsv_uc_vector *char_match2,
34
+ zsv_uc_vector *char_match3, zsv_uc_vector *char_match4,
35
+ zsv_mask_t *maskp) {
36
+ zsv_uc_vector *pSrc1 = (zsv_uc_vector *)s;
37
+ zsv_uc_vector str_simd;
38
+
39
+ unsigned j = n / sizeof(str_simd); // VECTOR_BYTES;
40
+ zsv_mask_t mask = 0;
41
+ unsigned total_bytes = 0;
42
+
43
+ for (unsigned i = 0; i < j; i++) {
44
+ memcpy(&str_simd, s + i * sizeof(str_simd), sizeof(str_simd));
45
+ zsv_uc_vector vtmp = str_simd == *char_match1;
46
+ vtmp += (str_simd == *char_match2);
47
+ vtmp += (str_simd == *char_match3);
48
+ vtmp += (str_simd == *char_match4);
49
+ mask = movemask_pseudo(vtmp);
50
+
51
+ if (LIKELY(mask != 0)) { // check if we found one of the 4 chars
52
+ *maskp = mask;
53
+ return total_bytes;
54
+ } else {
55
+ // not found, moving to next chunk
56
+ total_bytes += sizeof(*pSrc1);
57
+ }
58
+ }
59
+ return total_bytes; // nothing found in entire buffer
60
+ }