From 7033187abaf42772097377c0a1ffc2cd4cefdada Mon Sep 17 00:00:00 2001 From: JSDurand Date: Fri, 4 Aug 2023 10:12:04 +0800 Subject: minor adjustments Not bug deals but adjustments of details. --- src/test.c | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) (limited to 'src/test.c') diff --git a/src/test.c b/src/test.c index 249eb87..f9ab43b 100644 --- a/src/test.c +++ b/src/test.c @@ -25,13 +25,13 @@ main(int argc, char **argv) "\n" "item =/ header [ note ] *1( price )\n" "\n" -"header = *1star \"SP\" title %xA *( \"SP\" / %xA )\n" +"header = star \"SP\" title %xA *( \"SP\" / %xA )\n" "\n" "title = 1*\"TEXT\"\n" "\n" "star = %x2A\n" "\n" -"note = \"note:\" note-content %xA *( \"SP\" / %xA )\n" +"note = \"note:\" \"SP\" note-content %xA *( \"SP\" / %xA )\n" "\n" "note-content = 1*\"TEXT\"\n" "\n" @@ -58,7 +58,31 @@ main(int argc, char **argv) return 1; } - unsigned char *input = malloc (sizeof(unsigned char) * 10 * 8); + /* int input_unenc[] = { 3, 0, 2, 1, 5, 0, 6, 1 }; */ + + /* int input_unenc[] = { 3, 0, 2, 2, 2, 2, 1, 5, 0, + * 6, 6, 6, 1, 3, 0, 2, 2, 2, + * 2, 1, 5, 0, 6, 6, 6, 1, 3, + * 0, 2, 2, 2, 2, 1, 5, 0, 6, + * 6, 6, 1, 4, 2, 2, 2, 2, 2, + * 2, 2, 2, 2, 2, 2, 2, 2, 2, + * 2, 2, 1 }; */ + + int input_unenc[] = { 3, 0, 2, 1, + 5, 0, 6, 1, + 3, 0, 2, 1, + 5, 0, 6, 1, + 3, 0, 2, 1, + 5, 0, 6, 1, + 4, 0, 2, 1 }; + + int input_unenc_len = (int) (sizeof (input_unenc) / + sizeof(input_unenc[0])); + + printf("input length = %d\n", input_unenc_len); + + unsigned char *input = malloc (sizeof(unsigned char) * + input_unenc_len * 8); if (input == NULL) { clean_parser(parser); @@ -67,14 +91,14 @@ main(int argc, char **argv) return EXIT_FAILURE; } - - int input_unenc[10] = { 3, 0, 2, 2, 2, 1, 5, 0, 6, 1 }; - - for (int i = 0; i < 10; i++) + + for (int i = 0; i < input_unenc_len; i++) to_big_endian(input_unenc[i], input + (8 * i)); unsigned char input_len[8] = { 0 }; - input_len[7] = 8*10; + /* input_len[7] = 8*10; */ + + to_big_endian((uint64_t) (8 * input_unenc_len), input_len); struct UnsignedVec input_vec = (struct UnsignedVec) { input_len, NULL, input }; -- cgit v1.2.3-18-g5258