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,253 +0,0 @@
1
- #include <yajl_helper/yajl_helper.h>
2
- #include <zsv/utils/file.h>
3
- #include <zsv/utils/os.h>
4
-
5
- struct zsv_dir_from_json_ctx {
6
- const char *filepath_prefix;
7
- unsigned char buff[4096];
8
- size_t content_start;
9
- FILE *out;
10
- char *out_filepath;
11
- struct jv_to_json_ctx jctx;
12
- zsv_jq_handle zjq;
13
-
14
- int err;
15
- unsigned char in_obj : 1;
16
- unsigned char do_check : 1;
17
- unsigned char dry : 1;
18
- unsigned char _ : 5;
19
- };
20
-
21
- static void zsv_dir_from_json_close_out(struct zsv_dir_from_json_ctx *ctx) {
22
- if (ctx->zjq) {
23
- zsv_jq_finish(ctx->zjq);
24
- zsv_jq_delete(ctx->zjq);
25
- ctx->zjq = NULL;
26
- }
27
- if (ctx->out) {
28
- fclose(ctx->out);
29
- ctx->out = NULL;
30
- free(ctx->out_filepath);
31
- ctx->out_filepath = NULL;
32
- }
33
- }
34
-
35
- static int zsv_dir_from_json_map_key(yajl_helper_t yh, const unsigned char *s, size_t len) {
36
- if (yajl_helper_level(yh) == 1 && len) { // new property file entry
37
- struct zsv_dir_from_json_ctx *ctx = yajl_helper_ctx(yh);
38
-
39
- char *fn = NULL;
40
- if (ctx->filepath_prefix)
41
- asprintf(&fn, "%s%c%.*s", ctx->filepath_prefix, FILESLASH, (int)len, s);
42
- else
43
- asprintf(&fn, "%.*s", (int)len, s);
44
-
45
- // if we have any backslashes, replace with fwd slash
46
- if (fn)
47
- for (int i = 0, j = strlen(fn); i < j; i++)
48
- if (fn[i] == '\\')
49
- fn[i] = '/';
50
- if (!fn) {
51
- errno = ENOMEM;
52
- perror(NULL);
53
- } else if (ctx->do_check) {
54
- // we just want to check if the destination file exists
55
- if (access(fn, F_OK) != -1) { // it exists
56
- ctx->err = errno = EEXIST;
57
- perror(fn);
58
- }
59
- } else if (ctx->dry) { // just output the name of the file
60
- printf("%s\n", fn);
61
- } else if (zsv_mkdirs(fn, 1)) {
62
- fprintf(stderr, "Unable to create directories for %s\n", fn);
63
- } else if (!((ctx->out = zsv_fopen(fn, "wb")))) {
64
- perror(fn);
65
- } else {
66
- ctx->out_filepath = fn;
67
- fn = NULL;
68
-
69
- // if it's a JSON file, use a jq filter to pretty-print
70
- if (strlen(ctx->out_filepath) > 5 &&
71
- !zsv_stricmp((const unsigned char *)ctx->out_filepath + strlen(ctx->out_filepath) - 5,
72
- (const unsigned char *)".json")) {
73
- ctx->jctx.write1 = zsv_jq_fwrite1;
74
- ctx->jctx.ctx = ctx->out;
75
- ctx->jctx.flags = JV_PRINT_PRETTY | JV_PRINT_SPACE1;
76
- enum zsv_jq_status jqstat;
77
- ctx->zjq = zsv_jq_new((const unsigned char *)".", jv_to_json_func, &ctx->jctx, &jqstat);
78
- if (!ctx->zjq) {
79
- fprintf(stderr, "zsv_jq_new: unable to open for %s\n", ctx->out_filepath);
80
- zsv_dir_from_json_close_out(ctx);
81
- }
82
- }
83
- }
84
- free(fn);
85
- }
86
- return 1;
87
- }
88
-
89
- static int zsv_dir_from_json_start_obj(yajl_helper_t yh) {
90
- if (yajl_helper_level(yh) == 2) {
91
- struct zsv_dir_from_json_ctx *ctx = yajl_helper_ctx(yh);
92
- ctx->in_obj = 1;
93
- ctx->content_start = yajl_get_bytes_consumed(yajl_helper_yajl(yh)) - 1;
94
- }
95
- return 1;
96
- }
97
-
98
- // zsv_dir_from_json_flush(): return err
99
- static int zsv_dir_from_json_flush(yajl_handle yajl, struct zsv_dir_from_json_ctx *ctx) {
100
- if (ctx->zjq) {
101
- size_t current_position = yajl_get_bytes_consumed(yajl);
102
- if (current_position <= ctx->content_start)
103
- fprintf(stderr, "Error! zsv_dir_from_json_flush unexpected current position\n");
104
- else
105
- zsv_jq_parse(ctx->zjq, ctx->buff + ctx->content_start, current_position - ctx->content_start);
106
- ctx->content_start = 0;
107
- }
108
- return 0;
109
- }
110
-
111
- static int zsv_dir_from_json_end_obj(yajl_helper_t yh) {
112
- if (yajl_helper_level(yh) == 1) { // just finished level 2
113
- struct zsv_dir_from_json_ctx *ctx = yajl_helper_ctx(yh);
114
- zsv_dir_from_json_flush(yajl_helper_yajl(yh), yajl_helper_ctx(yh));
115
- zsv_dir_from_json_close_out(ctx);
116
- ctx->in_obj = 0;
117
- }
118
- return 1;
119
- }
120
-
121
- static int zsv_dir_from_json_process_value(yajl_helper_t yh, struct json_value *value) {
122
- if (yajl_helper_level(yh) == 1) { // just finished level 2
123
- struct zsv_dir_from_json_ctx *ctx = yajl_helper_ctx(yh);
124
- const unsigned char *jsstr;
125
- size_t len;
126
- json_value_default_string(value, &jsstr, &len);
127
- if (ctx->zjq) {
128
- unsigned char *js = len ? zsv_json_from_str_n(jsstr, len) : NULL;
129
- if (js)
130
- zsv_jq_parse(ctx->zjq, js, strlen((char *)js));
131
- else
132
- zsv_jq_parse(ctx->zjq, "null", 4);
133
- free(js);
134
- } else if (len && ctx->out)
135
- fwrite(jsstr, 1, len, ctx->out);
136
- zsv_dir_from_json_close_out(ctx);
137
- }
138
- return 1;
139
- }
140
-
141
- /**
142
- * Convert a JSON stream into file and directory contents
143
- * This function is the inverse of zsv_dir_to_json()
144
- * Output schema is a dictionary where key = path and value = contents
145
- * Files named with .json suffix will be exported as JSON (content must be valid JSON)
146
- * Files named with any other suffix will be exported as a single string value (do not try with large files)
147
- */
148
- int zsv_dir_from_json(const unsigned char *target_dir, FILE *src,
149
- unsigned int flags, // ZSV_DIR_FLAG_XX
150
- unsigned char _verbose) {
151
- (void)(_verbose);
152
- int err = 0;
153
- int force = !!(flags & ZSV_DIR_FLAG_FORCE);
154
- int dry = !!(flags & ZSV_DIR_FLAG_DRY);
155
- char *tmp_fn = NULL; // only used if force = 0 and src == stdin
156
- if (!force) {
157
- // if input is stdin, we'll need to read it twice, so save it first
158
- // this isn't the most efficient way to do it, as it reads it 3 times
159
- // but it's easier and the diff is immaterial
160
- if (src == stdin) {
161
- src = NULL;
162
- tmp_fn = zsv_get_temp_filename("zsv_prop_XXXXXXXX");
163
- FILE *tmp_f;
164
- if (!tmp_fn) {
165
- err = errno = ENOMEM;
166
- perror(NULL);
167
- } else if (!(tmp_f = zsv_fopen(tmp_fn, "wb"))) {
168
- err = errno;
169
- perror(tmp_fn);
170
- } else {
171
- err = zsv_copy_file_ptr(stdin, tmp_f);
172
- fclose(tmp_f);
173
- if (!(src = zsv_fopen(tmp_fn, "rb"))) {
174
- err = errno;
175
- perror(tmp_fn);
176
- }
177
- }
178
- }
179
- }
180
-
181
- if (!err) {
182
- // we will run this loop either once (force) or twice (no force):
183
- // 1. check before running (no force)
184
- // 2. do the import
185
- char do_check = !force;
186
- if (do_check && !zsv_dir_exists((const char *)target_dir))
187
- do_check = 0;
188
-
189
- for (int i = do_check ? 0 : 1; i < 2 && !err; i++) {
190
- do_check = i == 0;
191
-
192
- size_t bytes_read;
193
- yajl_helper_t yh;
194
- struct zsv_dir_from_json_ctx ctx = {0};
195
- ctx.filepath_prefix = (const char *)target_dir;
196
-
197
- int (*start_obj)(yajl_helper_t yh) = NULL;
198
- int (*end_obj)(yajl_helper_t yh) = NULL;
199
- int (*process_value)(struct yajl_helper_parse_state *, struct json_value *) = NULL;
200
-
201
- if (do_check)
202
- ctx.do_check = do_check;
203
- else {
204
- ctx.dry = dry;
205
- if (!ctx.dry) {
206
- start_obj = zsv_dir_from_json_start_obj;
207
- end_obj = zsv_dir_from_json_end_obj;
208
- process_value = zsv_dir_from_json_process_value;
209
- }
210
- }
211
-
212
- yh = yajl_helper_new(32, start_obj, end_obj, // map start/end
213
- zsv_dir_from_json_map_key, start_obj, end_obj, // array start/end
214
- process_value, &ctx);
215
- if (!yh) {
216
- err = errno = ENOMEM;
217
- perror(NULL);
218
- } else {
219
- yajl_handle y = yajl_helper_yajl(yh);
220
- while ((bytes_read = fread(ctx.buff, 1, sizeof(ctx.buff), src)) > 0) {
221
- if (yajl_parse(y, ctx.buff, bytes_read) != yajl_status_ok)
222
- yajl_helper_print_err(y, ctx.buff, bytes_read);
223
- if (ctx.in_obj)
224
- zsv_dir_from_json_flush(y, &ctx);
225
- }
226
- if (yajl_complete_parse(y) != yajl_status_ok)
227
- yajl_helper_print_err(y, ctx.buff, bytes_read);
228
-
229
- if (ctx.out) { // e.g. if bad JSON and parse failed
230
- fclose(ctx.out);
231
- free(ctx.out_filepath);
232
- }
233
- yajl_helper_delete(yh);
234
- }
235
-
236
- if (ctx.err)
237
- err = ctx.err;
238
- if (i == 0) {
239
- rewind(src);
240
- if (errno) {
241
- err = errno;
242
- perror(NULL);
243
- }
244
- }
245
- }
246
- }
247
- if (tmp_fn) {
248
- unlink(tmp_fn);
249
- free(tmp_fn);
250
- }
251
-
252
- return err;
253
- }
@@ -1,121 +0,0 @@
1
- struct zsv_dir_foreach_to_json_ctx {
2
- struct zsv_dir_filter zsv_dir_filter;
3
- const unsigned char *parent_dir;
4
- struct jv_to_json_ctx jctx;
5
- zsv_jq_handle zjq;
6
- unsigned count; // number of files exported so far
7
- int err;
8
- };
9
-
10
- static int zsv_dir_foreach_to_json(struct zsv_foreach_dirent_handle *h, size_t depth) {
11
- struct zsv_dir_foreach_to_json_ctx *ctx = h->ctx;
12
- h->ctx = ctx->zsv_dir_filter.ctx;
13
- if (!ctx->zsv_dir_filter.filter(h, depth))
14
- h->no_recurse = 1; // skip this node (only matters if node is dir)
15
- else if (!h->is_dir) { // process this file
16
- char suffix = 0;
17
- if (strlen(h->parent_and_entry) > 5 &&
18
- !zsv_stricmp((const unsigned char *)h->parent_and_entry + strlen(h->parent_and_entry) - 5,
19
- (const unsigned char *)".json"))
20
- suffix = 'j'; // json
21
- else if (strlen(h->parent_and_entry) > 4 &&
22
- !zsv_stricmp((const unsigned char *)h->parent_and_entry + strlen(h->parent_and_entry) - 4,
23
- (const unsigned char *)".txt"))
24
- suffix = 't'; // text
25
- if (suffix) {
26
- // for now, only handle json or txt
27
- FILE *f = fopen(h->parent_and_entry, "rb");
28
- if (!f)
29
- perror(h->parent_and_entry);
30
- else {
31
- // create an entry for this file. the map key is the file name; its value is the file contents
32
- unsigned char *js =
33
- zsv_json_from_str((const unsigned char *)h->parent_and_entry + strlen((const char *)ctx->parent_dir) + 1);
34
- if (!js)
35
- errno = ENOMEM, perror(NULL);
36
- else if (*js) {
37
- if (ctx->count > 0)
38
- if (zsv_jq_parse(ctx->zjq, ",", 1))
39
- ctx->err = 1;
40
- if (!ctx->err) {
41
- ctx->count++;
42
- if (zsv_jq_parse(ctx->zjq, js, strlen((const char *)js)) || zsv_jq_parse(ctx->zjq, ":", 1))
43
- ctx->err = 1;
44
- else {
45
- switch (suffix) {
46
- case 'j': // json
47
- if (zsv_jq_parse_file(ctx->zjq, f))
48
- ctx->err = 1;
49
- break;
50
- case 't': // txt
51
- // for now we are going to limit txt file values to 4096 chars and JSON-stringify it
52
- {
53
- unsigned char buff[4096];
54
- size_t n = fread(buff, 1, sizeof(buff), f);
55
- unsigned char *txt_js = NULL;
56
- if (n) {
57
- txt_js = zsv_json_from_str_n(buff, n);
58
- if (zsv_jq_parse(ctx->zjq, txt_js ? txt_js : (const unsigned char *)"null",
59
- txt_js ? strlen((const char *)txt_js) : 4))
60
- ctx->err = 1;
61
- }
62
- }
63
- break;
64
- }
65
- }
66
- }
67
- }
68
- free(js);
69
- fclose(f);
70
- }
71
- }
72
- }
73
- h->ctx = ctx;
74
- return 0;
75
- }
76
-
77
- /**
78
- * Convert directory contents into a single JSON file
79
- * Output schema is a dictionary where key = path and value = contents
80
- * Files named with .json suffix will be exported as JSON (content must be valid JSON)
81
- * Files named with any other suffix will be exported as a single string value (do not try with large files)
82
- *
83
- * @param parent_dir : directory to export
84
- * @param dest : file path to output to, or NULL to output to stdout
85
- */
86
- int zsv_dir_to_json(const unsigned char *parent_dir, const unsigned char *output_filename,
87
- struct zsv_dir_filter *zsv_dir_filter, unsigned char verbose) {
88
- int err = 0;
89
- FILE *fdest = output_filename ? fopen((const char *)output_filename, "wb") : stdout;
90
- if (!fdest)
91
- err = errno, perror((const char *)output_filename);
92
- else {
93
- struct zsv_dir_foreach_to_json_ctx ctx = {0};
94
- ctx.zsv_dir_filter = *zsv_dir_filter;
95
- ctx.parent_dir = parent_dir;
96
-
97
- // use a jq filter to pretty-print
98
- ctx.jctx.write1 = zsv_jq_fwrite1;
99
- ctx.jctx.ctx = fdest;
100
- ctx.jctx.flags = JV_PRINT_PRETTY | JV_PRINT_SPACE1;
101
- enum zsv_jq_status jqstat;
102
- ctx.zjq = zsv_jq_new((const unsigned char *)".", jv_to_json_func, &ctx.jctx, &jqstat);
103
- if (!ctx.zjq)
104
- err = 1, fprintf(stderr, "zsv_jq_new\n");
105
- else {
106
- if (jqstat == zsv_jq_status_ok && zsv_jq_parse(ctx.zjq, "{", 1) == zsv_jq_status_ok) {
107
- // export each file
108
- zsv_foreach_dirent((const char *)parent_dir, ctx.zsv_dir_filter.max_depth, zsv_dir_foreach_to_json, &ctx,
109
- verbose);
110
- if (!ctx.err && zsv_jq_parse(ctx.zjq, "}", 1))
111
- ctx.err = 1;
112
- if (!ctx.err && zsv_jq_finish(ctx.zjq))
113
- ctx.err = 1;
114
- zsv_jq_delete(ctx.zjq);
115
- }
116
- err = ctx.err;
117
- }
118
- fclose(fdest);
119
- }
120
- return err;
121
- }
@@ -1,20 +0,0 @@
1
- /*
2
- * Copyright (C) 2021 Liquidaty and the zsv/lib contributors
3
- * All rights reserved
4
- *
5
- * This file is part of zsv/lib, distributed under the license defined at
6
- * https://opensource.org/licenses/MIT
7
- */
8
-
9
- #include <zsv/utils/dl.h>
10
-
11
- void (*zsv_dlsym(void *restrict handle, const char *restrict name))(void) {
12
- #pragma GCC diagnostic push
13
- #pragma GCC diagnostic ignored "-Wpedantic"
14
- return dlsym(handle, name);
15
- #pragma GCC diagnostic pop
16
- }
17
-
18
- #ifdef _WIN32
19
- #include "win/dl.c"
20
- #endif
@@ -1,159 +0,0 @@
1
- #include <stdlib.h>
2
- #include <stdio.h>
3
- #include <string.h>
4
- #include <unistd.h>
5
- #include <dirent.h>
6
- #include <sys/stat.h>
7
-
8
- #ifdef __EMSCRIPTEN__
9
- #include <emscripten.h>
10
- #else
11
- #define EMSCRIPTEN_KEEPALIVE
12
- #endif
13
-
14
- #include <zsv/utils/emcc/fs_api.h>
15
-
16
- struct fs_data {
17
- FILE *f;
18
- };
19
-
20
- EMSCRIPTEN_KEEPALIVE
21
- fshandle fsopen(const char *fn, const char *mode) {
22
- struct fs_data *d = calloc(1, sizeof(*d));
23
- if (d)
24
- d->f = fopen(fn, mode);
25
- return d;
26
- }
27
-
28
- EMSCRIPTEN_KEEPALIVE
29
- int fsclose(fshandle h) {
30
- if (h) {
31
- int rc = fclose(h->f);
32
- free(h);
33
- return rc;
34
- }
35
- return 1;
36
- }
37
-
38
- EMSCRIPTEN_KEEPALIVE
39
- size_t fswrite(const void *ptr, size_t n, size_t m, fshandle h) {
40
- return fwrite(ptr, n, m, h->f);
41
- }
42
-
43
- EMSCRIPTEN_KEEPALIVE
44
- void stdflush(int addNewline) {
45
- fflush(stdout);
46
- if (addNewline)
47
- fprintf(stdout, "\n");
48
-
49
- fflush(stderr);
50
- if (addNewline)
51
- fprintf(stderr, "\n");
52
- }
53
-
54
- /*
55
- EMSCRIPTEN_KEEPALIVE
56
- size_t bytesum(const char *fn) {
57
- size_t sum = 0;
58
- FILE *f = fopen(fn, "rb");
59
- if(f) {
60
- char buff[1024];
61
- size_t bytes_read;
62
- while((bytes_read = fread(buff, 1, sizeof(buff), f))) {
63
- for(size_t i = 0; i < bytes_read; i++) {
64
- sum += buff[i];
65
- sum = sum % 1000000000;
66
- }
67
- }
68
- fclose(f);
69
- }
70
- return sum;
71
- }
72
- */
73
-
74
- EMSCRIPTEN_KEEPALIVE
75
- size_t fsread(void *ptr, size_t n, size_t m, fshandle h) {
76
- return fread(ptr, n, m, h->f);
77
- }
78
-
79
- EMSCRIPTEN_KEEPALIVE
80
- int fsrm(const char *fn) {
81
- return unlink(fn);
82
- }
83
-
84
- EMSCRIPTEN_KEEPALIVE
85
- int fsmkdir(const char *path) {
86
- #ifdef _WIN32
87
- return mkdir(path);
88
- #endif
89
- return mkdir(path, S_IRWXU);
90
- }
91
-
92
- EMSCRIPTEN_KEEPALIVE
93
- int fsprint(const char *s) {
94
- fwrite(s, 1, strlen(s), stdout);
95
- return 0;
96
- }
97
-
98
- EMSCRIPTEN_KEEPALIVE
99
- int fsprinterr(const char *s) {
100
- fwrite(s, 1, strlen(s), stderr);
101
- fprintf(stderr, "printed fsprinterr\n");
102
- return 0;
103
- }
104
-
105
- /**
106
- * return single string of entries delimited by newline
107
- * caller must free()
108
- */
109
- EMSCRIPTEN_KEEPALIVE
110
- char *fsls(const char *dir) {
111
- struct dirent *de; // Pointer for directory entry
112
- // opendir() returns a pointer of DIR type.
113
- if (!dir || !*dir)
114
- dir = ".";
115
- DIR *dr = opendir(dir);
116
- if (!dr)
117
- fprintf(stderr, "Could not open current directory");
118
- else {
119
- size_t total_mem = 0;
120
- struct tmp_str_list {
121
- struct tmp_str_list *next;
122
- char *c;
123
- };
124
- struct tmp_str_list *head = NULL, **tail = &head;
125
- while ((de = readdir(dr)) != NULL) { // see http://pubs.opengroup.org/onlinepubs/7990989775/xsh/readdir.html
126
- struct tmp_str_list *tmp = malloc(sizeof(*tmp));
127
- if (tmp) {
128
- tmp->next = NULL;
129
- tmp->c = strdup(de->d_name);
130
- if (!tmp->c)
131
- free(tmp);
132
- else {
133
- total_mem += (1 + strlen(tmp->c));
134
- *tail = tmp;
135
- tail = &tmp->next;
136
- }
137
- }
138
- }
139
-
140
- char *final_result = NULL;
141
- if (total_mem && (final_result = malloc(total_mem + 1))) {
142
- size_t offset = 0;
143
- for (struct tmp_str_list *tmp = head, *next; tmp; tmp = next) {
144
- next = tmp->next;
145
- size_t len = strlen(tmp->c);
146
- memcpy(final_result + offset, tmp->c, len);
147
- offset += len + 1;
148
- final_result[offset - 1] = '\n';
149
- free(tmp->c);
150
- free(tmp);
151
- }
152
- final_result[total_mem - 1] = '\0';
153
- }
154
-
155
- closedir(dr);
156
- return final_result;
157
- }
158
- return NULL;
159
- }
@@ -1,24 +0,0 @@
1
- /*
2
- * Copyright (C) 2021 Liquidaty and the zsv/lib contributors
3
- * All rights reserved
4
- *
5
- * This file is part of zsv/lib, distributed under the license defined at
6
- * https://opensource.org/licenses/MIT
7
- */
8
-
9
- #include <stdio.h>
10
- #include <stdarg.h>
11
-
12
- int zsv_app_printerr(const char *appname, int eno, const char *fmt, ...) {
13
- if (appname && *appname)
14
- fprintf(stderr, "(%s) %i: ", appname, eno);
15
- else
16
- fprintf(stderr, "%i: ", eno);
17
-
18
- va_list argv;
19
- va_start(argv, fmt);
20
- vfprintf(stderr, fmt, argv);
21
- va_end(argv);
22
- fprintf(stderr, "\n");
23
- return eno;
24
- }