summaryrefslogtreecommitdiff
path: root/src/tuple.c
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2022-02-08 00:29:10 +0800
committerJSDurand <mmemmew@gmail.com>2022-02-08 12:33:05 +0800
commit5426d9e2a6b820e34809d639838b26643df9ab17 (patch)
tree111f2b478b671092e3f2e64a6171970b8a5cdf99 /src/tuple.c
parentaaa12504c6095b2cdfa213a3d4b269bbd5e7038a (diff)
fix errorsHEADmaster
There are multiple subtle errors in the previous version, both in the codes and in the description of the BNF format. This version should fix some problems now. This version can successfully parse the grammar of its own grammar format, which is quite nice. See test/check_reader.c for parsing this format.
Diffstat (limited to 'src/tuple.c')
-rw-r--r--src/tuple.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/tuple.c b/src/tuple.c
index 92f2e6a..190aa19 100644
--- a/src/tuple.c
+++ b/src/tuple.c
@@ -185,7 +185,9 @@ LONSTRUCT(6);
static void
destroy_tuple1(tuple1 tup, NUM * UNUSED len) {
+ /* fleprintf0("hi\n"); */
if (!(tup.initialized)) return;
+ /* fleprintf0("hi\n"); */
free(tup.array);
}
@@ -196,8 +198,11 @@ void
destroy_tuple4(tuple4 tup, NUM *len)
{
if (!(tup.initialized)) return;
- for (NUM i4 = 0; i4 < *len; i4++)
+ /* fleprintf("len = %ld\n", *len); */
+ for (NUM i4 = 0; i4 < *len; i4++) {
+ /* fleprintf("i4 = %ld\n", i4); */
destroy_tuple3(*(tup.array+i4), len+1);
+ }
free(tup.array);
}
@@ -296,7 +301,7 @@ add_to_tuple_6_pt_2(tuple6 *tup, NUM *len, pair2 label)
if (!(((tup->array+label.x)->array+label.y)->initialized)) {
SAFE_CALLOC(tuple3,
((tup->array+label.x)->array+label.y)->array,
- *(len+1), goto cleanup;);
+ *(len+2), goto cleanup;);
((tup->array+label.x)->array+label.y)->initialized = 1;
}
@@ -610,6 +615,7 @@ luple5_free_1(luple5 *lup, NUM label)
if (!((tuple->array+label)->initialized)) return;
destroy_tuple4(*(tuple->array+label), lup->lengths+1);
+ /* fleprintf("label = %ld\n", label); */
(tuple->array+label)->initialized = 0;
}