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,157 @@
1
+ /* inih -- simple .INI file parser
2
+
3
+ SPDX-License-Identifier: BSD-3-Clause
4
+
5
+ Copyright (C) 2009-2020, Ben Hoyt
6
+
7
+ inih is released under the New BSD license (see LICENSE.txt). Go to the project
8
+ home page for more info:
9
+
10
+ https://github.com/benhoyt/inih
11
+
12
+ */
13
+
14
+ #ifndef INI_H
15
+ #define INI_H
16
+
17
+ /* Make this header file easier to include in C++ code */
18
+ #ifdef __cplusplus
19
+ extern "C" {
20
+ #endif
21
+
22
+ #include <stdio.h>
23
+
24
+ /* Nonzero if ini_handler callback should accept lineno parameter. */
25
+ #ifndef INI_HANDLER_LINENO
26
+ #define INI_HANDLER_LINENO 0
27
+ #endif
28
+
29
+ /* Typedef for prototype of handler function. */
30
+ #if INI_HANDLER_LINENO
31
+ typedef int (*ini_handler)(void* user, const char* section,
32
+ const char* name, const char* value,
33
+ int lineno);
34
+ #else
35
+ typedef int (*ini_handler)(void* user, const char* section,
36
+ const char* name, const char* value);
37
+ #endif
38
+
39
+ /* Typedef for prototype of fgets-style reader function. */
40
+ typedef char* (*ini_reader)(char* str, int num, void* stream);
41
+
42
+ /* Parse given INI-style file. May have [section]s, name=value pairs
43
+ (whitespace stripped), and comments starting with ';' (semicolon). Section
44
+ is "" if name=value pair parsed before any section heading. name:value
45
+ pairs are also supported as a concession to Python's configparser.
46
+
47
+ For each name=value pair parsed, call handler function with given user
48
+ pointer as well as section, name, and value (data only valid for duration
49
+ of handler call). Handler should return nonzero on success, zero on error.
50
+
51
+ Returns 0 on success, line number of first error on parse error (doesn't
52
+ stop on first error), -1 on file open error, or -2 on memory allocation
53
+ error (only when INI_USE_STACK is zero).
54
+ */
55
+ int ini_parse(const char* filename, ini_handler handler, void* user);
56
+
57
+ /* Same as ini_parse(), but takes a FILE* instead of filename. This doesn't
58
+ close the file when it's finished -- the caller must do that. */
59
+ int ini_parse_file(FILE* file, ini_handler handler, void* user);
60
+
61
+ /* Same as ini_parse(), but takes an ini_reader function pointer instead of
62
+ filename. Used for implementing custom or string-based I/O (see also
63
+ ini_parse_string). */
64
+ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
65
+ void* user);
66
+
67
+ /* Same as ini_parse(), but takes a zero-terminated string with the INI data
68
+ instead of a file. Useful for parsing INI data from a network socket or
69
+ already in memory. */
70
+ int ini_parse_string(const char* string, ini_handler handler, void* user);
71
+
72
+ /* Nonzero to allow multi-line value parsing, in the style of Python's
73
+ configparser. If allowed, ini_parse() will call the handler with the same
74
+ name for each subsequent line parsed. */
75
+ #ifndef INI_ALLOW_MULTILINE
76
+ #define INI_ALLOW_MULTILINE 1
77
+ #endif
78
+
79
+ /* Nonzero to allow a UTF-8 BOM sequence (0xEF 0xBB 0xBF) at the start of
80
+ the file. See https://github.com/benhoyt/inih/issues/21 */
81
+ #ifndef INI_ALLOW_BOM
82
+ #define INI_ALLOW_BOM 1
83
+ #endif
84
+
85
+ /* Chars that begin a start-of-line comment. Per Python configparser, allow
86
+ both ; and # comments at the start of a line by default. */
87
+ #ifndef INI_START_COMMENT_PREFIXES
88
+ #define INI_START_COMMENT_PREFIXES ";#"
89
+ #endif
90
+
91
+ /* Nonzero to allow inline comments (with valid inline comment characters
92
+ specified by INI_INLINE_COMMENT_PREFIXES). Set to 0 to turn off and match
93
+ Python 3.2+ configparser behaviour. */
94
+ #ifndef INI_ALLOW_INLINE_COMMENTS
95
+ #define INI_ALLOW_INLINE_COMMENTS 1
96
+ #endif
97
+ #ifndef INI_INLINE_COMMENT_PREFIXES
98
+ #define INI_INLINE_COMMENT_PREFIXES ";"
99
+ #endif
100
+
101
+ /* Nonzero to use stack for line buffer, zero to use heap (malloc/free). */
102
+ #ifndef INI_USE_STACK
103
+ #define INI_USE_STACK 1
104
+ #endif
105
+
106
+ /* Maximum line length for any line in INI file (stack or heap). Note that
107
+ this must be 3 more than the longest line (due to '\r', '\n', and '\0'). */
108
+ #ifndef INI_MAX_LINE
109
+ #define INI_MAX_LINE 200
110
+ #endif
111
+
112
+ /* Nonzero to allow heap line buffer to grow via realloc(), zero for a
113
+ fixed-size buffer of INI_MAX_LINE bytes. Only applies if INI_USE_STACK is
114
+ zero. */
115
+ #ifndef INI_ALLOW_REALLOC
116
+ #define INI_ALLOW_REALLOC 0
117
+ #endif
118
+
119
+ /* Initial size in bytes for heap line buffer. Only applies if INI_USE_STACK
120
+ is zero. */
121
+ #ifndef INI_INITIAL_ALLOC
122
+ #define INI_INITIAL_ALLOC 200
123
+ #endif
124
+
125
+ /* Stop parsing on first error (default is to keep parsing). */
126
+ #ifndef INI_STOP_ON_FIRST_ERROR
127
+ #define INI_STOP_ON_FIRST_ERROR 0
128
+ #endif
129
+
130
+ /* Nonzero to call the handler at the start of each new section (with
131
+ name and value NULL). Default is to only call the handler on
132
+ each name=value pair. */
133
+ #ifndef INI_CALL_HANDLER_ON_NEW_SECTION
134
+ #define INI_CALL_HANDLER_ON_NEW_SECTION 0
135
+ #endif
136
+
137
+ /* Nonzero to allow a name without a value (no '=' or ':' on the line) and
138
+ call the handler with value NULL in this case. Default is to treat
139
+ no-value lines as an error. */
140
+ #ifndef INI_ALLOW_NO_VALUE
141
+ #define INI_ALLOW_NO_VALUE 0
142
+ #endif
143
+
144
+ /* Nonzero to use custom ini_malloc, ini_free, and ini_realloc memory
145
+ allocation functions (INI_USE_STACK must also be 0). These functions must
146
+ have the same signatures as malloc/free/realloc and behave in a similar
147
+ way. ini_realloc is only needed if INI_ALLOW_REALLOC is set. */
148
+ #ifndef INI_CUSTOM_ALLOCATOR
149
+ #define INI_CUSTOM_ALLOCATOR 0
150
+ #endif
151
+
152
+
153
+ #ifdef __cplusplus
154
+ }
155
+ #endif
156
+
157
+ #endif /* INI_H */
@@ -0,0 +1,177 @@
1
+ #include <stdbool.h> // For bool, true, false
2
+ #include <stddef.h> // For size_t
3
+ #include <ctype.h> // For isdigit
4
+
5
+ /**
6
+ * @brief Checks if a buffer segment represents a valid JSON number (RFC 8259 compliant).
7
+ *
8
+ * Follows RFC 8259 Section 6 rules strictly. Numbers MUST have an integer part.
9
+ * Operates on a character buffer `str` of explicit `length`.
10
+ * Assumes `str` is NOT null-terminated and reads exactly `length` bytes.
11
+ * Accessing memory beyond `str + length - 1` is avoided.
12
+ *
13
+ * JSON Number Format (RFC 8259):
14
+ * number = [ minus ] int [ frac ] [ exp ]
15
+ * int = zero / ( digit1-9 *DIGIT )
16
+ * frac = decimal-point 1*DIGIT
17
+ * exp = e [ minus / plus ] 1*DIGIT
18
+ *
19
+ * @param str Pointer to the start of the character buffer.
20
+ * @param length The exact number of characters in the buffer segment to validate.
21
+ * @return true if the buffer segment [str, str + length) is a valid JSON number
22
+ * per RFC 8259, false otherwise.
23
+ */
24
+ bool is_valid_json_number(const char *str, size_t length) {
25
+ // 1. Handle NULL pointer or Zero Length
26
+ if (str == NULL || length == 0) {
27
+ return false;
28
+ }
29
+
30
+ const char *p = str;
31
+ const char * const end = str + length; // Pointer to one position *after* the last valid char
32
+
33
+ // 2. Optional Minus Sign
34
+ // Check bounds before dereferencing
35
+ if (p < end && *p == '-') {
36
+ p++; // Advance pointer
37
+ }
38
+
39
+ // 3. Integer Part (Mandatory per RFC 8259)
40
+ // Check if we are already at the end (e.g., input was "-" or empty after sign)
41
+ if (p >= end) {
42
+ return false;
43
+ }
44
+
45
+ if (*p == '0') {
46
+ p++; // Consumed '0'
47
+ // Check bounds *before* looking at the next character for leading zero violation
48
+ if (p < end && isdigit((unsigned char)*p)) {
49
+ return false; // Leading zero rule violation (e.g., "01")
50
+ }
51
+ // '0' must be followed by '.', 'e', 'E', or the end of the buffer.
52
+ } else if (isdigit((unsigned char)*p)) { // Starts with 1-9
53
+ p++; // Consume the first digit (1-9)
54
+ // Consume subsequent digits, checking bounds in the loop
55
+ while (p < end && isdigit((unsigned char)*p)) {
56
+ p++;
57
+ }
58
+ } else {
59
+ // Did not start with '0' or '1'-'9' after optional sign. Invalid.
60
+ // Correctly rejects ".2", "-.2" etc. even with length check.
61
+ return false;
62
+ }
63
+ // If we reached here, a valid integer part was parsed up to the current 'p'.
64
+
65
+ // 4. Optional Fractional Part
66
+ // Check bounds before checking for '.'
67
+ if (p < end && *p == '.') {
68
+ p++; // Consumed '.'
69
+ // Check bounds *before* looking for the mandatory digit after '.'
70
+ if (p >= end || !isdigit((unsigned char)*p)) {
71
+ // Reached end immediately after '.', or next char not a digit (e.g., "1.", "0.")
72
+ return false;
73
+ }
74
+ p++; // Consumed the first digit after '.'
75
+ // Consume subsequent digits, checking bounds in the loop
76
+ while (p < end && isdigit((unsigned char)*p)) {
77
+ p++;
78
+ }
79
+ }
80
+
81
+ // 5. Optional Exponent Part
82
+ // Check bounds before checking for 'e'/'E'
83
+ if (p < end && (*p == 'e' || *p == 'E')) {
84
+ p++; // Consumed 'e' or 'E'
85
+ // Check bounds before checking for optional sign
86
+ if (p < end && (*p == '+' || *p == '-')) {
87
+ p++; // Consumed optional sign
88
+ }
89
+ // Check bounds *before* looking for the mandatory digit after exponent part
90
+ if (p >= end || !isdigit((unsigned char)*p)) {
91
+ // Reached end immediately after 'e'/'E'/sign, or next char not a digit (e.g., "1e", "1E+")
92
+ return false;
93
+ }
94
+ p++; // Consumed the first digit after exponent part
95
+ // Consume subsequent digits, checking bounds in the loop
96
+ while (p < end && isdigit((unsigned char)*p)) {
97
+ p++;
98
+ }
99
+ }
100
+
101
+ // 6. Final Check: Must have consumed exactly 'length' characters
102
+ // If p == end, we successfully processed all characters from str to str + length - 1
103
+ // according to the JSON number rules.
104
+ return p == end;
105
+ }
106
+
107
+ #ifdef JSON_NUMERIC_TEST
108
+
109
+ // --- Example Usage ---
110
+ #include <stdio.h>
111
+ #include <string.h> // For strlen in test driver ONLY
112
+
113
+ // Updated test function to use length
114
+ void test_json_number_len(const char* str, size_t len) {
115
+ // Create a temporary non-null terminated buffer for printing if needed,
116
+ // or just print the pointer and length. Be careful printing non-terminated strings.
117
+ // Using printf("%.*s", (int)len, str) is safer for printing.
118
+ printf("\"%.*s\" (len %zu) -> %s\n", (int)len, str ? str : "(null)", len,
119
+ is_valid_json_number(str, len) ? "VALID" : "INVALID");
120
+ }
121
+
122
+ // Helper for testing null-terminated strings using the length-based function
123
+ void test_json_number_nul(const char* str) {
124
+ if (str == NULL) {
125
+ printf("NULL (len 0) -> %s\n", is_valid_json_number(NULL, 0) ? "VALID" : "INVALID");
126
+ return;
127
+ }
128
+ size_t len = strlen(str); // Use strlen JUST for the test case driver
129
+ test_json_number_len(str, len);
130
+ }
131
+
132
+
133
+ int main() {
134
+ printf("--- Testing with NUL-terminated strings ---\n");
135
+ printf("--- Valid Examples (RFC 8259 Compliant) ---\n");
136
+ test_json_number_nul("0");
137
+ test_json_number_nul("1");
138
+ test_json_number_nul("-1");
139
+ test_json_number_nul("12345");
140
+ test_json_number_nul("0.5");
141
+ test_json_number_nul("1.234");
142
+ test_json_number_nul("1e5");
143
+ test_json_number_nul("1E-5");
144
+ test_json_number_nul("1.2E+10");
145
+ test_json_number_nul("-0.123e-4");
146
+
147
+ printf("\n--- Invalid Examples (RFC 8259 Compliant) ---\n");
148
+ test_json_number_nul(NULL);
149
+ test_json_number_nul("");
150
+ test_json_number_nul("-");
151
+ test_json_number_nul(".");
152
+ test_json_number_nul(".2");
153
+ test_json_number_nul("1.");
154
+ test_json_number_nul("01");
155
+ test_json_number_nul("1e");
156
+ test_json_number_nul("1e+");
157
+ test_json_number_nul("1.2a");
158
+ test_json_number_nul("1.2e5 "); // Trailing space
159
+
160
+ printf("\n--- Testing with specific lengths ---\n");
161
+ test_json_number_len("12345", 3); // "123" -> VALID (Consumes exactly 3)
162
+ test_json_number_len("12a45", 2); // "12" -> VALID (Consumes exactly 2)
163
+ test_json_number_len("12a45", 3); // "12a" -> INVALID (a is not part of num, doesn't consume exactly 3 as num)
164
+ test_json_number_len("1.5x", 3); // "1.5" -> VALID (Consumes exactly 3)
165
+ test_json_number_len("1.5x", 4); // "1.5x" -> INVALID (x is extra)
166
+ test_json_number_len("1.", 1); // "1" -> VALID (Consumes exactly 1)
167
+ test_json_number_len("1.", 2); // "1." -> INVALID (Needs digit after .)
168
+ test_json_number_len("-", 1); // "-" -> INVALID (No digits)
169
+ test_json_number_len("-1", 1); // "-" -> INVALID (Only consumes 1, needs the digit too)
170
+ test_json_number_len("-1", 2); // "-1" -> VALID (Consumes exactly 2)
171
+ test_json_number_len("0", 1); // "0" -> VALID
172
+ test_json_number_len("0", 0); // "" -> INVALID (Zero length handled)
173
+ test_json_number_len(NULL, 0); // NULL -> INVALID
174
+
175
+ return 0;
176
+ }
177
+ #endif