zsv 1.3.1 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (259) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +153 -2
  3. data/README.md +132 -240
  4. data/ext/zsv/ZSV_UPSTREAM +7 -0
  5. data/ext/zsv/common.h +0 -12
  6. data/ext/zsv/extconf.rb +70 -122
  7. data/ext/zsv/options.c +63 -62
  8. data/ext/zsv/options.h +8 -11
  9. data/ext/zsv/parser.c +390 -201
  10. data/ext/zsv/parser.h +35 -22
  11. data/ext/zsv/row.c +75 -28
  12. data/ext/zsv/row.h +15 -9
  13. data/ext/zsv/upstream.rb +55 -0
  14. data/ext/zsv/vendor/zsv/LICENSE +21 -0
  15. data/ext/zsv/vendor/zsv/VENDORED_FROM +2 -0
  16. data/ext/zsv/vendor/zsv/configure +1212 -0
  17. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/api.h +39 -0
  18. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/common.h +36 -0
  19. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/ext/sheet.h +8 -1
  20. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/ext.h +6 -2
  21. data/ext/zsv/vendor/zsv/include/zsv/utils/appname.h +51 -0
  22. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/arg.h +50 -1
  23. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/compiler.h +19 -8
  24. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/dirs.h +2 -0
  25. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/file-mem.h +1 -0
  26. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/file.h +28 -2
  27. data/ext/zsv/vendor/zsv/include/zsv/utils/os.h +145 -0
  28. data/ext/zsv/vendor/zsv/include/zsv/utils/output.h +34 -0
  29. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/overwrite_writer.h +1 -1
  30. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/prop.h +16 -4
  31. data/ext/zsv/vendor/zsv/include/zsv/utils/rng.h +35 -0
  32. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/signal.h +7 -0
  33. data/ext/zsv/vendor/zsv/include/zsv/utils/sql.h +13 -0
  34. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/string.h +25 -0
  35. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/writer.h +9 -1
  36. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/zsv_export.h +1 -1
  37. data/ext/zsv/vendor/{zsv-1.3.0/include/zsv.h → zsv/include/zsv.h.in} +1 -3
  38. data/ext/zsv/vendor/zsv/src/Makefile +238 -0
  39. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/src/zsv.c +152 -14
  40. data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/src/zsv_internal.c +108 -50
  41. data/ext/zsv/vendor/zsv/src/zsv_scan_delim_fast.c +741 -0
  42. data/ext/zsv/vendor/zsv/src/zsv_scan_simd_avx2.h +89 -0
  43. data/ext/zsv/vendor/zsv/src/zsv_scan_simd_neon.h +80 -0
  44. data/ext/zsv/vendor/zsv/src/zsv_scan_simd_sse2.h +93 -0
  45. data/ext/zsv/vendor/zsv/src/zsv_scan_simd_wasm.h +79 -0
  46. data/ext/zsv/vendor/zsv/src/zsv_strencode.c +84 -0
  47. data/ext/zsv/zsv_ext.c +176 -105
  48. data/lib/zsv/errors.rb +32 -0
  49. data/lib/zsv/input.rb +88 -0
  50. data/lib/zsv/options.rb +132 -0
  51. data/lib/zsv/strict_validator.rb +124 -0
  52. data/lib/zsv/version.rb +1 -1
  53. data/lib/zsv.rb +137 -35
  54. metadata +81 -230
  55. data/ext/zsv/vendor/zsv-1.3.0/app/2db.c +0 -756
  56. data/ext/zsv/vendor/zsv-1.3.0/app/2json.c +0 -381
  57. data/ext/zsv/vendor/zsv-1.3.0/app/2tsv.c +0 -228
  58. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/help.c +0 -123
  59. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/license.c +0 -39
  60. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/register.c +0 -104
  61. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/thirdparty.c +0 -41
  62. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/unregister.c +0 -1
  63. data/ext/zsv/vendor/zsv-1.3.0/app/builtin/version.c +0 -14
  64. data/ext/zsv/vendor/zsv-1.3.0/app/check/simdutf_wrapper.h +0 -19
  65. data/ext/zsv/vendor/zsv-1.3.0/app/check/utf8.c +0 -116
  66. data/ext/zsv/vendor/zsv-1.3.0/app/check.c +0 -194
  67. data/ext/zsv/vendor/zsv-1.3.0/app/cli.c +0 -796
  68. data/ext/zsv/vendor/zsv-1.3.0/app/cli_const.h +0 -41
  69. data/ext/zsv/vendor/zsv-1.3.0/app/cli_export.h +0 -16
  70. data/ext/zsv/vendor/zsv-1.3.0/app/cli_ini.c +0 -280
  71. data/ext/zsv/vendor/zsv-1.3.0/app/cli_internal.h +0 -36
  72. data/ext/zsv/vendor/zsv-1.3.0/app/compare.c +0 -913
  73. data/ext/zsv/vendor/zsv-1.3.0/app/compare.h +0 -23
  74. data/ext/zsv/vendor/zsv-1.3.0/app/compare_added_column.c +0 -20
  75. data/ext/zsv/vendor/zsv-1.3.0/app/compare_internal.h +0 -140
  76. data/ext/zsv/vendor/zsv-1.3.0/app/compare_sort.c +0 -91
  77. data/ext/zsv/vendor/zsv-1.3.0/app/compare_unique_colname.c +0 -81
  78. data/ext/zsv/vendor/zsv-1.3.0/app/count-pull.c +0 -82
  79. data/ext/zsv/vendor/zsv-1.3.0/app/count.c +0 -404
  80. data/ext/zsv/vendor/zsv-1.3.0/app/desc.c +0 -569
  81. data/ext/zsv/vendor/zsv-1.3.0/app/echo.c +0 -365
  82. data/ext/zsv/vendor/zsv-1.3.0/app/ext_example/my_extension.c +0 -366
  83. data/ext/zsv/vendor/zsv-1.3.0/app/ext_example/mysheet_extension.c +0 -341
  84. data/ext/zsv/vendor/zsv-1.3.0/app/ext_template/YOUR_EXTENSION_zsvext.c +0 -263
  85. data/ext/zsv/vendor/zsv-1.3.0/app/external/inih/ini.c +0 -298
  86. data/ext/zsv/vendor/zsv-1.3.0/app/external/inih/ini.h +0 -157
  87. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/json_numeric.c +0 -177
  88. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/jsonwriter.c +0 -444
  89. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/jsonwriter.h +0 -145
  90. data/ext/zsv/vendor/zsv-1.3.0/app/external/json_writer-1.01/utils.c +0 -110
  91. data/ext/zsv/vendor/zsv-1.3.0/app/external/memfile-1.0/include/memfile.h +0 -15
  92. data/ext/zsv/vendor/zsv-1.3.0/app/external/memfile-1.0/src/memfile.c +0 -64
  93. data/ext/zsv/vendor/zsv-1.3.0/app/external/sglib/sglib.h +0 -1955
  94. data/ext/zsv/vendor/zsv-1.3.0/app/external/simdutf/simdutf.h +0 -6802
  95. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3.c +0 -230517
  96. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3.h +0 -12174
  97. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_and_csv_vtab.c +0 -2
  98. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab-mem.c +0 -142
  99. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab-mem.h +0 -49
  100. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab-zsv.c +0 -485
  101. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3_csv_vtab.c +0 -1015
  102. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/sqlite3ext.h +0 -663
  103. data/ext/zsv/vendor/zsv-1.3.0/app/external/sqlite3/vtab_helper.c +0 -85
  104. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_common.h +0 -75
  105. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_gen.h +0 -167
  106. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_parse.h +0 -228
  107. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_tree.h +0 -186
  108. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/build/yajl-2.1.1/include/yajl/yajl_version.h +0 -23
  109. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_common.h +0 -76
  110. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_gen.h +0 -167
  111. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_parse.h +0 -238
  112. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/api/yajl_tree.h +0 -186
  113. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl.c +0 -184
  114. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_alloc.c +0 -52
  115. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_alloc.h +0 -34
  116. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_buf.c +0 -103
  117. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_buf.h +0 -57
  118. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_bytestack.h +0 -69
  119. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_encode.c +0 -220
  120. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_encode.h +0 -34
  121. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_gen.c +0 -362
  122. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_lex.c +0 -764
  123. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_lex.h +0 -117
  124. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_parser.c +0 -508
  125. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_parser.h +0 -78
  126. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_tree.c +0 -505
  127. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl/src/yajl_version.c +0 -7
  128. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper/json_value.h +0 -59
  129. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper/yajl_helper.h +0 -208
  130. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper.c +0 -795
  131. data/ext/zsv/vendor/zsv-1.3.0/app/external/yajl_helper/yajl_helper_internal.h +0 -28
  132. data/ext/zsv/vendor/zsv-1.3.0/app/flatten.c +0 -851
  133. data/ext/zsv/vendor/zsv-1.3.0/app/jq.c +0 -106
  134. data/ext/zsv/vendor/zsv-1.3.0/app/jq.h +0 -6
  135. data/ext/zsv/vendor/zsv-1.3.0/app/mv.c +0 -113
  136. data/ext/zsv/vendor/zsv-1.3.0/app/noop.c +0 -90
  137. data/ext/zsv/vendor/zsv-1.3.0/app/overwrite.c +0 -295
  138. data/ext/zsv/vendor/zsv-1.3.0/app/paste.c +0 -175
  139. data/ext/zsv/vendor/zsv-1.3.0/app/pretty.c +0 -693
  140. data/ext/zsv/vendor/zsv-1.3.0/app/prop.c +0 -980
  141. data/ext/zsv/vendor/zsv-1.3.0/app/rm.c +0 -131
  142. data/ext/zsv/vendor/zsv-1.3.0/app/select/fixed.c +0 -130
  143. data/ext/zsv/vendor/zsv-1.3.0/app/select/internal.h +0 -118
  144. data/ext/zsv/vendor/zsv-1.3.0/app/select/parallel.c +0 -45
  145. data/ext/zsv/vendor/zsv-1.3.0/app/select/parallel.h +0 -41
  146. data/ext/zsv/vendor/zsv-1.3.0/app/select/processing.c +0 -107
  147. data/ext/zsv/vendor/zsv-1.3.0/app/select/rand.c +0 -20
  148. data/ext/zsv/vendor/zsv-1.3.0/app/select/regex.c +0 -61
  149. data/ext/zsv/vendor/zsv-1.3.0/app/select/search.c +0 -14
  150. data/ext/zsv/vendor/zsv-1.3.0/app/select/selection.c +0 -192
  151. data/ext/zsv/vendor/zsv-1.3.0/app/select/usage.c +0 -72
  152. data/ext/zsv/vendor/zsv-1.3.0/app/select-pull.c +0 -812
  153. data/ext/zsv/vendor/zsv-1.3.0/app/select.c +0 -753
  154. data/ext/zsv/vendor/zsv-1.3.0/app/serialize.c +0 -372
  155. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/curses.h +0 -15
  156. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/cursor.c +0 -119
  157. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/errors.c +0 -45
  158. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/file.c +0 -63
  159. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/file.h +0 -12
  160. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/filter.c +0 -166
  161. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/handlers.c +0 -214
  162. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/handlers_internal.h +0 -128
  163. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/help.c +0 -43
  164. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/index.c +0 -81
  165. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/index.h +0 -25
  166. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/key-bindings.c +0 -325
  167. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/key-bindings.h +0 -73
  168. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/lexer.c +0 -203
  169. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/newline_handler.c +0 -7
  170. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/pivot.c +0 -318
  171. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/procedure.c +0 -134
  172. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/procedure.h +0 -119
  173. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/read-data.c +0 -322
  174. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/screen_buffer.c +0 -203
  175. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/screen_buffer.h +0 -36
  176. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/sheet-sql.c +0 -167
  177. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/sheet_internal.h +0 -36
  178. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/sqlfilter.c +0 -153
  179. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/terminfo.c +0 -32
  180. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/transformation.c +0 -312
  181. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/transformation.h +0 -29
  182. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/ui_buffer.c +0 -266
  183. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/usage.c +0 -9
  184. data/ext/zsv/vendor/zsv-1.3.0/app/sheet/utf8-width.c +0 -60
  185. data/ext/zsv/vendor/zsv-1.3.0/app/sheet.c +0 -1007
  186. data/ext/zsv/vendor/zsv-1.3.0/app/sql.c +0 -453
  187. data/ext/zsv/vendor/zsv-1.3.0/app/sql_internal.c +0 -101
  188. data/ext/zsv/vendor/zsv-1.3.0/app/sql_internal.h +0 -49
  189. data/ext/zsv/vendor/zsv-1.3.0/app/stack.c +0 -393
  190. data/ext/zsv/vendor/zsv-1.3.0/app/utils/arg.c +0 -322
  191. data/ext/zsv/vendor/zsv-1.3.0/app/utils/cache.c +0 -228
  192. data/ext/zsv/vendor/zsv-1.3.0/app/utils/cat.c +0 -91
  193. data/ext/zsv/vendor/zsv-1.3.0/app/utils/chunk.c +0 -240
  194. data/ext/zsv/vendor/zsv-1.3.0/app/utils/chunk.h +0 -63
  195. data/ext/zsv/vendor/zsv-1.3.0/app/utils/clock.c +0 -57
  196. data/ext/zsv/vendor/zsv-1.3.0/app/utils/db.c +0 -148
  197. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs-no-jq.c +0 -2
  198. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs.c +0 -427
  199. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs_from_json.c +0 -253
  200. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dirs_to_json.c +0 -121
  201. data/ext/zsv/vendor/zsv-1.3.0/app/utils/dl.c +0 -20
  202. data/ext/zsv/vendor/zsv-1.3.0/app/utils/emcc/fs_api.c +0 -159
  203. data/ext/zsv/vendor/zsv-1.3.0/app/utils/err.c +0 -24
  204. data/ext/zsv/vendor/zsv-1.3.0/app/utils/file-mem.c +0 -180
  205. data/ext/zsv/vendor/zsv-1.3.0/app/utils/file.c +0 -256
  206. data/ext/zsv/vendor/zsv-1.3.0/app/utils/index.c +0 -197
  207. data/ext/zsv/vendor/zsv-1.3.0/app/utils/index.h +0 -49
  208. data/ext/zsv/vendor/zsv-1.3.0/app/utils/jq.c +0 -400
  209. data/ext/zsv/vendor/zsv-1.3.0/app/utils/json.c +0 -120
  210. data/ext/zsv/vendor/zsv-1.3.0/app/utils/mem.c +0 -18
  211. data/ext/zsv/vendor/zsv-1.3.0/app/utils/memmem.c +0 -132
  212. data/ext/zsv/vendor/zsv-1.3.0/app/utils/os.c +0 -178
  213. data/ext/zsv/vendor/zsv-1.3.0/app/utils/overwrite.c +0 -258
  214. data/ext/zsv/vendor/zsv-1.3.0/app/utils/overwrite_writer.c +0 -246
  215. data/ext/zsv/vendor/zsv-1.3.0/app/utils/pcre2-8/pcre2-8-test.c +0 -123
  216. data/ext/zsv/vendor/zsv-1.3.0/app/utils/pcre2-8/pcre2-8.c +0 -153
  217. data/ext/zsv/vendor/zsv-1.3.0/app/utils/pcre2-8/pcre2-8.h +0 -54
  218. data/ext/zsv/vendor/zsv-1.3.0/app/utils/prop.c +0 -267
  219. data/ext/zsv/vendor/zsv-1.3.0/app/utils/signal.c +0 -53
  220. data/ext/zsv/vendor/zsv-1.3.0/app/utils/string.c +0 -357
  221. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/dir_exists_longpath.c +0 -83
  222. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/dl.c +0 -33
  223. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/fopen_longpath.c +0 -184
  224. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/foreach_dirent_longpath.c +0 -292
  225. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/io.c +0 -259
  226. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/io.h +0 -13
  227. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/mkdir_longpath.c +0 -255
  228. data/ext/zsv/vendor/zsv-1.3.0/app/utils/win/remove_longpath.c +0 -96
  229. data/ext/zsv/vendor/zsv-1.3.0/app/utils/writer.c +0 -361
  230. data/ext/zsv/vendor/zsv-1.3.0/app/zsv_command.h +0 -40
  231. data/ext/zsv/vendor/zsv-1.3.0/app/zsv_command_standalone.c +0 -16
  232. data/ext/zsv/vendor/zsv-1.3.0/app/zsv_main.h +0 -44
  233. data/ext/zsv/vendor/zsv-1.3.0/examples/js/zsv_parser_api_dummy.c +0 -3
  234. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/parse_by_chunk.c +0 -100
  235. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/print_my_column.c +0 -143
  236. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/pull.c +0 -89
  237. data/ext/zsv/vendor/zsv-1.3.0/examples/lib/simple.c +0 -123
  238. data/ext/zsv/vendor/zsv-1.3.0/fuzz/fuzz.c +0 -16
  239. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/os.h +0 -54
  240. data/ext/zsv/vendor/zsv-1.3.0/include/zsv/utils/sql.h +0 -11
  241. data/ext/zsv/vendor/zsv-1.3.0/src/zsv_strencode.c +0 -51
  242. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/ext/implementation.h +0 -0
  243. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/ext/implementation_private.h +0 -0
  244. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/cache.h +0 -0
  245. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/clock.h +0 -0
  246. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/db.h +0 -0
  247. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/dl.h +0 -0
  248. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/emcc/fs_api.h +0 -0
  249. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/err.h +0 -0
  250. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/jq.h +0 -0
  251. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/json.h +0 -0
  252. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/mem.h +0 -0
  253. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/memmem.h +0 -0
  254. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/overwrite.h +0 -0
  255. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/utf8.h +0 -0
  256. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/include/zsv/utils/win/dl.h +0 -0
  257. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/src/vector_delim.c +0 -0
  258. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/src/zsv_scan_delim.c +0 -0
  259. /data/ext/zsv/vendor/{zsv-1.3.0 → zsv}/src/zsv_scan_fixed.c +0 -0
@@ -1,325 +0,0 @@
1
- #include "procedure.h"
2
- #include "key-bindings.h"
3
-
4
- #include <errno.h>
5
- #include <stdio.h>
6
- #include <assert.h>
7
-
8
- #ifndef ZSVSHEET_CTRL
9
- /* clang-format off */
10
- #define ZSVSHEET_CTRL(c) ((c)&037)
11
- /* clang-format on */
12
- #endif
13
-
14
- #if 0
15
- #define keyb_debug(...) fprintf(stderr, __VA_ARGS__)
16
- #else
17
- #define keyb_debug(...) ((void)0)
18
- #endif
19
-
20
- #define MAX_KEY_BINDINGS 512
21
-
22
- static int prev_ch = -1;
23
- static struct zsvsheet_key_binding key_bindings[MAX_KEY_BINDINGS] = {0};
24
-
25
- zsvsheet_status zsvsheet_proc_key_binding_handler(struct zsvsheet_key_binding_context *ctx) {
26
- return zsvsheet_proc_invoke_from_keypress(ctx->binding->proc_id, ctx->ch, ctx->subcommand_context);
27
- }
28
-
29
- int zsvsheet_register_key_binding(struct zsvsheet_key_binding *binding) {
30
- if (binding->ch && zsvsheet_find_key_binding(binding->ch))
31
- return EEXIST; /* Key bound already */
32
-
33
- if (binding->proc_id != ZSVSHEET_PROC_INVALID && binding->handler == NULL)
34
- binding->handler = zsvsheet_proc_key_binding_handler;
35
-
36
- assert(binding->handler);
37
-
38
- for (int i = 0; i < MAX_KEY_BINDINGS; ++i) {
39
- if (key_bindings[i].taken == 0) {
40
- key_bindings[i] = *binding;
41
- key_bindings[i].taken = 1;
42
- return 0;
43
- }
44
- }
45
-
46
- return -ENOMEM;
47
- }
48
-
49
- int zsvsheet_register_proc_key_binding(char ch, zsvsheet_proc_id_t proc_id) {
50
- struct zsvsheet_key_binding binding = {
51
- .ch = ch,
52
- .proc_id = proc_id,
53
- };
54
- return zsvsheet_register_key_binding(&binding);
55
- }
56
-
57
- struct zsvsheet_key_binding *zsvsheet_get_key_binding(size_t i) {
58
- if (i >= MAX_KEY_BINDINGS)
59
- return NULL;
60
-
61
- if (key_bindings[i].ch != -1)
62
- return &key_bindings[i];
63
-
64
- return NULL;
65
- }
66
-
67
- struct zsvsheet_key_binding *zsvsheet_find_key_binding(int ch) {
68
- for (int i = 0; i < MAX_KEY_BINDINGS; ++i) {
69
- if (key_bindings[i].ch == ch)
70
- return &key_bindings[i];
71
- }
72
- return NULL;
73
- }
74
-
75
- /* Subcommand context, that we later pass to procedures, seems a little out
76
- * of place here. Alternatively this function could only return the binding
77
- * and allow user to execute it.
78
- */
79
- zsvsheet_status zsvsheet_key_press(int ch, void *subcommand_context) {
80
- int ret = zsvsheet_status_error;
81
- struct zsvsheet_key_binding *binding;
82
- struct zsvsheet_key_binding_context ctx;
83
-
84
- keyb_debug("key press %d prev %d\n", ch, prev_ch);
85
-
86
- binding = zsvsheet_find_key_binding(ch);
87
- if (!binding)
88
- goto not_found;
89
-
90
- ctx.ch = ch;
91
- ctx.prev_ch = prev_ch;
92
- ctx.binding = binding;
93
- ctx.subcommand_context = subcommand_context;
94
- ret = binding->handler(&ctx);
95
- not_found:
96
- prev_ch = ch;
97
- return ret;
98
- }
99
-
100
- /*
101
- * Specific key bindings
102
- */
103
-
104
- void zsvsheet_register_builtin_key_bindings(struct zsvsheet_key_binding *arr) {
105
- for (struct zsvsheet_key_binding *binding = arr; binding->ch != -1; ++binding)
106
- zsvsheet_register_key_binding(binding);
107
- }
108
-
109
- /*
110
- * VIM key bindings
111
- */
112
-
113
- zsvsheet_status zsvsheet_vim_g_key_binding_dmux_handler(struct zsvsheet_key_binding_context *ctx) {
114
- /* Double g takes you to the top of the file in vim. We need to wait for the
115
- * second g in a row to execute the procedure */
116
- if (ctx->prev_ch == 'g') {
117
- if (ctx->ch == ctx->prev_ch)
118
- return zsvsheet_proc_invoke_from_keypress(zsvsheet_builtin_proc_move_top, ctx->ch, ctx->subcommand_context);
119
- else if (ctx->ch == '/')
120
- return zsvsheet_proc_invoke_from_keypress(zsvsheet_builtin_proc_sqlfilter, ctx->ch, ctx->subcommand_context);
121
- }
122
- return zsvsheet_status_ok;
123
- }
124
-
125
- /* clang-format off */
126
- struct zsvsheet_key_binding zsvsheet_vim_key_bindings[] = {
127
- { .ch = 'q', .proc_id = zsvsheet_builtin_proc_quit, },
128
-
129
- { .ch = 27, .proc_id = zsvsheet_builtin_proc_escape, },
130
- {
131
- .ch = KEY_RESIZE,
132
- .proc_id = zsvsheet_builtin_proc_resize,
133
- .hidden = 1,
134
- },
135
- { .ch = '^', .proc_id = zsvsheet_builtin_proc_move_first_col,},
136
- { .ch = '$', .proc_id = zsvsheet_builtin_proc_move_last_col, },
137
- { .ch = KEY_SLEFT, .proc_id = zsvsheet_builtin_proc_move_first_col,},
138
- { .ch = KEY_SRIGHT, .proc_id = zsvsheet_builtin_proc_move_last_col, },
139
-
140
- { .ch = 'k', .proc_id = zsvsheet_builtin_proc_move_up, },
141
- { .ch = 'j', .proc_id = zsvsheet_builtin_proc_move_down, },
142
- { .ch = 'h', .proc_id = zsvsheet_builtin_proc_move_left, },
143
- { .ch = 'l', .proc_id = zsvsheet_builtin_proc_move_right, },
144
- { .ch = KEY_UP, .proc_id = zsvsheet_builtin_proc_move_up, },
145
- { .ch = KEY_DOWN, .proc_id = zsvsheet_builtin_proc_move_down, },
146
- { .ch = KEY_LEFT, .proc_id = zsvsheet_builtin_proc_move_left, },
147
- { .ch = KEY_RIGHT, .proc_id = zsvsheet_builtin_proc_move_right, },
148
-
149
- { .ch = ZSVSHEET_CTRL('d'), .proc_id = zsvsheet_builtin_proc_pg_down, },
150
- { .ch = ZSVSHEET_CTRL('u'), .proc_id = zsvsheet_builtin_proc_pg_up, },
151
- { .ch = KEY_NPAGE, .proc_id = zsvsheet_builtin_proc_pg_down, },
152
- { .ch = KEY_PPAGE, .proc_id = zsvsheet_builtin_proc_pg_up, },
153
-
154
- {
155
- .ch = 'g',
156
- .ch_name = "g g",
157
- .proc_id = zsvsheet_builtin_proc_move_top,
158
- .handler = zsvsheet_vim_g_key_binding_dmux_handler
159
- },
160
- { .ch = 'G', .proc_id = zsvsheet_builtin_proc_move_bottom, },
161
- /* Shift up/down also move you to the top/bottom of the page
162
- * TODO: Figure out how to map KEY_SUP and KEY_SDOWN (curses doesn't implement)
163
- */
164
- // { .ch = KEY_SUP, .proc_id = zsvsheet_builtin_proc_move_top, },
165
- // { .ch = KEY_SDOWN, .proc_id = zsvsheet_builtin_proc_move_bottom, },
166
-
167
- { .ch = '/', .proc_id = zsvsheet_builtin_proc_find, },
168
- { .ch = 'n', .proc_id = zsvsheet_builtin_proc_find_next, },
169
-
170
- { .ch = '|', .proc_id = zsvsheet_builtin_proc_goto_column, },
171
-
172
- /* Open is a subcommand only in vim. Keeping the binding for now */
173
- { .ch = 'e', .proc_id = zsvsheet_builtin_proc_open_file, },
174
- { .ch = 'f', .proc_id = zsvsheet_builtin_proc_filter, },
175
- { .ch = 'F', .proc_id = zsvsheet_builtin_proc_filter_this, },
176
- { .ch = ':', .proc_id = zsvsheet_builtin_proc_subcommand, },
177
- { .ch = '?', .proc_id = zsvsheet_builtin_proc_help, },
178
- { .ch = '\n', .proc_id = zsvsheet_builtin_proc_newline, },
179
- { .ch = '\r', .proc_id = zsvsheet_builtin_proc_newline, },
180
- { .ch = 'v', .proc_id = zsvsheet_builtin_proc_pivot_cur_col, },
181
- { .ch = 'V', .proc_id = zsvsheet_builtin_proc_pivot_expr, },
182
- {
183
- .ch = '\0',
184
- .ch_name = "",
185
- .proc_id = zsvsheet_builtin_proc_sqlfilter,
186
- },
187
- {
188
- .ch = '\0',
189
- .ch_name = "",
190
- .proc_id = zsvsheet_builtin_proc_errors,
191
- },
192
- {
193
- .ch = '\0',
194
- .ch_name = "",
195
- .proc_id = zsvsheet_builtin_proc_errors_clear,
196
- },
197
- { .ch = -1 }
198
- };
199
- /* clang-format on */
200
-
201
- void zsvsheet_register_vim_key_bindings(void) {
202
- zsvsheet_register_builtin_key_bindings(zsvsheet_vim_key_bindings);
203
- }
204
-
205
- /*
206
- * EMACS key bindings
207
- */
208
-
209
- zsvsheet_status zsvsheet_emacs_Cx_key_binding_dmux_handler(struct zsvsheet_key_binding_context *ctx) {
210
- if (ctx->ch == ZSVSHEET_CTRL('c'))
211
- return zsvsheet_proc_invoke_from_keypress(zsvsheet_builtin_proc_quit, ctx->ch, ctx->subcommand_context);
212
- return zsvsheet_status_ok;
213
- }
214
-
215
- zsvsheet_status zsvsheet_emacs_Cf_key_binding_dmux_handler(struct zsvsheet_key_binding_context *ctx) {
216
- if (ctx->prev_ch == ZSVSHEET_CTRL('x') && ctx->ch == ZSVSHEET_CTRL('f'))
217
- return zsvsheet_proc_invoke_from_keypress(zsvsheet_builtin_proc_open_file, ctx->ch, ctx->subcommand_context);
218
- return zsvsheet_status_ok;
219
- }
220
-
221
- zsvsheet_status zsvsheet_emacs_Cs_key_binding_dmux_handler(struct zsvsheet_key_binding_context *ctx) {
222
- (void)(ctx);
223
- return zsvsheet_status_ok;
224
- }
225
-
226
- /* clang-format off */
227
- struct zsvsheet_key_binding zsvsheet_emacs_key_bindings[] = {
228
- { .ch = 27, .proc_id = zsvsheet_builtin_proc_escape, },
229
- {
230
- .ch = KEY_RESIZE,
231
- .proc_id = zsvsheet_builtin_proc_resize,
232
- .hidden = 1,
233
- },
234
- { .ch = ZSVSHEET_CTRL('a'), .proc_id = zsvsheet_builtin_proc_move_first_col,},
235
- { .ch = ZSVSHEET_CTRL('e'), .proc_id = zsvsheet_builtin_proc_move_last_col,},
236
-
237
- { .ch = KEY_UP, .proc_id = zsvsheet_builtin_proc_move_up, },
238
- { .ch = KEY_DOWN, .proc_id = zsvsheet_builtin_proc_move_down, },
239
- { .ch = KEY_LEFT, .proc_id = zsvsheet_builtin_proc_move_left, },
240
- { .ch = KEY_RIGHT, .proc_id = zsvsheet_builtin_proc_move_right, },
241
-
242
- { .ch = ZSVSHEET_CTRL('v'), .proc_id = zsvsheet_builtin_proc_pg_down, },
243
- { .ch = ZSVSHEET_CTRL('u'), .proc_id = zsvsheet_builtin_proc_pg_up, },
244
- { .ch = KEY_NPAGE, .proc_id = zsvsheet_builtin_proc_pg_down, },
245
- { .ch = KEY_PPAGE, .proc_id = zsvsheet_builtin_proc_pg_up, },
246
-
247
- // TODO: find is ctrl-s in emacs, pressed again causes find next.
248
- // However, it is being captured by the shell. Figure out
249
- // how to prevent that, if emacs can we can do it too.
250
- //{ .ch = ZSVSHEET_CTRL('s'), .handler = zsvsheet_emacs_Cs_key_binding_dmux_handler, },
251
-
252
- { .ch = ZSVSHEET_CTRL('f'), .handler = zsvsheet_emacs_Cf_key_binding_dmux_handler, },
253
- /* No such thing in emacs, find a more suitable binding */
254
- { .ch = 'f', .proc_id = zsvsheet_builtin_proc_filter, },
255
- { .ch = 'F', .proc_id = zsvsheet_builtin_proc_filter_this, },
256
- { .ch = '|', .proc_id = zsvsheet_builtin_proc_goto_column, },
257
- { .ch = ZSVSHEET_CTRL('h'), .proc_id = zsvsheet_builtin_proc_help, },
258
- { .ch = '\n', .proc_id = zsvsheet_builtin_proc_newline, },
259
- { .ch = '\r', .proc_id = zsvsheet_builtin_proc_newline, },
260
-
261
- { .ch = 'v', .proc_id = zsvsheet_builtin_proc_pivot_cur_col, },
262
- { .ch = 'V', .proc_id = zsvsheet_builtin_proc_pivot_expr, },
263
- {
264
- .ch = '\0',
265
- .ch_name = "",
266
- .proc_id = zsvsheet_builtin_proc_sqlfilter,
267
- },
268
- {
269
- .ch = '\0',
270
- .ch_name = "",
271
- .proc_id = zsvsheet_builtin_proc_errors,
272
- },
273
- {
274
- .ch = '\0',
275
- .ch_name = "",
276
- .proc_id = zsvsheet_builtin_proc_errors_clear,
277
- },
278
-
279
- { .ch = -1 }
280
- };
281
- /* clang-format on */
282
-
283
- void zsvsheet_register_emacs_key_bindings(void) {
284
- zsvsheet_register_builtin_key_bindings(zsvsheet_emacs_key_bindings);
285
- }
286
-
287
- struct zsvsheet_ch_name {
288
- int ch;
289
- const char *name;
290
- };
291
-
292
- /* clang-format off */
293
- struct zsvsheet_ch_name zsvsheet_common_ch_names[] = {
294
- { .ch = KEY_RESIZE, .name = "<resize>" },
295
- { .ch = 27, .name = "<esc>" },
296
- { .ch = KEY_SLEFT, .name = "<shift><left>" },
297
- { .ch = KEY_SRIGHT, .name = "<shift><right>" },
298
- { .ch = KEY_UP, .name = "<up>" },
299
- { .ch = KEY_DOWN, .name = "<down>" },
300
- { .ch = KEY_LEFT, .name = "<left>" },
301
- { .ch = KEY_RIGHT, .name = "<right>" },
302
- { .ch = ZSVSHEET_CTRL('a'), .name = "<ctrl>a" },
303
- { .ch = ZSVSHEET_CTRL('d'), .name = "<ctrl>d" },
304
- { .ch = ZSVSHEET_CTRL('e'), .name = "<ctrl>e" },
305
- { .ch = ZSVSHEET_CTRL('f'), .name = "<ctrl>f" },
306
- { .ch = ZSVSHEET_CTRL('h'), .name = "<ctrl>f" },
307
- { .ch = ZSVSHEET_CTRL('u'), .name = "<ctrl>u" },
308
- { .ch = ZSVSHEET_CTRL('v'), .name = "<ctrl>v" },
309
- { .ch = KEY_NPAGE, .name = "<page up>" },
310
- { .ch = KEY_PPAGE, .name = "<page down>" },
311
- { .ch = -1 },
312
- };
313
- /* clang-format on */
314
-
315
- const char *zsvsheet_key_binding_ch_name(struct zsvsheet_key_binding *binding) {
316
- if (binding->ch_name)
317
- return binding->ch_name;
318
-
319
- for (int i = 0; zsvsheet_common_ch_names[i].ch != -1; i++) {
320
- if (zsvsheet_common_ch_names[i].ch == binding->ch)
321
- return zsvsheet_common_ch_names[i].name;
322
- }
323
-
324
- return keyname(binding->ch);
325
- }
@@ -1,73 +0,0 @@
1
- #ifndef ZSVSHEET_KEY_BINDINGS_H
2
- #define ZSVSHEET_KEY_BINDINGS_H
3
- #include "procedure.h"
4
-
5
- enum zsvsheet_key {
6
- zsvsheet_key_unknown = 0,
7
- zsvsheet_key_quit,
8
- zsvsheet_key_escape,
9
- zsvsheet_key_move_bottom,
10
- zsvsheet_key_move_top,
11
- zsvsheet_key_move_first_col,
12
- zsvsheet_key_pg_down,
13
- zsvsheet_key_pg_up,
14
- zsvsheet_key_move_last_col,
15
- zsvsheet_key_move_up,
16
- zsvsheet_key_move_down,
17
- zsvsheet_key_move_left,
18
- zsvsheet_key_move_right,
19
- zsvsheet_key_filter,
20
- zsvsheet_key_find,
21
- zsvsheet_key_find_next,
22
- zsvsheet_key_goto_column,
23
- zsvsheet_key_open_file,
24
- zsvsheet_key_resize,
25
- zsvsheet_key_question,
26
- };
27
-
28
- struct zsvsheet_key_binding_context;
29
-
30
- typedef zsvsheet_status (*zsvsheet_key_binding_fn)(struct zsvsheet_key_binding_context *);
31
-
32
- /* Most key bindings will simply execute a procedure, handler then becomes
33
- * a simple wrapper around proc_invoke. More sophisticated key mappings can
34
- * be implemented if need be by defining a custom handler */
35
- struct zsvsheet_key_binding {
36
- int ch;
37
- const char *ch_name;
38
- char hidden;
39
- zsvsheet_key_binding_fn handler;
40
- zsvsheet_proc_id_t proc_id;
41
- unsigned char taken : 1;
42
- unsigned char _ : 7;
43
- };
44
-
45
- struct zsvsheet_key_binding_context {
46
- int ch;
47
- int prev_ch;
48
- const struct zsvsheet_key_binding *binding;
49
- void *subcommand_context;
50
- };
51
-
52
- /* Use this one if you just need to call a procedure */
53
- int zsvsheet_register_proc_key_binding(char ch, zsvsheet_proc_id_t proc_id);
54
-
55
- /* Use this one if you key binding is stateful and you need logic */
56
- int zsvsheet_register_key_binding(struct zsvsheet_key_binding *binding);
57
-
58
- zsvsheet_status zsvsheet_key_press(int ch, void *subcommand_context);
59
-
60
- struct zsvsheet_key_binding *zsvsheet_get_key_binding(size_t i);
61
- struct zsvsheet_key_binding *zsvsheet_find_key_binding(int ch);
62
-
63
- /*
64
- * Specific key bindings
65
- */
66
-
67
- void zsvsheet_register_vim_key_bindings(void);
68
-
69
- void zsvsheet_register_emacs_key_bindings(void);
70
-
71
- const char *zsvsheet_key_binding_ch_name(struct zsvsheet_key_binding *binding);
72
-
73
- #endif
@@ -1,203 +0,0 @@
1
- #include <string.h>
2
-
3
- #if 0
4
- #define lexer_debug(FMT, ...) fprintf(stderr, "%s:%d: " FMT "\n", __func__, __LINE__, __VA_ARGS__)
5
- #else
6
- #define lexer_debug(...) ((void)0)
7
- #endif
8
-
9
- enum zsvsheet_lexer_status {
10
- zsvsheet_lexer_status_ok,
11
- zsvsheet_lexer_status_error,
12
- zsvsheet_lexer_status_nomem,
13
- zsvsheet_lexer_status_finish,
14
- };
15
-
16
- struct zsvsheet_lexer {
17
- const char *string;
18
- const char *rover;
19
- int left;
20
-
21
- char *tokbuf;
22
- int tokbufsz;
23
-
24
- char **toks;
25
- int max_toks;
26
- int num_toks;
27
- };
28
-
29
- void zsvsheet_lexer_init(struct zsvsheet_lexer *lexer, const char *string, char *tokbuf, int tokbufsz, char **toks,
30
- int max_toks) {
31
- lexer_debug("%s", string);
32
- lexer->string = string;
33
- lexer->rover = string;
34
- lexer->left = strlen(string);
35
-
36
- lexer->tokbuf = tokbuf;
37
- lexer->tokbufsz = tokbufsz;
38
-
39
- lexer->toks = toks;
40
- lexer->max_toks = max_toks;
41
- lexer->num_toks = 0;
42
- }
43
-
44
- int zsvsheet_lexer_skip_space(struct zsvsheet_lexer *lexer) {
45
- int orig_left = lexer->left;
46
- while (lexer->left > 0 && isspace(*lexer->rover)) {
47
- lexer->rover++;
48
- lexer->left--;
49
- }
50
- return orig_left - lexer->left;
51
- }
52
-
53
- int zsvsheet_lexer_skip_not_space(struct zsvsheet_lexer *lexer) {
54
- int orig_left = lexer->left;
55
- while (lexer->left > 0 && !isspace(*lexer->rover)) {
56
- lexer->rover++;
57
- lexer->left--;
58
- }
59
- return orig_left - lexer->left;
60
- }
61
-
62
- enum zsvsheet_lexer_status zsvsheet_lexer_append_char(struct zsvsheet_lexer *lexer, char c) {
63
- if (!lexer->tokbufsz)
64
- return zsvsheet_lexer_status_nomem;
65
- *(lexer->tokbuf++) = c;
66
- lexer->tokbufsz--;
67
- return zsvsheet_lexer_status_ok;
68
- }
69
-
70
- enum zsvsheet_lexer_status zsvsheet_lexer_append_escaped_char(struct zsvsheet_lexer *lexer, char c) {
71
- switch (c) {
72
- case 'a':
73
- return zsvsheet_lexer_append_char(lexer, (char)7);
74
- case 'b':
75
- return zsvsheet_lexer_append_char(lexer, (char)8);
76
- case 't':
77
- return zsvsheet_lexer_append_char(lexer, (char)9);
78
- case 'n':
79
- return zsvsheet_lexer_append_char(lexer, (char)10);
80
- case 'v':
81
- return zsvsheet_lexer_append_char(lexer, (char)11);
82
- case 'f':
83
- return zsvsheet_lexer_append_char(lexer, (char)12);
84
- case 'r':
85
- return zsvsheet_lexer_append_char(lexer, (char)13);
86
- case '"':
87
- return zsvsheet_lexer_append_char(lexer, (char)'"');
88
- case '\\':
89
- return zsvsheet_lexer_append_char(lexer, (char)'\\');
90
- // We don't allow for escaped zeros, our tokens are null terminated.
91
- // case '0': *(s++) = 0; break;
92
- default:
93
- lexer_debug("Invalid escape character '\\%c'", c);
94
- }
95
- return zsvsheet_lexer_status_error;
96
- }
97
-
98
- enum zsvsheet_lexer_status zsvsheet_lexer_extract_string(struct zsvsheet_lexer *lexer) {
99
- enum {
100
- ESCAPE = 0x1,
101
- START_QUOTE = 0x2,
102
- END_QUOTE = 0x4,
103
- };
104
- unsigned flags = 0;
105
- char *tokbuf_start = lexer->tokbuf;
106
- enum zsvsheet_lexer_status status;
107
-
108
- if (lexer->num_toks >= lexer->max_toks)
109
- return zsvsheet_lexer_status_nomem;
110
- if (lexer->left < 2 || *lexer->rover != '"')
111
- return zsvsheet_lexer_status_error;
112
-
113
- flags |= START_QUOTE;
114
- lexer->rover++;
115
- lexer->left--;
116
-
117
- while (lexer->left) {
118
- if (flags & ESCAPE) {
119
- if ((status = zsvsheet_lexer_append_escaped_char(lexer, *lexer->rover)))
120
- return status;
121
- flags &= ~ESCAPE;
122
- } else {
123
- if (*lexer->rover == '"') {
124
- flags |= END_QUOTE;
125
- lexer->rover++;
126
- lexer->left--;
127
- break;
128
- } else if (*lexer->rover == '\\') {
129
- flags |= ESCAPE;
130
- } else {
131
- if ((status = zsvsheet_lexer_append_char(lexer, *lexer->rover)))
132
- return status;
133
- }
134
- }
135
- lexer->rover++;
136
- lexer->left--;
137
- }
138
-
139
- if (flags & START_QUOTE) {
140
- if (!(flags & END_QUOTE)) {
141
- lexer_debug("Unterminated string: %s", lexer->string);
142
- return zsvsheet_lexer_status_error;
143
- }
144
- } else
145
- return 0;
146
-
147
- if ((status = zsvsheet_lexer_append_char(lexer, '\0')))
148
- return status;
149
-
150
- lexer->toks[lexer->num_toks] = tokbuf_start;
151
- lexer->num_toks += 1;
152
-
153
- return zsvsheet_lexer_status_ok;
154
- }
155
-
156
- enum zsvsheet_lexer_status zsvsheet_lexer_extract_word(struct zsvsheet_lexer *lexer) {
157
- int extracted;
158
- const char *token = lexer->rover;
159
- extracted = zsvsheet_lexer_skip_not_space(lexer);
160
- if (extracted == 0)
161
- return zsvsheet_lexer_status_error;
162
- if (extracted + 1 > lexer->tokbufsz)
163
- return zsvsheet_lexer_status_nomem;
164
- if (lexer->num_toks >= lexer->max_toks)
165
- return zsvsheet_lexer_status_nomem;
166
- memcpy(lexer->tokbuf, token, extracted);
167
- lexer->tokbuf[extracted] = '\0';
168
- lexer->toks[lexer->num_toks] = lexer->tokbuf;
169
- lexer->num_toks += 1;
170
- lexer->tokbuf += extracted + 1;
171
- lexer->tokbufsz -= extracted + 1;
172
- return zsvsheet_lexer_status_ok;
173
- }
174
-
175
- enum zsvsheet_lexer_status zsvsheet_lexer_parse_token(struct zsvsheet_lexer *lexer) {
176
- enum zsvsheet_lexer_status status;
177
-
178
- zsvsheet_lexer_skip_space(lexer);
179
- if (!lexer->left)
180
- return zsvsheet_lexer_status_finish;
181
-
182
- if (*lexer->rover == '"')
183
- status = zsvsheet_lexer_extract_string(lexer);
184
- else
185
- status = zsvsheet_lexer_extract_word(lexer);
186
- lexer_debug("status=%d num_toks=%d left=%d", status, lexer->num_toks, lexer->left);
187
- return status;
188
- }
189
-
190
- enum zsvsheet_lexer_status zsvsheet_lexer_parse(struct zsvsheet_lexer *lexer) {
191
- enum zsvsheet_lexer_status status;
192
- while (true) {
193
- status = zsvsheet_lexer_parse_token(lexer);
194
- lexer_debug("status=%d", status);
195
- if (status == zsvsheet_lexer_status_ok)
196
- continue;
197
- else
198
- break;
199
- }
200
- if (status == zsvsheet_lexer_status_finish)
201
- status = zsvsheet_lexer_status_ok;
202
- return status;
203
- }
@@ -1,7 +0,0 @@
1
- static zsvsheet_status zsvsheet_newline_handler(struct zsvsheet_proc_context *ctx) {
2
- struct zsvsheet_sheet_context *state = (struct zsvsheet_sheet_context *)ctx->subcommand_context;
3
- struct zsvsheet_ui_buffer *current_ui_buffer = *state->display_info.ui_buffers.current;
4
- if (current_ui_buffer->on_newline)
5
- current_ui_buffer->on_newline(ctx);
6
- return zsvsheet_status_ok;
7
- }