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,322 +0,0 @@
1
- #include <stdlib.h>
2
- #include <string.h>
3
- #include <pthread.h>
4
- #include <zsv/utils/prop.h>
5
- #include "sheet_internal.h"
6
- #include "screen_buffer.h"
7
- #include "../utils/index.h"
8
- #include "index.h"
9
-
10
- #if defined(WIN32) || defined(_WIN32)
11
- #ifndef NO_MEMMEM
12
- #define NO_MEMMEM
13
- #endif
14
- #include <zsv/utils/memmem.h>
15
- #endif
16
- #include <zsv/utils/writer.h>
17
- #include <zsv/utils/file.h>
18
-
19
- // zsvsheet_found_in_row: return 0 if not found, else 1-based index of column
20
- static size_t zsvsheet_found_in_row(zsv_parser parser, size_t col_start, size_t col_count, const char *target,
21
- size_t target_len, size_t specified_column_plus_1,
22
- char find_exact // not yet implemented
23
- ) {
24
- if (col_start >= col_count)
25
- return 0;
26
-
27
- struct zsv_cell first_cell = zsv_get_cell(parser, col_start);
28
- struct zsv_cell last_cell = zsv_get_cell(parser, col_count - 1);
29
-
30
- if (memmem(first_cell.str, last_cell.str - first_cell.str + last_cell.len, target, target_len)) {
31
- for (size_t i = col_start; i < col_count; i++) {
32
- if (specified_column_plus_1 == 0 || i + 1 == specified_column_plus_1) {
33
- struct zsv_cell c = zsv_get_cell(parser, i);
34
- if (find_exact) {
35
- if (c.len == target_len && !memcmp(c.str, target, c.len))
36
- return i + 1;
37
- } else if (memmem(c.str, c.len, target, target_len))
38
- return i + 1;
39
- }
40
- }
41
- }
42
- return 0;
43
- }
44
-
45
- static void *get_data_index(void *d);
46
-
47
- static void get_data_index_async(struct zsvsheet_ui_buffer *uibuffp, const char *filename, struct zsv_opts *optsp,
48
- struct zsv_prop_handler *custom_prop_handler, char *old_ui_status) {
49
- struct zsvsheet_index_opts *ixopts = calloc(1, sizeof(*ixopts));
50
- ixopts->mutexp = &uibuffp->mutex;
51
- ixopts->filename = filename;
52
- ixopts->zsv_opts = *optsp;
53
- ixopts->custom_prop_handler = custom_prop_handler;
54
- ixopts->uib = uibuffp;
55
- ixopts->uib->ixopts = ixopts;
56
- ixopts->old_ui_status = old_ui_status;
57
-
58
- if (uibuffp->worker_active)
59
- zsvsheet_ui_buffer_join_worker(uibuffp);
60
- zsvsheet_ui_buffer_create_worker(uibuffp, get_data_index, ixopts);
61
- }
62
-
63
- static int read_data(struct zsvsheet_ui_buffer **uibufferp, // a new zsvsheet_ui_buffer will be allocated
64
- struct zsvsheet_ui_buffer_opts *uibopts, // if *uibufferp == NULL and uibopts != NULL
65
- size_t start_row, size_t start_col, size_t header_span, struct zsvsheet_opts *zsvsheet_opts,
66
- struct zsv_prop_handler *custom_prop_handler) {
67
- int rc = 0;
68
- struct uib_parse_errs parse_errs;
69
- uib_parse_errs_init(&parse_errs, 100);
70
- FILE *fp = NULL;
71
- const char *filename = (uibufferp && *uibufferp) ? (*uibufferp)->filename : uibopts ? uibopts->filename : NULL;
72
- struct zsv_opts opts = {0};
73
- if (uibufferp && *uibufferp)
74
- opts = (*uibufferp)->zsv_opts;
75
- else if (uibopts)
76
- opts = uibopts->zsv_opts;
77
-
78
- struct zsvsheet_ui_buffer *uibuff = uibufferp ? *uibufferp : NULL;
79
- size_t remaining_rows_to_skip = start_row;
80
- size_t remaining_header_to_skip = header_span;
81
- size_t original_row_num = 0;
82
-
83
- if (uibuff) {
84
- if (uibuff->data_filename)
85
- filename = uibuff->data_filename;
86
- else if (uibuff->filename)
87
- filename = uibuff->filename;
88
- }
89
-
90
- if (!filename && uibopts) {
91
- if (uibopts->data_filename)
92
- filename = uibopts->data_filename;
93
- else if (uibopts->filename)
94
- filename = uibopts->filename;
95
- }
96
-
97
- assert(filename != NULL);
98
- fp = fopen(filename, "rb");
99
- if (!fp) {
100
- rc = errno;
101
- goto done;
102
- }
103
-
104
- opts.stream = fp; // Input file stream
105
-
106
- opts.errprintf = uib_parse_errs_printf;
107
- if (uibuff)
108
- opts.errf = &uibuff->parse_errs;
109
- else
110
- opts.errf = &parse_errs;
111
-
112
- zsv_parser parser = {0};
113
- if (zsv_new_with_properties(&opts, custom_prop_handler, filename, &parser) != zsv_status_ok) {
114
- rc = errno ? errno : -1;
115
- goto done;
116
- }
117
-
118
- // clear error logging before reusing opts
119
- opts.errprintf = zsv_no_printf;
120
- if (uibuff) {
121
- pthread_mutex_lock(&uibuff->mutex);
122
-
123
- enum zsv_index_status zst = zsv_index_status_ok;
124
- if (zsvsheet_ui_buffer_index_ready(uibuff, 1)) {
125
- opts.header_span = 0;
126
- opts.rows_to_ignore = 0;
127
-
128
- zst = zsv_index_seek_row(uibuff->index, &opts, start_row);
129
-
130
- zsv_delete(parser);
131
- parser = zsv_new(&opts);
132
-
133
- remaining_header_to_skip = 0;
134
- remaining_rows_to_skip = 0;
135
- original_row_num = header_span + start_row;
136
- }
137
- pthread_mutex_unlock(&uibuff->mutex);
138
- if (zst != zsv_index_status_ok) {
139
- rc = errno ? errno : -1;
140
- goto done;
141
- }
142
- }
143
-
144
- size_t rows_read = header_span;
145
-
146
- size_t find_len = zsvsheet_opts->find ? strlen(zsvsheet_opts->find) : 0;
147
- size_t rows_searched = 0;
148
- zsvsheet_screen_buffer_t buffer = uibuff ? uibuff->buffer : NULL;
149
- if (uibuff && uibuff->has_row_num)
150
- zsvsheet_opts->hide_row_nums = 1;
151
-
152
- while (zsv_next_row(parser) == zsv_status_row &&
153
- (rows_read == 0 || rows_read < zsvsheet_screen_buffer_rows(buffer))) { // for each row
154
-
155
- size_t col_count = zsv_cell_count(parser);
156
- if (uibuff == NULL && uibufferp && uibopts && col_count > 0) {
157
- enum zsvsheet_priv_status stat;
158
- struct zsvsheet_ui_buffer *tmp_uibuff = NULL;
159
- if (!(buffer = zsvsheet_screen_buffer_new(col_count, uibopts->buff_opts, &stat)) ||
160
- stat != zsvsheet_priv_status_ok || !(tmp_uibuff = zsvsheet_ui_buffer_new(buffer, uibopts))) {
161
- if (tmp_uibuff)
162
- zsvsheet_ui_buffer_delete(tmp_uibuff);
163
- else
164
- zsvsheet_screen_buffer_delete(buffer);
165
- rc = -1;
166
- goto done;
167
- }
168
- *uibufferp = uibuff = tmp_uibuff;
169
- if (uibuff) {
170
- uibuff->parse_errs = parse_errs; // transfer errors
171
- memset(&parse_errs, 0, sizeof(parse_errs)); // prevent double-free
172
- }
173
- }
174
-
175
- // row number
176
- size_t rownum_column_offset = 0;
177
- if (rows_read == 0 && zsvsheet_opts->hide_row_nums == 0) {
178
- // Check if we already have Row #
179
- // TO DO: instead of checking the header, use (*uibufferp)->has_row_num
180
- struct zsv_cell c = zsv_get_cell(parser, 0);
181
- if (c.len == ZSVSHEET_ROWNUM_HEADER_LEN && !memcmp(c.str, ZSVSHEET_ROWNUM_HEADER, c.len)) {
182
- zsvsheet_opts->hide_row_nums = 1;
183
- if (uibuff)
184
- uibuff->has_row_num = 1;
185
- }
186
- }
187
-
188
- original_row_num++;
189
- if (remaining_header_to_skip > 0) {
190
- remaining_header_to_skip--;
191
- continue;
192
- }
193
- if (uibuff) {
194
- if (col_count + !buffer->opts.no_rownum_column > buffer->cols) {
195
- if (zsvsheet_screen_buffer_grow(buffer, col_count) != zsvsheet_priv_status_ok) {
196
- rc = -1;
197
- goto done;
198
- }
199
- }
200
- if (col_count > uibuff->dimensions.col_count)
201
- uibuff->dimensions.col_count = col_count;
202
- }
203
-
204
- if (remaining_rows_to_skip > 0) {
205
- remaining_rows_to_skip--;
206
- continue;
207
- }
208
-
209
- if (zsvsheet_opts->find) { // find the next occurrence
210
- rows_searched++;
211
- size_t colIndexPlus1 =
212
- zsvsheet_found_in_row(parser, zsvsheet_opts->found_colnum, col_count, zsvsheet_opts->find, find_len,
213
- zsvsheet_opts->find_specified_column_plus_1, zsvsheet_opts->find_exact);
214
- if (colIndexPlus1) {
215
- zsvsheet_opts->found_rownum = rows_searched + start_row;
216
- zsvsheet_opts->found_colnum = colIndexPlus1 - 1;
217
- break;
218
- } else
219
- zsvsheet_opts->found_colnum = 0; // next row search starts at beg of row
220
- continue;
221
- }
222
-
223
- if (zsvsheet_opts->hide_row_nums == 0) {
224
- if (rows_read == 0) // header
225
- zsvsheet_screen_buffer_write_cell(buffer, 0, 0, (const unsigned char *)ZSVSHEET_ROWNUM_HEADER);
226
- else {
227
- char buff[32];
228
- int n = snprintf(buff, sizeof(buff), "%zu", original_row_num - 1);
229
- if (!(n > 0 && n < (int)sizeof(buff)))
230
- sprintf(buff, "########");
231
- zsvsheet_screen_buffer_write_cell(buffer, rows_read, 0, (unsigned char *)buff);
232
- }
233
- rownum_column_offset = 1;
234
- }
235
-
236
- for (size_t i = start_col; i < col_count && i + rownum_column_offset < zsvsheet_screen_buffer_cols(buffer); i++) {
237
- struct zsv_cell c = zsv_get_cell(parser, i);
238
- if (c.len)
239
- zsvsheet_screen_buffer_write_cell_w_len(buffer, rows_read, i + rownum_column_offset, c.str, c.len);
240
- }
241
-
242
- rows_read++;
243
- }
244
- if (!uibuff) {
245
- rc = 0;
246
- goto done;
247
- }
248
-
249
- pthread_mutex_lock(&uibuff->mutex);
250
- char need_index = !uibuff->index_started && !uibuff->write_in_progress;
251
- char *old_ui_status = uibuff->status;
252
- if (need_index)
253
- uibuff->index_started = 1;
254
- pthread_mutex_unlock(&uibuff->mutex);
255
-
256
- if (need_index) {
257
- if (asprintf(&uibuff->status, "%s(building index) ", old_ui_status ? old_ui_status : "") == -1) {
258
- rc = -1;
259
- goto done;
260
- }
261
-
262
- uibuff->buff_used_rows = rows_read;
263
- uibuff->dimensions.row_count = rows_read;
264
- if (original_row_num > 1 && rows_read > 0) {
265
- opts.stream = NULL;
266
- get_data_index_async(uibuff, filename, &opts, custom_prop_handler, old_ui_status);
267
- }
268
- } else if (rows_read > uibuff->buff_used_rows) {
269
- uibuff->buff_used_rows = rows_read;
270
- uibuff->dimensions.row_count = rows_read;
271
- }
272
-
273
- done:
274
- uib_parse_errs_clear(&parse_errs);
275
- if (fp)
276
- fclose(fp);
277
- zsv_delete(parser);
278
- return rc;
279
- }
280
-
281
- // get_data_index(): return an index for constant-time access
282
- static void *get_data_index(void *gdi) {
283
- struct zsvsheet_index_opts *d = gdi;
284
- pthread_mutex_t *mutexp = d->mutexp;
285
- int *errp = d->errp;
286
- struct zsvsheet_ui_buffer *uib = d->uib;
287
- char *ui_status = uib->status;
288
-
289
- enum zsv_index_status ix_status = build_memory_index(d);
290
-
291
- if (ix_status != zsv_index_status_ok) {
292
- pthread_mutex_lock(mutexp);
293
- if (errp != NULL)
294
- *errp = errno;
295
- free(d);
296
- pthread_mutex_unlock(mutexp);
297
- return NULL;
298
- }
299
-
300
- pthread_mutex_lock(mutexp);
301
- uib->status = d->old_ui_status;
302
- uib->ixopts = NULL;
303
- pthread_mutex_unlock(mutexp);
304
-
305
- free(ui_status);
306
- free(d);
307
-
308
- return NULL;
309
- }
310
-
311
- static size_t zsvsheet_find_next(struct zsvsheet_ui_buffer *uib, struct zsvsheet_opts *zsvsheet_opts,
312
- size_t header_span, struct zsv_prop_handler *custom_prop_handler) {
313
- struct zsvsheet_rowcol *input_offset = &uib->input_offset;
314
- struct zsvsheet_rowcol *buff_offset = &uib->buff_offset;
315
- size_t cursor_row = uib->cursor_row;
316
- size_t start_row = input_offset->row + buff_offset->row + header_span + cursor_row - 1;
317
- if (start_row > 0)
318
- start_row--;
319
- read_data(&uib, NULL, start_row, 0, header_span, zsvsheet_opts, custom_prop_handler);
320
- zsvsheet_opts->find = NULL;
321
- return zsvsheet_opts->found_rownum;
322
- }
@@ -1,203 +0,0 @@
1
- #include "screen_buffer.h"
2
-
3
- #include <zsv/ext.h> // zsvsheet_cell_attr_t
4
-
5
- struct zsvsheet_screen_buffer {
6
- size_t cols;
7
- size_t long_cell_count;
8
- struct zsvsheet_screen_buffer_opts opts;
9
- unsigned char *data;
10
- zsvsheet_cell_attr_t *cell_attrs; // used for per-cell attron() and attroff()
11
- // to do: add hooks for extension
12
- };
13
-
14
- static inline size_t buffer_data_offset(zsvsheet_screen_buffer_t buff, size_t row, size_t col) {
15
- assert(row < buff->opts.rows && col < buff->cols);
16
- return row * buff->cols * buff->opts.cell_buff_len + col * buff->opts.cell_buff_len;
17
- }
18
-
19
- static void set_long_cell(zsvsheet_screen_buffer_t buff, size_t offset, char *heap) {
20
- char **target = (char **)(buff->data + offset);
21
- *target = heap;
22
- // set flag indicating that this is long cell
23
- *(buff->data + offset + buff->opts.cell_buff_len - 1) = (char)1;
24
- }
25
-
26
- static char *get_long_cell(zsvsheet_screen_buffer_t buff, size_t offset) {
27
- char **valuep = (char **)(buff->data + offset);
28
- if (valuep)
29
- return *valuep;
30
- return NULL;
31
- }
32
-
33
- static inline int is_long_cell(const unsigned char *mem, size_t cell_buff_len) {
34
- return *(mem + cell_buff_len - 1) != '\0';
35
- }
36
-
37
- size_t zsvsheet_screen_buffer_cols(zsvsheet_screen_buffer_t buff) {
38
- return buff->cols;
39
- }
40
-
41
- size_t zsvsheet_screen_buffer_rows(zsvsheet_screen_buffer_t buff) {
42
- return buff->opts.rows;
43
- }
44
-
45
- static void free_long_cell(zsvsheet_screen_buffer_t buff, size_t offset) {
46
- if (is_long_cell(buff->data + offset, buff->opts.cell_buff_len)) {
47
- char *value_copy = get_long_cell(buff, offset);
48
- free(value_copy);
49
- memset(buff->data + offset, 0, buff->opts.cell_buff_len);
50
- buff->long_cell_count--;
51
- }
52
- }
53
-
54
- void zsvsheet_screen_buffer_delete(zsvsheet_screen_buffer_t buff) {
55
- if (buff) {
56
- for (size_t i = 0; i < buff->opts.rows && buff->long_cell_count > 0; i++) {
57
- for (size_t j = 0; j < buff->cols && buff->long_cell_count > 0; j++) {
58
- size_t offset = buffer_data_offset(buff, i, j);
59
- free_long_cell(buff, offset);
60
- }
61
- }
62
- free(buff->cell_attrs);
63
- free(buff->data);
64
- free(buff);
65
- }
66
- }
67
-
68
- zsvsheet_screen_buffer_t zsvsheet_screen_buffer_new(size_t cols, struct zsvsheet_screen_buffer_opts *opts,
69
- enum zsvsheet_priv_status *stat) {
70
- struct zsvsheet_screen_buffer_opts bopts = {0};
71
- if (!opts)
72
- opts = &bopts;
73
- *stat = zsvsheet_priv_status_ok;
74
- if (opts->rows == 0)
75
- opts->rows = ZSVSHEET_SCREEN_BUFFER_DEFAULT_ROW_COUNT;
76
- else if (opts->rows < 256)
77
- opts->rows = 256;
78
- if (opts->cell_buff_len == 0)
79
- opts->cell_buff_len = ZSVSHEET_SCREEN_BUFFER_DEFAULT_CELL_BUFF_LEN;
80
- if (opts->max_cell_len == 0)
81
- opts->max_cell_len = ZSVSHEET_SCREEN_BUFFER_DEFAULT_MAX_CELL_LEN;
82
- if (opts->cell_buff_len < sizeof(void *) * 2)
83
- *stat = zsvsheet_priv_status_error;
84
- else {
85
- if (!opts->no_rownum_column)
86
- cols++;
87
- void *data = calloc(opts->rows, cols * opts->cell_buff_len);
88
- if (!data)
89
- *stat = zsvsheet_priv_status_memory;
90
- else {
91
- struct zsvsheet_screen_buffer *buff = calloc(1, sizeof(*buff));
92
- if (!buff)
93
- *stat = zsvsheet_priv_status_memory;
94
- else {
95
- buff->opts.rows = opts->rows;
96
- buff->cols = cols;
97
- buff->data = data;
98
- buff->opts = *opts;
99
- return buff;
100
- }
101
- }
102
- free(data);
103
- }
104
- return NULL;
105
- }
106
-
107
- enum zsvsheet_priv_status zsvsheet_screen_buffer_grow(zsvsheet_screen_buffer_t buff, size_t cols) {
108
- size_t old_cols = buff->cols;
109
- size_t rows = buff->opts.rows;
110
- size_t cell_buff_len = buff->opts.cell_buff_len;
111
- size_t old_row_len = old_cols * cell_buff_len;
112
-
113
- if (!buff->opts.no_rownum_column)
114
- cols++;
115
-
116
- size_t row_len = cols * cell_buff_len;
117
-
118
- assert(cols > old_cols);
119
-
120
- void *old_data = buff->data;
121
- void *data = calloc(rows, cols * cell_buff_len);
122
- if (!data)
123
- return zsvsheet_priv_status_memory;
124
-
125
- for (size_t i = 0; i < rows; i++) {
126
- size_t old_row_off = i * old_row_len;
127
- size_t row_off = i * row_len;
128
-
129
- memcpy((char *)data + row_off, (char *)old_data + old_row_off, old_row_len);
130
- }
131
-
132
- buff->data = data;
133
- buff->cols = cols;
134
-
135
- free(old_data);
136
-
137
- return zsvsheet_priv_status_ok;
138
- }
139
-
140
- #ifndef UTF8_NOT_FIRST_CHAR
141
- #define UTF8_NOT_FIRST_CHAR(x) ((x & 0xC0) == 0x80)
142
- #endif
143
-
144
- enum zsvsheet_priv_status zsvsheet_screen_buffer_write_cell_w_len(zsvsheet_screen_buffer_t buff, size_t row, size_t col,
145
- const unsigned char *value, size_t len) {
146
- enum zsvsheet_priv_status stat = zsvsheet_priv_status_ok;
147
- size_t offset = buffer_data_offset(buff, row, col);
148
- free_long_cell(buff, offset);
149
- if (len < buff->opts.cell_buff_len) {
150
- if (len)
151
- // copy into fixed-size buff
152
- memcpy(buff->data + offset, value, len);
153
- *(buff->data + offset + len) = '\0';
154
- } else {
155
- // we have a long cell
156
- if (len > buff->opts.max_cell_len) {
157
- len = buff->opts.max_cell_len;
158
- while (len > 0 && value[len] >= 128 && UTF8_NOT_FIRST_CHAR(value[len]))
159
- // we are in the middle of a multibyte char, so back up
160
- len--;
161
- }
162
- if (!len) // the only reason len could be 0 is if our input was not valid utf8, but check to make sure anyway
163
- stat = zsvsheet_priv_status_utf8;
164
- else {
165
- char *value_copy = malloc(1 + len);
166
- if (value_copy) {
167
- memcpy(value_copy, value, len);
168
- value_copy[len] = '\0';
169
- set_long_cell(buff, offset, value_copy);
170
- buff->long_cell_count++;
171
- } else
172
- stat = zsvsheet_priv_status_memory;
173
- }
174
- }
175
- return stat;
176
- }
177
-
178
- enum zsvsheet_priv_status zsvsheet_screen_buffer_write_cell(zsvsheet_screen_buffer_t buff, size_t row, size_t col,
179
- const unsigned char *value) {
180
- return zsvsheet_screen_buffer_write_cell_w_len(buff, row, col, value, strlen((void *)value));
181
- }
182
-
183
- int zsvsheet_screen_buffer_cell_attrs(zsvsheet_screen_buffer_t buff, size_t row, size_t col) {
184
- if (buff->cell_attrs) {
185
- size_t offset = row * buff->cols + col;
186
- return buff->cell_attrs[offset];
187
- }
188
- return 0;
189
- }
190
-
191
- const unsigned char *zsvsheet_screen_buffer_cell_display(zsvsheet_screen_buffer_t buff, size_t row, size_t col) {
192
- if (row < buff->opts.rows && col < buff->cols) {
193
- size_t offset = row * buff->cols * buff->opts.cell_buff_len + col * buff->opts.cell_buff_len;
194
- const unsigned char *cell = &buff->data[offset];
195
- if (!is_long_cell(cell, buff->opts.cell_buff_len))
196
- return cell;
197
-
198
- // if the fixed-length cell memory does not end with NULL,
199
- // then the cell value is a pointer to memory holding the value
200
- return (unsigned char *)get_long_cell(buff, offset);
201
- }
202
- return NULL;
203
- }
@@ -1,36 +0,0 @@
1
- #ifndef ZSVSHEET_SCREEN_BUFFER_H
2
- #define ZSVSHEET_SCREEN_BUFFER_H
3
-
4
- #define ZSVSHEET_SCREEN_BUFFER_DEFAULT_CELL_BUFF_LEN 16
5
- #define ZSVSHEET_SCREEN_BUFFER_DEFAULT_MAX_CELL_LEN 32768 - 1
6
- #define ZSVSHEET_SCREEN_BUFFER_DEFAULT_ROW_COUNT 1024
7
-
8
- typedef struct zsvsheet_screen_buffer *zsvsheet_screen_buffer_t;
9
-
10
- struct zsvsheet_screen_buffer_opts {
11
- size_t cell_buff_len; // default = 16. must be >= 2 * sizeof(void *)
12
- size_t max_cell_len; // length in bytes; defaults to 32767
13
- size_t rows; // rows to buffer. cannot be < 256
14
- char no_rownum_column; // reserved. TO DO: if set, omit row num column
15
- };
16
-
17
- zsvsheet_screen_buffer_t zsvsheet_screen_buffer_new(size_t cols, struct zsvsheet_screen_buffer_opts *opts,
18
- enum zsvsheet_priv_status *stat);
19
- enum zsvsheet_priv_status zsvsheet_screen_buffer_grow(zsvsheet_screen_buffer_t buff, size_t cols);
20
-
21
- enum zsvsheet_priv_status zsvsheet_screen_buffer_write_cell(zsvsheet_screen_buffer_t buff, size_t row, size_t col,
22
- const unsigned char *value);
23
-
24
- enum zsvsheet_priv_status zsvsheet_screen_buffer_write_cell_w_len(zsvsheet_screen_buffer_t buff, size_t row, size_t col,
25
- const unsigned char *value, size_t len);
26
-
27
- const unsigned char *zsvsheet_screen_buffer_cell_display(zsvsheet_screen_buffer_t buff, size_t row, size_t col);
28
-
29
- int zsvsheet_screen_buffer_cell_attrs(zsvsheet_screen_buffer_t buff, size_t row, size_t col);
30
-
31
- void zsvsheet_screen_buffer_delete(zsvsheet_screen_buffer_t);
32
-
33
- size_t zsvsheet_screen_buffer_cols(zsvsheet_screen_buffer_t);
34
- size_t zsvsheet_screen_buffer_rows(zsvsheet_screen_buffer_t buff);
35
-
36
- #endif