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,220 +0,0 @@
1
- /*
2
- * Copyright (c) 2007-2014, Lloyd Hilaiel <me@lloyd.io>
3
- *
4
- * Permission to use, copy, modify, and/or distribute this software for any
5
- * purpose with or without fee is hereby granted, provided that the above
6
- * copyright notice and this permission notice appear in all copies.
7
- *
8
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
- */
16
-
17
- #include "yajl_encode.h"
18
-
19
- #include <assert.h>
20
- #include <stdlib.h>
21
- #include <string.h>
22
- #include <stdio.h>
23
-
24
- static void CharToHex(unsigned char c, char * hexBuf)
25
- {
26
- const char * hexchar = "0123456789ABCDEF";
27
- hexBuf[0] = hexchar[c >> 4];
28
- hexBuf[1] = hexchar[c & 0x0F];
29
- }
30
-
31
- void
32
- yajl_string_encode(const yajl_print_t print,
33
- void * ctx,
34
- const unsigned char * str,
35
- size_t len,
36
- int escape_solidus)
37
- {
38
- size_t beg = 0;
39
- size_t end = 0;
40
- char hexBuf[7];
41
- hexBuf[0] = '\\'; hexBuf[1] = 'u'; hexBuf[2] = '0'; hexBuf[3] = '0';
42
- hexBuf[6] = 0;
43
-
44
- while (end < len) {
45
- const char * escaped = NULL;
46
- switch (str[end]) {
47
- case '\r': escaped = "\\r"; break;
48
- case '\n': escaped = "\\n"; break;
49
- case '\\': escaped = "\\\\"; break;
50
- /* it is not required to escape a solidus in JSON:
51
- * read sec. 2.5: http://www.ietf.org/rfc/rfc4627.txt
52
- * specifically, this production from the grammar:
53
- * unescaped = %x20-21 / %x23-5B / %x5D-10FFFF
54
- */
55
- case '/': if (escape_solidus) escaped = "\\/"; break;
56
- case '"': escaped = "\\\""; break;
57
- case '\f': escaped = "\\f"; break;
58
- case '\b': escaped = "\\b"; break;
59
- case '\t': escaped = "\\t"; break;
60
- default:
61
- if ((unsigned char) str[end] < 32) {
62
- CharToHex(str[end], hexBuf + 4);
63
- escaped = hexBuf;
64
- }
65
- break;
66
- }
67
- if (escaped != NULL) {
68
- print(ctx, (const char *) (str + beg), end - beg);
69
- print(ctx, escaped, (unsigned int)strlen(escaped));
70
- beg = ++end;
71
- } else {
72
- ++end;
73
- }
74
- }
75
- print(ctx, (const char *) (str + beg), end - beg);
76
- }
77
-
78
- static void hexToDigit(unsigned int * val, const unsigned char * hex)
79
- {
80
- unsigned int i;
81
- for (i=0;i<4;i++) {
82
- unsigned char c = hex[i];
83
- if (c >= 'A') c = (c & ~0x20) - 7;
84
- c -= '0';
85
- assert(!(c & 0xF0));
86
- *val = (*val << 4) | c;
87
- }
88
- }
89
-
90
- static void Utf32toUtf8(unsigned int codepoint, char * utf8Buf)
91
- {
92
- if (codepoint < 0x80) {
93
- utf8Buf[0] = (char) codepoint;
94
- utf8Buf[1] = 0;
95
- } else if (codepoint < 0x0800) {
96
- utf8Buf[0] = (char) ((codepoint >> 6) | 0xC0);
97
- utf8Buf[1] = (char) ((codepoint & 0x3F) | 0x80);
98
- utf8Buf[2] = 0;
99
- } else if (codepoint < 0x10000) {
100
- utf8Buf[0] = (char) ((codepoint >> 12) | 0xE0);
101
- utf8Buf[1] = (char) (((codepoint >> 6) & 0x3F) | 0x80);
102
- utf8Buf[2] = (char) ((codepoint & 0x3F) | 0x80);
103
- utf8Buf[3] = 0;
104
- } else if (codepoint < 0x200000) {
105
- utf8Buf[0] =(char)((codepoint >> 18) | 0xF0);
106
- utf8Buf[1] =(char)(((codepoint >> 12) & 0x3F) | 0x80);
107
- utf8Buf[2] =(char)(((codepoint >> 6) & 0x3F) | 0x80);
108
- utf8Buf[3] =(char)((codepoint & 0x3F) | 0x80);
109
- utf8Buf[4] = 0;
110
- } else {
111
- utf8Buf[0] = '?';
112
- utf8Buf[1] = 0;
113
- }
114
- }
115
-
116
- void yajl_string_decode(yajl_buf buf, const unsigned char * str,
117
- size_t len)
118
- {
119
- size_t beg = 0;
120
- size_t end = 0;
121
-
122
- while (end < len) {
123
- if (str[end] == '\\') {
124
- char utf8Buf[5];
125
- const char * unescaped = "?";
126
- yajl_buf_append(buf, str + beg, end - beg);
127
- switch (str[++end]) {
128
- case 'r': unescaped = "\r"; break;
129
- case 'n': unescaped = "\n"; break;
130
- case '\\': unescaped = "\\"; break;
131
- case '/': unescaped = "/"; break;
132
- case '"': unescaped = "\""; break;
133
- case 'f': unescaped = "\f"; break;
134
- case 'b': unescaped = "\b"; break;
135
- case 't': unescaped = "\t"; break;
136
- case 'u': {
137
- unsigned int codepoint = 0;
138
- hexToDigit(&codepoint, str + ++end);
139
- end+=3;
140
- /* check if this is a surrogate */
141
- if ((codepoint & 0xFC00) == 0xD800) {
142
- end++;
143
- if (str[end] == '\\' && str[end + 1] == 'u') {
144
- unsigned int surrogate = 0;
145
- hexToDigit(&surrogate, str + end + 2);
146
- codepoint =
147
- (((codepoint & 0x3F) << 10) |
148
- ((((codepoint >> 6) & 0xF) + 1) << 16) |
149
- (surrogate & 0x3FF));
150
- end += 5;
151
- } else {
152
- unescaped = "?";
153
- break;
154
- }
155
- }
156
-
157
- Utf32toUtf8(codepoint, utf8Buf);
158
- unescaped = utf8Buf;
159
-
160
- if (codepoint == 0) {
161
- yajl_buf_append(buf, unescaped, 1);
162
- beg = ++end;
163
- continue;
164
- }
165
-
166
- break;
167
- }
168
- default:
169
- assert("this should never happen" == NULL);
170
- }
171
- yajl_buf_append(buf, unescaped, (unsigned int)strlen(unescaped));
172
- beg = ++end;
173
- } else {
174
- end++;
175
- }
176
- }
177
- yajl_buf_append(buf, str + beg, end - beg);
178
- }
179
-
180
- #define ADV_PTR s++; if (!(len--)) return 0;
181
-
182
- int yajl_string_validate_utf8(const unsigned char * s, size_t len)
183
- {
184
- if (!len) return 1;
185
- if (!s) return 0;
186
-
187
- while (len--) {
188
- /* single byte */
189
- if (*s <= 0x7f) {
190
- /* noop */
191
- }
192
- /* two byte */
193
- else if ((*s >> 5) == 0x6) {
194
- ADV_PTR;
195
- if (!((*s >> 6) == 0x2)) return 0;
196
- }
197
- /* three byte */
198
- else if ((*s >> 4) == 0x0e) {
199
- ADV_PTR;
200
- if (!((*s >> 6) == 0x2)) return 0;
201
- ADV_PTR;
202
- if (!((*s >> 6) == 0x2)) return 0;
203
- }
204
- /* four byte */
205
- else if ((*s >> 3) == 0x1e) {
206
- ADV_PTR;
207
- if (!((*s >> 6) == 0x2)) return 0;
208
- ADV_PTR;
209
- if (!((*s >> 6) == 0x2)) return 0;
210
- ADV_PTR;
211
- if (!((*s >> 6) == 0x2)) return 0;
212
- } else {
213
- return 0;
214
- }
215
-
216
- s++;
217
- }
218
-
219
- return 1;
220
- }
@@ -1,34 +0,0 @@
1
- /*
2
- * Copyright (c) 2007-2014, Lloyd Hilaiel <me@lloyd.io>
3
- *
4
- * Permission to use, copy, modify, and/or distribute this software for any
5
- * purpose with or without fee is hereby granted, provided that the above
6
- * copyright notice and this permission notice appear in all copies.
7
- *
8
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
- */
16
-
17
- #ifndef __YAJL_ENCODE_H__
18
- #define __YAJL_ENCODE_H__
19
-
20
- #include "yajl_buf.h"
21
- #include "api/yajl_gen.h"
22
-
23
- void yajl_string_encode(const yajl_print_t printer,
24
- void * ctx,
25
- const unsigned char * str,
26
- size_t length,
27
- int escape_solidus);
28
-
29
- void yajl_string_decode(yajl_buf buf, const unsigned char * str,
30
- size_t length);
31
-
32
- int yajl_string_validate_utf8(const unsigned char * s, size_t len);
33
-
34
- #endif
@@ -1,362 +0,0 @@
1
- /*
2
- * Copyright (c) 2007-2014, Lloyd Hilaiel <me@lloyd.io>
3
- *
4
- * Permission to use, copy, modify, and/or distribute this software for any
5
- * purpose with or without fee is hereby granted, provided that the above
6
- * copyright notice and this permission notice appear in all copies.
7
- *
8
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
- */
16
-
17
- #include "api/yajl_gen.h"
18
- #include "yajl_buf.h"
19
- #include "yajl_encode.h"
20
-
21
- #include <stdlib.h>
22
- #include <string.h>
23
- #include <stdio.h>
24
- #include <math.h>
25
- #include <stdarg.h>
26
-
27
- typedef enum {
28
- yajl_gen_start,
29
- yajl_gen_map_start,
30
- yajl_gen_map_key,
31
- yajl_gen_map_val,
32
- yajl_gen_array_start,
33
- yajl_gen_in_array,
34
- yajl_gen_complete,
35
- yajl_gen_error
36
- } yajl_gen_state;
37
-
38
- struct yajl_gen_t
39
- {
40
- unsigned int flags;
41
- unsigned int depth;
42
- const char * indentString;
43
- yajl_gen_state state[YAJL_MAX_DEPTH];
44
- yajl_print_t print;
45
- void * ctx; /* yajl_buf */
46
- /* memory allocation routines */
47
- yajl_alloc_funcs alloc;
48
- };
49
-
50
- int
51
- yajl_gen_config(yajl_gen g, yajl_gen_option opt, ...)
52
- {
53
- int rv = 1;
54
- va_list ap;
55
- va_start(ap, opt);
56
-
57
- switch(opt) {
58
- case yajl_gen_beautify:
59
- case yajl_gen_validate_utf8:
60
- case yajl_gen_escape_solidus:
61
- if (va_arg(ap, int)) g->flags |= opt;
62
- else g->flags &= ~opt;
63
- break;
64
- case yajl_gen_indent_string: {
65
- const char *indent = va_arg(ap, const char *);
66
- g->indentString = indent;
67
- for (; *indent; indent++) {
68
- if (*indent != '\n'
69
- && *indent != '\v'
70
- && *indent != '\f'
71
- && *indent != '\t'
72
- && *indent != '\r'
73
- && *indent != ' ')
74
- {
75
- g->indentString = NULL;
76
- rv = 0;
77
- }
78
- }
79
- break;
80
- }
81
- case yajl_gen_print_callback:
82
- yajl_buf_free(g->ctx);
83
- g->print = va_arg(ap, const yajl_print_t);
84
- g->ctx = va_arg(ap, void *);
85
- break;
86
- default:
87
- rv = 0;
88
- }
89
-
90
- va_end(ap);
91
-
92
- return rv;
93
- }
94
-
95
-
96
-
97
- yajl_gen
98
- yajl_gen_alloc(const yajl_alloc_funcs * afs)
99
- {
100
- yajl_gen g = NULL;
101
- yajl_alloc_funcs afsBuffer;
102
-
103
- /* first order of business is to set up memory allocation routines */
104
- if (afs != NULL) {
105
- if (afs->malloc == NULL || afs->realloc == NULL || afs->free == NULL)
106
- {
107
- return NULL;
108
- }
109
- } else {
110
- yajl_set_default_alloc_funcs(&afsBuffer);
111
- afs = &afsBuffer;
112
- }
113
-
114
- g = (yajl_gen) YA_MALLOC(afs, sizeof(struct yajl_gen_t));
115
- if (!g) return NULL;
116
-
117
- memset((void *) g, 0, sizeof(struct yajl_gen_t));
118
- /* copy in pointers to allocation routines */
119
- memcpy((void *) &(g->alloc), (void *) afs, sizeof(yajl_alloc_funcs));
120
-
121
- g->print = (yajl_print_t)&yajl_buf_append;
122
- g->ctx = yajl_buf_alloc(&(g->alloc));
123
- g->indentString = " ";
124
-
125
- return g;
126
- }
127
-
128
- void
129
- yajl_gen_reset(yajl_gen g, const char * sep)
130
- {
131
- g->depth = 0;
132
- memset((void *) &(g->state), 0, sizeof(g->state));
133
- if (sep != NULL) g->print(g->ctx, sep, strlen(sep));
134
- }
135
-
136
- void
137
- yajl_gen_free(yajl_gen g)
138
- {
139
- if (g->print == (yajl_print_t)&yajl_buf_append) yajl_buf_free((yajl_buf)g->ctx);
140
- YA_FREE(&(g->alloc), g);
141
- }
142
-
143
- #define INSERT_SEP \
144
- if (g->state[g->depth] == yajl_gen_map_key || \
145
- g->state[g->depth] == yajl_gen_in_array) { \
146
- g->print(g->ctx, ",", 1); \
147
- if ((g->flags & yajl_gen_beautify)) g->print(g->ctx, "\n", 1); \
148
- } else if (g->state[g->depth] == yajl_gen_map_val) { \
149
- g->print(g->ctx, ":", 1); \
150
- if ((g->flags & yajl_gen_beautify)) g->print(g->ctx, " ", 1); \
151
- }
152
-
153
- #define INSERT_WHITESPACE \
154
- if ((g->flags & yajl_gen_beautify)) { \
155
- if (g->state[g->depth] != yajl_gen_map_val) { \
156
- unsigned int _i; \
157
- for (_i=0;_i<g->depth;_i++) \
158
- g->print(g->ctx, \
159
- g->indentString, \
160
- (unsigned int)strlen(g->indentString)); \
161
- } \
162
- }
163
-
164
- #define ENSURE_NOT_KEY \
165
- if (g->state[g->depth] == yajl_gen_map_key || \
166
- g->state[g->depth] == yajl_gen_map_start) { \
167
- return yajl_gen_keys_must_be_strings; \
168
- } \
169
-
170
- /* check that we're not complete, or in error state. in a valid state
171
- * to be generating */
172
- #define ENSURE_VALID_STATE \
173
- if (g->state[g->depth] == yajl_gen_error) { \
174
- return yajl_gen_in_error_state;\
175
- } else if (g->state[g->depth] == yajl_gen_complete) { \
176
- return yajl_gen_generation_complete; \
177
- }
178
-
179
- #define INCREMENT_DEPTH \
180
- if (++(g->depth) >= YAJL_MAX_DEPTH) return yajl_max_depth_exceeded;
181
-
182
- #define DECREMENT_DEPTH \
183
- if (--(g->depth) >= YAJL_MAX_DEPTH) return yajl_gen_generation_complete;
184
-
185
- #define APPENDED_ATOM \
186
- switch (g->state[g->depth]) { \
187
- case yajl_gen_start: \
188
- g->state[g->depth] = yajl_gen_complete; \
189
- break; \
190
- case yajl_gen_map_start: \
191
- case yajl_gen_map_key: \
192
- g->state[g->depth] = yajl_gen_map_val; \
193
- break; \
194
- case yajl_gen_array_start: \
195
- g->state[g->depth] = yajl_gen_in_array; \
196
- break; \
197
- case yajl_gen_map_val: \
198
- g->state[g->depth] = yajl_gen_map_key; \
199
- break; \
200
- default: \
201
- break; \
202
- } \
203
-
204
- #define FINAL_NEWLINE \
205
- if ((g->flags & yajl_gen_beautify) && g->state[g->depth] == yajl_gen_complete) \
206
- g->print(g->ctx, "\n", 1);
207
-
208
- yajl_gen_status
209
- yajl_gen_integer(yajl_gen g, long long int number)
210
- {
211
- char i[32];
212
- ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE;
213
- sprintf(i, "%lld", number);
214
- g->print(g->ctx, i, (unsigned int)strlen(i));
215
- APPENDED_ATOM;
216
- FINAL_NEWLINE;
217
- return yajl_gen_status_ok;
218
- }
219
-
220
- #if defined(_WIN32) || defined(WIN32)
221
- #include <float.h>
222
- #define isnan _isnan
223
- #define isinf !_finite
224
- #endif
225
-
226
- yajl_gen_status
227
- yajl_gen_double(yajl_gen g, double number)
228
- {
229
- char i[32];
230
- ENSURE_VALID_STATE; ENSURE_NOT_KEY;
231
- if (isnan(number) || isinf(number)) return yajl_gen_invalid_number;
232
- INSERT_SEP; INSERT_WHITESPACE;
233
- sprintf(i, "%.20g", number);
234
- if (strspn(i, "0123456789-") == strlen(i)) {
235
- strcat(i, ".0");
236
- }
237
- g->print(g->ctx, i, (unsigned int)strlen(i));
238
- APPENDED_ATOM;
239
- FINAL_NEWLINE;
240
- return yajl_gen_status_ok;
241
- }
242
-
243
- yajl_gen_status
244
- yajl_gen_number(yajl_gen g, const char * s, size_t l)
245
- {
246
- ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE;
247
- g->print(g->ctx, s, l);
248
- APPENDED_ATOM;
249
- FINAL_NEWLINE;
250
- return yajl_gen_status_ok;
251
- }
252
-
253
- yajl_gen_status
254
- yajl_gen_string(yajl_gen g, const unsigned char * str,
255
- size_t len)
256
- {
257
- // if validation is enabled, check that the string is valid utf8
258
- // XXX: This checking could be done a little faster, in the same pass as
259
- // the string encoding
260
- if (g->flags & yajl_gen_validate_utf8) {
261
- if (!yajl_string_validate_utf8(str, len)) {
262
- return yajl_gen_invalid_string;
263
- }
264
- }
265
- ENSURE_VALID_STATE; INSERT_SEP; INSERT_WHITESPACE;
266
- g->print(g->ctx, "\"", 1);
267
- yajl_string_encode(g->print, g->ctx, str, len, g->flags & yajl_gen_escape_solidus);
268
- g->print(g->ctx, "\"", 1);
269
- APPENDED_ATOM;
270
- FINAL_NEWLINE;
271
- return yajl_gen_status_ok;
272
- }
273
-
274
- yajl_gen_status
275
- yajl_gen_null(yajl_gen g)
276
- {
277
- ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE;
278
- g->print(g->ctx, "null", strlen("null"));
279
- APPENDED_ATOM;
280
- FINAL_NEWLINE;
281
- return yajl_gen_status_ok;
282
- }
283
-
284
- yajl_gen_status
285
- yajl_gen_bool(yajl_gen g, int boolean)
286
- {
287
- const char * val = boolean ? "true" : "false";
288
-
289
- ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE;
290
- g->print(g->ctx, val, (unsigned int)strlen(val));
291
- APPENDED_ATOM;
292
- FINAL_NEWLINE;
293
- return yajl_gen_status_ok;
294
- }
295
-
296
- yajl_gen_status
297
- yajl_gen_map_open(yajl_gen g)
298
- {
299
- ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE;
300
- INCREMENT_DEPTH;
301
-
302
- g->state[g->depth] = yajl_gen_map_start;
303
- g->print(g->ctx, "{", 1);
304
- if ((g->flags & yajl_gen_beautify)) g->print(g->ctx, "\n", 1);
305
- FINAL_NEWLINE;
306
- return yajl_gen_status_ok;
307
- }
308
-
309
- yajl_gen_status
310
- yajl_gen_map_close(yajl_gen g)
311
- {
312
- ENSURE_VALID_STATE;
313
- DECREMENT_DEPTH;
314
-
315
- if ((g->flags & yajl_gen_beautify)) g->print(g->ctx, "\n", 1);
316
- APPENDED_ATOM;
317
- INSERT_WHITESPACE;
318
- g->print(g->ctx, "}", 1);
319
- FINAL_NEWLINE;
320
- return yajl_gen_status_ok;
321
- }
322
-
323
- yajl_gen_status
324
- yajl_gen_array_open(yajl_gen g)
325
- {
326
- ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE;
327
- INCREMENT_DEPTH;
328
- g->state[g->depth] = yajl_gen_array_start;
329
- g->print(g->ctx, "[", 1);
330
- if ((g->flags & yajl_gen_beautify)) g->print(g->ctx, "\n", 1);
331
- FINAL_NEWLINE;
332
- return yajl_gen_status_ok;
333
- }
334
-
335
- yajl_gen_status
336
- yajl_gen_array_close(yajl_gen g)
337
- {
338
- ENSURE_VALID_STATE;
339
- DECREMENT_DEPTH;
340
- if ((g->flags & yajl_gen_beautify)) g->print(g->ctx, "\n", 1);
341
- APPENDED_ATOM;
342
- INSERT_WHITESPACE;
343
- g->print(g->ctx, "]", 1);
344
- FINAL_NEWLINE;
345
- return yajl_gen_status_ok;
346
- }
347
-
348
- yajl_gen_status
349
- yajl_gen_get_buf(yajl_gen g, const unsigned char ** buf,
350
- size_t * len)
351
- {
352
- if (g->print != (yajl_print_t)&yajl_buf_append) return yajl_gen_no_buf;
353
- *buf = yajl_buf_data((yajl_buf)g->ctx);
354
- *len = yajl_buf_len((yajl_buf)g->ctx);
355
- return yajl_gen_status_ok;
356
- }
357
-
358
- void
359
- yajl_gen_clear(yajl_gen g)
360
- {
361
- if (g->print == (yajl_print_t)&yajl_buf_append) yajl_buf_clear((yajl_buf)g->ctx);
362
- }