├── .gitignore ├── DESIGN.html ├── DESIGN.md ├── LICENSE ├── Makefile ├── README.html ├── README.md ├── block.c ├── boxed.c ├── cee-common.c ├── cee-header.h ├── cee-json ├── .gitignore ├── LICENSE ├── Makefile ├── README.txt ├── USAGE.md ├── cee-json.h ├── cee_json_merge.c ├── diffuse_all.sh ├── parser.c ├── release │ ├── cee-json.c │ └── cee-json.h ├── snprint.c ├── test │ ├── test-parser.c │ ├── test-print.c │ ├── test.mk │ ├── test_parsing │ │ ├── i_array_extra_comma.json │ │ ├── i_array_number_and_comma.json │ │ ├── i_number_double_huge_neg_exp.json │ │ ├── i_number_huge_exp.json │ │ ├── i_number_neg_int_huge_exp.json │ │ ├── i_number_pos_double_huge_exp.json │ │ ├── i_number_real_neg_overflow.json │ │ ├── i_number_real_pos_overflow.json │ │ ├── i_number_real_underflow.json │ │ ├── i_number_too_big_neg_int.json │ │ ├── i_number_too_big_pos_int.json │ │ ├── i_number_very_big_negative_int.json │ │ ├── i_object_key_lone_2nd_surrogate.json │ │ ├── i_object_lone_continuation_byte_in_key_and_trailing_comma.json │ │ ├── i_object_trailing_comma.json │ │ ├── i_string_1st_surrogate_but_2nd_missing.json │ │ ├── i_string_1st_valid_surrogate_2nd_invalid.json │ │ ├── i_string_UTF-16LE_with_BOM.json │ │ ├── i_string_UTF-8_invalid_sequence.json │ │ ├── i_string_UTF8_surrogate_U+D800.json │ │ ├── i_string_incomplete_surrogate_and_escape_valid.json │ │ ├── i_string_incomplete_surrogate_pair.json │ │ ├── i_string_incomplete_surrogates_escape_valid.json │ │ ├── i_string_invalid_lonely_surrogate.json │ │ ├── i_string_invalid_surrogate.json │ │ ├── i_string_invalid_utf-8.json │ │ ├── i_string_inverted_surrogates_U+1D11E.json │ │ ├── i_string_iso_latin_1.json │ │ ├── i_string_lone_second_surrogate.json │ │ ├── i_string_lone_utf8_continuation_byte.json │ │ ├── i_string_not_in_unicode_range.json │ │ ├── i_string_overlong_sequence_2_bytes.json │ │ ├── i_string_overlong_sequence_6_bytes.json │ │ ├── i_string_overlong_sequence_6_bytes_null.json │ │ ├── i_string_truncated-utf-8.json │ │ ├── i_string_utf16BE_no_BOM.json │ │ ├── i_string_utf16LE_no_BOM.json │ │ ├── i_structure_500_nested_arrays.json │ │ ├── i_structure_UTF-8_BOM_empty_object.json │ │ ├── n_10.json │ │ ├── n_101.json │ │ ├── n_11.json │ │ ├── n_12.json │ │ ├── n_125.json │ │ ├── n_127.json │ │ ├── n_13.json │ │ ├── n_136.json │ │ ├── n_137.json │ │ ├── n_139.json │ │ ├── n_14.json │ │ ├── n_140.json │ │ ├── n_145.json │ │ ├── n_147.json │ │ ├── n_149.json │ │ ├── n_15.json │ │ ├── n_150.json │ │ ├── n_151.json │ │ ├── n_153.json │ │ ├── n_154.json │ │ ├── n_155.json │ │ ├── n_156.json │ │ ├── n_157.json │ │ ├── n_158.json │ │ ├── n_159.json │ │ ├── n_16.json │ │ ├── n_160.json │ │ ├── n_161.json │ │ ├── n_162.json │ │ ├── n_163.json │ │ ├── n_164.json │ │ ├── n_165.json │ │ ├── n_169.json │ │ ├── n_17.json │ │ ├── n_171.json │ │ ├── n_172.json │ │ ├── n_173.json │ │ ├── n_175.json │ │ ├── n_176.json │ │ ├── n_177.json │ │ ├── n_178.json │ │ ├── n_179.json │ │ ├── n_18.json │ │ ├── n_180.json │ │ ├── n_181.json │ │ ├── n_183.json │ │ ├── n_184.json │ │ ├── n_185.json │ │ ├── n_186.json │ │ ├── n_187.json │ │ ├── n_188.json │ │ ├── n_189.json │ │ ├── n_19.json │ │ ├── n_190.json │ │ ├── n_191.json │ │ ├── n_192.json │ │ ├── n_193.json │ │ ├── n_194.json │ │ ├── n_195.json │ │ ├── n_197.json │ │ ├── n_198.json │ │ ├── n_199.json │ │ ├── n_2.json │ │ ├── n_20.json │ │ ├── n_200.json │ │ ├── n_201.json │ │ ├── n_202.json │ │ ├── n_203.json │ │ ├── n_204.json │ │ ├── n_205.json │ │ ├── n_206.json │ │ ├── n_207.json │ │ ├── n_208.json │ │ ├── n_209.json │ │ ├── n_21.json │ │ ├── n_210.json │ │ ├── n_211.json │ │ ├── n_212.json │ │ ├── n_213.json │ │ ├── n_214.json │ │ ├── n_216.json │ │ ├── n_217.json │ │ ├── n_218.json │ │ ├── n_219.json │ │ ├── n_22.json │ │ ├── n_220.json │ │ ├── n_221.json │ │ ├── n_222.json │ │ ├── n_223.json │ │ ├── n_23.json │ │ ├── n_24.json │ │ ├── n_25.json │ │ ├── n_26.json │ │ ├── n_27.json │ │ ├── n_28.json │ │ ├── n_29.json │ │ ├── n_3.json │ │ ├── n_30.json │ │ ├── n_31.json │ │ ├── n_32.json │ │ ├── n_33.json │ │ ├── n_34.json │ │ ├── n_35.json │ │ ├── n_36.json │ │ ├── n_37.json │ │ ├── n_4.json │ │ ├── n_40.json │ │ ├── n_44.json │ │ ├── n_46.json │ │ ├── n_5.json │ │ ├── n_54.json │ │ ├── n_55.json │ │ ├── n_59.json │ │ ├── n_6.json │ │ ├── n_63.json │ │ ├── n_64.json │ │ ├── n_66.json │ │ ├── n_69.json │ │ ├── n_7.json │ │ ├── n_77.json │ │ ├── n_78.json │ │ ├── n_79.json │ │ ├── n_8.json │ │ ├── n_80.json │ │ ├── n_81.json │ │ ├── n_82.json │ │ ├── n_83.json │ │ ├── n_85.json │ │ ├── n_86.json │ │ ├── n_87.json │ │ ├── n_9.json │ │ ├── n_91.json │ │ ├── n_array_1_true_without_comma.json │ │ ├── n_array_a_invalid_utf8.json │ │ ├── n_array_colon_instead_of_comma.json │ │ ├── n_array_comma_after_close.json │ │ ├── n_array_comma_and_number.json │ │ ├── n_array_double_comma.json │ │ ├── n_array_double_extra_comma.json │ │ ├── n_array_extra_close.json │ │ ├── n_array_extra_comma.json │ │ ├── n_array_incomplete.json │ │ ├── n_array_incomplete_invalid_value.json │ │ ├── n_array_inner_array_no_comma.json │ │ ├── n_array_invalid_utf8.json │ │ ├── n_array_items_separated_by_semicolon.json │ │ ├── n_array_just_comma.json │ │ ├── n_array_just_minus.json │ │ ├── n_array_missing_value.json │ │ ├── n_array_newlines_unclosed.json │ │ ├── n_array_number_and_comma.json │ │ ├── n_array_number_and_several_commas.json │ │ ├── n_array_spaces_vertical_tab_formfeed.json │ │ ├── n_array_star_inside.json │ │ ├── n_array_unclosed.json │ │ ├── n_array_unclosed_trailing_comma.json │ │ ├── n_array_unclosed_with_new_lines.json │ │ ├── n_array_unclosed_with_object_inside.json │ │ ├── n_incomplete_false.json │ │ ├── n_incomplete_null.json │ │ ├── n_incomplete_true.json │ │ ├── n_multidigit_number_then_00.json │ │ ├── n_number_++.json │ │ ├── n_number_+1.json │ │ ├── n_number_+Inf.json │ │ ├── n_number_-01.json │ │ ├── n_number_-1.0..json │ │ ├── n_number_-2..json │ │ ├── n_number_-NaN.json │ │ ├── n_number_.-1.json │ │ ├── n_number_.2e-3.json │ │ ├── n_number_0.1.2.json │ │ ├── n_number_0.3e+.json │ │ ├── n_number_0.3e.json │ │ ├── n_number_0.e1.json │ │ ├── n_number_0_capital_E+.json │ │ ├── n_number_0_capital_E.json │ │ ├── n_number_0e+.json │ │ ├── n_number_0e.json │ │ ├── n_number_1.0e+.json │ │ ├── n_number_1.0e-.json │ │ ├── n_number_1.0e.json │ │ ├── n_number_1_000.json │ │ ├── n_number_1eE2.json │ │ ├── n_number_2.e+3.json │ │ ├── n_number_2.e-3.json │ │ ├── n_number_2.e3.json │ │ ├── n_number_9.e+.json │ │ ├── n_number_Inf.json │ │ ├── n_number_NaN.json │ │ ├── n_number_U+FF11_fullwidth_digit_one.json │ │ ├── n_number_expression.json │ │ ├── n_number_hex_1_digit.json │ │ ├── n_number_hex_2_digits.json │ │ ├── n_number_infinity.json │ │ ├── n_number_invalid+-.json │ │ ├── n_number_invalid-negative-real.json │ │ ├── n_number_invalid-utf-8-in-bigger-int.json │ │ ├── n_number_invalid-utf-8-in-exponent.json │ │ ├── n_number_invalid-utf-8-in-int.json │ │ ├── n_number_minus_infinity.json │ │ ├── n_number_minus_sign_with_trailing_garbage.json │ │ ├── n_number_minus_space_1.json │ │ ├── n_number_neg_int_starting_with_zero.json │ │ ├── n_number_neg_real_without_int_part.json │ │ ├── n_number_neg_with_garbage_at_end.json │ │ ├── n_number_real_garbage_after_e.json │ │ ├── n_number_real_with_invalid_utf8_after_e.json │ │ ├── n_number_real_without_fractional_part.json │ │ ├── n_number_starting_with_dot.json │ │ ├── n_number_with_alpha.json │ │ ├── n_number_with_alpha_char.json │ │ ├── n_number_with_leading_zero.json │ │ ├── n_object_bad_value.json │ │ ├── n_object_bracket_key.json │ │ ├── n_object_comma_instead_of_colon.json │ │ ├── n_object_double_colon.json │ │ ├── n_object_emoji.json │ │ ├── n_object_garbage_at_end.json │ │ ├── n_object_key_with_single_quotes.json │ │ ├── n_object_lone_continuation_byte_in_key_and_trailing_comma.json │ │ ├── n_object_missing_colon.json │ │ ├── n_object_missing_key.json │ │ ├── n_object_missing_semicolon.json │ │ ├── n_object_missing_value.json │ │ ├── n_object_no-colon.json │ │ ├── n_object_non_string_key.json │ │ ├── n_object_non_string_key_but_huge_number_instead.json │ │ ├── n_object_repeated_null_null.json │ │ ├── n_object_several_trailing_commas.json │ │ ├── n_object_single_quote.json │ │ ├── n_object_trailing_comma.json │ │ ├── n_object_trailing_comment.json │ │ ├── n_object_trailing_comment_open.json │ │ ├── n_object_trailing_comment_slash_open.json │ │ ├── n_object_trailing_comment_slash_open_incomplete.json │ │ ├── n_object_two_commas_in_a_row.json │ │ ├── n_object_unquoted_key.json │ │ ├── n_object_unterminated-value.json │ │ ├── n_object_with_single_string.json │ │ ├── n_object_with_trailing_garbage.json │ │ ├── n_single_space.json │ │ ├── n_string_1_surrogate_then_escape.json │ │ ├── n_string_1_surrogate_then_escape_u.json │ │ ├── n_string_1_surrogate_then_escape_u1.json │ │ ├── n_string_1_surrogate_then_escape_u1x.json │ │ ├── n_string_accentuated_char_no_quotes.json │ │ ├── n_string_backslash_00.json │ │ ├── n_string_escape_x.json │ │ ├── n_string_escaped_backslash_bad.json │ │ ├── n_string_escaped_ctrl_char_tab.json │ │ ├── n_string_escaped_emoji.json │ │ ├── n_string_incomplete_escape.json │ │ ├── n_string_incomplete_escaped_character.json │ │ ├── n_string_incomplete_surrogate.json │ │ ├── n_string_incomplete_surrogate_escape_invalid.json │ │ ├── n_string_invalid-utf-8-in-escape.json │ │ ├── n_string_invalid_backslash_esc.json │ │ ├── n_string_invalid_unicode_escape.json │ │ ├── n_string_invalid_utf8_after_escape.json │ │ ├── n_string_leading_uescaped_thinspace.json │ │ ├── n_string_no_quotes_with_bad_escape.json │ │ ├── n_string_single_doublequote.json │ │ ├── n_string_single_quote.json │ │ ├── n_string_single_string_no_double_quotes.json │ │ ├── n_string_start_escape_unclosed.json │ │ ├── n_string_unescaped_ctrl_char.json │ │ ├── n_string_unescaped_newline.json │ │ ├── n_string_unescaped_tab.json │ │ ├── n_string_unicode_CapitalU.json │ │ ├── n_string_with_trailing_garbage.json │ │ ├── n_structure_100000_opening_arrays.json │ │ ├── n_structure_U+2060_word_joined.json │ │ ├── n_structure_UTF8_BOM_no_data.json │ │ ├── n_structure_angle_bracket_..json │ │ ├── n_structure_angle_bracket_null.json │ │ ├── n_structure_array_trailing_garbage.json │ │ ├── n_structure_array_with_extra_array_close.json │ │ ├── n_structure_array_with_unclosed_string.json │ │ ├── n_structure_ascii-unicode-identifier.json │ │ ├── n_structure_capitalized_True.json │ │ ├── n_structure_close_unopened_array.json │ │ ├── n_structure_comma_instead_of_closing_brace.json │ │ ├── n_structure_double_array.json │ │ ├── n_structure_end_array.json │ │ ├── n_structure_incomplete_UTF8_BOM.json │ │ ├── n_structure_lone-invalid-utf-8.json │ │ ├── n_structure_lone-open-bracket.json │ │ ├── n_structure_no_data.json │ │ ├── n_structure_null-byte-outside-string.json │ │ ├── n_structure_number_with_trailing_garbage.json │ │ ├── n_structure_object_followed_by_closing_object.json │ │ ├── n_structure_object_unclosed_no_value.json │ │ ├── n_structure_object_with_comment.json │ │ ├── n_structure_object_with_trailing_garbage.json │ │ ├── n_structure_open_array_apostrophe.json │ │ ├── n_structure_open_array_comma.json │ │ ├── n_structure_open_array_object.json │ │ ├── n_structure_open_array_open_object.json │ │ ├── n_structure_open_array_open_string.json │ │ ├── n_structure_open_array_string.json │ │ ├── n_structure_open_object.json │ │ ├── n_structure_open_object_close_array.json │ │ ├── n_structure_open_object_comma.json │ │ ├── n_structure_open_object_open_array.json │ │ ├── n_structure_open_object_open_string.json │ │ ├── n_structure_open_object_string_with_apostrophes.json │ │ ├── n_structure_open_open.json │ │ ├── n_structure_single_eacute.json │ │ ├── n_structure_single_star.json │ │ ├── n_structure_trailing_#.json │ │ ├── n_structure_uescaped_LF_before_string.json │ │ ├── n_structure_unclosed_array.json │ │ ├── n_structure_unclosed_array_partial_null.json │ │ ├── n_structure_unclosed_array_unfinished_false.json │ │ ├── n_structure_unclosed_array_unfinished_true.json │ │ ├── n_structure_unclosed_object.json │ │ ├── n_structure_unicode-identifier.json │ │ ├── n_structure_whitespace_U+2060_word_joiner.json │ │ ├── n_structure_whitespace_formfeed.json │ │ ├── number_-9223372036854775808.json │ │ ├── number_-9223372036854775809.json │ │ ├── number_1.0.json │ │ ├── number_1.000000000000000005.json │ │ ├── number_1000000000000000.json │ │ ├── number_10000000000000000999.json │ │ ├── number_1e-999.json │ │ ├── number_1e6.json │ │ ├── number_9223372036854775807.json │ │ ├── number_9223372036854775808.json │ │ ├── y_100.json │ │ ├── y_102.json │ │ ├── y_103.json │ │ ├── y_104.json │ │ ├── y_105.json │ │ ├── y_106.json │ │ ├── y_107.json │ │ ├── y_108.json │ │ ├── y_109.json │ │ ├── y_110.json │ │ ├── y_111.json │ │ ├── y_112.json │ │ ├── y_113.json │ │ ├── y_114.json │ │ ├── y_115.json │ │ ├── y_116.json │ │ ├── y_117.json │ │ ├── y_118.json │ │ ├── y_119.json │ │ ├── y_120.json │ │ ├── y_121.json │ │ ├── y_122.json │ │ ├── y_123.json │ │ ├── y_124.json │ │ ├── y_126.json │ │ ├── y_128.json │ │ ├── y_129.json │ │ ├── y_130.json │ │ ├── y_131.json │ │ ├── y_132.json │ │ ├── y_133.json │ │ ├── y_134.json │ │ ├── y_135.json │ │ ├── y_138.json │ │ ├── y_141.json │ │ ├── y_142.json │ │ ├── y_143.json │ │ ├── y_144.json │ │ ├── y_146.json │ │ ├── y_148.json │ │ ├── y_152.json │ │ ├── y_166.json │ │ ├── y_167.json │ │ ├── y_168.json │ │ ├── y_170.json │ │ ├── y_174.json │ │ ├── y_182.json │ │ ├── y_196.json │ │ ├── y_215.json │ │ ├── y_38.json │ │ ├── y_39.json │ │ ├── y_41.json │ │ ├── y_42.json │ │ ├── y_43.json │ │ ├── y_45.json │ │ ├── y_47.json │ │ ├── y_48.json │ │ ├── y_49.json │ │ ├── y_50.json │ │ ├── y_51.json │ │ ├── y_52.json │ │ ├── y_53.json │ │ ├── y_56.json │ │ ├── y_57.json │ │ ├── y_58.json │ │ ├── y_60.json │ │ ├── y_61.json │ │ ├── y_62.json │ │ ├── y_65.json │ │ ├── y_67.json │ │ ├── y_68.json │ │ ├── y_70.json │ │ ├── y_71.json │ │ ├── y_72.json │ │ ├── y_73.json │ │ ├── y_74.json │ │ ├── y_75.json │ │ ├── y_76.json │ │ ├── y_84.json │ │ ├── y_88.json │ │ ├── y_89.json │ │ ├── y_90.json │ │ ├── y_92.json │ │ ├── y_93.json │ │ ├── y_94.json │ │ ├── y_95.json │ │ ├── y_96.json │ │ ├── y_97.json │ │ ├── y_98.json │ │ ├── y_99.json │ │ ├── y_array_arraysWithSpaces.json │ │ ├── y_array_empty-string.json │ │ ├── y_array_empty.json │ │ ├── y_array_ending_with_newline.json │ │ ├── y_array_false.json │ │ ├── y_array_heterogeneous.json │ │ ├── y_array_null.json │ │ ├── y_array_with_1_and_newline.json │ │ ├── y_array_with_leading_space.json │ │ ├── y_array_with_several_null.json │ │ ├── y_array_with_trailing_space.json │ │ ├── y_number.json │ │ ├── y_number_0e+1.json │ │ ├── y_number_0e1.json │ │ ├── y_number_after_space.json │ │ ├── y_number_double_close_to_zero.json │ │ ├── y_number_int_with_exp.json │ │ ├── y_number_minus_zero.json │ │ ├── y_number_negative_int.json │ │ ├── y_number_negative_one.json │ │ ├── y_number_negative_zero.json │ │ ├── y_number_real_capital_e.json │ │ ├── y_number_real_capital_e_neg_exp.json │ │ ├── y_number_real_capital_e_pos_exp.json │ │ ├── y_number_real_exponent.json │ │ ├── y_number_real_fraction_exponent.json │ │ ├── y_number_real_neg_exp.json │ │ ├── y_number_real_pos_exponent.json │ │ ├── y_number_simple_int.json │ │ ├── y_number_simple_real.json │ │ ├── y_object.json │ │ ├── y_object_basic.json │ │ ├── y_object_duplicated_key.json │ │ ├── y_object_duplicated_key_and_value.json │ │ ├── y_object_empty.json │ │ ├── y_object_empty_key.json │ │ ├── y_object_escaped_null_in_key.json │ │ ├── y_object_extreme_numbers.json │ │ ├── y_object_long_strings.json │ │ ├── y_object_simple.json │ │ ├── y_object_string_unicode.json │ │ ├── y_object_with_newlines.json │ │ ├── y_string_1_2_3_bytes_UTF-8_sequences.json │ │ ├── y_string_accepted_surrogate_pair.json │ │ ├── y_string_accepted_surrogate_pairs.json │ │ ├── y_string_allowed_escapes.json │ │ ├── y_string_backslash_and_u_escaped_zero.json │ │ ├── y_string_backslash_doublequotes.json │ │ ├── y_string_comments.json │ │ ├── y_string_double_escape_a.json │ │ ├── y_string_double_escape_n.json │ │ ├── y_string_escaped_control_character.json │ │ ├── y_string_escaped_noncharacter.json │ │ ├── y_string_in_array.json │ │ ├── y_string_in_array_with_leading_space.json │ │ ├── y_string_last_surrogates_1_and_2.json │ │ ├── y_string_nbsp_uescaped.json │ │ ├── y_string_nonCharacterInUTF-8_U+10FFFF.json │ │ ├── y_string_nonCharacterInUTF-8_U+FFFF.json │ │ ├── y_string_null_escape.json │ │ ├── y_string_one-byte-utf-8.json │ │ ├── y_string_pi.json │ │ ├── y_string_reservedCharacterInUTF-8_U+1BFFF.json │ │ ├── y_string_simple_ascii.json │ │ ├── y_string_space.json │ │ ├── y_string_surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF.json │ │ ├── y_string_three-byte-utf-8.json │ │ ├── y_string_two-byte-utf-8.json │ │ ├── y_string_u+2028_line_sep.json │ │ ├── y_string_u+2029_par_sep.json │ │ ├── y_string_uEscape.json │ │ ├── y_string_uescaped_newline.json │ │ ├── y_string_unescaped_char_delete.json │ │ ├── y_string_unicode.json │ │ ├── y_string_unicodeEscapedBackslash.json │ │ ├── y_string_unicode_2.json │ │ ├── y_string_unicode_U+10FFFE_nonchar.json │ │ ├── y_string_unicode_U+1FFFE_nonchar.json │ │ ├── y_string_unicode_U+200B_ZERO_WIDTH_SPACE.json │ │ ├── y_string_unicode_U+2064_invisible_plus.json │ │ ├── y_string_unicode_U+FDD0_nonchar.json │ │ ├── y_string_unicode_U+FFFE_nonchar.json │ │ ├── y_string_unicode_escaped_double_quote.json │ │ ├── y_string_utf8.json │ │ ├── y_string_with_del_character.json │ │ ├── y_structure_lonely_false.json │ │ ├── y_structure_lonely_int.json │ │ ├── y_structure_lonely_negative_real.json │ │ ├── y_structure_lonely_null.json │ │ ├── y_structure_lonely_string.json │ │ ├── y_structure_lonely_true.json │ │ ├── y_structure_string_empty.json │ │ ├── y_structure_trailing_newline.json │ │ ├── y_structure_true_in_array.json │ │ └── y_structure_whitespace_array.json │ ├── test_transform │ │ ├── number_-9223372036854775808.json │ │ ├── number_-9223372036854775809.json │ │ ├── number_1.0.json │ │ ├── number_1.000000000000000005.json │ │ ├── number_1000000000000000.json │ │ ├── number_10000000000000000999.json │ │ ├── number_1e-999.json │ │ ├── number_1e6.json │ │ ├── number_9223372036854775807.json │ │ ├── number_9223372036854775808.json │ │ ├── object_key_nfc_nfd.json │ │ ├── object_key_nfd_nfc.json │ │ ├── object_same_key_different_values.json │ │ ├── object_same_key_same_value.json │ │ ├── object_same_key_unclear_values.json │ │ ├── string_1_escaped_invalid_codepoint.json │ │ ├── string_1_invalid_codepoint.json │ │ ├── string_2_escaped_invalid_codepoints.json │ │ ├── string_2_invalid_codepoints.json │ │ ├── string_3_escaped_invalid_codepoints.json │ │ ├── string_3_invalid_codepoints.json │ │ └── string_with_escaped_NULL.json │ ├── tester.c │ └── tester2.c ├── tokenizer.c ├── tokenizer.h └── value.c ├── cee-resize.h ├── cee.h ├── closure.c ├── convention.txt ├── dict.c ├── diffuse_all.sh ├── env.c ├── list.c ├── map.c ├── musl-hsearch.c ├── musl-insque.c ├── musl-lsearch.c ├── musl-search.h ├── musl-tsearch.c ├── n_tuple.c ├── quadruple.c ├── release ├── cee.c └── cee.h ├── scripts ├── get-cee-std.sh └── get-cee-utils.sh ├── set.c ├── singleton.c ├── sqlite3 ├── cee-sqlite3.c ├── cee-sqlite3.h ├── cee_dbm.c ├── cee_dbm.h └── join.c ├── stack.c ├── state.c ├── str.c ├── strview.c ├── tagged.c ├── test ├── test-func.c ├── test-memory.c └── test.mk ├── triple.c └── tuple.c /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | tmp.c 3 | .stensal_* 4 | cee-one.c 5 | *.out 6 | cee-utils 7 | *.gcno 8 | *.gcda 9 | lcov-out 10 | -------------------------------------------------------------------------------- /DESIGN.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 59 | 60 | 66 | 67 | 68 |
69 | 70 | 71 | -------------------------------------------------------------------------------- /DESIGN.md: -------------------------------------------------------------------------------- 1 | # Design Goals and Principles 2 | 3 | ## Goals 4 | * Easy to maniupate strings 5 | * Ready to use vector, set, map, stack, and dict 6 | 7 | ## Design principles 8 | 9 | * Standard C functions should be directly appliable to memory layout equivalent cee structs, 10 | e.g. all C standard string functions can be applied directly to `cee_str *`. 11 | 12 | * Easy to build correct Proof of Concept (POC) by using the default settings, 13 | e.g. memory leaks are considered benign in POC. 14 | 15 | * Easy things should be easy and hard things should be possible. 16 | 17 | * Memory leak removal is considered as an optimization, it should be 18 | handled easily in later iterations with advanced tooling like 19 | https://cee.studio, valgrind, or ASAN. 20 | 21 | * Performance optimziation should be easy to do by removing abstraction and falling back to 22 | more C idiomatic implementations. 23 | 24 | ## Other considerations 25 | * struct cee_* are used intentionally to distinguish them from their memory layout 26 | equivalent data structures, but they need to be handled different in memory deallocation 27 | 28 | * Code readability triumphs conciseness with the assumption morden IDE's 29 | auto-completion will be used to write code 30 | 31 | * More concise abstraction should be handled by libraries built on top of this lib -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020, 2021 Stensal Inc. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | 1. Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | 2. Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | 3. Neither the name of the copyright holder nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | SHELL := /bin/bash 2 | CC ?= gcc 3 | 4 | OBJDIR = obj 5 | TESTDIR = test 6 | CEE_UTILS_DIR = cee-utils 7 | 8 | MUSL_SRC = musl-hsearch.c musl-insque.c musl-lsearch.c musl-tsearch.c 9 | CEE_SRC = cee-common.c boxed.c str.c dict.c map.c set.c stack.c tuple.c triple.c \ 10 | quadruple.c list.c tagged.c singleton.c closure.c block.c n_tuple.c env.c state.c 11 | SRC = $(MUSL_SRC) $(CEE_SRC) 12 | STD_HDR = stdio.h string.h stdlib.h stdarg.h assert.h errno.h 13 | OBJS = $(SRC:%.c=$(OBJDIR)/%.o) 14 | 15 | CFLAGS := -std=c99 -g -I./ -I./$(CEE_UTILS_DIR) 16 | 17 | ifeq ($(LCOV),1) 18 | CFLAGS += --coverage 19 | LDFLAGS += --coverage 20 | endif 21 | 22 | define cee_amalgamation 23 | @echo "#define CEE_AMALGAMATION" > tmp.c 24 | @for ii in $(SRC); do echo '#include "'$$ii'"' >> tmp.c; done 25 | @echo "#ifndef CEE_ONE" > $(1) 26 | @echo "#define CEE_ONE" >> $(1) 27 | @echo "#define _GNU_SOURCE" >> $(1) 28 | @for ii in $(STD_HDR); do echo '#include <'$$ii'>' >> $(1); done 29 | @cat cee.h >> $(1) 30 | @cat musl-search.h >> $(1) 31 | @echo " " >> $(1) 32 | $(CC) -E -CC $(2) -nostdinc tmp.c >> $(1) 33 | @echo "#endif" >> $(1) 34 | @rm -f tmp.c 35 | endef 36 | 37 | COMMIT_SHA = $(shell git log -n 1 --pretty=format:\"%H\") 38 | 39 | .PHONY: release clean distclean 40 | 41 | # generic compilation 42 | $(OBJDIR)/%.o: %.c 43 | $(CC) $(CFLAGS) -c -o $@ $< 44 | 45 | all: cee_utils $(OBJS) cee-one.c 46 | 47 | cee_utils: $(CEE_UTILS_DIR) 48 | $(OBJS): | $(OBJDIR) 49 | 50 | $(CEE_UTILS_DIR): 51 | if [[ ! -d $@ ]]; then \ 52 | ./scripts/get-cee-utils.sh || exit; \ 53 | fi 54 | $(OBJDIR): 55 | @mkdir -p $(OBJDIR) 56 | 57 | cee-one.c: $(SRC) 58 | $(call cee_amalgamation, cee-one.c) 59 | 60 | release: all 61 | $(call cee_amalgamation, cee.c,-P) 62 | @mkdir -p release 63 | @mv cee.c release 64 | @cp cee.h release 65 | $(MAKE) -C cee-json release 66 | 67 | test: all 68 | $(MAKE) -C $(TESTDIR) -f test.mk 69 | $(TESTDIR)/test-func.out 70 | $(TESTDIR)/test-memory.out 71 | $(MAKE) -C cee-json test_parse test_print 72 | 73 | lcov: 74 | $(MAKE) LCOV=1 release 75 | lcov --directory . --zerocounters -q 76 | $(MAKE) LCOV=1 -k test 77 | lcov --directory . -c -o /tmp/cee-std_test.info 78 | lcov --remove /tmp/cee-std_test.info "*/test/*" "*/cee-utils/*" -o /tmp/cee-std_coverage.info 79 | genhtml /tmp/cee-std_coverage.info --legend --title "commit $(COMMIT_SHA)" --output-directory lcov-out 80 | 81 | echo: 82 | @ echo $(COMMIT_SHA) 83 | @ echo "$(SRC)" 84 | 85 | clean: 86 | rm -rf cee-one.c cee.c tmp.c a.out 87 | rm -rf $(OBJDIR) 88 | $(MAKE) -C $(TESTDIR) -f test.mk clean 89 | $(MAKE) -C cee-json clean 90 | rm -rf lcov-out /tmp/cee-std_*.info 91 | lcov --zerocounters --directory . 92 | -------------------------------------------------------------------------------- /README.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 59 | 60 | 66 | 67 | 68 |
69 | 70 | 71 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # A minimalist C container library 2 | 3 | The goal is to improve C's productivity for building "*high level*" stuff 4 | by providing similar functionalities of C++ STL, but it does not intend to 5 | replicate C++ STL function by function. It relies on C's memory layout to 6 | achieve interoperability with idiomatic C code without requiring any wrappers. 7 | 8 | ## It's optimized for the following use cases: 9 | 10 | 1. If you need simple and minimum C style containers. 11 | 12 | 2. If you want to develop your own dynamic typed scripting languages but 13 | you don't want to reinvent a runtime system. 14 | 15 | ## How to use it ? 16 | 17 | 1. Download the two files; 18 | ``` 19 | wget https://raw.githubusercontent.com/cee-studio/cee-std/master/release/cee.h 20 | wget https://raw.githubusercontent.com/cee-studio/cee-std/master/release/cee.c 21 | ``` 22 | 2. Add them to your source folder 23 | 24 | 25 | ## Examples 26 | 27 | **string** 28 | 29 | ```c 30 | #include "cee.h" 31 | 32 | struct cee_str * s, * s1, * s2; 33 | 34 | s = cee_str_mk(state, "the number ten: %d", 10); 35 | printf("%s\n", (char *)s); 36 | 37 | s1 = cee_str_mk(state, "the number ten point three: %.1f", 10.3); 38 | printf("%s\n", (char *)e); 39 | 40 | s2 = cee_str_mk(state, "%s, %s", s, s1); 41 | printf("%s\n", (char *)s2); 42 | 43 | // delete strings 44 | cee_del(s); 45 | cee_del(s1); 46 | cee_del(s2); 47 | ``` 48 | 49 | **list** 50 | ```c 51 | #include "cee.h" 52 | struct cee_list *v; 53 | 54 | v = cee_list_mk(state, 1); 55 | 56 | v = cee_list_append(v, cee_str("1")); 57 | v = cee_list_append(v, cee_str("2")); 58 | v = cee_list_append(v, cee_str("3")); 59 | 60 | printf("v.count %u\n", cee_list_size(v)); 61 | for (int i = 0; i < cee_list_size(v); i++) { 62 | printf ("%d:%s\n", i, (char *)v->_[i]); 63 | } 64 | 65 | // delete list 66 | cee_del(v); 67 | ``` 68 | 69 | **set** 70 | ```c 71 | #include "cee.h" 72 | 73 | struct cee_set * st = cee_set_mk(state, (cee_cmp_fun)strcmp); 74 | printf ("st: %p\n", st); 75 | cee_set_add(st, cee_str("a")); 76 | cee_set_add(st, cee_str("aabc")); 77 | char * p = cee_set_find(st, "aabc"); 78 | printf ("%s\n", p); 79 | 80 | // delete set 81 | cee_del(st); 82 | ``` 83 | 84 | **map** 85 | ```c 86 | #include "cee.h" 87 | 88 | struct cee_map * mp = cee_map_mk(state, (cee_cmp_fun)strcmp); 89 | cee_map_add(mp, cee_str("1"), cee_box_i32(10)); 90 | cee_map_add(mp, cee_str("2"), cee_box_i32(20)); 91 | cee_map_add(mp, cee_str("3"), cee_box_i32(30)); 92 | 93 | void * t = cee_map_find(mp, "1"); 94 | printf ("found value %u\n", (uintptr_t)t); 95 | 96 | struct cee_vect * keys = cee_map_keys(mp); 97 | for (int i = 0; i < cee_vect_count(keys); i++) { 98 | printf ("[%d] key:%s\n", i, (char *)keys->_[i]); 99 | } 100 | 101 | // delete map 102 | cee_del(mp); 103 | ``` 104 | 105 | **stack** 106 | ```c 107 | #include "cee.h" 108 | 109 | struct cee_stack * sp = cee_stack_mk_e(state, CEE_DP_NOOP, 100); 110 | cee_stack_push(sp, "1"); 111 | cee_stack_push(sp, "2"); 112 | cee_stack_push(sp, "3"); 113 | printf ("%s\n", cee_stack_top(sp, 0)); 114 | 115 | // delete stack, optional 116 | cee_del(stack); 117 | ``` 118 | 119 | **free any memory blocks of `struct cee_*`** 120 | 121 | any memory blocks pointed by a `cee struct` can be freed with `cee_del` like the following: 122 | ```c 123 | #include "cee.h" 124 | 125 | struct cee_str * s = ..; 126 | cee_del(s); 127 | 128 | struct cee_vect * v = ..; 129 | cee_del(v); 130 | 131 | struct cee_map * m = ..; 132 | cee_del(m); 133 | 134 | struct cee_stack * sp = ..; 135 | cee_del(sp); 136 | ``` 137 | 138 | ## How to test/develop it ? 139 | 140 | ### Using https://www.cee.studio cloud IDE 141 | 142 | cee.studio is our primary development IDE as it can automatically detect and 143 | report all memory access violations, and memory leaks. 144 | 145 | 1. click [https://cee.studio/?bucket=orca&name=cee-std](https://cee.studio/?bucket=orca&name=cee-std) 146 | 2. clone to my account 147 | 3. click Start 148 | 4. run it Terminal 149 | 150 | cee.studio will detect and report all memory access violations. 151 | 152 | 153 | ### Using your computer 154 | 155 | You will need to install `valgrind` to debug memory access violations, and memory leaks. 156 | 157 | ``` 158 | git clone https://github.com/cee-studio/cee-std.git 159 | cd cee-std 160 | make 161 | ./a.out 162 | ``` 163 | 164 | ## Rationale 165 | 166 | [DESIGN](./DESIGN.md) 167 | 168 | 169 | ## Contributions are welcome 170 | We follow [the orca coding guide line](https://github.com/cee-studio/orca/blob/master/docs/CODING_GUIDELINES.md) for this project. 171 | 172 | Please join our discord [https://discord.gg/nBUqrWf](https://discord.gg/nBUqrWf) 173 | -------------------------------------------------------------------------------- /block.c: -------------------------------------------------------------------------------- 1 | #ifdef CEE_AMALGAMATION 2 | #undef S 3 | #define S(f) _cee_block_##f 4 | #else 5 | #define S(f) _##f 6 | #include "cee.h" 7 | #include 8 | #include 9 | #include 10 | #include 11 | #endif 12 | #include "cee-header.h" 13 | 14 | #ifndef CEE_BLOCK 15 | #define CEE_BLOCK 64 16 | #endif 17 | 18 | struct S(header) { 19 | uintptr_t capacity; 20 | enum cee_del_policy del_policy; 21 | struct cee_sect cs; 22 | char _[1]; /* actual data */ 23 | }; 24 | 25 | #include "cee-resize.h" 26 | 27 | static void S(trace) (void * p, enum cee_trace_action ta) { 28 | struct S(header) * m = FIND_HEADER(p); 29 | switch (ta) { 30 | case CEE_TRACE_DEL_FOLLOW: 31 | case CEE_TRACE_DEL_NO_FOLLOW: 32 | S(de_chain)(m); 33 | free(m); 34 | break; 35 | case CEE_TRACE_MARK: 36 | default: 37 | m->cs.gc_mark = ta - CEE_TRACE_MARK; 38 | break; 39 | } 40 | } 41 | 42 | static void S(mark) (void * p) { 43 | /* we don't know anything about this block 44 | * do nothing now. 45 | */ 46 | }; 47 | 48 | void *cee_block_mk_nonzero(struct cee_state *s, size_t n){ 49 | size_t mem_block_size; 50 | va_list ap; 51 | 52 | mem_block_size = n + sizeof(struct S(header)); 53 | struct S(header) * m = malloc(mem_block_size); 54 | 55 | ZERO_CEE_SECT(&m->cs); 56 | m->del_policy = CEE_DP_DEL_RC; 57 | S(chain)(m, s); 58 | 59 | m->cs.trace = S(trace); 60 | m->cs.resize_method = CEE_RESIZE_WITH_MALLOC; 61 | m->cs.mem_block_size = mem_block_size; 62 | m->cs.cmp = (void *)memcmp; 63 | m->capacity = n; 64 | 65 | return (struct cee_block *)(m->_); 66 | } 67 | 68 | void *cee_block_mk(struct cee_state *s, size_t n){ 69 | void *p = cee_block_mk_nonzero(s, n); 70 | memset(p, 0, n); 71 | return p; 72 | } 73 | 74 | /* 75 | * @param init_f: a function to initialize the allocated block 76 | */ 77 | void *cee_block_mk_e(struct cee_state *s, size_t n, void *cxt, void (*init_f)(void *cxt, void *block)){ 78 | void *block = cee_block_mk_nonzero(s, n); 79 | init_f(cxt, block); 80 | return block; 81 | } 82 | 83 | 84 | size_t cee_block_size (struct cee_block *b) 85 | { 86 | struct S(header) *h = FIND_HEADER(b); 87 | return h->capacity; 88 | } 89 | -------------------------------------------------------------------------------- /cee-common.c: -------------------------------------------------------------------------------- 1 | #ifdef CEE_AMALGAMATION 2 | #undef S 3 | #define S(f) _cee_common_##f 4 | #else 5 | #define $(f) _##f 6 | #include "cee.h" 7 | #include 8 | #include 9 | #include 10 | #endif 11 | 12 | #define FIND_SECT(p) (struct cee_sect *)((void *)((char *)p - sizeof(struct cee_sect))) 13 | 14 | void cee_trace (void *p, enum cee_trace_action ta) { 15 | if (!p) return; 16 | 17 | struct cee_sect * cs = FIND_SECT(p); 18 | cs->trace(p, ta); 19 | } 20 | 21 | /* 22 | * a generic resource delete function for all cee_* pointers 23 | */ 24 | void cee_del(void *p) { 25 | if (!p) return; 26 | 27 | struct cee_sect * cs = FIND_SECT(p); 28 | cs->trace(p, CEE_TRACE_DEL_FOLLOW); 29 | } 30 | 31 | 32 | struct cee_state* cee_get_state (void *p) { 33 | struct cee_sect *cs = FIND_SECT(p); 34 | return cs->state; 35 | } 36 | 37 | void cee_del_ref(void *p) { 38 | if (!p) return; 39 | 40 | struct cee_sect * cs = FIND_SECT(p); 41 | 42 | if (cs->in_degree) cs->in_degree --; 43 | 44 | /* if it's retained by an owner, 45 | it should be freed by cee_del 46 | */ 47 | if (cs->retained) return; 48 | 49 | /* none points to me, let's remove 50 | * the references to all blocks pointed by 51 | * me 52 | */ 53 | if (!cs->in_degree) cs->trace(p, CEE_TRACE_DEL_FOLLOW); 54 | } 55 | 56 | void cee_use_realloc(void * p) { 57 | struct cee_sect * cs = FIND_SECT(p); 58 | if (cs->resize_method) 59 | cs->resize_method = CEE_RESIZE_WITH_REALLOC; 60 | } 61 | 62 | void cee_use_malloc(void * p) { 63 | struct cee_sect * cs = FIND_SECT(p); 64 | if (cs->resize_method) 65 | cs->resize_method = CEE_RESIZE_WITH_MALLOC; 66 | } 67 | 68 | static void _cee_common_incr_rc (void * p) { 69 | struct cee_sect * cs = FIND_SECT(p); 70 | if (cs->retained) return; 71 | 72 | cs->in_degree ++; 73 | } 74 | 75 | static void _cee_common_decr_rc (void * p) { 76 | struct cee_sect * cs = FIND_SECT(p); 77 | if (cs->retained) return; 78 | 79 | if (cs->in_degree) 80 | cs->in_degree --; 81 | else { 82 | /* report warnings */ 83 | } 84 | } 85 | 86 | uint16_t get_in_degree (void * p) { 87 | struct cee_sect * cs = FIND_SECT(p); 88 | return cs->in_degree; 89 | } 90 | 91 | static void _cee_common_retain (void *p) { 92 | struct cee_sect * cs = FIND_SECT(p); 93 | cs->retained = 1; 94 | } 95 | 96 | static void _cee_common_release (void * p) { 97 | struct cee_sect * cs = FIND_SECT(p); 98 | if(cs->retained) 99 | cs->retained = 0; 100 | else { 101 | /* report error */ 102 | cee_segfault(); 103 | } 104 | } 105 | 106 | void cee_incr_indegree (enum cee_del_policy o, void * p) { 107 | switch(o) { 108 | case CEE_DP_DEL_RC: 109 | _cee_common_incr_rc(p); 110 | break; 111 | case CEE_DP_DEL: 112 | _cee_common_retain(p); 113 | break; 114 | case CEE_DP_NOOP: 115 | break; 116 | } 117 | } 118 | 119 | void cee_decr_indegree (enum cee_del_policy o, void * p) { 120 | switch(o) { 121 | case CEE_DP_DEL_RC: 122 | _cee_common_decr_rc(p); 123 | break; 124 | case CEE_DP_DEL: 125 | _cee_common_release(p); 126 | break; 127 | case CEE_DP_NOOP: 128 | break; 129 | } 130 | } 131 | 132 | 133 | void cee_del_e (enum cee_del_policy o, void *p) { 134 | switch(o) { 135 | case CEE_DP_DEL_RC: 136 | cee_del_ref(p); 137 | break; 138 | case CEE_DP_DEL: 139 | cee_del(p); 140 | break; 141 | case CEE_DP_NOOP: 142 | break; 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /cee-header.h: -------------------------------------------------------------------------------- 1 | #undef DATA_OFFSET 2 | #undef FIND_HEADER 3 | #define DATA_OFFSET (__builtin_offsetof(struct S(header), _)) 4 | #define FIND_HEADER(p) (struct S(header) *)((void *)((char *)(p) - DATA_OFFSET)) 5 | #define ZERO_CEE_SECT(s) do{ memset(s, 0, sizeof(struct cee_sect)); } while(0); 6 | -------------------------------------------------------------------------------- /cee-json/.gitignore: -------------------------------------------------------------------------------- 1 | tmp.c 2 | cee-json-one* 3 | .stensal_* 4 | *.o 5 | -------------------------------------------------------------------------------- /cee-json/LICENSE: -------------------------------------------------------------------------------- 1 | The folder contains code that belongs to the following projects; 2 | cppcms:https://github.com/artyom-beilis/cppcms 3 | cJSON:https://github.com/DaveGamble/cJSON 4 | stonky:https://github.com/antirez/stonky 5 | 6 | Copyright 2020 Stensal Inc. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | 1. Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | 15 | 2. Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | 19 | 3. Neither the name of the copyright holder nor the names of its 20 | contributors may be used to endorse or promote products derived from 21 | this software without specific prior written permission. 22 | 23 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 29 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 30 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 31 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | -------------------------------------------------------------------------------- /cee-json/Makefile: -------------------------------------------------------------------------------- 1 | TOP = .. 2 | CC ?= gcc 3 | 4 | OBJDIR = obj 5 | TESTDIR = test 6 | 7 | SRC = value.c parser.c snprint.c tokenizer.c cee_json_merge.c 8 | HDR = cee-json.h tokenizer.h 9 | STD_HDR = stdlib.h string.h errno.h sys/types.h sys/stat.h unistd.h stdio.h ctype.h 10 | OBJS = $(SRC:%.c=$(OBJDIR)/%.o) 11 | 12 | CFLAGS := -fno-exceptions -g -I./ -I$(TOP)/ -I$(TOP)/cee-utils 13 | 14 | ifeq ($(LCOV),1) 15 | CFLAGS += --coverage 16 | LDFLAGS += --coverage 17 | endif 18 | 19 | .PHONY: release clean test 20 | 21 | define cee_json_amalgamation 22 | @echo "#ifndef CEE_JSON_ONE" > $(1) 23 | @echo "#define CEE_JSON_ONE" >> $(1) 24 | @echo "#define _GNU_SOURCE" >> $(1) 25 | @for ii in $(STD_HDR); do echo '#include <'$$ii'>' >> $(1); done 26 | @echo "#include \"cee.h\"" >> $(1) 27 | @echo " " >> $(1) 28 | @for ii in $(HDR); do cat $$ii >> $(1); echo " " >> $(1); done 29 | @echo "#define CEE_JSON_AMALGAMATION" > tmp.c 30 | @for ii in $(SRC); do echo '#include "'$$ii'"' >> tmp.c; done 31 | $(CC) -E -CC $(2) -nostdinc tmp.c >> $(1) 32 | @echo "#endif" >> $(1) 33 | @rm -f tmp.c 34 | endef 35 | 36 | # generic compilation 37 | $(OBJDIR)/%.o: %.c 38 | $(CC) $(CFLAGS) -c -o $@ $< 39 | 40 | all: $(OBJS) cee-json-one.c 41 | 42 | $(OBJS): | $(OBJDIR) 43 | 44 | $(OBJDIR): 45 | @mkdir -p $(OBJDIR) 46 | 47 | cee-json-one.c: $(TOP)/cee-one.c $(SRC) 48 | $(call cee_json_amalgamation, $@) 49 | 50 | $(TOP)/cee-one.c: 51 | $(MAKE) -C $(TOP) release 52 | 53 | release: all 54 | $(call cee_json_amalgamation, cee-json.c,-P) 55 | @mkdir -p release 56 | @mv cee-json.c release 57 | @cp cee-json.h release 58 | 59 | test: all 60 | $(MAKE) -C $(TESTDIR) -f test.mk 61 | 62 | test_parse: test 63 | $(MAKE) -C $(TESTDIR) -f test.mk test_parse 64 | 65 | test_print: test 66 | $(MAKE) -C $(TESTDIR) -f test.mk test_print 67 | 68 | clean: 69 | rm -rf a.c cee-json-one.c 70 | rm -rf $(OBJDIR) 71 | $(MAKE) -C $(TESTDIR) -f test.mk clean 72 | -------------------------------------------------------------------------------- /cee-json/README.txt: -------------------------------------------------------------------------------- 1 | This folder contains the C reimplementation of cppcms's json to demostrate that 2 | with the help of `cee-std` the C implementation is simpler and easier to reason 3 | than the original C++ implementation. 4 | 5 | The COPYRIGHT of the algorithm and some 6 | code belongs to Artyom Beilis (Tonkikh) 7 | 8 | 9 | The folder contains code/algorithm that are shamelessly stolen from these great works: 10 | 11 | CPPMS: https://github.com/artyom-beilis/cppcms/blob/master/src/json.cpp 12 | Stonky: https://github.com/antirez/stonky/blob/main/stonky.c 13 | -------------------------------------------------------------------------------- /cee-json/USAGE.md: -------------------------------------------------------------------------------- 1 | ## How to use this release 2 | * copy cee.h and cee.c to your source folder 3 | * add "#include "cee.h" to your code 4 | * link cee.c to your code -------------------------------------------------------------------------------- /cee-json/cee_json_merge.c: -------------------------------------------------------------------------------- 1 | #ifndef CEE_JSON_AMALGAMATION 2 | #include 3 | #include "cee.h" 4 | #include "cee-json.h" 5 | #endif 6 | 7 | int cee_json_merge_all(char **json_files, int json_file_count, char *merged){ 8 | static char perror_buf[128] = {0}; 9 | 10 | FILE *f0 = fopen(json_files[0], "r"), *fn, *f_combined; 11 | if( !f0 ){ 12 | snprintf(perror_buf, sizeof perror_buf, "fopen(%s)", json_files[0]); 13 | perror(perror_buf); 14 | return 1; 15 | } 16 | struct cee_state *state = cee_state_mk(100); 17 | int line = -1; 18 | struct cee_json *j0, *jn; 19 | j0 = cee_json_load_from_FILE(state, f0, true, &line); 20 | if( j0 == NULL ){ 21 | fprintf(stderr, "error at %s:%d\n", json_files[0], line); 22 | return 1; 23 | } 24 | 25 | for( int i = 1; i < json_file_count; i++ ){ 26 | fn = fopen(json_files[i], "r"); 27 | if( !fn ){ 28 | snprintf(perror_buf, sizeof perror_buf, "fopen(%s)", json_files[i]); 29 | perror(perror_buf); 30 | return 1; 31 | } 32 | line = -1; 33 | jn = cee_json_load_from_FILE(state, fn, true, &line); 34 | if( jn == NULL ){ 35 | fprintf(stderr, "error at %s:%d\n", json_files[i], line); 36 | return 1; 37 | } 38 | cee_json_merge(j0, jn); 39 | fclose(fn); 40 | } 41 | 42 | f_combined = fopen(merged, "w"); 43 | if( !f_combined ){ 44 | perror(merged); 45 | return 1; 46 | } 47 | struct cee_json *inputs = cee_json_array_mk(state, json_file_count); 48 | cee_json_object_set(j0, "originals", inputs); 49 | for( int i = 0; i < json_file_count; i++ ){ 50 | struct cee_json *a = cee_json_str_mkf(state, "%s", json_files[i]); 51 | cee_json_array_append(inputs, a); 52 | } 53 | 54 | cee_json_save(state, j0, f_combined, 1); 55 | fclose(f_combined); 56 | fclose(f0); 57 | cee_del(state); 58 | return 0; 59 | } 60 | -------------------------------------------------------------------------------- /cee-json/diffuse_all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | while [ $# -ne 0 ]; do 4 | case $1 in 5 | "--unstage") 6 | unstage="Y" 7 | ;; 8 | "--help") 9 | echo "Usage: $0 [--unstage]" 10 | exit 1 11 | ;; 12 | *) 13 | echo "Usage: $0 [--unstage]" 14 | exit 1 15 | ;; 16 | esac 17 | shift 18 | done 19 | 20 | for i in $(git status -s | awk '{ print $2'}); do 21 | diffuse $i 22 | if [ -z "unstage" ]; then 23 | read -p "STAGE '$i' ? y/[n]:" ans 24 | if [ "$ans" = "y" ] || [ "$ans" = "Y" ]; then 25 | echo "git add $i" 26 | git add $i 27 | fi 28 | else 29 | read -p "UNSTAGE '$i' ? y/[n]:" ans 30 | if [ "$ans" = "y" ] || [ "$ans" = "Y" ]; then 31 | echo "git reset HEAD $i" 32 | git reset HEAD $i 33 | fi 34 | fi 35 | done 36 | -------------------------------------------------------------------------------- /cee-json/test/test-parser.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "release/cee.c" 10 | #include "release/cee-json.c" 11 | #include "greatest.h" 12 | 13 | 14 | static char **g_files; 15 | static char **g_suffixes; 16 | static int g_n_files; 17 | 18 | enum action { 19 | ACTION_NONE = 0, 20 | ACTION_ACCEPT = 1 << 0, 21 | ACTION_REJECT = 1 << 2 22 | }; 23 | 24 | 25 | char* load_whole_file(char *filename, long *p_fsize) 26 | { 27 | FILE *f = fopen(filename,"rb"); 28 | assert(NULL != f && "Couldn't open file"); 29 | 30 | fseek(f, 0, SEEK_END); 31 | long fsize = ftell(f); 32 | fseek(f, 0, SEEK_SET); 33 | 34 | char *str = malloc(fsize + 1); 35 | 36 | str[fsize] = '\0'; 37 | fread(str, 1, fsize, f); 38 | 39 | fclose(f); 40 | 41 | if (p_fsize) *p_fsize = fsize; 42 | 43 | return str; 44 | } 45 | 46 | TEST check_parser(char str[], long len, enum action expected) 47 | { 48 | static char errbuf[2048]; 49 | pid_t pid; 50 | 51 | pid = fork(); 52 | if (pid < 0) { 53 | snprintf(errbuf, sizeof(errbuf), "%s", strerror(errno)); 54 | SKIPm(errbuf); 55 | } 56 | 57 | if (0 == pid) { // child process 58 | struct cee_state *st = cee_state_mk(10); 59 | struct cee_json *json = NULL; 60 | int errline = -1; 61 | 62 | cee_json_parsex(st, str, len, &json, true, &errline); 63 | _exit( -1 == errline ? EXIT_SUCCESS : EXIT_FAILURE ); 64 | } 65 | 66 | int status; 67 | wait(&status); 68 | if (!WIFEXITED(status)) { // child process crashed 69 | snprintf(errbuf, sizeof(errbuf), "Process crashed, JSON: %.*s", (int)len, str); 70 | FAILm(errbuf); 71 | } 72 | 73 | enum action action; 74 | if (EXIT_SUCCESS == WEXITSTATUS(status)) 75 | action = ACTION_ACCEPT; 76 | else 77 | action = ACTION_REJECT; 78 | 79 | if (!expected || action & expected) 80 | PASS(); 81 | 82 | snprintf(errbuf, sizeof(errbuf), "JSON: %.*s", (int)len, str); 83 | FAILm(errbuf); 84 | } 85 | 86 | SUITE(json_parsing) 87 | { 88 | char* jsonstr; 89 | long jsonlen; 90 | 91 | for (int i=0; i < g_n_files; ++i) { 92 | jsonstr = load_whole_file(g_files[i], &jsonlen); 93 | 94 | enum action expected; 95 | switch (g_suffixes[i][0]) { 96 | case 'y': expected = ACTION_ACCEPT; break; 97 | case 'n': expected = ACTION_REJECT; break; 98 | case 'i': expected = ACTION_ACCEPT | ACTION_REJECT; break; 99 | default: 100 | fprintf(stderr, "Error: File '%s' not conforming to github.com/nst/JSONTestSuite", g_files[i]); 101 | exit(EXIT_FAILURE); 102 | } 103 | 104 | greatest_set_test_suffix(g_suffixes[i]); 105 | RUN_TESTp(check_parser, jsonstr, jsonlen, expected); 106 | 107 | free(jsonstr); 108 | } 109 | } 110 | 111 | SUITE(json_transform) 112 | { 113 | char *jsonstr; 114 | long jsonlen; 115 | 116 | for (int i=0; i < g_n_files; ++i) { 117 | jsonstr = load_whole_file(g_files[i], &jsonlen); 118 | 119 | greatest_set_test_suffix(g_suffixes[i]); 120 | RUN_TESTp(check_parser, jsonstr, jsonlen, ACTION_NONE); 121 | 122 | free(jsonstr); 123 | } 124 | } 125 | 126 | GREATEST_MAIN_DEFS(); 127 | 128 | int main(int argc, char *argv[]) 129 | { 130 | GREATEST_MAIN_BEGIN(); 131 | 132 | for (int i=0; i < argc; ++i) { 133 | // we're assuming the files are after the "--" arg 134 | if (0 == strcmp("--", argv[i]) && (i+1 < argc)) { 135 | g_files = argv + (i+1); 136 | g_n_files = argc - (i+1); 137 | break; 138 | } 139 | } 140 | assert(g_n_files != 0 && "Couldn't locate files"); 141 | 142 | // create test suffixes for easy identification 143 | g_suffixes = malloc(g_n_files * sizeof(char *)); 144 | char *start, *end; 145 | for (int i=0; i < g_n_files; ++i) { 146 | if ( (start = strchr(g_files[i], '/')) ) 147 | ++start; 148 | else 149 | start = g_files[i]; 150 | end = strrchr(start, '.'); 151 | 152 | size_t size = end ? (end - start) : strlen(start); 153 | g_suffixes[i] = malloc(size + 1); 154 | memcpy(g_suffixes[i], start, size); 155 | g_suffixes[i][size] = '\0'; 156 | } 157 | 158 | RUN_SUITE(json_parsing); 159 | RUN_SUITE(json_transform); 160 | 161 | GREATEST_MAIN_END(); 162 | } 163 | -------------------------------------------------------------------------------- /cee-json/test/test.mk: -------------------------------------------------------------------------------- 1 | TOP = ../.. 2 | CC ?= gcc 3 | 4 | SRC = $(wildcard *.c) 5 | EXES = $(SRC:%.c=%.out) 6 | 7 | TEST_PARSING_DIR = test_parsing 8 | TEST_TRANSFORM_DIR = test_transform 9 | PARSER_SUITE_EXE = test-parser.out 10 | PRINT_SUITE_EXE = test-print.out 11 | 12 | CFLAGS := -std=c99 -fno-exceptions -g -I../ -I$(TOP)/ -I$(TOP)/cee-utils 13 | 14 | ifeq ($(LCOV),1) 15 | CFLAGS += --coverage 16 | LDFLAGS += --coverage 17 | endif 18 | 19 | # generic compilation 20 | %.out: %.c $(OBJS) ../obj/cJSON.o 21 | $(CC) $(CFLAGS) -g -o $@ $^ 22 | 23 | ../obj/cJSON.o: $(TOP)/cee-utils/cJSON.c 24 | $(CC) $(CFLAGS) -c -o $@ $< 25 | 26 | all: $(EXES) 27 | 28 | test_parse: $(EXES) $(TEST_PARSING_DIR) $(TEST_TRANSFORM_DIR) 29 | - ./$(PARSER_SUITE_EXE) -e -s json_parsing -- $(TEST_PARSING_DIR)/* 30 | - ./$(PARSER_SUITE_EXE) -e -s json_transform -- $(TEST_TRANSFORM_DIR)/* 31 | 32 | test_print: $(EXES) $(TEST_PARSING_DIR) $(TEST_TRANSFORM_DIR) 33 | - ./$(PRINT_SUITE_EXE) -s json_parsing -t cmp -- $(TEST_PARSING_DIR)/* 34 | - ./$(PRINT_SUITE_EXE) -s json_transform -t cmp -- $(TEST_TRANSFORM_DIR)/* 35 | 36 | clean: 37 | rm -f *.out *.gcno *.gcda 38 | 39 | .PHONY : all clean 40 | -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_array_extra_comma.json: -------------------------------------------------------------------------------- 1 | ["",] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_array_number_and_comma.json: -------------------------------------------------------------------------------- 1 | [1,] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_number_double_huge_neg_exp.json: -------------------------------------------------------------------------------- 1 | [123.456e-789] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_number_huge_exp.json: -------------------------------------------------------------------------------- 1 | [0.4e00669999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999969999999006] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_number_neg_int_huge_exp.json: -------------------------------------------------------------------------------- 1 | [-1e+9999] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_number_pos_double_huge_exp.json: -------------------------------------------------------------------------------- 1 | [1.5e+9999] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_number_real_neg_overflow.json: -------------------------------------------------------------------------------- 1 | [-123123e100000] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_number_real_pos_overflow.json: -------------------------------------------------------------------------------- 1 | [123123e100000] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_number_real_underflow.json: -------------------------------------------------------------------------------- 1 | [123e-10000000] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_number_too_big_neg_int.json: -------------------------------------------------------------------------------- 1 | [-123123123123123123123123123123] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_number_too_big_pos_int.json: -------------------------------------------------------------------------------- 1 | [100000000000000000000] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_number_very_big_negative_int.json: -------------------------------------------------------------------------------- 1 | [-237462374673276894279832749832423479823246327846] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_object_key_lone_2nd_surrogate.json: -------------------------------------------------------------------------------- 1 | {"\uDFAA":0} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_object_lone_continuation_byte_in_key_and_trailing_comma.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_parsing/i_object_lone_continuation_byte_in_key_and_trailing_comma.json -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_object_trailing_comma.json: -------------------------------------------------------------------------------- 1 | {"id":0,} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_string_1st_surrogate_but_2nd_missing.json: -------------------------------------------------------------------------------- 1 | ["\uDADA"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_string_1st_valid_surrogate_2nd_invalid.json: -------------------------------------------------------------------------------- 1 | ["\uD888\u1234"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_string_UTF-16LE_with_BOM.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_parsing/i_string_UTF-16LE_with_BOM.json -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_string_UTF-8_invalid_sequence.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_parsing/i_string_UTF-8_invalid_sequence.json -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_string_UTF8_surrogate_U+D800.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_parsing/i_string_UTF8_surrogate_U+D800.json -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_string_incomplete_surrogate_and_escape_valid.json: -------------------------------------------------------------------------------- 1 | ["\uD800\n"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_string_incomplete_surrogate_pair.json: -------------------------------------------------------------------------------- 1 | ["\uDd1ea"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_string_incomplete_surrogates_escape_valid.json: -------------------------------------------------------------------------------- 1 | ["\uD800\uD800\n"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_string_invalid_lonely_surrogate.json: -------------------------------------------------------------------------------- 1 | ["\ud800"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_string_invalid_surrogate.json: -------------------------------------------------------------------------------- 1 | ["\ud800abc"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_string_invalid_utf-8.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_parsing/i_string_invalid_utf-8.json -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_string_inverted_surrogates_U+1D11E.json: -------------------------------------------------------------------------------- 1 | ["\uDd1e\uD834"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_string_iso_latin_1.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_parsing/i_string_iso_latin_1.json -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_string_lone_second_surrogate.json: -------------------------------------------------------------------------------- 1 | ["\uDFAA"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_string_lone_utf8_continuation_byte.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_parsing/i_string_lone_utf8_continuation_byte.json -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_string_not_in_unicode_range.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_parsing/i_string_not_in_unicode_range.json -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_string_overlong_sequence_2_bytes.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_parsing/i_string_overlong_sequence_2_bytes.json -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_string_overlong_sequence_6_bytes.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_parsing/i_string_overlong_sequence_6_bytes.json -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_string_overlong_sequence_6_bytes_null.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_parsing/i_string_overlong_sequence_6_bytes_null.json -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_string_truncated-utf-8.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_parsing/i_string_truncated-utf-8.json -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_string_utf16BE_no_BOM.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_parsing/i_string_utf16BE_no_BOM.json -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_string_utf16LE_no_BOM.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_parsing/i_string_utf16LE_no_BOM.json -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_structure_500_nested_arrays.json: -------------------------------------------------------------------------------- 1 | [[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/i_structure_UTF-8_BOM_empty_object.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_10.json: -------------------------------------------------------------------------------- 1 | [1,2,] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_101.json: -------------------------------------------------------------------------------- 1 | ["hello", "bye\n\r\t\v"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_11.json: -------------------------------------------------------------------------------- 1 | [1:2} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_12.json: -------------------------------------------------------------------------------- 1 | {"1":2,} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_125.json: -------------------------------------------------------------------------------- 1 | hello -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_127.json: -------------------------------------------------------------------------------- 1 | [32, -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_13.json: -------------------------------------------------------------------------------- 1 | {1:2} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_136.json: -------------------------------------------------------------------------------- 1 | 3. -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_137.json: -------------------------------------------------------------------------------- 1 | .3 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_139.json: -------------------------------------------------------------------------------- 1 | 0.3e -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_14.json: -------------------------------------------------------------------------------- 1 | {"1":2, "2.5" : [3, 4, {}, {"5": ["6"], [7 ]}]} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_140.json: -------------------------------------------------------------------------------- 1 | 0.3e+ -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_145.json: -------------------------------------------------------------------------------- 1 | +3 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_147.json: -------------------------------------------------------------------------------- 1 | -3. -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_149.json: -------------------------------------------------------------------------------- 1 | .5 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_15.json: -------------------------------------------------------------------------------- 1 | {"1":2, "2.5" : [3, 4, {}, {"5": ["6"], [7]}]} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_150.json: -------------------------------------------------------------------------------- 1 | 5. -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_151.json: -------------------------------------------------------------------------------- 1 | 5.e1 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_153.json: -------------------------------------------------------------------------------- 1 | .3e1 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_154.json: -------------------------------------------------------------------------------- 1 | .3e+1 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_155.json: -------------------------------------------------------------------------------- 1 | .3e-1 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_156.json: -------------------------------------------------------------------------------- 1 | .3e-1 .5 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_157.json: -------------------------------------------------------------------------------- 1 | .3e-1.5 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_158.json: -------------------------------------------------------------------------------- 1 | .3e+1.5 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_159.json: -------------------------------------------------------------------------------- 1 | .3e+. -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_16.json: -------------------------------------------------------------------------------- 1 | {"1":2, "2.5" : [3, 4, {}, {"5": ["6"], "7" :[8 ]}] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_160.json: -------------------------------------------------------------------------------- 1 | .3e+.5 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_161.json: -------------------------------------------------------------------------------- 1 | .3e+1.5 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_162.json: -------------------------------------------------------------------------------- 1 | 9.3e+1.5 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_163.json: -------------------------------------------------------------------------------- 1 | 9.e+1.5 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_164.json: -------------------------------------------------------------------------------- 1 | 9.e+ -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_165.json: -------------------------------------------------------------------------------- 1 | 9.e+1 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_169.json: -------------------------------------------------------------------------------- 1 | "\".". -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_17.json: -------------------------------------------------------------------------------- 1 | {"1":2, "2.5" : [3, 4, {}, {"5": ["6"], "7" :[8 ]}]] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_171.json: -------------------------------------------------------------------------------- 1 | "\"\"\"\""" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_172.json: -------------------------------------------------------------------------------- 1 | ["\"\"\"\"", .5] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_173.json: -------------------------------------------------------------------------------- 1 | [.5] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_175.json: -------------------------------------------------------------------------------- 1 | ["\"\"\"\"", .5] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_176.json: -------------------------------------------------------------------------------- 1 | ["\"\"\"\"",.5] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_177.json: -------------------------------------------------------------------------------- 1 | ["\"",.5] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_178.json: -------------------------------------------------------------------------------- 1 | ["\".5",.5] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_179.json: -------------------------------------------------------------------------------- 1 | ["\".5",".5\"".5] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_18.json: -------------------------------------------------------------------------------- 1 | {"1":2, "3":4 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_180.json: -------------------------------------------------------------------------------- 1 | ["\".5",".5\"", .5] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_181.json: -------------------------------------------------------------------------------- 1 | ["\".5",".5\"",.5] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_183.json: -------------------------------------------------------------------------------- 1 | {"key":/*comment*/"value"} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_184.json: -------------------------------------------------------------------------------- 1 | {"key":/*comment"value"} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_185.json: -------------------------------------------------------------------------------- 1 | {"key":"value"}/* -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_186.json: -------------------------------------------------------------------------------- 1 | {"key":"value"}/**/ -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_187.json: -------------------------------------------------------------------------------- 1 | {"key":"value"}/***/ -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_188.json: -------------------------------------------------------------------------------- 1 | {"key":"value"}/**// -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_189.json: -------------------------------------------------------------------------------- 1 | {"key":"value"}/**/// -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_19.json: -------------------------------------------------------------------------------- 1 | "1\u2" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_190.json: -------------------------------------------------------------------------------- 1 | {"key":"value"}/**///---- -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_191.json: -------------------------------------------------------------------------------- 1 | {"key":"value"}# -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_192.json: -------------------------------------------------------------------------------- 1 | {"key":"value"}#{ -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_193.json: -------------------------------------------------------------------------------- 1 | {"key":"value"}#{} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_194.json: -------------------------------------------------------------------------------- 1 | {"key":"value"}#, -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_195.json: -------------------------------------------------------------------------------- 1 | {"key":"value"/**/, "k2":"v2"} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_197.json: -------------------------------------------------------------------------------- 1 | "hello\'" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_198.json: -------------------------------------------------------------------------------- 1 | 'hello\'' -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_199.json: -------------------------------------------------------------------------------- 1 | 'hello' -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_2.json: -------------------------------------------------------------------------------- 1 | " -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_20.json: -------------------------------------------------------------------------------- 1 | [,2] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_200.json: -------------------------------------------------------------------------------- 1 | 'hell\'o' -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_201.json: -------------------------------------------------------------------------------- 1 | '\'hello' -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_202.json: -------------------------------------------------------------------------------- 1 | '\'hello\'' -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_203.json: -------------------------------------------------------------------------------- 1 | \'hello\' -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_204.json: -------------------------------------------------------------------------------- 1 | 'hello\' -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_205.json: -------------------------------------------------------------------------------- 1 | ['hello\'] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_206.json: -------------------------------------------------------------------------------- 1 | ['hello\''] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_207.json: -------------------------------------------------------------------------------- 1 | ['hello"'] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_208.json: -------------------------------------------------------------------------------- 1 | ['hello\"'] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_209.json: -------------------------------------------------------------------------------- 1 | ['hello"o'] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_21.json: -------------------------------------------------------------------------------- 1 | "3 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_210.json: -------------------------------------------------------------------------------- 1 | ['"'] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_211.json: -------------------------------------------------------------------------------- 1 | '"' -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_212.json: -------------------------------------------------------------------------------- 1 | '"hello"' -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_213.json: -------------------------------------------------------------------------------- 1 | '"hello' -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_214.json: -------------------------------------------------------------------------------- 1 | '"hi"' -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_216.json: -------------------------------------------------------------------------------- 1 | nil -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_217.json: -------------------------------------------------------------------------------- 1 | fals -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_218.json: -------------------------------------------------------------------------------- 1 | falsify -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_219.json: -------------------------------------------------------------------------------- 1 | falsetto -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_22.json: -------------------------------------------------------------------------------- 1 | "3" "4" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_220.json: -------------------------------------------------------------------------------- 1 | truism -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_221.json: -------------------------------------------------------------------------------- 1 | {"key" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_222.json: -------------------------------------------------------------------------------- 1 | {"key","key2":value} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_223.json: -------------------------------------------------------------------------------- 1 | "\u0000" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_23.json: -------------------------------------------------------------------------------- 1 | [3[4] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_24.json: -------------------------------------------------------------------------------- 1 | [3[4]] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_25.json: -------------------------------------------------------------------------------- 1 | [3, [4, [5], 6] 7, 8 9] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_26.json: -------------------------------------------------------------------------------- 1 | [3, [4, [5], 6] 7, 8, 9] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_27.json: -------------------------------------------------------------------------------- 1 | [3, [4, [5], 6], 7, 8 9] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_28.json: -------------------------------------------------------------------------------- 1 | {"hello":true, "bye":false, null} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_29.json: -------------------------------------------------------------------------------- 1 | {"hello":true, "bye":false, null:null} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_3.json: -------------------------------------------------------------------------------- 1 | [,] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_30.json: -------------------------------------------------------------------------------- 1 | "hi -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_31.json: -------------------------------------------------------------------------------- 1 | "hi""" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_32.json: -------------------------------------------------------------------------------- 1 | {"hi": "bye"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_33.json: -------------------------------------------------------------------------------- 1 | "\uD800\uD800" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_34.json: -------------------------------------------------------------------------------- 1 | "\uD800\uDBFF" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_35.json: -------------------------------------------------------------------------------- 1 | "\UD834\UDD1E" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_36.json: -------------------------------------------------------------------------------- 1 | "\uDB00" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_37.json: -------------------------------------------------------------------------------- 1 | "\uDB00\uDBFF" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_4.json: -------------------------------------------------------------------------------- 1 | [) -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_40.json: -------------------------------------------------------------------------------- 1 | . -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_44.json: -------------------------------------------------------------------------------- 1 | +. -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_46.json: -------------------------------------------------------------------------------- 1 | 0.e1 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_5.json: -------------------------------------------------------------------------------- 1 | []] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_54.json: -------------------------------------------------------------------------------- 1 | +1234 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_55.json: -------------------------------------------------------------------------------- 1 | ++1234 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_59.json: -------------------------------------------------------------------------------- 1 | 123.e-142 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_6.json: -------------------------------------------------------------------------------- 1 | [} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_63.json: -------------------------------------------------------------------------------- 1 | .246e-142 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_64.json: -------------------------------------------------------------------------------- 1 | .2e-142 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_66.json: -------------------------------------------------------------------------------- 1 | .3 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_69.json: -------------------------------------------------------------------------------- 1 | +3. -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_7.json: -------------------------------------------------------------------------------- 1 | {,} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_77.json: -------------------------------------------------------------------------------- 1 | +3.5 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_78.json: -------------------------------------------------------------------------------- 1 | .3e -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_79.json: -------------------------------------------------------------------------------- 1 | .3e1 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_8.json: -------------------------------------------------------------------------------- 1 | {] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_80.json: -------------------------------------------------------------------------------- 1 | .3e-1 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_81.json: -------------------------------------------------------------------------------- 1 | .3e+1 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_82.json: -------------------------------------------------------------------------------- 1 | 3.e1 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_83.json: -------------------------------------------------------------------------------- 1 | 3.e+1 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_85.json: -------------------------------------------------------------------------------- 1 | .5 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_86.json: -------------------------------------------------------------------------------- 1 | +.5 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_87.json: -------------------------------------------------------------------------------- 1 | .5e+1 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_9.json: -------------------------------------------------------------------------------- 1 | ["1":2] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_91.json: -------------------------------------------------------------------------------- 1 | .e-14234 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_array_1_true_without_comma.json: -------------------------------------------------------------------------------- 1 | [1 true] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_array_a_invalid_utf8.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_parsing/n_array_a_invalid_utf8.json -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_array_colon_instead_of_comma.json: -------------------------------------------------------------------------------- 1 | ["": 1] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_array_comma_after_close.json: -------------------------------------------------------------------------------- 1 | [""], -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_array_comma_and_number.json: -------------------------------------------------------------------------------- 1 | [,1] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_array_double_comma.json: -------------------------------------------------------------------------------- 1 | [1,,2] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_array_double_extra_comma.json: -------------------------------------------------------------------------------- 1 | ["x",,] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_array_extra_close.json: -------------------------------------------------------------------------------- 1 | ["x"]] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_array_extra_comma.json: -------------------------------------------------------------------------------- 1 | ["",] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_array_incomplete.json: -------------------------------------------------------------------------------- 1 | ["x" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_array_incomplete_invalid_value.json: -------------------------------------------------------------------------------- 1 | [x -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_array_inner_array_no_comma.json: -------------------------------------------------------------------------------- 1 | [3[4]] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_array_invalid_utf8.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_parsing/n_array_invalid_utf8.json -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_array_items_separated_by_semicolon.json: -------------------------------------------------------------------------------- 1 | [1:2] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_array_just_comma.json: -------------------------------------------------------------------------------- 1 | [,] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_array_just_minus.json: -------------------------------------------------------------------------------- 1 | [-] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_array_missing_value.json: -------------------------------------------------------------------------------- 1 | [ , ""] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_array_newlines_unclosed.json: -------------------------------------------------------------------------------- 1 | ["a", 2 | 4 3 | ,1, -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_array_number_and_comma.json: -------------------------------------------------------------------------------- 1 | [1,] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_array_number_and_several_commas.json: -------------------------------------------------------------------------------- 1 | [1,,] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_array_spaces_vertical_tab_formfeed.json: -------------------------------------------------------------------------------- 1 | [" a"\f] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_array_star_inside.json: -------------------------------------------------------------------------------- 1 | [*] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_array_unclosed.json: -------------------------------------------------------------------------------- 1 | ["" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_array_unclosed_trailing_comma.json: -------------------------------------------------------------------------------- 1 | [1, -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_array_unclosed_with_new_lines.json: -------------------------------------------------------------------------------- 1 | [1, 2 | 1 3 | ,1 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_array_unclosed_with_object_inside.json: -------------------------------------------------------------------------------- 1 | [{} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_incomplete_false.json: -------------------------------------------------------------------------------- 1 | [fals] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_incomplete_null.json: -------------------------------------------------------------------------------- 1 | [nul] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_incomplete_true.json: -------------------------------------------------------------------------------- 1 | [tru] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_multidigit_number_then_00.json: -------------------------------------------------------------------------------- 1 | 123 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_++.json: -------------------------------------------------------------------------------- 1 | [++1234] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_+1.json: -------------------------------------------------------------------------------- 1 | [+1] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_+Inf.json: -------------------------------------------------------------------------------- 1 | [+Inf] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_-01.json: -------------------------------------------------------------------------------- 1 | [-01] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_-1.0..json: -------------------------------------------------------------------------------- 1 | [-1.0.] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_-2..json: -------------------------------------------------------------------------------- 1 | [-2.] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_-NaN.json: -------------------------------------------------------------------------------- 1 | [-NaN] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_.-1.json: -------------------------------------------------------------------------------- 1 | [.-1] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_.2e-3.json: -------------------------------------------------------------------------------- 1 | [.2e-3] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_0.1.2.json: -------------------------------------------------------------------------------- 1 | [0.1.2] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_0.3e+.json: -------------------------------------------------------------------------------- 1 | [0.3e+] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_0.3e.json: -------------------------------------------------------------------------------- 1 | [0.3e] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_0.e1.json: -------------------------------------------------------------------------------- 1 | [0.e1] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_0_capital_E+.json: -------------------------------------------------------------------------------- 1 | [0E+] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_0_capital_E.json: -------------------------------------------------------------------------------- 1 | [0E] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_0e+.json: -------------------------------------------------------------------------------- 1 | [0e+] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_0e.json: -------------------------------------------------------------------------------- 1 | [0e] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_1.0e+.json: -------------------------------------------------------------------------------- 1 | [1.0e+] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_1.0e-.json: -------------------------------------------------------------------------------- 1 | [1.0e-] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_1.0e.json: -------------------------------------------------------------------------------- 1 | [1.0e] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_1_000.json: -------------------------------------------------------------------------------- 1 | [1 000.0] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_1eE2.json: -------------------------------------------------------------------------------- 1 | [1eE2] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_2.e+3.json: -------------------------------------------------------------------------------- 1 | [2.e+3] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_2.e-3.json: -------------------------------------------------------------------------------- 1 | [2.e-3] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_2.e3.json: -------------------------------------------------------------------------------- 1 | [2.e3] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_9.e+.json: -------------------------------------------------------------------------------- 1 | [9.e+] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_Inf.json: -------------------------------------------------------------------------------- 1 | [Inf] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_NaN.json: -------------------------------------------------------------------------------- 1 | [NaN] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_U+FF11_fullwidth_digit_one.json: -------------------------------------------------------------------------------- 1 | [1] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_expression.json: -------------------------------------------------------------------------------- 1 | [1+2] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_hex_1_digit.json: -------------------------------------------------------------------------------- 1 | [0x1] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_hex_2_digits.json: -------------------------------------------------------------------------------- 1 | [0x42] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_infinity.json: -------------------------------------------------------------------------------- 1 | [Infinity] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_invalid+-.json: -------------------------------------------------------------------------------- 1 | [0e+-1] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_invalid-negative-real.json: -------------------------------------------------------------------------------- 1 | [-123.123foo] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_invalid-utf-8-in-bigger-int.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_parsing/n_number_invalid-utf-8-in-bigger-int.json -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_invalid-utf-8-in-exponent.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_parsing/n_number_invalid-utf-8-in-exponent.json -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_invalid-utf-8-in-int.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_parsing/n_number_invalid-utf-8-in-int.json -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_minus_infinity.json: -------------------------------------------------------------------------------- 1 | [-Infinity] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_minus_sign_with_trailing_garbage.json: -------------------------------------------------------------------------------- 1 | [-foo] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_minus_space_1.json: -------------------------------------------------------------------------------- 1 | [- 1] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_neg_int_starting_with_zero.json: -------------------------------------------------------------------------------- 1 | [-012] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_neg_real_without_int_part.json: -------------------------------------------------------------------------------- 1 | [-.123] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_neg_with_garbage_at_end.json: -------------------------------------------------------------------------------- 1 | [-1x] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_real_garbage_after_e.json: -------------------------------------------------------------------------------- 1 | [1ea] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_real_with_invalid_utf8_after_e.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_parsing/n_number_real_with_invalid_utf8_after_e.json -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_real_without_fractional_part.json: -------------------------------------------------------------------------------- 1 | [1.] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_starting_with_dot.json: -------------------------------------------------------------------------------- 1 | [.123] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_with_alpha.json: -------------------------------------------------------------------------------- 1 | [1.2a-3] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_with_alpha_char.json: -------------------------------------------------------------------------------- 1 | [1.8011670033376514H-308] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_number_with_leading_zero.json: -------------------------------------------------------------------------------- 1 | [012] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_bad_value.json: -------------------------------------------------------------------------------- 1 | ["x", truth] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_bracket_key.json: -------------------------------------------------------------------------------- 1 | {[: "x"} 2 | -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_comma_instead_of_colon.json: -------------------------------------------------------------------------------- 1 | {"x", null} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_double_colon.json: -------------------------------------------------------------------------------- 1 | {"x"::"b"} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_emoji.json: -------------------------------------------------------------------------------- 1 | {🇨🇭} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_garbage_at_end.json: -------------------------------------------------------------------------------- 1 | {"a":"a" 123} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_key_with_single_quotes.json: -------------------------------------------------------------------------------- 1 | {key: 'value'} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_lone_continuation_byte_in_key_and_trailing_comma.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_parsing/n_object_lone_continuation_byte_in_key_and_trailing_comma.json -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_missing_colon.json: -------------------------------------------------------------------------------- 1 | {"a" b} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_missing_key.json: -------------------------------------------------------------------------------- 1 | {:"b"} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_missing_semicolon.json: -------------------------------------------------------------------------------- 1 | {"a" "b"} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_missing_value.json: -------------------------------------------------------------------------------- 1 | {"a": -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_no-colon.json: -------------------------------------------------------------------------------- 1 | {"a" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_non_string_key.json: -------------------------------------------------------------------------------- 1 | {1:1} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_non_string_key_but_huge_number_instead.json: -------------------------------------------------------------------------------- 1 | {9999E9999:1} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_repeated_null_null.json: -------------------------------------------------------------------------------- 1 | {null:null,null:null} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_several_trailing_commas.json: -------------------------------------------------------------------------------- 1 | {"id":0,,,,,} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_single_quote.json: -------------------------------------------------------------------------------- 1 | {'a':0} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_trailing_comma.json: -------------------------------------------------------------------------------- 1 | {"id":0,} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_trailing_comment.json: -------------------------------------------------------------------------------- 1 | {"a":"b"}/**/ -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_trailing_comment_open.json: -------------------------------------------------------------------------------- 1 | {"a":"b"}/**// -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_trailing_comment_slash_open.json: -------------------------------------------------------------------------------- 1 | {"a":"b"}// -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_trailing_comment_slash_open_incomplete.json: -------------------------------------------------------------------------------- 1 | {"a":"b"}/ -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_two_commas_in_a_row.json: -------------------------------------------------------------------------------- 1 | {"a":"b",,"c":"d"} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_unquoted_key.json: -------------------------------------------------------------------------------- 1 | {a: "b"} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_unterminated-value.json: -------------------------------------------------------------------------------- 1 | {"a":"a -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_with_single_string.json: -------------------------------------------------------------------------------- 1 | { "foo" : "bar", "a" } -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_object_with_trailing_garbage.json: -------------------------------------------------------------------------------- 1 | {"a":"b"}# -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_single_space.json: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_1_surrogate_then_escape.json: -------------------------------------------------------------------------------- 1 | ["\uD800\"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_1_surrogate_then_escape_u.json: -------------------------------------------------------------------------------- 1 | ["\uD800\u"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_1_surrogate_then_escape_u1.json: -------------------------------------------------------------------------------- 1 | ["\uD800\u1"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_1_surrogate_then_escape_u1x.json: -------------------------------------------------------------------------------- 1 | ["\uD800\u1x"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_accentuated_char_no_quotes.json: -------------------------------------------------------------------------------- 1 | [é] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_backslash_00.json: -------------------------------------------------------------------------------- 1 | ["\"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_escape_x.json: -------------------------------------------------------------------------------- 1 | ["\x00"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_escaped_backslash_bad.json: -------------------------------------------------------------------------------- 1 | ["\\\"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_escaped_ctrl_char_tab.json: -------------------------------------------------------------------------------- 1 | ["\ "] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_escaped_emoji.json: -------------------------------------------------------------------------------- 1 | ["\🌀"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_incomplete_escape.json: -------------------------------------------------------------------------------- 1 | ["\"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_incomplete_escaped_character.json: -------------------------------------------------------------------------------- 1 | ["\u00A"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_incomplete_surrogate.json: -------------------------------------------------------------------------------- 1 | ["\uD834\uDd"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_incomplete_surrogate_escape_invalid.json: -------------------------------------------------------------------------------- 1 | ["\uD800\uD800\x"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_invalid-utf-8-in-escape.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_parsing/n_string_invalid-utf-8-in-escape.json -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_invalid_backslash_esc.json: -------------------------------------------------------------------------------- 1 | ["\a"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_invalid_unicode_escape.json: -------------------------------------------------------------------------------- 1 | ["\uqqqq"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_invalid_utf8_after_escape.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_parsing/n_string_invalid_utf8_after_escape.json -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_leading_uescaped_thinspace.json: -------------------------------------------------------------------------------- 1 | [\u0020"asd"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_no_quotes_with_bad_escape.json: -------------------------------------------------------------------------------- 1 | [\n] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_single_doublequote.json: -------------------------------------------------------------------------------- 1 | " -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_single_quote.json: -------------------------------------------------------------------------------- 1 | ['single quote'] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_single_string_no_double_quotes.json: -------------------------------------------------------------------------------- 1 | abc -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_start_escape_unclosed.json: -------------------------------------------------------------------------------- 1 | ["\ -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_unescaped_ctrl_char.json: -------------------------------------------------------------------------------- 1 | ["aa"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_unescaped_newline.json: -------------------------------------------------------------------------------- 1 | ["new 2 | line"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_unescaped_tab.json: -------------------------------------------------------------------------------- 1 | [" "] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_unicode_CapitalU.json: -------------------------------------------------------------------------------- 1 | "\UA66D" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_string_with_trailing_garbage.json: -------------------------------------------------------------------------------- 1 | ""x -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_U+2060_word_joined.json: -------------------------------------------------------------------------------- 1 | [⁠] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_UTF8_BOM_no_data.json: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_angle_bracket_..json: -------------------------------------------------------------------------------- 1 | <.> -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_angle_bracket_null.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_array_trailing_garbage.json: -------------------------------------------------------------------------------- 1 | [1]x -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_array_with_extra_array_close.json: -------------------------------------------------------------------------------- 1 | [1]] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_array_with_unclosed_string.json: -------------------------------------------------------------------------------- 1 | ["asd] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_ascii-unicode-identifier.json: -------------------------------------------------------------------------------- 1 | aå -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_capitalized_True.json: -------------------------------------------------------------------------------- 1 | [True] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_close_unopened_array.json: -------------------------------------------------------------------------------- 1 | 1] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_comma_instead_of_closing_brace.json: -------------------------------------------------------------------------------- 1 | {"x": true, -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_double_array.json: -------------------------------------------------------------------------------- 1 | [][] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_end_array.json: -------------------------------------------------------------------------------- 1 | ] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_incomplete_UTF8_BOM.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_parsing/n_structure_incomplete_UTF8_BOM.json -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_lone-invalid-utf-8.json: -------------------------------------------------------------------------------- 1 | � -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_lone-open-bracket.json: -------------------------------------------------------------------------------- 1 | [ -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_no_data.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_parsing/n_structure_no_data.json -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_null-byte-outside-string.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_number_with_trailing_garbage.json: -------------------------------------------------------------------------------- 1 | 2@ -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_object_followed_by_closing_object.json: -------------------------------------------------------------------------------- 1 | {}} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_object_unclosed_no_value.json: -------------------------------------------------------------------------------- 1 | {"": -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_object_with_comment.json: -------------------------------------------------------------------------------- 1 | {"a":/*comment*/"b"} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_object_with_trailing_garbage.json: -------------------------------------------------------------------------------- 1 | {"a": true} "x" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_open_array_apostrophe.json: -------------------------------------------------------------------------------- 1 | [' -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_open_array_comma.json: -------------------------------------------------------------------------------- 1 | [, -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_open_array_open_object.json: -------------------------------------------------------------------------------- 1 | [{ -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_open_array_open_string.json: -------------------------------------------------------------------------------- 1 | ["a -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_open_array_string.json: -------------------------------------------------------------------------------- 1 | ["a" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_open_object.json: -------------------------------------------------------------------------------- 1 | { -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_open_object_close_array.json: -------------------------------------------------------------------------------- 1 | {] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_open_object_comma.json: -------------------------------------------------------------------------------- 1 | {, -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_open_object_open_array.json: -------------------------------------------------------------------------------- 1 | {[ -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_open_object_open_string.json: -------------------------------------------------------------------------------- 1 | {"a -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_open_object_string_with_apostrophes.json: -------------------------------------------------------------------------------- 1 | {'a' -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_open_open.json: -------------------------------------------------------------------------------- 1 | ["\{["\{["\{["\{ -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_single_eacute.json: -------------------------------------------------------------------------------- 1 | � -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_single_star.json: -------------------------------------------------------------------------------- 1 | * -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_trailing_#.json: -------------------------------------------------------------------------------- 1 | {"a":"b"}#{} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_uescaped_LF_before_string.json: -------------------------------------------------------------------------------- 1 | [\u000A""] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_unclosed_array.json: -------------------------------------------------------------------------------- 1 | [1 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_unclosed_array_partial_null.json: -------------------------------------------------------------------------------- 1 | [ false, nul -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_unclosed_array_unfinished_false.json: -------------------------------------------------------------------------------- 1 | [ true, fals -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_unclosed_array_unfinished_true.json: -------------------------------------------------------------------------------- 1 | [ false, tru -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_unclosed_object.json: -------------------------------------------------------------------------------- 1 | {"asd":"asd" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_unicode-identifier.json: -------------------------------------------------------------------------------- 1 | å -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_whitespace_U+2060_word_joiner.json: -------------------------------------------------------------------------------- 1 | [⁠] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/n_structure_whitespace_formfeed.json: -------------------------------------------------------------------------------- 1 | [ ] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/number_-9223372036854775808.json: -------------------------------------------------------------------------------- 1 | [-9223372036854775808] 2 | -------------------------------------------------------------------------------- /cee-json/test/test_parsing/number_-9223372036854775809.json: -------------------------------------------------------------------------------- 1 | [-9223372036854775809] 2 | -------------------------------------------------------------------------------- /cee-json/test/test_parsing/number_1.0.json: -------------------------------------------------------------------------------- 1 | [1.0] 2 | -------------------------------------------------------------------------------- /cee-json/test/test_parsing/number_1.000000000000000005.json: -------------------------------------------------------------------------------- 1 | [1.000000000000000005] 2 | -------------------------------------------------------------------------------- /cee-json/test/test_parsing/number_1000000000000000.json: -------------------------------------------------------------------------------- 1 | [1000000000000000] 2 | -------------------------------------------------------------------------------- /cee-json/test/test_parsing/number_10000000000000000999.json: -------------------------------------------------------------------------------- 1 | [10000000000000000999] 2 | -------------------------------------------------------------------------------- /cee-json/test/test_parsing/number_1e-999.json: -------------------------------------------------------------------------------- 1 | [1E-999] 2 | -------------------------------------------------------------------------------- /cee-json/test/test_parsing/number_1e6.json: -------------------------------------------------------------------------------- 1 | [1E6] 2 | -------------------------------------------------------------------------------- /cee-json/test/test_parsing/number_9223372036854775807.json: -------------------------------------------------------------------------------- 1 | [9223372036854775807] 2 | -------------------------------------------------------------------------------- /cee-json/test/test_parsing/number_9223372036854775808.json: -------------------------------------------------------------------------------- 1 | [9223372036854775808] 2 | -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_100.json: -------------------------------------------------------------------------------- 1 | ["hello", "bye\n\r\t\b",true , false, null] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_102.json: -------------------------------------------------------------------------------- 1 | {"hello":true} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_103.json: -------------------------------------------------------------------------------- 1 | {"hello":true, "bye":false} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_104.json: -------------------------------------------------------------------------------- 1 | {"hello":true, "bye":false, "foo":["one","two","three"]} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_105.json: -------------------------------------------------------------------------------- 1 | "hi" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_106.json: -------------------------------------------------------------------------------- 1 | ["hi"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_107.json: -------------------------------------------------------------------------------- 1 | ["hi", "bye"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_108.json: -------------------------------------------------------------------------------- 1 | {"hi": "bye"} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_109.json: -------------------------------------------------------------------------------- 1 | ["hi", "bye", 3] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_110.json: -------------------------------------------------------------------------------- 1 | ["hi", "bye[", 3] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_111.json: -------------------------------------------------------------------------------- 1 | "\u0007" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_112.json: -------------------------------------------------------------------------------- 1 | "\u0008" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_113.json: -------------------------------------------------------------------------------- 1 | "\u0009" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_114.json: -------------------------------------------------------------------------------- 1 | "\u0010" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_115.json: -------------------------------------------------------------------------------- 1 | "\u0020" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_116.json: -------------------------------------------------------------------------------- 1 | "\u10000" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_117.json: -------------------------------------------------------------------------------- 1 | "\u1234" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_118.json: -------------------------------------------------------------------------------- 1 | "\u99999" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_119.json: -------------------------------------------------------------------------------- 1 | "\ud800\udc00" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_120.json: -------------------------------------------------------------------------------- 1 | "\uD800\uDC00" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_121.json: -------------------------------------------------------------------------------- 1 | "\uD834\uDD1E" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_122.json: -------------------------------------------------------------------------------- 1 | "\uDBFF\uDFFF" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_123.json: -------------------------------------------------------------------------------- 1 | "\uFFFD" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_124.json: -------------------------------------------------------------------------------- 1 | "\uFFFF" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_126.json: -------------------------------------------------------------------------------- 1 | [32, 1] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_128.json: -------------------------------------------------------------------------------- 1 | "\uD800\uDC00" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_129.json: -------------------------------------------------------------------------------- 1 | "\n" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_130.json: -------------------------------------------------------------------------------- 1 | "hello" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_131.json: -------------------------------------------------------------------------------- 1 | "hello\u0009world" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_132.json: -------------------------------------------------------------------------------- 1 | "hello" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_133.json: -------------------------------------------------------------------------------- 1 | "hello\n" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_134.json: -------------------------------------------------------------------------------- 1 | "hello" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_135.json: -------------------------------------------------------------------------------- 1 | 3 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_138.json: -------------------------------------------------------------------------------- 1 | 0.3 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_141.json: -------------------------------------------------------------------------------- 1 | 0.3e+5 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_142.json: -------------------------------------------------------------------------------- 1 | 0.3e-5 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_143.json: -------------------------------------------------------------------------------- 1 | 0.3e5 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_144.json: -------------------------------------------------------------------------------- 1 | "hello" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_146.json: -------------------------------------------------------------------------------- 1 | -3 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_148.json: -------------------------------------------------------------------------------- 1 | -3.1 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_152.json: -------------------------------------------------------------------------------- 1 | 0.5 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_166.json: -------------------------------------------------------------------------------- 1 | "\"" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_167.json: -------------------------------------------------------------------------------- 1 | "\"3.5" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_168.json: -------------------------------------------------------------------------------- 1 | "\"." -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_170.json: -------------------------------------------------------------------------------- 1 | "\"....." -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_174.json: -------------------------------------------------------------------------------- 1 | ["\"\"\"\"", 0.5] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_182.json: -------------------------------------------------------------------------------- 1 | ["\".5",".5\"",0.5] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_196.json: -------------------------------------------------------------------------------- 1 | "\u0027" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_215.json: -------------------------------------------------------------------------------- 1 | [ 1 , 2 , 3 ] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_38.json: -------------------------------------------------------------------------------- 1 | "\uFFFE" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_39.json: -------------------------------------------------------------------------------- 1 | "\uFFFF" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_41.json: -------------------------------------------------------------------------------- 1 | "" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_42.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_43.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_45.json: -------------------------------------------------------------------------------- 1 | 0.5 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_47.json: -------------------------------------------------------------------------------- 1 | {"1":{}} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_48.json: -------------------------------------------------------------------------------- 1 | {"1":2} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_49.json: -------------------------------------------------------------------------------- 1 | {"1":2, "2.5" : [3, 4, {}, {"5": ["6"]}]} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_50.json: -------------------------------------------------------------------------------- 1 | {"1":2, "2.5" : [3, 4, {}, {"5": ["6"], "7" :[8 ]}]} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_51.json: -------------------------------------------------------------------------------- 1 | 1234 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_52.json: -------------------------------------------------------------------------------- 1 | -1234 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_53.json: -------------------------------------------------------------------------------- 1 | {"1":2, "3":4} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_56.json: -------------------------------------------------------------------------------- 1 | 123.456e142 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_57.json: -------------------------------------------------------------------------------- 1 | 123.456e-142 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_58.json: -------------------------------------------------------------------------------- 1 | 123.456e+142 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_60.json: -------------------------------------------------------------------------------- 1 | "1\u2000" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_61.json: -------------------------------------------------------------------------------- 1 | "1\u20001" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_62.json: -------------------------------------------------------------------------------- 1 | 2 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_65.json: -------------------------------------------------------------------------------- 1 | 3 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_67.json: -------------------------------------------------------------------------------- 1 | "3" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_68.json: -------------------------------------------------------------------------------- 1 | [3] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_70.json: -------------------------------------------------------------------------------- 1 | 3.2e+1 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_71.json: -------------------------------------------------------------------------------- 1 | [3, [4]] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_72.json: -------------------------------------------------------------------------------- 1 | [3, [4, [5]]] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_73.json: -------------------------------------------------------------------------------- 1 | [3, [4, [5], 6]] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_74.json: -------------------------------------------------------------------------------- 1 | [3, [4, [5], 6], 7] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_75.json: -------------------------------------------------------------------------------- 1 | [3, [4, [5], 6], 7, 8] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_76.json: -------------------------------------------------------------------------------- 1 | [3, [4, [5], 6], 7, 8, 9] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_84.json: -------------------------------------------------------------------------------- 1 | 3e+1 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_88.json: -------------------------------------------------------------------------------- 1 | [ 7] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_89.json: -------------------------------------------------------------------------------- 1 | [7 ] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_90.json: -------------------------------------------------------------------------------- 1 | [7] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_92.json: -------------------------------------------------------------------------------- 1 | "hello" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_93.json: -------------------------------------------------------------------------------- 1 | ["hello"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_94.json: -------------------------------------------------------------------------------- 1 | ["hello", "bye"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_95.json: -------------------------------------------------------------------------------- 1 | ["hello", "bye\n"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_96.json: -------------------------------------------------------------------------------- 1 | ["hello", "bye\n\r\t"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_97.json: -------------------------------------------------------------------------------- 1 | ["hello", "bye\n\r\t\b"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_98.json: -------------------------------------------------------------------------------- 1 | ["hello", "bye\n\r\t\b",true] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_99.json: -------------------------------------------------------------------------------- 1 | ["hello", "bye\n\r\t\b",true , false] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_array_arraysWithSpaces.json: -------------------------------------------------------------------------------- 1 | [[] ] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_array_empty-string.json: -------------------------------------------------------------------------------- 1 | [""] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_array_empty.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_array_ending_with_newline.json: -------------------------------------------------------------------------------- 1 | ["a"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_array_false.json: -------------------------------------------------------------------------------- 1 | [false] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_array_heterogeneous.json: -------------------------------------------------------------------------------- 1 | [null, 1, "1", {}] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_array_null.json: -------------------------------------------------------------------------------- 1 | [null] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_array_with_1_and_newline.json: -------------------------------------------------------------------------------- 1 | [1 2 | ] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_array_with_leading_space.json: -------------------------------------------------------------------------------- 1 | [1] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_array_with_several_null.json: -------------------------------------------------------------------------------- 1 | [1,null,null,null,2] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_array_with_trailing_space.json: -------------------------------------------------------------------------------- 1 | [2] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_number.json: -------------------------------------------------------------------------------- 1 | [123e65] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_number_0e+1.json: -------------------------------------------------------------------------------- 1 | [0e+1] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_number_0e1.json: -------------------------------------------------------------------------------- 1 | [0e1] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_number_after_space.json: -------------------------------------------------------------------------------- 1 | [ 4] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_number_double_close_to_zero.json: -------------------------------------------------------------------------------- 1 | [-0.000000000000000000000000000000000000000000000000000000000000000000000000000001] 2 | -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_number_int_with_exp.json: -------------------------------------------------------------------------------- 1 | [20e1] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_number_minus_zero.json: -------------------------------------------------------------------------------- 1 | [-0] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_number_negative_int.json: -------------------------------------------------------------------------------- 1 | [-123] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_number_negative_one.json: -------------------------------------------------------------------------------- 1 | [-1] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_number_negative_zero.json: -------------------------------------------------------------------------------- 1 | [-0] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_number_real_capital_e.json: -------------------------------------------------------------------------------- 1 | [1E22] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_number_real_capital_e_neg_exp.json: -------------------------------------------------------------------------------- 1 | [1E-2] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_number_real_capital_e_pos_exp.json: -------------------------------------------------------------------------------- 1 | [1E+2] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_number_real_exponent.json: -------------------------------------------------------------------------------- 1 | [123e45] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_number_real_fraction_exponent.json: -------------------------------------------------------------------------------- 1 | [123.456e78] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_number_real_neg_exp.json: -------------------------------------------------------------------------------- 1 | [1e-2] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_number_real_pos_exponent.json: -------------------------------------------------------------------------------- 1 | [1e+2] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_number_simple_int.json: -------------------------------------------------------------------------------- 1 | [123] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_number_simple_real.json: -------------------------------------------------------------------------------- 1 | [123.456789] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_object.json: -------------------------------------------------------------------------------- 1 | {"asd":"sdf", "dfg":"fgh"} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_object_basic.json: -------------------------------------------------------------------------------- 1 | {"asd":"sdf"} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_object_duplicated_key.json: -------------------------------------------------------------------------------- 1 | {"a":"b","a":"c"} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_object_duplicated_key_and_value.json: -------------------------------------------------------------------------------- 1 | {"a":"b","a":"b"} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_object_empty.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_object_empty_key.json: -------------------------------------------------------------------------------- 1 | {"":0} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_object_escaped_null_in_key.json: -------------------------------------------------------------------------------- 1 | {"foo\u0000bar": 42} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_object_extreme_numbers.json: -------------------------------------------------------------------------------- 1 | { "min": -1.0e+28, "max": 1.0e+28 } -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_object_long_strings.json: -------------------------------------------------------------------------------- 1 | {"x":[{"id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}], "id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_object_simple.json: -------------------------------------------------------------------------------- 1 | {"a":[]} -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_object_string_unicode.json: -------------------------------------------------------------------------------- 1 | {"title":"\u041f\u043e\u043b\u0442\u043e\u0440\u0430 \u0417\u0435\u043c\u043b\u0435\u043a\u043e\u043f\u0430" } -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_object_with_newlines.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "b" 3 | } -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_1_2_3_bytes_UTF-8_sequences.json: -------------------------------------------------------------------------------- 1 | ["\u0060\u012a\u12AB"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_accepted_surrogate_pair.json: -------------------------------------------------------------------------------- 1 | ["\uD801\udc37"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_accepted_surrogate_pairs.json: -------------------------------------------------------------------------------- 1 | ["\ud83d\ude39\ud83d\udc8d"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_allowed_escapes.json: -------------------------------------------------------------------------------- 1 | ["\"\\\/\b\f\n\r\t"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_backslash_and_u_escaped_zero.json: -------------------------------------------------------------------------------- 1 | ["\\u0000"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_backslash_doublequotes.json: -------------------------------------------------------------------------------- 1 | ["\""] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_comments.json: -------------------------------------------------------------------------------- 1 | ["a/*b*/c/*d//e"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_double_escape_a.json: -------------------------------------------------------------------------------- 1 | ["\\a"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_double_escape_n.json: -------------------------------------------------------------------------------- 1 | ["\\n"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_escaped_control_character.json: -------------------------------------------------------------------------------- 1 | ["\u0012"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_escaped_noncharacter.json: -------------------------------------------------------------------------------- 1 | ["\uFFFF"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_in_array.json: -------------------------------------------------------------------------------- 1 | ["asd"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_in_array_with_leading_space.json: -------------------------------------------------------------------------------- 1 | [ "asd"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_last_surrogates_1_and_2.json: -------------------------------------------------------------------------------- 1 | ["\uDBFF\uDFFF"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_nbsp_uescaped.json: -------------------------------------------------------------------------------- 1 | ["new\u00A0line"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_nonCharacterInUTF-8_U+10FFFF.json: -------------------------------------------------------------------------------- 1 | ["􏿿"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_nonCharacterInUTF-8_U+FFFF.json: -------------------------------------------------------------------------------- 1 | ["￿"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_null_escape.json: -------------------------------------------------------------------------------- 1 | ["\u0000"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_one-byte-utf-8.json: -------------------------------------------------------------------------------- 1 | ["\u002c"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_pi.json: -------------------------------------------------------------------------------- 1 | ["π"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_reservedCharacterInUTF-8_U+1BFFF.json: -------------------------------------------------------------------------------- 1 | ["𛿿"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_simple_ascii.json: -------------------------------------------------------------------------------- 1 | ["asd "] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_space.json: -------------------------------------------------------------------------------- 1 | " " -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_surrogates_U+1D11E_MUSICAL_SYMBOL_G_CLEF.json: -------------------------------------------------------------------------------- 1 | ["\uD834\uDd1e"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_three-byte-utf-8.json: -------------------------------------------------------------------------------- 1 | ["\u0821"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_two-byte-utf-8.json: -------------------------------------------------------------------------------- 1 | ["\u0123"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_u+2028_line_sep.json: -------------------------------------------------------------------------------- 1 | ["
"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_u+2029_par_sep.json: -------------------------------------------------------------------------------- 1 | ["
"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_uEscape.json: -------------------------------------------------------------------------------- 1 | ["\u0061\u30af\u30EA\u30b9"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_uescaped_newline.json: -------------------------------------------------------------------------------- 1 | ["new\u000Aline"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_unescaped_char_delete.json: -------------------------------------------------------------------------------- 1 | [""] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_unicode.json: -------------------------------------------------------------------------------- 1 | ["\uA66D"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_unicodeEscapedBackslash.json: -------------------------------------------------------------------------------- 1 | ["\u005C"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_unicode_2.json: -------------------------------------------------------------------------------- 1 | ["⍂㈴⍂"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_unicode_U+10FFFE_nonchar.json: -------------------------------------------------------------------------------- 1 | ["\uDBFF\uDFFE"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_unicode_U+1FFFE_nonchar.json: -------------------------------------------------------------------------------- 1 | ["\uD83F\uDFFE"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_unicode_U+200B_ZERO_WIDTH_SPACE.json: -------------------------------------------------------------------------------- 1 | ["\u200B"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_unicode_U+2064_invisible_plus.json: -------------------------------------------------------------------------------- 1 | ["\u2064"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_unicode_U+FDD0_nonchar.json: -------------------------------------------------------------------------------- 1 | ["\uFDD0"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_unicode_U+FFFE_nonchar.json: -------------------------------------------------------------------------------- 1 | ["\uFFFE"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_unicode_escaped_double_quote.json: -------------------------------------------------------------------------------- 1 | ["\u0022"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_utf8.json: -------------------------------------------------------------------------------- 1 | ["€𝄞"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_string_with_del_character.json: -------------------------------------------------------------------------------- 1 | ["aa"] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_structure_lonely_false.json: -------------------------------------------------------------------------------- 1 | false -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_structure_lonely_int.json: -------------------------------------------------------------------------------- 1 | 42 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_structure_lonely_negative_real.json: -------------------------------------------------------------------------------- 1 | -0.1 -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_structure_lonely_null.json: -------------------------------------------------------------------------------- 1 | null -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_structure_lonely_string.json: -------------------------------------------------------------------------------- 1 | "asd" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_structure_lonely_true.json: -------------------------------------------------------------------------------- 1 | true -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_structure_string_empty.json: -------------------------------------------------------------------------------- 1 | "" -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_structure_trailing_newline.json: -------------------------------------------------------------------------------- 1 | ["a"] 2 | -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_structure_true_in_array.json: -------------------------------------------------------------------------------- 1 | [true] -------------------------------------------------------------------------------- /cee-json/test/test_parsing/y_structure_whitespace_array.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /cee-json/test/test_transform/number_-9223372036854775808.json: -------------------------------------------------------------------------------- 1 | [-9223372036854775808] 2 | -------------------------------------------------------------------------------- /cee-json/test/test_transform/number_-9223372036854775809.json: -------------------------------------------------------------------------------- 1 | [-9223372036854775809] 2 | -------------------------------------------------------------------------------- /cee-json/test/test_transform/number_1.0.json: -------------------------------------------------------------------------------- 1 | [1.0] 2 | -------------------------------------------------------------------------------- /cee-json/test/test_transform/number_1.000000000000000005.json: -------------------------------------------------------------------------------- 1 | [1.000000000000000005] 2 | -------------------------------------------------------------------------------- /cee-json/test/test_transform/number_1000000000000000.json: -------------------------------------------------------------------------------- 1 | [1000000000000000] 2 | -------------------------------------------------------------------------------- /cee-json/test/test_transform/number_10000000000000000999.json: -------------------------------------------------------------------------------- 1 | [10000000000000000999] 2 | -------------------------------------------------------------------------------- /cee-json/test/test_transform/number_1e-999.json: -------------------------------------------------------------------------------- 1 | [1E-999] 2 | -------------------------------------------------------------------------------- /cee-json/test/test_transform/number_1e6.json: -------------------------------------------------------------------------------- 1 | [1E6] 2 | -------------------------------------------------------------------------------- /cee-json/test/test_transform/number_9223372036854775807.json: -------------------------------------------------------------------------------- 1 | [9223372036854775807] 2 | -------------------------------------------------------------------------------- /cee-json/test/test_transform/number_9223372036854775808.json: -------------------------------------------------------------------------------- 1 | [9223372036854775808] 2 | -------------------------------------------------------------------------------- /cee-json/test/test_transform/object_key_nfc_nfd.json: -------------------------------------------------------------------------------- 1 | {"é":"NFC","é":"NFD"} -------------------------------------------------------------------------------- /cee-json/test/test_transform/object_key_nfd_nfc.json: -------------------------------------------------------------------------------- 1 | {"é":"NFD","é":"NFC"} -------------------------------------------------------------------------------- /cee-json/test/test_transform/object_same_key_different_values.json: -------------------------------------------------------------------------------- 1 | {"a":1,"a":2} -------------------------------------------------------------------------------- /cee-json/test/test_transform/object_same_key_same_value.json: -------------------------------------------------------------------------------- 1 | {"a":1,"a":1} -------------------------------------------------------------------------------- /cee-json/test/test_transform/object_same_key_unclear_values.json: -------------------------------------------------------------------------------- 1 | {"a":0, "a":-0} 2 | -------------------------------------------------------------------------------- /cee-json/test/test_transform/string_1_escaped_invalid_codepoint.json: -------------------------------------------------------------------------------- 1 | ["\uD800"] -------------------------------------------------------------------------------- /cee-json/test/test_transform/string_1_invalid_codepoint.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_transform/string_1_invalid_codepoint.json -------------------------------------------------------------------------------- /cee-json/test/test_transform/string_2_escaped_invalid_codepoints.json: -------------------------------------------------------------------------------- 1 | ["\uD800\uD800"] -------------------------------------------------------------------------------- /cee-json/test/test_transform/string_2_invalid_codepoints.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_transform/string_2_invalid_codepoints.json -------------------------------------------------------------------------------- /cee-json/test/test_transform/string_3_escaped_invalid_codepoints.json: -------------------------------------------------------------------------------- 1 | ["\uD800\uD800\uD800"] -------------------------------------------------------------------------------- /cee-json/test/test_transform/string_3_invalid_codepoints.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cee-studio/cee-std/e5d5848d9499536a2ad24d5f7332f7207720c08a/cee-json/test/test_transform/string_3_invalid_codepoints.json -------------------------------------------------------------------------------- /cee-json/test/test_transform/string_with_escaped_NULL.json: -------------------------------------------------------------------------------- 1 | ["A\u0000B"] -------------------------------------------------------------------------------- /cee-json/test/tester.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "release/cee.c" 6 | #include "release/cee-json.c" 7 | 8 | int main () { 9 | struct cee_state * st = cee_state_mk(10); 10 | struct cee_json * js = cee_json_object_mk (st); 11 | 12 | cee_json_object_set_bool(js, "b", true); 13 | cee_json_object_set_bool(js, "b1", false); 14 | 15 | cee_json_object_set_str(js, "s1", "xxx\n"); 16 | struct cee_json * js1 = cee_json_object_mk (st); 17 | cee_json_object_set_str(js1, "s2", "yyy"); 18 | cee_json_object_set(js, "y1", js1); 19 | 20 | struct cee_json * js2 = cee_json_array_mk (st, 10); 21 | cee_json_array_append_str(js2, "false"); 22 | cee_json_array_append_str(js2, "true"); 23 | cee_json_object_set(js, "a1", js2); 24 | 25 | size_t jlen = cee_json_snprint (st, NULL, 0, js, 1); 26 | printf (" %zu\n", jlen); 27 | jlen = cee_json_snprint (st, NULL, 0, js, 0); 28 | printf (" %zu\n", jlen); 29 | 30 | char buf[1000]; 31 | cee_json_snprint (st, buf, 109, js, 1); 32 | printf ("%s\n", buf); 33 | 34 | cee_json_snprint (st, buf, 109, js, 0); 35 | printf ("%s\n", buf); 36 | struct cee_json * result = NULL; 37 | int line; 38 | printf ("parsing\n"); 39 | cee_json_parsex(st, buf, jlen, &result, true, &line); 40 | printf ("end of parsing\n"); 41 | 42 | cee_json_snprint (st, buf, 109, result, 0); 43 | printf ("parsed -> printed\n"); 44 | printf ("%s\n", buf); 45 | 46 | struct cee_json *x = cee_json_select(result, ".a1[0]:s"); 47 | printf ("%p\n", x); 48 | 49 | cee_del(result); 50 | cee_del(js); 51 | cee_del(st); 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /cee-json/test/tester2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "release/cee.c" 6 | #include "release/cee-json.c" 7 | 8 | int main () { 9 | struct cee_state *state = cee_state_mk(100); 10 | 11 | #if 0 12 | char *buf = "{ \"a\":[[]], \"b\":5e10, \"c\":5e-10, \"d\":1.337, \"e\":-1 }"; 13 | #else 14 | char *buf = "{ \"f\":{ \"f\":1, \"a\":true}, \"a\":[[]], \"b\":5e10, \"c\":5e-10, \"d\":1.337, \"e\":-1 }"; 15 | #endif 16 | 17 | struct cee_json *result = NULL; 18 | int line = 0; 19 | if (!cee_json_parsex(state, buf, strlen(buf), &result, true, &line)) { 20 | fprintf(stderr, "parsing error at line %d\n", line); 21 | return 0; 22 | } 23 | 24 | cee_json_asprint(state, &buf, NULL, result, 0); 25 | fprintf(stdout, "%s\n", buf); 26 | 27 | char *buf1 = "{ \"f\":{ \"f\":true} }"; 28 | 29 | 30 | struct cee_json *result1 = NULL; 31 | if (!cee_json_parsex(state, buf1, strlen(buf1), &result1, true, &line)) { 32 | fprintf(stderr, "parsing error at line %d\n", line); 33 | return 0; 34 | } 35 | cee_json_asprint(state, &buf1, NULL, result1, 0); 36 | fprintf(stdout, "%s\n", buf1); 37 | 38 | 39 | cee_json_merge(result, result1); 40 | cee_json_asprint(state, &buf, NULL, result, 0); 41 | fprintf(stdout, "%s\n", buf); 42 | cee_del(state); 43 | } 44 | -------------------------------------------------------------------------------- /cee-json/tokenizer.h: -------------------------------------------------------------------------------- 1 | #ifndef CEE_JSON_TOKENIZER_H 2 | #define CEE_JSON_TOKENIZER_H 3 | enum token { 4 | tock_eof = 255, 5 | tock_err, 6 | tock_str, 7 | tock_number, 8 | tock_true, 9 | tock_false, 10 | tock_null 11 | }; 12 | 13 | struct tokenizer { 14 | int line; 15 | char * buf; 16 | char * buf_end; 17 | struct cee_str * str; 18 | enum number_type { 19 | NUMBER_IS_DOUBLE, 20 | NUMBER_IS_I64, 21 | NUMBER_IS_U64 22 | } type; 23 | union { 24 | double real; 25 | int64_t i64; 26 | uint64_t u64; 27 | } number; 28 | }; 29 | 30 | extern enum token cee_json_next_token(struct cee_state *, struct tokenizer * t); 31 | #endif /* CEE_JSON_TOKENIZER_H */ 32 | -------------------------------------------------------------------------------- /cee-resize.h: -------------------------------------------------------------------------------- 1 | /* 2 | * add a struct to the trace chain of st so if cee_del is called on 3 | * st, this struct is freed too. 4 | */ 5 | static void S(chain) (struct S(header) * h, struct cee_state * st) { 6 | h->cs.state = st; 7 | 8 | h->cs.trace_prev = st->trace_tail; 9 | st->trace_tail->trace_next = &h->cs; 10 | 11 | st->trace_tail = &h->cs; 12 | } 13 | 14 | 15 | /* 16 | * remove a struct to the trace chain, this should 17 | * be called whenver the struct is to be freed. 18 | */ 19 | static void S(de_chain) (struct S(header) * h) { 20 | struct cee_state * st = h->cs.state; 21 | 22 | struct cee_sect * prev = h->cs.trace_prev; 23 | struct cee_sect * next = h->cs.trace_next; 24 | 25 | if (st->trace_tail == &h->cs) { 26 | prev->trace_next = NULL; 27 | st->trace_tail = prev; 28 | } 29 | else { 30 | prev->trace_next = next; 31 | if (next) 32 | next->trace_prev = prev; 33 | } 34 | } 35 | 36 | /* 37 | * resize a struct, and update its existance in the trace chain 38 | */ 39 | static struct S(header) * S(resize)(struct S(header) * h, size_t n) 40 | { 41 | struct cee_state * state = h->cs.state; 42 | struct S(header) * ret; 43 | switch(h->cs.resize_method) 44 | { 45 | case CEE_RESIZE_WITH_REALLOC: 46 | S(de_chain)(h); /* remove the old struct from the chain */ 47 | ret = realloc(h, n); 48 | ret->cs.mem_block_size = n; 49 | S(chain)(ret, state); /* add the new struct to the chain */ 50 | break; 51 | case CEE_RESIZE_WITH_MALLOC: 52 | /* TODO: remove this option, it errors on correctness at the cost of leaking memory */ 53 | ret = malloc(n); 54 | memcpy(ret, h, h->cs.mem_block_size); 55 | ret->cs.mem_block_size = n; 56 | S(chain)(ret, state); /* add the new struct to the chain */ 57 | break; 58 | case CEE_RESIZE_WITH_IDENTITY: 59 | ret = h; 60 | break; 61 | } 62 | return ret; 63 | } 64 | -------------------------------------------------------------------------------- /closure.c: -------------------------------------------------------------------------------- 1 | #ifdef CEE_AMALGAMATION 2 | #undef S 3 | #define S(f) _cee_closure_##f 4 | #else 5 | #define S(f) _##f 6 | #include "cee.h" 7 | #include 8 | #include 9 | #include 10 | #include 11 | #endif 12 | #include "cee-header.h" 13 | 14 | struct S(header) { 15 | struct cee_sect cs; 16 | struct cee_closure _; 17 | }; 18 | 19 | #include "cee-resize.h" 20 | 21 | static void S(trace) (void * v, enum cee_trace_action sa) { 22 | struct S(header) * m = FIND_HEADER(v); 23 | switch (sa) { 24 | case CEE_TRACE_DEL_NO_FOLLOW: 25 | case CEE_TRACE_DEL_FOLLOW: 26 | S(de_chain)(m); 27 | free(m); 28 | break; 29 | case CEE_TRACE_MARK: 30 | default: 31 | break; 32 | } 33 | } 34 | 35 | struct cee_closure * cee_closure_mk (struct cee_state * s, struct cee_env * env, void * fun) { 36 | size_t mem_block_size = sizeof(struct S(header)); 37 | struct S(header) * b = malloc(mem_block_size); 38 | ZERO_CEE_SECT(&b->cs); 39 | S(chain)(b, s); 40 | 41 | b->cs.trace = S(trace); 42 | b->cs.resize_method = CEE_RESIZE_WITH_IDENTITY; 43 | b->cs.mem_block_size = mem_block_size; 44 | 45 | b->_.env = env; 46 | b->_.vfun = fun; 47 | return &(b->_); 48 | } 49 | 50 | void * cee_closure_call (struct cee_state * s, struct cee_closure * c, size_t n, ...) { 51 | va_list ap; 52 | va_start(ap, n); 53 | 54 | void *ret = c->vfun(s, c->env, n, ap); 55 | 56 | va_end(ap); 57 | 58 | return ret; 59 | } 60 | -------------------------------------------------------------------------------- /convention.txt: -------------------------------------------------------------------------------- 1 | 0 success 2 | non-zero failure 3 | 4 | 5 | n number of bytes consumed 6 | -1 error 7 | -------------------------------------------------------------------------------- /dict.c: -------------------------------------------------------------------------------- 1 | #ifdef CEE_AMALGAMATION 2 | #undef S 3 | #define S(f) _cee_dict_##f 4 | #else 5 | #define S(f) _##f 6 | #include "cee.h" 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "musl-search.h" 14 | #endif 15 | #include "cee-header.h" 16 | 17 | struct S(header) { 18 | struct cee_list * keys; 19 | struct cee_list * vals; 20 | uintptr_t size; 21 | enum cee_del_policy del_policy; 22 | struct cee_sect cs; 23 | struct musl_hsearch_data _[1]; 24 | }; 25 | 26 | #include "cee-resize.h" 27 | 28 | static void S(trace)(void *d, enum cee_trace_action ta) { 29 | struct S(header) * m = FIND_HEADER(d); 30 | 31 | switch (ta) { 32 | case CEE_TRACE_DEL_NO_FOLLOW: 33 | musl_hdestroy_r(m->_); 34 | S(de_chain)(m); 35 | free(m); 36 | break; 37 | case CEE_TRACE_DEL_FOLLOW: 38 | cee_del_e(m->del_policy, m->keys); 39 | cee_del_e(m->del_policy, m->vals); 40 | musl_hdestroy_r(m->_); 41 | S(de_chain)(m); 42 | free(m); 43 | break; 44 | case CEE_TRACE_MARK: 45 | default: 46 | m->cs.gc_mark = ta - CEE_TRACE_MARK; 47 | cee_trace(m->keys, ta); 48 | cee_trace(m->vals, ta); 49 | break; 50 | } 51 | } 52 | 53 | struct cee_dict * cee_dict_mk_e (struct cee_state * s, enum cee_del_policy o, size_t size) { 54 | size_t mem_block_size = sizeof(struct S(header)); 55 | struct S(header) * m = malloc(mem_block_size); 56 | m->del_policy = o; 57 | m->keys = cee_list_mk(s, size); 58 | cee_use_realloc(m->keys); 59 | 60 | m->vals = cee_list_mk(s, size); 61 | cee_use_realloc(m->vals); 62 | 63 | m->size = size; 64 | ZERO_CEE_SECT(&m->cs); 65 | S(chain)(m, s); 66 | 67 | m->cs.trace = S(trace); 68 | m->cs.mem_block_size = mem_block_size; 69 | m->cs.resize_method = CEE_RESIZE_WITH_IDENTITY; 70 | m->cs.n_product = 2; /* key:str, value */ 71 | size_t hsize = (size_t)((float)size * 1.25); 72 | memset(m->_, 0, sizeof(struct musl_hsearch_data)); 73 | if (musl_hcreate_r(hsize, m->_)) { 74 | return (struct cee_dict *)(&m->_); 75 | } 76 | else { 77 | cee_del(m->keys); 78 | cee_del(m->vals); 79 | free(m); 80 | return NULL; 81 | } 82 | } 83 | 84 | struct cee_dict * cee_dict_mk (struct cee_state *s, size_t size) { 85 | return cee_dict_mk_e (s, CEE_DP_DEL_RC, size); 86 | } 87 | 88 | void cee_dict_add (struct cee_dict * d, char * key, void * value) { 89 | struct S(header) * m = FIND_HEADER(d); 90 | MUSL_ENTRY n, *np; 91 | n.key = key; 92 | n.data = value; 93 | if (!musl_hsearch_r(n, ENTER, &np, m->_)) 94 | cee_segfault(); 95 | cee_list_append(m->keys, key); 96 | cee_list_append(m->vals, value); 97 | } 98 | 99 | void * cee_dict_find(struct cee_dict * d, char * key) { 100 | struct S(header) * m = FIND_HEADER(d); 101 | MUSL_ENTRY n, *np; 102 | n.key = key; 103 | n.data = NULL; 104 | if (musl_hsearch_r(n, FIND, &np, m->_)) 105 | return np->data; 106 | fprintf(stderr, "%s\n", strerror(errno)); 107 | return NULL; 108 | } 109 | -------------------------------------------------------------------------------- /diffuse_all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | while [ $# -ne 0 ]; do 4 | case $1 in 5 | "--unstage") 6 | unstage="Y" 7 | ;; 8 | "--help") 9 | echo "Usage: $0 [--unstage]" 10 | exit 1 11 | ;; 12 | *) 13 | echo "Usage: $0 [--unstage]" 14 | exit 1 15 | ;; 16 | esac 17 | shift 18 | done 19 | 20 | for i in $(git status -s | awk '{ print $2'}); do 21 | diffuse $i 22 | if [ -z "unstage" ]; then 23 | read -p "STAGE '$i' ? y/[n]:" ans 24 | if [ "$ans" = "y" ] || [ "$ans" = "Y" ]; then 25 | echo "git add $i" 26 | git add $i 27 | fi 28 | else 29 | read -p "UNSTAGE '$i' ? y/[n]:" ans 30 | if [ "$ans" = "y" ] || [ "$ans" = "Y" ]; then 31 | echo "git reset HEAD $i" 32 | git reset HEAD $i 33 | fi 34 | fi 35 | done 36 | -------------------------------------------------------------------------------- /env.c: -------------------------------------------------------------------------------- 1 | #ifdef CEE_AMALGAMATION 2 | #undef S 3 | #define S(f) _cee_env_##f 4 | #else 5 | #define S(f) _##f 6 | #include "cee.h" 7 | #include 8 | #include 9 | #include 10 | #endif 11 | #include "cee-header.h" 12 | 13 | struct S(header) { 14 | enum cee_del_policy env_dp; 15 | enum cee_del_policy vars_dp; 16 | struct cee_sect cs; 17 | struct cee_env _; 18 | }; 19 | 20 | #include "cee-resize.h" 21 | 22 | static void S(trace) (void * v, enum cee_trace_action ta) { 23 | struct S(header) * h = FIND_HEADER(v); 24 | switch (ta) { 25 | case CEE_TRACE_DEL_NO_FOLLOW: 26 | S(de_chain)(h); 27 | free(h); 28 | break; 29 | case CEE_TRACE_DEL_FOLLOW: 30 | cee_del_e(h->env_dp, h->_.outer); 31 | cee_del_e(h->vars_dp, h->_.vars); 32 | S(de_chain)(h); 33 | free(h); 34 | break; 35 | case CEE_TRACE_MARK: 36 | default: 37 | h->cs.gc_mark = ta - CEE_TRACE_MARK; 38 | cee_trace(h->_.outer, ta); 39 | cee_trace(h->_.vars, ta); 40 | break; 41 | } 42 | } 43 | 44 | struct cee_env * cee_env_mk_e(struct cee_state * st, enum cee_del_policy dp[2], struct cee_env * outer, struct cee_map * vars) { 45 | size_t mem_block_size = sizeof(struct S(header)); 46 | struct S(header) * h = malloc(mem_block_size); 47 | 48 | ZERO_CEE_SECT(&h->cs); 49 | S(chain)(h, st); 50 | 51 | h->cs.trace = S(trace); 52 | h->cs.resize_method = CEE_RESIZE_WITH_IDENTITY; 53 | h->cs.mem_block_size = mem_block_size; 54 | h->cs.cmp = NULL; 55 | h->cs.n_product = 0; 56 | 57 | h->env_dp = dp[0]; 58 | h->vars_dp = dp[1]; 59 | h->_.outer = outer; 60 | h->_.vars = vars; 61 | 62 | return &h->_; 63 | } 64 | 65 | struct cee_env * cee_env_mk(struct cee_state * st, struct cee_env * outer, struct cee_map * vars) { 66 | enum cee_del_policy dp[2] = { CEE_DP_DEL_RC, CEE_DP_DEL_RC }; 67 | return cee_env_mk_e (st, dp, outer, vars); 68 | } 69 | 70 | void * cee_env_find(struct cee_env * e, char * key) { 71 | struct cee_boxed * ret; 72 | while (e && e->vars) { 73 | if ( (ret = cee_map_find(e->vars, key)) ) 74 | return ret; 75 | e = e->outer; 76 | } 77 | return NULL; 78 | } 79 | -------------------------------------------------------------------------------- /list.c: -------------------------------------------------------------------------------- 1 | #ifdef CEE_AMALGAMATION 2 | #undef S 3 | #define S(f) _cee_list_##f 4 | #else 5 | #define S(f) _##f 6 | #include "cee.h" 7 | #include 8 | #include 9 | #include 10 | #include 11 | #endif 12 | #include "cee-header.h" 13 | 14 | struct S(header) { 15 | uintptr_t size; 16 | uintptr_t capacity; 17 | enum cee_del_policy del_policy; 18 | struct cee_sect cs; 19 | struct cee_list _; 20 | }; 21 | 22 | #include "cee-resize.h" 23 | 24 | static void S(trace) (void * v, enum cee_trace_action ta) { 25 | struct S(header) * m = FIND_HEADER(v); 26 | int i; 27 | 28 | switch(ta) { 29 | case CEE_TRACE_DEL_NO_FOLLOW: 30 | S(de_chain)(m); 31 | free(m->_.a); 32 | free(m); 33 | break; 34 | case CEE_TRACE_DEL_FOLLOW: 35 | for (i = 0; i < m->size; i++) 36 | cee_del_e(m->del_policy, m->_.a[i]); 37 | S(de_chain)(m); 38 | free(m->_.a); 39 | free(m); 40 | break; 41 | case CEE_TRACE_MARK: 42 | default: 43 | m->cs.gc_mark = ta - CEE_TRACE_MARK; 44 | for (i = 0; i < m->size; i++) 45 | cee_trace(m->_.a[i], ta); 46 | break; 47 | } 48 | } 49 | 50 | struct cee_list * cee_list_mk_e (struct cee_state * st, enum cee_del_policy o, size_t cap) { 51 | size_t mem_block_size = sizeof(struct S(header)); 52 | struct S(header) * m = malloc(mem_block_size); 53 | m->capacity = cap; 54 | m->size = 0; 55 | m->del_policy = o; 56 | ZERO_CEE_SECT(&m->cs); 57 | S(chain)(m, st); 58 | 59 | m->cs.trace = S(trace); 60 | m->cs.resize_method = CEE_RESIZE_WITH_MALLOC; 61 | m->cs.mem_block_size = mem_block_size; 62 | 63 | struct cee_list *ret = (struct cee_list *)&(m->_); 64 | ret->a = malloc(cap * sizeof(void *)); 65 | 66 | return ret; 67 | } 68 | 69 | struct cee_list * cee_list_mk (struct cee_state * s, size_t cap) { 70 | return cee_list_mk_e(s, CEE_DP_DEL_RC, cap); 71 | } 72 | 73 | void cee_list_append (struct cee_list *v, void *e) { 74 | struct S(header) * m = FIND_HEADER(v); 75 | size_t capacity = m->capacity; 76 | size_t extra_cap = capacity ? capacity : 1; 77 | if (m->size == m->capacity) { 78 | m->capacity = capacity + extra_cap; 79 | void *a = realloc(v->a, m->capacity * sizeof(void *)); 80 | v->a = a; 81 | } 82 | v->a[m->size] = e; 83 | m->size ++; 84 | cee_incr_indegree(m->del_policy, e); 85 | } 86 | 87 | void cee_list_insert(struct cee_list *v, int index, void *e) { 88 | struct S(header) * m = FIND_HEADER(v); 89 | size_t capacity = m->capacity; 90 | size_t extra_cap = capacity ? capacity : 1; 91 | if (m->size == m->capacity) { 92 | m->capacity = capacity + extra_cap; 93 | void *a = realloc(v->a, m->capacity * sizeof(void *)); 94 | v->a = a; 95 | } 96 | int i; 97 | for (i = m->size; i > index; i--) 98 | v->a[i] = v->a[i-1]; 99 | 100 | v->a[index] = e; 101 | m->size ++; 102 | cee_incr_indegree(m->del_policy, e); 103 | } 104 | 105 | bool cee_list_remove(struct cee_list *v, int index) { 106 | if (!v) return false; 107 | struct S(header) *m = FIND_HEADER(v); 108 | if (index >= m->size) return false; 109 | 110 | void *e = v->a[index]; 111 | v->a[index] = 0; 112 | int i; 113 | for (i = index; i < (m->size - 1); i++) 114 | v->a[i] = v->a[i+1]; 115 | 116 | m->size --; 117 | cee_decr_indegree(m->del_policy, e); 118 | return true; 119 | } 120 | 121 | 122 | size_t cee_list_size (struct cee_list *x) { 123 | if (!x) return 0; 124 | struct S(header) * m = FIND_HEADER(x); 125 | return m->size; 126 | } 127 | 128 | size_t cee_list_capacity (struct cee_list *x) { 129 | if (!x) return 0; 130 | struct S(header) * h = FIND_HEADER(x); 131 | return h->capacity; 132 | } 133 | 134 | int cee_list_iterate (struct cee_list *x, void *ctx, 135 | int (*f)(void *cxt, void *e, int idx)) { 136 | if (!x) return 0; 137 | struct S(header) *m = FIND_HEADER(x); 138 | int i, ret; 139 | for (i = 0; i < m->size; i++) { 140 | ret = f(ctx, x->a[i], i); 141 | if (ret) break; 142 | } 143 | return ret; 144 | } 145 | 146 | static int S(_add_v)(void *cxt, void *e, int idx){ 147 | struct cee_list *l = cxt; 148 | cee_list_append(l, e); 149 | return 0; 150 | } 151 | 152 | void cee_list_merge (struct cee_list *dest, struct cee_list *src) 153 | { 154 | cee_list_iterate (src, dest, S(_add_v)); 155 | } 156 | -------------------------------------------------------------------------------- /musl-hsearch.c: -------------------------------------------------------------------------------- 1 | #ifdef CEE_AMALGAMATION 2 | #undef S 3 | #define S(f) _cee_htable_##f 4 | #else 5 | #define S(f) _##f 6 | #include 7 | #include 8 | #include "musl-search.h" 9 | #endif 10 | 11 | 12 | /* 13 | open addressing hash table with 2^n table size 14 | quadratic probing is used in case of hash collision 15 | tab indices and hash are size_t 16 | after resize fails with ENOMEM the state of tab is still usable 17 | 18 | with the posix api items cannot be iterated and length cannot be queried 19 | */ 20 | 21 | #define MINSIZE 8 22 | #define MAXSIZE ((size_t)-1/2 + 1) 23 | 24 | struct __tab { 25 | MUSL_ENTRY *entries; 26 | size_t mask; 27 | size_t used; 28 | }; 29 | 30 | static struct musl_hsearch_data htab; 31 | 32 | /* 33 | static int musl_hcreate_r(size_t, struct musl_hsearch_data *); 34 | static void musl_hdestroy_r(struct musl_hsearch_data *); 35 | static int mul_hsearch_r(MUSL_ENTRY, ACTION, MUSL_ENTRY **, struct musl_hsearch_data *); 36 | */ 37 | 38 | static size_t keyhash(char *k) 39 | { 40 | unsigned char *p = (unsigned char *)k; 41 | size_t h = 0; 42 | 43 | while (*p) 44 | h = 31*h + *p++; 45 | return h; 46 | } 47 | 48 | static int resize(size_t nel, struct musl_hsearch_data *htab) 49 | { 50 | size_t newsize; 51 | size_t i, j; 52 | MUSL_ENTRY *e, *newe; 53 | MUSL_ENTRY *oldtab = htab->__tab->entries; 54 | MUSL_ENTRY *oldend = htab->__tab->entries + htab->__tab->mask + 1; 55 | 56 | if (nel > MAXSIZE) 57 | nel = MAXSIZE; 58 | for (newsize = MINSIZE; newsize < nel; newsize *= 2); 59 | htab->__tab->entries = (MUSL_ENTRY *)calloc(newsize, sizeof *htab->__tab->entries); 60 | if (!htab->__tab->entries) { 61 | htab->__tab->entries = oldtab; 62 | return 0; 63 | } 64 | htab->__tab->mask = newsize - 1; 65 | if (!oldtab) 66 | return 1; 67 | for (e = oldtab; e < oldend; e++) 68 | if (e->key) { 69 | for (i=keyhash(e->key),j=1; ; i+=j++) { 70 | newe = htab->__tab->entries + (i & htab->__tab->mask); 71 | if (!newe->key) 72 | break; 73 | } 74 | *newe = *e; 75 | } 76 | free(oldtab); 77 | return 1; 78 | } 79 | 80 | int musl_hcreate(size_t nel) 81 | { 82 | return musl_hcreate_r(nel, &htab); 83 | } 84 | 85 | void musl_hdestroy(void) 86 | { 87 | musl_hdestroy_r(&htab); 88 | } 89 | 90 | static MUSL_ENTRY *lookup(char *key, size_t hash, struct musl_hsearch_data *htab) 91 | { 92 | size_t i, j; 93 | MUSL_ENTRY *e; 94 | 95 | for (i=hash,j=1; ; i+=j++) { 96 | e = htab->__tab->entries + (i & htab->__tab->mask); 97 | if (!e->key || strcmp(e->key, key) == 0) 98 | break; 99 | } 100 | return e; 101 | } 102 | 103 | MUSL_ENTRY *musl_hsearch(MUSL_ENTRY item, ACTION action) 104 | { 105 | MUSL_ENTRY *e; 106 | musl_hsearch_r(item, action, &e, &htab); 107 | return e; 108 | } 109 | 110 | int musl_hcreate_r(size_t nel, struct musl_hsearch_data *htab) 111 | { 112 | int r; 113 | 114 | htab->__tab = (struct __tab *) calloc(1, sizeof *htab->__tab); 115 | if (!htab->__tab) 116 | return 0; 117 | r = resize(nel, htab); 118 | if (r == 0) { 119 | free(htab->__tab); 120 | htab->__tab = 0; 121 | } 122 | return r; 123 | } 124 | 125 | void musl_hdestroy_r(struct musl_hsearch_data *htab) 126 | { 127 | if (htab->__tab) free(htab->__tab->entries); 128 | free(htab->__tab); 129 | htab->__tab = 0; 130 | } 131 | 132 | int musl_hsearch_r(MUSL_ENTRY item, ACTION action, MUSL_ENTRY **retval, 133 | struct musl_hsearch_data *htab) 134 | { 135 | size_t hash = keyhash(item.key); 136 | MUSL_ENTRY *e = lookup(item.key, hash, htab); 137 | 138 | if (e->key) { 139 | *retval = e; 140 | return 1; 141 | } 142 | if (action == FIND) { 143 | *retval = 0; 144 | return 0; 145 | } 146 | *e = item; 147 | if (++htab->__tab->used > htab->__tab->mask - htab->__tab->mask/4) { 148 | if (!resize(2*htab->__tab->used, htab)) { 149 | htab->__tab->used--; 150 | e->key = 0; 151 | *retval = 0; 152 | return 0; 153 | } 154 | e = lookup(item.key, hash, htab); 155 | } 156 | *retval = e; 157 | return 1; 158 | } 159 | -------------------------------------------------------------------------------- /musl-insque.c: -------------------------------------------------------------------------------- 1 | #ifdef CEE_AMALGAMATION 2 | #undef S 3 | #define S(x) _musl_lsearch__##x 4 | #else 5 | #define S(f) _##f 6 | #include "musl-search.h" 7 | #endif 8 | 9 | struct S(node) { 10 | struct S(node) *next; 11 | struct S(node) *prev; 12 | }; 13 | 14 | void musl_insque(void *element, void *pred) 15 | { 16 | struct S(node) *e = (struct S(node) *)element; 17 | struct S(node) *p = (struct S(node) *)pred; 18 | 19 | if (!p) { 20 | e->next = e->prev = 0; 21 | return; 22 | } 23 | e->next = p->next; 24 | e->prev = p; 25 | p->next = e; 26 | if (e->next) 27 | e->next->prev = e; 28 | } 29 | 30 | void musl_remque(void *element) 31 | { 32 | struct S(node) *e = (struct S(node) *)element; 33 | 34 | if (e->next) 35 | e->next->prev = e->prev; 36 | if (e->prev) 37 | e->prev->next = e->next; 38 | } 39 | -------------------------------------------------------------------------------- /musl-lsearch.c: -------------------------------------------------------------------------------- 1 | #ifdef CEE_AMALGAMATION 2 | #undef S 3 | #define S(f) _cee_lsearch##f 4 | #else 5 | #define S(f) _##f 6 | #include "musl-search.h" 7 | #include 8 | #endif 9 | 10 | void *musl_lsearch(const void *key, void *base, size_t *nelp, size_t width, 11 | int (*compar)(const void *, const void *)) 12 | { 13 | char **p = (char **)base; 14 | size_t n = *nelp; 15 | size_t i; 16 | 17 | for (i = 0; i < n; i++) 18 | if (compar(p[i], key) == 0) 19 | return p[i]; 20 | *nelp = n+1; 21 | /* b.o. here when width is longer than the size of key */ 22 | return memcpy(p[n], key, width); 23 | } 24 | 25 | void *musl_lfind(const void *key, const void *base, size_t *nelp, 26 | size_t width, int (*compar)(const void *, const void *)) 27 | { 28 | char **p = (char **)base; 29 | size_t n = *nelp; 30 | size_t i; 31 | 32 | for (i = 0; i < n; i++) 33 | if (compar(p[i], key) == 0) 34 | return p[i]; 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /musl-search.h: -------------------------------------------------------------------------------- 1 | #ifndef MUSL_SEARCH_H 2 | #define MUSL_SEARCH_H 3 | #ifdef CEE_AMALGAMATION 4 | #else 5 | #include 6 | #endif 7 | 8 | typedef enum { FIND, ENTER } ACTION; 9 | typedef enum { preorder, postorder, endorder, leaf } VISIT; 10 | 11 | typedef struct musl_entry { 12 | char *key; 13 | void *data; 14 | } MUSL_ENTRY; 15 | 16 | int musl_hcreate(size_t); 17 | void musl_hdestroy(void); 18 | MUSL_ENTRY *musl_hsearch(MUSL_ENTRY, ACTION); 19 | 20 | 21 | struct musl_hsearch_data { 22 | struct __tab *__tab; 23 | unsigned int __unused1; 24 | unsigned int __unused2; 25 | }; 26 | 27 | int musl_hcreate_r(size_t, struct musl_hsearch_data *); 28 | void musl_hdestroy_r(struct musl_hsearch_data *); 29 | int musl_hsearch_r(MUSL_ENTRY, ACTION, MUSL_ENTRY **, struct musl_hsearch_data *); 30 | 31 | void musl_insque(void *, void *); 32 | void musl_remque(void *); 33 | 34 | void *musl_lsearch(const void *, void *, size_t *, size_t, 35 | int (*)(const void *, const void *)); 36 | void *musl_lfind(const void *, const void *, size_t *, size_t, 37 | int (*)(const void *, const void *)); 38 | 39 | void *musl_tdelete(void * cxt, const void *__restrict, void **__restrict, int(*)(void *, const void *, const void *)); 40 | void *musl_tfind(void * cxt, const void *, void *const *, int(*)(void *, const void *, const void *)); 41 | void *musl_tsearch(void * cxt, const void *, void **, int (*)(void *, const void *, const void *)); 42 | void musl_twalk(void * cxt, const void *, void (*)(void *, const void *, VISIT, int)); 43 | 44 | 45 | struct musl_qelem { 46 | struct qelem *q_forw, *q_back; 47 | char q_data[1]; 48 | }; 49 | 50 | void musl_tdestroy(void * cxt, void *, void (*)(void * cxt, void *)); 51 | 52 | #endif /* MUSL_SEARCH */ 53 | 54 | -------------------------------------------------------------------------------- /n_tuple.c: -------------------------------------------------------------------------------- 1 | #ifdef CEE_AMALGAMATION 2 | #undef S 3 | #define S(f) _cee_n_tuple_##f 4 | #else 5 | #define S(f) _##f 6 | #include "cee.h" 7 | #include 8 | #include 9 | #include 10 | #endif 11 | #include "cee-header.h" 12 | 13 | #define CEE_MAX_N_TUPLE 16 14 | 15 | struct S(header) { 16 | enum cee_del_policy del_policies[CEE_MAX_N_TUPLE]; 17 | struct cee_sect cs; 18 | void * _[CEE_MAX_N_TUPLE]; 19 | }; 20 | 21 | #include "cee-resize.h" 22 | 23 | static void S(trace)(void * v, enum cee_trace_action ta) { 24 | struct S(header) * b = FIND_HEADER(v); 25 | int i; 26 | 27 | switch (ta) { 28 | case CEE_TRACE_DEL_NO_FOLLOW: 29 | S(de_chain)(b); 30 | free(b); 31 | break; 32 | case CEE_TRACE_DEL_FOLLOW: 33 | for (i = 0; i < b->cs.n_product; i++) 34 | cee_del_e(b->del_policies[i], b->_[i]); 35 | 36 | S(de_chain)(b); 37 | free(b); 38 | break; 39 | case CEE_TRACE_MARK: 40 | default: 41 | b->cs.gc_mark = ta - CEE_TRACE_MARK; 42 | for (i = 0; i < b->cs.n_product; i++) 43 | cee_trace(b->_[i], ta); 44 | break; 45 | } 46 | } 47 | 48 | static struct S(header) * cee_n_tuple_v (struct cee_state * st, size_t ntuple, 49 | enum cee_del_policy o[], va_list ap) { 50 | if (ntuple > CEE_MAX_N_TUPLE) 51 | cee_segfault(); 52 | 53 | size_t mem_block_size = sizeof(struct S(header)); 54 | struct S(header) * m = malloc(mem_block_size); 55 | ZERO_CEE_SECT(&m->cs); 56 | S(chain)(m, st); 57 | 58 | m->cs.trace = S(trace); 59 | m->cs.resize_method = CEE_RESIZE_WITH_IDENTITY; 60 | m->cs.mem_block_size = mem_block_size; 61 | m->cs.n_product = ntuple; 62 | 63 | int i; 64 | for(i = 0; i < ntuple; i++) { 65 | m->_[i] = va_arg(ap, void *); 66 | m->del_policies[i] = o[i]; 67 | cee_incr_indegree(o[i], m->_[i]); 68 | } 69 | return m; 70 | } 71 | 72 | struct cee_n_tuple * cee_n_tuple_mk (struct cee_state * st, size_t ntuple, ...) { 73 | va_list ap; 74 | va_start(ap, ntuple); 75 | enum cee_del_policy * o = malloc(ntuple * sizeof (enum cee_del_policy)); 76 | int i; 77 | for (i = 0; i < ntuple; i++) 78 | o[i] = CEE_DP_DEL_RC; 79 | 80 | struct S(header) * h = cee_n_tuple_v(st, ntuple, o, ap); 81 | free(o); 82 | return (struct cee_n_tuple *)(h->_); 83 | } 84 | -------------------------------------------------------------------------------- /quadruple.c: -------------------------------------------------------------------------------- 1 | #ifdef CEE_AMALGAMATION 2 | #undef S 3 | #define S(f) _cee_quadruple_##f 4 | #else 5 | #define S(f) _##f 6 | #include "cee.h" 7 | #include 8 | #include 9 | #endif 10 | #include "cee-header.h" 11 | 12 | struct S(header) { 13 | enum cee_del_policy del_policies[4]; 14 | struct cee_sect cs; 15 | void * _[4]; 16 | }; 17 | 18 | #include "cee-resize.h" 19 | 20 | static void S(trace)(void * v, enum cee_trace_action ta) { 21 | struct S(header) * b = FIND_HEADER(v); 22 | int i; 23 | 24 | switch (ta) { 25 | case CEE_TRACE_DEL_NO_FOLLOW: 26 | S(de_chain)(b); 27 | free(b); 28 | break; 29 | case CEE_TRACE_DEL_FOLLOW: 30 | for (i = 0; i < 4; i++) 31 | cee_del_e(b->del_policies[i], b->_[i]); 32 | S(de_chain)(b); 33 | free(b); 34 | break; 35 | case CEE_TRACE_MARK: 36 | default: 37 | b->cs.gc_mark = ta - CEE_TRACE_MARK; 38 | for (i = 0; i < 4; i++) 39 | cee_trace(b->_[i], ta); 40 | break; 41 | } 42 | } 43 | 44 | struct cee_quadruple * cee_quadruple_mk_e (struct cee_state * st, enum cee_del_policy o[4], 45 | void * v1, void * v2, void * v3, void * v4) { 46 | size_t mem_block_size = sizeof(struct S(header)); 47 | struct S(header) * m = malloc(mem_block_size); 48 | ZERO_CEE_SECT(&m->cs); 49 | S(chain)(m, st); 50 | 51 | m->cs.trace = S(trace); 52 | m->cs.resize_method = CEE_RESIZE_WITH_IDENTITY; 53 | m->cs.mem_block_size = mem_block_size; 54 | m->cs.n_product = 4; 55 | m->cs.state = st; 56 | m->_[0] = v1; 57 | m->_[1] = v2; 58 | m->_[2] = v3; 59 | m->_[3] = v4; 60 | int i; 61 | for (i = 0; i < 4; i++) { 62 | m->del_policies[i] = o[i]; 63 | cee_incr_indegree(o[i], m->_[i]); 64 | } 65 | return (struct cee_quadruple *)&m->_; 66 | } 67 | -------------------------------------------------------------------------------- /scripts/get-cee-std.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | set -o pipefail 4 | 5 | mypath=$(dirname $(readlink -f $0)) 6 | url="https://raw.githubusercontent.com/cee-studio/cee-std/master" 7 | url="file:///${HOME}/workspace/cee-std" 8 | 9 | curl $url/scripts/get-cee-std.sh -o ${mypath}/get-cee-std.sh 10 | chmod +x ${mypath}/get-cee-std.sh 11 | 12 | cee_list=" 13 | cee.h 14 | cee.c" 15 | 16 | json_list=" 17 | cee-json.h 18 | cee-json.c" 19 | 20 | sqlite3_list=" 21 | cee_dbm.h 22 | cee_dbm.c 23 | join.c 24 | cee-sqlite3.h 25 | cee-sqlite3.c" 26 | 27 | mkdir -p $mypath/../cee-std 28 | pushd $mypath/../cee-std 29 | for i in $cee_list; do 30 | echo "getting $i" 31 | echo "$url/release/$i" 32 | curl $url/release/$i -o $i 33 | done 34 | 35 | for i in $json_list; do 36 | echo "getting $i" 37 | echo "$url/cee-json/release/$i" 38 | curl $url/cee-json/release/$i -o $i 39 | done 40 | 41 | for i in $sqlite3_list; do 42 | echo "getting $i" 43 | echo "$url/sqlite3/$i" 44 | curl $url/sqlite3/$i -o $i 45 | done 46 | popd 47 | -------------------------------------------------------------------------------- /scripts/get-cee-utils.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | set -o pipefail 4 | 5 | mypath=$(dirname $(readlink -f $0)) 6 | url="https://raw.githubusercontent.com/cee-studio/cee-utils/master" 7 | 8 | wget $url/scripts/get-cee-utils.sh -O ${mypath}/get-cee-utils.sh 9 | chmod +x ${mypath}/get-cee-utils.sh 10 | 11 | list="README.md 12 | debug.h 13 | cee-sqlite3.h 14 | cee-sqlite3.c 15 | jsmn.h 16 | json-actor-boxed.c 17 | json-actor-boxed.h 18 | json-actor.c 19 | json-actor.h 20 | json-parser.c 21 | json-printf.c 22 | json-scanf.c 23 | json-scanf.h 24 | json-string.c 25 | json-struct.c 26 | cJSON.c 27 | cJSON.h 28 | log.c 29 | logconf.c 30 | logconf.h 31 | log.h 32 | ntl.c 33 | ntl.h 34 | cee-utils.c 35 | cee-utils.h 36 | utarray.h 37 | url-encode.h 38 | hmac.h 39 | hmac.c 40 | teeny-sha1.c 41 | cee-data-sizes.h 42 | sha.h 43 | sha1.c 44 | greatest.h 45 | utf8.h 46 | uthash.h 47 | utlist.h 48 | utringbuffer.h 49 | utstack.h 50 | utstring.h" 51 | 52 | mkdir -p $mypath/../cee-utils 53 | pushd $mypath/../cee-utils 54 | for i in $list; do 55 | echo "getting $i" 56 | echo "$url/$i" 57 | wget $url/$i -O $i 58 | done 59 | popd 60 | -------------------------------------------------------------------------------- /singleton.c: -------------------------------------------------------------------------------- 1 | #ifdef CEE_AMALGAMATION 2 | #undef S 3 | #define S(f) _cee_singleton_##f 4 | #else 5 | #define S(f) _##f 6 | #include 7 | #include "cee.h" 8 | #endif 9 | #include "cee-header.h" 10 | 11 | struct S(header) { 12 | struct cee_sect cs; 13 | uintptr_t _; /* tag */ 14 | uintptr_t val; 15 | }; 16 | 17 | /* 18 | * the parameter of this function has to be a global/static 19 | * uintptr_t array of two elements 20 | */ 21 | #if 1 /* original */ 22 | /* 23 | * singleton should never be deleted, hence we pass a noop 24 | */ 25 | static void S(noop)(void *p, enum cee_trace_action ta) {} 26 | 27 | struct cee_singleton * cee_singleton_init(void *s, uintptr_t tag, uintptr_t val) { 28 | struct S(header) * b = (struct S(header)* )s; 29 | ZERO_CEE_SECT(&b->cs); 30 | b->cs.trace = S(noop); 31 | b->cs.resize_method = CEE_RESIZE_WITH_IDENTITY; 32 | b->cs.mem_block_size = 0; 33 | b->cs.n_product = 0; 34 | b->_ = tag; 35 | b->val = val; 36 | return (struct cee_singleton *)&(b->_); 37 | } 38 | #else /* update attempt */ 39 | 40 | #include "cee-resize.h" 41 | 42 | static void S(trace) (void * v, enum cee_trace_action ta) { 43 | struct S(header) * m = FIND_HEADER(v); 44 | switch(ta) { 45 | case CEE_TRACE_DEL_FOLLOW: 46 | case CEE_TRACE_DEL_NO_FOLLOW: 47 | S(de_chain)(m); 48 | free(m); 49 | break; 50 | case CEE_TRACE_MARK: 51 | m->cs.gc_mark = ta - CEE_TRACE_MARK; 52 | break; 53 | } 54 | } 55 | 56 | struct cee_singleton * cee_singleton_mk(struct cee_state * st, cee_tag_t tag, uintptr_t val) { 57 | size_t mem_block_size = sizeof(struct S(header)); 58 | struct S(header) * b = malloc(mem_block_size); 59 | ZERO_CEE_SECT(&b->cs); 60 | S(chain)(b, st); 61 | 62 | b->cs.trace = S(trace); 63 | b->cs.resize_method = CEE_RESIZE_WITH_IDENTITY; 64 | b->cs.mem_block_size = mem_block_size; 65 | 66 | b->_ = tag; 67 | b->val = val; 68 | cee_state_add_singleton(st, tag, val); 69 | return (struct cee_singleton *)&(b->_); 70 | } 71 | #endif 72 | -------------------------------------------------------------------------------- /sqlite3/cee_dbm.h: -------------------------------------------------------------------------------- 1 | #ifndef CEE_DBM_H 2 | #define CEE_DBM_H 3 | #include 4 | #include 5 | #include "cee-sqlite3.h" 6 | #include "cee-json.h" 7 | /* the code to manage sqlite3 db for creation, restoration, migration, and population */ 8 | 9 | struct cee_dbm_path_info{ 10 | char schema_script_path[128]; 11 | char data_script_path[128]; 12 | char db_file_path[128]; 13 | }; 14 | 15 | /* filename without path */ 16 | typedef char db_file_t[32]; 17 | 18 | struct cee_dbm_db_info{ 19 | char kind[16]; 20 | db_file_t file; 21 | bool recreate_db; /* */ 22 | bool restore_db; /* */ 23 | bool customize_db; 24 | int create_version; 25 | int final_version; 26 | }; 27 | 28 | extern int cee_dbm_path_info_load(char *start, uintptr_t size, struct cee_dbm_path_info *info); 29 | extern uintptr_t cee_dbm_path_info_snprint(char *buf, uintptr_t size, struct cee_dbm_path_info *s); 30 | 31 | extern int cee_dbm_db_info_load(char *start, uintptr_t size, struct cee_dbm_db_info *info); 32 | extern uintptr_t cee_dbm_settings_snprint(char *buf, uintptr_t size, struct cee_dbm_db_info *s); 33 | extern void cee_dbm_path_info_normalize (struct cee_dbm_path_info *db, char *home_dir); 34 | 35 | /* db_file has to exist, otherwise segfault will be caused */ 36 | extern void cee_dbm_open_db(struct cee_state *state, struct cee_sqlite3 * cs, 37 | struct cee_dbm_path_info *path_info, 38 | char *db_kind, 39 | char *db_file, 40 | sqlite3* (*open_db)(const char *db_file)); 41 | 42 | /* attatch db as to support join tables in multiple dbs */ 43 | void cee_dbm_attach_db(struct cee_sqlite3 *cs, 44 | struct cee_dbm_path_info *path_info, 45 | char *db_file, char *as_name); 46 | 47 | /* db_file does not have to exist */ 48 | extern bool cee_dbm_db_init(struct cee_dbm_path_info *path_info, 49 | struct cee_dbm_db_info *s, 50 | const char *db_file_, 51 | const char *restore_data_prefix, 52 | int *db_version); 53 | extern bool cee_dbm_db_exist(struct cee_dbm_path_info *path_info, const char *db_file); 54 | 55 | 56 | void cee_dbm_path_info2str(struct cee_dbm_path_info *info, size_t buf_size, char *buf); 57 | void cee_dbm_db_info2str(struct cee_dbm_db_info *info, size_t buf_size, char *buf); 58 | 59 | bool cee_dbm_db_backup(struct cee_dbm_path_info *path_info, 60 | struct cee_dbm_db_info *s, 61 | const char *db_file_, 62 | const char *restore_data_prefix); 63 | #endif //CEE_DBM_H 64 | -------------------------------------------------------------------------------- /sqlite3/join.c: -------------------------------------------------------------------------------- 1 | #include "cee-sqlite3.h" 2 | #include 3 | struct join_ctx { 4 | struct cee_sqlite3 *cs; 5 | char *sql; 6 | struct cee_sqlite3_bind_info *info; 7 | struct cee_sqlite3_bind_data *data; 8 | char *key; 9 | }; 10 | 11 | static int join_one (void *ctx, void *elem, int idx) { 12 | struct join_ctx *join_ctx = ctx; 13 | struct cee_sqlite3_bind_info *info = join_ctx->info; 14 | struct cee_sqlite3_bind_data *data = join_ctx->data, *item = NULL; 15 | struct cee_json *one = elem; 16 | 17 | int i; 18 | for( i = 0; info[i].var_name; i++ ){ 19 | item = NULL; 20 | if( data && data[i].has_value ) 21 | item = data + i; 22 | else if( info[i].data.has_value ) 23 | item = &info[i].data; 24 | 25 | if( item == NULL ) continue; 26 | 27 | struct cee_json *value = cee_json_object_get(elem, info[i].col_name); 28 | if( value == NULL ){ 29 | cee_json_object_set_strf(one, "error", "cannot find json key %s for %s", 30 | info[i].col_name, info[i].var_name); 31 | return 1; /* stop */ 32 | } 33 | switch( value->t ){ 34 | case CEE_JSON_I64: 35 | if( cee_json_to_intx(value, &item->i) ){ 36 | cee_json_object_set_strf( 37 | one, "error", "failed to convert json key %s's value to int", 38 | info[i].col_name); 39 | return 1; /* stop */ 40 | } 41 | break; /* switch */ 42 | case CEE_JSON_STRING: 43 | item->value = cee_json_to_str(value)->_; 44 | break; /* switch */ 45 | case CEE_JSON_NULL: 46 | cee_json_object_set_strf( 47 | one, "error", "unsupported json key %s's value is null", 48 | info[i].col_name); 49 | return 1; /* stop */ 50 | default: 51 | /* change to unspported type errors */ 52 | cee_json_object_set_strf( 53 | one, "error", "unsupported json key %s's value type %d", 54 | info[i].col_name, value->t); 55 | return 1; /* stop */ 56 | } 57 | } 58 | if( join_ctx->key == NULL ){ 59 | cee_sqlite3_select1(join_ctx->cs, info, data, join_ctx->sql, &one); 60 | if( cee_json_select(one, ".error") ) 61 | return 1; 62 | }else{ 63 | struct cee_json *rows = NULL, *error = NULL; 64 | cee_sqlite3_select(join_ctx->cs, info, data, join_ctx->sql, &rows); 65 | cee_json_object_set(one, join_ctx->key, rows); 66 | if( (error = cee_json_select(rows, ".error")) ){ 67 | return 1; 68 | } 69 | } 70 | 71 | return 0; 72 | } 73 | 74 | void cee_sqlite3_json_array_join_table(struct cee_sqlite3 *cs, 75 | struct cee_json *json, 76 | struct cee_sqlite3_bind_info *info, 77 | struct cee_sqlite3_bind_data *data, 78 | char *sql, char *key) { 79 | struct join_ctx join_ctx = {0}; 80 | join_ctx.key = key; 81 | join_ctx.cs = cs; 82 | join_ctx.sql = sql; 83 | join_ctx.info = info; 84 | join_ctx.data = data; 85 | struct cee_list *list = cee_json_to_array(json); 86 | cee_list_iterate(list, &join_ctx, join_one); 87 | } 88 | 89 | void cee_sqlite3_json_object_join_table(struct cee_sqlite3 *cs, 90 | struct cee_json *json, 91 | struct cee_sqlite3_bind_info *info, 92 | struct cee_sqlite3_bind_data *data, 93 | char *sql, char *key) { 94 | struct join_ctx join_ctx = {0}; 95 | join_ctx.key = key; 96 | join_ctx.cs = cs; 97 | join_ctx.sql = sql; 98 | join_ctx.info = info; 99 | join_ctx.data = data; 100 | join_one(&join_ctx, json, 0); 101 | } 102 | -------------------------------------------------------------------------------- /stack.c: -------------------------------------------------------------------------------- 1 | #ifdef CEE_AMALGAMATION 2 | #undef S 3 | #define S(f) _cee_stack_##f 4 | #else 5 | #define S(f) _##f 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "cee.h" 11 | #endif 12 | #include "cee-header.h" 13 | 14 | struct S(header) { 15 | uintptr_t used; 16 | uintptr_t top; 17 | uintptr_t capacity; 18 | enum cee_del_policy del_policy; 19 | struct cee_sect cs; 20 | void * _[]; 21 | }; 22 | 23 | #include "cee-resize.h" 24 | 25 | static void S(trace) (void * v, enum cee_trace_action ta) { 26 | struct S(header) * m = FIND_HEADER(v); 27 | int i; 28 | 29 | switch (ta) { 30 | case CEE_TRACE_DEL_NO_FOLLOW: 31 | S(de_chain)(m); 32 | free(m); 33 | break; 34 | case CEE_TRACE_DEL_FOLLOW: 35 | for (i = 0; i < m->used; i++) 36 | cee_del_e(m->del_policy, m->_[i]); 37 | S(de_chain)(m); 38 | free(m); 39 | break; 40 | case CEE_TRACE_MARK: 41 | default: 42 | m->cs.gc_mark = ta - CEE_TRACE_MARK; 43 | for (i = 0; i < m->used; i++) 44 | cee_trace(m->_[i], ta); 45 | break; 46 | } 47 | } 48 | 49 | struct cee_stack * cee_stack_mk_e (struct cee_state * st, enum cee_del_policy o, size_t size) { 50 | uintptr_t mem_block_size = sizeof(struct S(header)) + size * sizeof(void *); 51 | struct S(header) * m = malloc(mem_block_size); 52 | m->capacity = size; 53 | m->used = 0; 54 | m->top = (0-1); 55 | m->del_policy = o; 56 | 57 | ZERO_CEE_SECT(&m->cs); 58 | S(chain)(m, st); 59 | 60 | m->cs.trace = S(trace); 61 | m->cs.mem_block_size = mem_block_size; 62 | return (struct cee_stack *)(m->_); 63 | } 64 | 65 | struct cee_stack * cee_stack_mk (struct cee_state * st, size_t size) { 66 | return cee_stack_mk_e(st, CEE_DP_DEL_RC, size); 67 | } 68 | 69 | int cee_stack_push (struct cee_stack * v, void *e) { 70 | struct S(header) * m = FIND_HEADER((void **)v); 71 | if (m->used == m->capacity) 72 | return 0; 73 | 74 | m->top ++; 75 | m->used ++; 76 | m->_[m->top] = e; 77 | cee_incr_indegree(m->del_policy, e); 78 | return 1; 79 | } 80 | 81 | void * cee_stack_pop (struct cee_stack * v) { 82 | struct S(header) * b = FIND_HEADER((void **)v); 83 | if (b->used == 0) { 84 | return NULL; 85 | } 86 | else { 87 | void * p = b->_[b->top]; 88 | b->used --; 89 | b->top --; 90 | cee_decr_indegree(b->del_policy, p); 91 | return p; 92 | } 93 | } 94 | 95 | /* 96 | * nth: 0 -> the topest element 97 | * 1 -> 1 element way from the topest element 98 | */ 99 | void * cee_stack_top (struct cee_stack * v, uintptr_t nth) { 100 | struct S(header) * b = FIND_HEADER(v); 101 | if (b->used == 0 || nth >= b->used) 102 | return NULL; 103 | else 104 | return b->_[b->top-nth]; 105 | } 106 | 107 | uintptr_t cee_stack_size (struct cee_stack *x) { 108 | struct S(header) * m = FIND_HEADER((void **)x); 109 | return m->used; 110 | } 111 | 112 | #if 0 113 | uintptr_t cee_stack_capacity (struct cee_stack *s) { 114 | struct S(header) * m = FIND_HEADER(s); 115 | return m->capacity; 116 | } 117 | #endif 118 | 119 | bool cee_stack_empty (struct cee_stack *x) { 120 | struct S(header) * b = FIND_HEADER(x); 121 | return b->used == 0; 122 | } 123 | 124 | bool cee_stack_full (struct cee_stack *x) { 125 | struct S(header) * b = FIND_HEADER(x); 126 | return b->used >= b->capacity; 127 | } 128 | -------------------------------------------------------------------------------- /state.c: -------------------------------------------------------------------------------- 1 | #ifdef CEE_AMALGAMATION 2 | #undef S 3 | #define S(f) _cee_state_##f 4 | #else 5 | #define S(f) _##f 6 | #include "cee.h" 7 | #include 8 | #include 9 | #include 10 | #endif 11 | #include "cee-header.h" 12 | 13 | struct S(header) { 14 | struct cee_sect cs; 15 | struct cee_state _; 16 | }; 17 | 18 | static void S(trace) (void * v, enum cee_trace_action ta) { 19 | struct S(header) * m = FIND_HEADER(v); 20 | switch (ta) { 21 | case CEE_TRACE_DEL_FOLLOW: 22 | { 23 | /* 24 | * This path will be invoked by cee_del(cee_state *). 25 | * Following this trace chain but not the points-to relation 26 | * started from roots and contexts. 27 | */ 28 | struct cee_sect * tail = m->_.trace_tail; 29 | while (tail != &m->cs) { 30 | /* cee_trace should call S(de_chain) to remove tail from the chain */ 31 | cee_trace(tail + 1, CEE_TRACE_DEL_NO_FOLLOW); 32 | /* m->_.trace_tail should point to a new tail */ 33 | tail = m->_.trace_tail; 34 | } 35 | free(m); 36 | break; 37 | } 38 | case CEE_TRACE_DEL_NO_FOLLOW: 39 | { 40 | /* 41 | * Not sure how this is possible. Most likely 42 | * this is a dead path as we cannot create a state 43 | * from other states. 44 | * 45 | * TODO detach the this state from all 46 | * memory blocks allocated by this state 47 | */ 48 | free(m); 49 | break; 50 | } 51 | case CEE_TRACE_MARK: 52 | default: 53 | { /* 54 | * this will be only invoked by cee_state_gc 55 | * mark all blocks that are reachable thru 56 | * roots, stack, and contexts 57 | */ 58 | m->cs.gc_mark = ta - CEE_TRACE_MARK; 59 | cee_trace(m->_.roots, ta); 60 | cee_trace(m->_.stack, ta); 61 | cee_trace(m->_.contexts, ta); 62 | break; 63 | } 64 | } 65 | } 66 | 67 | static void S(sweep) (void * v, enum cee_trace_action ta) { 68 | struct S(header) * m = FIND_HEADER(v); 69 | struct cee_sect * head = &m->cs; 70 | /* find all blocks that are not reachable 71 | in the mark cycle and delete them 72 | */ 73 | while (head != NULL) { 74 | struct cee_sect * next = head->trace_next; 75 | if (head->gc_mark != ta - CEE_TRACE_MARK) 76 | cee_trace(head + 1, CEE_TRACE_DEL_NO_FOLLOW); 77 | head = next; 78 | } 79 | } 80 | 81 | static int S(cmp) (const void * v1, const void * v2) { 82 | if (v1 < v2) 83 | return -1; 84 | else if (v1 == v2) 85 | return 0; 86 | else 87 | return 1; 88 | } 89 | 90 | struct cee_state * cee_state_mk(size_t n) { 91 | size_t memblock_size = sizeof(struct S(header)); 92 | struct S(header) * h = malloc(memblock_size); 93 | ZERO_CEE_SECT(&h->cs); 94 | h->cs.trace = S(trace); 95 | h->_.trace_tail = &h->cs; /* points to self; */ 96 | 97 | struct cee_set * roots = cee_set_mk_e(&h->_, CEE_DP_NOOP, S(cmp)); 98 | h->_.roots = roots; 99 | h->_.next_mark = 1; 100 | h->_.stack = cee_stack_mk(&h->_, n); 101 | h->_.contexts = cee_map_mk(&h->_, (cee_cmp_fun)strcmp); 102 | return &h->_; 103 | } 104 | 105 | 106 | /* 107 | * add a struct to the roots, so it will survive cee_state_gc. 108 | * but it will not survive cee_del(cee_state *). 109 | */ 110 | void cee_state_add_gc_root(struct cee_state * s, void * key) { 111 | cee_set_add(s->roots, key); 112 | } 113 | 114 | /* 115 | * remove a struct from the roots, so it will be collected by cee_state_gc. 116 | */ 117 | void cee_state_remove_gc_root(struct cee_state * s, void * key) { 118 | cee_set_remove(s->roots, key); 119 | } 120 | 121 | /* 122 | * add a struct to the contexts, so it will survive cee_state_gc. 123 | * but it will not survive cee_del(cee_state *). 124 | */ 125 | void cee_state_add_context (struct cee_state * s, char * key, void * val) { 126 | cee_map_add(s->contexts, key, val); 127 | } 128 | 129 | /* 130 | * remove a struct from the contexts, so it will be collected by cee_state_gc. 131 | */ 132 | void cee_state_remove_context (struct cee_state * s, char * key) { 133 | cee_map_remove(s->contexts, key); 134 | } 135 | 136 | void * cee_state_get_context (struct cee_state * s, char * key) { 137 | return cee_map_find(s->contexts, key); 138 | } 139 | 140 | void cee_state_gc (struct cee_state * s) { 141 | struct S(header) * h = FIND_HEADER(s); 142 | int mark = CEE_TRACE_MARK + s->next_mark; 143 | 144 | /* 145 | * mark all blocks that are reachable thru 146 | * roots/contexts 147 | */ 148 | cee_trace(s, (enum cee_trace_action)mark); 149 | S(sweep)(s, (enum cee_trace_action) mark); 150 | 151 | if (s->next_mark == 0) { 152 | s->next_mark = 1; 153 | } else { 154 | s->next_mark = 0; 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /tagged.c: -------------------------------------------------------------------------------- 1 | #ifdef CEE_AMALGAMATION 2 | #undef S 3 | #define S(f) _cee_tagged_##f 4 | #else 5 | #define S(f) _##f 6 | #include "cee.h" 7 | #include 8 | #include 9 | #endif 10 | #include "cee-header.h" 11 | 12 | struct S(header) { 13 | enum cee_del_policy del_policy; 14 | struct cee_sect cs; 15 | struct cee_tagged _; 16 | }; 17 | 18 | #include "cee-resize.h" 19 | 20 | static void S(trace) (void * v, enum cee_trace_action ta) { 21 | struct S(header) * m = FIND_HEADER(v); 22 | switch (ta) { 23 | case CEE_TRACE_DEL_NO_FOLLOW: 24 | S(de_chain)(m); 25 | free(m); 26 | break; 27 | case CEE_TRACE_DEL_FOLLOW: 28 | cee_del_e(m->del_policy, m->_.ptr._); 29 | S(de_chain)(m); 30 | free(m); 31 | break; 32 | case CEE_TRACE_MARK: 33 | default: 34 | m->cs.gc_mark = ta - CEE_TRACE_MARK; 35 | cee_trace(m->_.ptr._, ta); 36 | break; 37 | } 38 | } 39 | 40 | struct cee_tagged * cee_tagged_mk_e (struct cee_state * st, enum cee_del_policy o, uintptr_t tag, void *p) { 41 | size_t mem_block_size = sizeof(struct S(header)); 42 | struct S(header) * b = malloc(mem_block_size); 43 | ZERO_CEE_SECT(&b->cs); 44 | S(chain)(b, st); 45 | 46 | b->cs.trace = S(trace); 47 | b->cs.resize_method = CEE_RESIZE_WITH_IDENTITY; 48 | b->cs.mem_block_size = mem_block_size; 49 | 50 | b->_.tag = tag; 51 | b->_.ptr._ = p; 52 | b->del_policy = o; 53 | if( p ) 54 | cee_incr_indegree(o, p); 55 | return &b->_; 56 | } 57 | 58 | struct cee_tagged * cee_tagged_mk (struct cee_state * st, uintptr_t tag, void *p) { 59 | return cee_tagged_mk_e(st, CEE_DP_DEL_RC, tag, p); 60 | } 61 | -------------------------------------------------------------------------------- /test/test-memory.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "release/cee.c" 7 | #include "greatest.h" 8 | 9 | #define N_APPENDS 1000 10 | 11 | struct generic { 12 | enum { UNDEF=0, INT32, STRING, FLOAT } type; 13 | void *key; 14 | union { 15 | void *p; 16 | int i; 17 | float f; 18 | }; 19 | }; 20 | 21 | typedef void (*add_n_check_fn)(struct cee_state *st, unsigned n_append, void **p_root); 22 | 23 | void add_n_list(struct cee_state *st, unsigned n_append, void **p_root) 24 | { 25 | struct cee_list *list = cee_list_mk(st, 10); 26 | for (unsigned i=0, j=0; i < n_append; ++i, ++j) { 27 | switch (j) { 28 | case 0: cee_list_append(list, cee_str_mk(st, "%u", i)); break; 29 | case 1: cee_list_append(list, cee_tagged_mk(st, FLOAT, cee_boxed_from_float(st, 1.0f * i))); break; 30 | case 2: cee_list_append(list, cee_tagged_mk(st, INT32, cee_boxed_from_i32(st, i))); break; 31 | case 3: cee_list_append(list, cee_tagged_mk(st, STRING, cee_str_mk(st, "%u", i))); j=0; break; 32 | } 33 | } 34 | cee_state_add_gc_root(st, list); 35 | *p_root = list; 36 | } 37 | 38 | void add_n_set(struct cee_state *st, unsigned n_append, void **p_root) 39 | { 40 | struct cee_set *set = cee_set_mk(st, (cee_cmp_fun)&strcmp); 41 | for (unsigned i=0; i < n_append; ++i) { 42 | cee_set_add(set, cee_str_mk(st, "%u", i)); 43 | } 44 | cee_state_add_gc_root(st, set); 45 | *p_root = set; 46 | } 47 | 48 | void add_n_map(struct cee_state *st, unsigned n_append, void **p_root) 49 | { 50 | struct cee_map *map = cee_map_mk(st, (cee_cmp_fun)&strcmp); 51 | for (unsigned i=0, j=0; i < n_append; ++i, ++j) { 52 | struct cee_str *key = cee_str_mk(st, "%u", i); 53 | switch (j) { 54 | case 0: cee_map_add(map, key, cee_boxed_from_i32(st, i)); break; 55 | case 1: cee_map_add(map, key, cee_str_mk(st, "hello %u", i)); break; 56 | case 2: cee_map_add(map, key, cee_tagged_mk(st, FLOAT, cee_boxed_from_float(st, 1.0f * i))); break; 57 | case 3: cee_map_add(map, key, cee_tagged_mk(st, INT32, cee_boxed_from_i32(st, i))); break; 58 | case 4: cee_map_add(map, key, cee_tagged_mk(st, STRING, cee_str_mk(st, "%u", i))); j = 0; break; 59 | } 60 | } 61 | cee_state_add_gc_root(st, map); 62 | *p_root = map; 63 | } 64 | 65 | void add_n_stack(struct cee_state *st, unsigned n_append, void **p_root) 66 | { 67 | struct cee_stack *s = cee_stack_mk(st, 100); 68 | for (unsigned i=0, j=0; i < n_append; ++i, ++j) { 69 | switch (j) { 70 | case 0: cee_stack_push(s, cee_boxed_from_i32(st, i)); break; 71 | case 1: cee_stack_push(s, cee_str_mk(st, "hello %u", i)); break; 72 | case 2: cee_stack_push(s, cee_tagged_mk(st, FLOAT, cee_boxed_from_float(st, 1.0f * i))); break; 73 | case 3: cee_stack_push(s, cee_tagged_mk(st, INT32, cee_boxed_from_i32(st, i))); break; 74 | case 4: cee_stack_push(s, cee_tagged_mk(st, STRING, cee_str_mk(st, "%u", i))); j = 0; break; 75 | } 76 | } 77 | cee_state_add_gc_root(st, s); 78 | *p_root = s; 79 | } 80 | 81 | void add_n_dict(struct cee_state *st, unsigned n_append, void **p_root) 82 | { 83 | struct cee_dict *dict = cee_dict_mk(st, 100); 84 | for (unsigned i=0, j=0; i < n_append; ++i, ++j) { 85 | char *key = cee_str_mk(st, "%u", i)->_; 86 | switch (j) { 87 | case 0: cee_dict_add(dict, key, cee_boxed_from_i32(st, i)); break; 88 | case 1: cee_dict_add(dict, key, cee_str_mk(st, "hello %u", i)); break; 89 | case 2: cee_dict_add(dict, key, cee_tagged_mk(st, FLOAT, cee_boxed_from_float(st, 1.0f * i))); break; 90 | case 3: cee_dict_add(dict, key, cee_tagged_mk(st, INT32, cee_boxed_from_i32(st, i))); break; 91 | case 4: cee_dict_add(dict, key, cee_tagged_mk(st, STRING, cee_str_mk(st, "%u", i))); j = 0; break; 92 | } 93 | } 94 | cee_state_add_gc_root(st, dict); 95 | *p_root = dict; 96 | } 97 | 98 | TEST add_all__then_run_gc(const int n_appends) 99 | { 100 | /* simply add new tests to the list */ 101 | add_n_check_fn test_list[] = { add_n_list, add_n_set, add_n_map, add_n_stack, add_n_dict }; 102 | #define N_TESTS (sizeof(test_list) / sizeof(add_n_check_fn)) 103 | 104 | struct cee_state *st = cee_state_mk(10); 105 | void *roots[N_TESTS] = {}; 106 | for (unsigned i=0; i < N_TESTS; ++i) { 107 | test_list[i](st, n_appends, &roots[i]); 108 | } for (unsigned i=0; i < N_TESTS; ++i) { 109 | cee_state_gc(st); 110 | cee_state_remove_gc_root(st, roots[i]); 111 | } 112 | cee_del(st); 113 | PASS(); 114 | #undef N_TESTS 115 | } 116 | 117 | SUITE(garbage_collector) 118 | { 119 | RUN_TESTp(add_all__then_run_gc, N_APPENDS); 120 | } 121 | 122 | GREATEST_MAIN_DEFS(); 123 | 124 | int main(int argc, char *argv[]) 125 | { 126 | GREATEST_MAIN_BEGIN(); 127 | 128 | RUN_SUITE(garbage_collector); 129 | 130 | GREATEST_MAIN_END(); 131 | } 132 | 133 | -------------------------------------------------------------------------------- /test/test.mk: -------------------------------------------------------------------------------- 1 | TOP = .. 2 | CC ?= gcc 3 | 4 | SRC = $(wildcard *.c) 5 | EXES = $(SRC:%.c=%.out) 6 | 7 | CFLAGS := -std=c99 -fno-exceptions -g -I$(TOP)/ -I$(TOP)/cee-utils -static 8 | 9 | ifeq ($(LCOV),1) 10 | CFLAGS += --coverage 11 | LDFLAGS += --coverage -static 12 | endif 13 | 14 | # generic compilation 15 | %.out: %.c 16 | $(CC) $(CFLAGS) -g -o $@ $^ 17 | 18 | all: $(EXES) 19 | 20 | clean: 21 | rm -f *.out *.gcno *.gcda 22 | 23 | .PHONY : all clean 24 | -------------------------------------------------------------------------------- /triple.c: -------------------------------------------------------------------------------- 1 | #ifdef CEE_AMALGAMATION 2 | #undef S 3 | #define S(f) _cee_triple_##f 4 | #else 5 | #define S(f) _##f 6 | #include "cee.h" 7 | #include 8 | #include 9 | #endif 10 | #include "cee-header.h" 11 | 12 | struct S(header) { 13 | enum cee_del_policy del_policies[3]; 14 | struct cee_sect cs; 15 | void * _[3]; 16 | }; 17 | 18 | #include "cee-resize.h" 19 | 20 | static void S(trace)(void * v, enum cee_trace_action ta) { 21 | struct S(header) * b = FIND_HEADER(v); 22 | int i; 23 | 24 | switch (ta) { 25 | case CEE_TRACE_DEL_NO_FOLLOW: 26 | S(de_chain)(b); 27 | free(b); 28 | break; 29 | case CEE_TRACE_DEL_FOLLOW: 30 | for (i = 0; i < 3; i++) 31 | cee_del_e(b->del_policies[i], b->_[i]); 32 | S(de_chain)(b); 33 | free(b); 34 | break; 35 | case CEE_TRACE_MARK: 36 | default: 37 | b->cs.gc_mark = ta - CEE_TRACE_MARK; 38 | for (i = 0; i < 3; i++) 39 | cee_trace(b->_[i], ta); 40 | break; 41 | } 42 | } 43 | 44 | struct cee_triple * cee_triple_mk_e (struct cee_state * st, enum cee_del_policy o[3], void * v1, void * v2, void * v3) { 45 | size_t mem_block_size = sizeof(struct S(header)); 46 | struct S(header) * m = malloc(mem_block_size); 47 | ZERO_CEE_SECT(&m->cs); 48 | S(chain)(m, st); 49 | 50 | m->cs.trace = S(trace); 51 | m->cs.resize_method = CEE_RESIZE_WITH_IDENTITY; 52 | m->cs.mem_block_size = mem_block_size; 53 | m->cs.state = st; 54 | m->_[0] = v1; 55 | m->_[1] = v2; 56 | m->_[2] = v3; 57 | int i; 58 | for (i = 0; i < 3; i++) { 59 | m->del_policies[i] = o[i]; 60 | cee_incr_indegree(o[i], m->_[i]); 61 | } 62 | return (struct cee_triple *)&m->_; 63 | } 64 | 65 | struct cee_triple * cee_triple_mk (struct cee_state * st, void * v1, void * v2, void *v3) { 66 | static enum cee_del_policy o[3] = { CEE_DP_DEL_RC, CEE_DP_DEL_RC, CEE_DP_DEL_RC }; 67 | return cee_triple_mk_e(st, o, v1, v2, v3); 68 | } 69 | -------------------------------------------------------------------------------- /tuple.c: -------------------------------------------------------------------------------- 1 | #ifdef CEE_AMALGAMATION 2 | #undef S 3 | #define S(f) _cee_tuple_##f 4 | #else 5 | #define S(f) _##f 6 | #include 7 | #include 8 | #include "cee.h" 9 | #endif 10 | #include "cee-header.h" 11 | 12 | struct S(header) { 13 | enum cee_del_policy del_policies[2]; 14 | struct cee_sect cs; 15 | void * _[2]; 16 | }; 17 | 18 | #include "cee-resize.h" 19 | 20 | static void S(trace)(void * v, enum cee_trace_action ta) { 21 | struct S(header) * b = FIND_HEADER(v); 22 | int i; 23 | 24 | switch (ta) { 25 | case CEE_TRACE_DEL_NO_FOLLOW: 26 | S(de_chain)(b); 27 | free(b); 28 | break; 29 | case CEE_TRACE_DEL_FOLLOW: 30 | for (i = 0; i < 2; i++) 31 | cee_del_e(b->del_policies[i], b->_[i]); 32 | S(de_chain)(b); 33 | free(b); 34 | break; 35 | case CEE_TRACE_MARK: 36 | default: 37 | b->cs.gc_mark = ta - CEE_TRACE_MARK; 38 | for (i = 0; i < 2; i++) 39 | cee_trace(b->_[i], ta); 40 | break; 41 | } 42 | } 43 | 44 | 45 | struct cee_tuple * cee_tuple_mk_e (struct cee_state * st, enum cee_del_policy o[2], void * v1, void * v2) { 46 | size_t mem_block_size = sizeof(struct S(header)); 47 | struct S(header) * m = malloc(mem_block_size); 48 | ZERO_CEE_SECT(&m->cs); 49 | S(chain)(m, st); 50 | 51 | m->cs.trace = S(trace); 52 | m->cs.resize_method = CEE_RESIZE_WITH_IDENTITY; 53 | m->cs.mem_block_size = mem_block_size; 54 | m->cs.state = st; 55 | m->_[0] = v1; 56 | m->_[1] = v2; 57 | int i; 58 | for (i = 0; i < 2; i++) { 59 | m->del_policies[i] = o[i]; 60 | cee_incr_indegree(o[i], m->_[i]); 61 | } 62 | return (struct cee_tuple *)&m->_; 63 | } 64 | 65 | struct cee_tuple * cee_tuple_mk (struct cee_state * st, void * v1, void * v2) { 66 | static enum cee_del_policy o[2] = { CEE_DP_DEL_RC, CEE_DP_DEL_RC }; 67 | return cee_tuple_mk_e(st, o, v1, v2); 68 | } 69 | 70 | 71 | void cee_tuple_update_del_policy(struct cee_tuple *t, int index, enum cee_del_policy v) { 72 | struct S(header) *b = FIND_HEADER(t); 73 | b->del_policies[index] = v; 74 | return; 75 | } 76 | --------------------------------------------------------------------------------