From 6bec387419693d24a8cc86c9f1b4181e95c4d7f0 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Tue, 24 Jan 2023 20:25:38 -0600 Subject: [PATCH] Bugfix: Further Fakefile processing with iki replacement space problems. This is a follow up to commit 3713a5f0bd90d32f564afaca29f01d9ccf329cfb. The other IKI variables still need the new lines when the context does not. Detect when certain IKI variables expand into nothing and in these cases do not append. When performing last line, only append if it is not by itself. --- level_3/fake/c/main/private-make-operate.c | 30 +++++++++++++++++++++++++++--- level_3/fake/c/main/private-make-operate.h | 2 ++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/level_3/fake/c/main/private-make-operate.c b/level_3/fake/c/main/private-make-operate.c index cb74472..7e8b73a 100644 --- a/level_3/fake/c/main/private-make-operate.c +++ b/level_3/fake/c/main/private-make-operate.c @@ -285,6 +285,9 @@ extern "C" { // 1 = is parameter, 2 = is define, 3 = is context. uint8_t is = 0; + // 0x1 = has parameter, 0x2 = has define, 0x4 = has context, 0x8 = non-context data appended. + uint8_t iki_type = 0; + bool unmatched = F_true; bool separate = F_false; @@ -424,6 +427,8 @@ extern "C" { } } + iki_type = 0; + for (j = 0; j < iki_data->variable.used; ++j) { is = 0; @@ -432,18 +437,21 @@ extern "C" { if (*status == F_equal_to) { is = 2; + iki_type |= 0x2; } else if (*status == F_equal_to_not) { *status = fl_string_dynamic_partial_compare_string(vocabulary_parameter.string, data_make->buffer, vocabulary_parameter.used, iki_data->vocabulary.array[j]); if (*status == F_equal_to) { is = 1; + iki_type |= 0x1; } else if (*status == F_equal_to_not) { *status = fl_string_dynamic_partial_compare_string(vocabulary_context.string, data_make->buffer, vocabulary_context.used, iki_data->vocabulary.array[j]); if (*status == F_equal_to) { is = 3; + iki_type |= 0x4; } } } @@ -605,6 +613,8 @@ extern "C" { if (!reserved_value[k]->array[l].used) continue; + iki_type |= 0x8; + // Unquoted use separate parameters rather then being separated by a space. if (separate) { ++data_make->cache_arguments.used; @@ -726,6 +736,10 @@ extern "C" { break; } + + if (*status == F_true) { + iki_type |= 0x8; + } } } else if (is == 2) { @@ -736,6 +750,10 @@ extern "C" { break; } + + if (*status == F_true) { + iki_type |= 0x8; + } } else if (is == 3) { *status = fake_make_operate_expand_context(data_make, quotes.array[i], iki_data->content.array[j]); @@ -745,6 +763,8 @@ extern "C" { break; } + + // Context is intended to merge with existing lines and so 0x8 bit is not subtracted. } // Make sure to copy content between multiple IKI variables within the same content. @@ -780,7 +800,7 @@ extern "C" { } } - if (!(content.array[i].start == iki_data->variable.array[0].start && content.array[i].stop == iki_data->variable.array[0].stop && !quotes.array[i]) || i + 1 == content.used) { + if (!(content.array[i].start == iki_data->variable.array[0].start && content.array[i].stop == iki_data->variable.array[0].stop && !quotes.array[i]) || (iki_type & 0xb) && !quotes.array[i] || i && content.used > 1 && i + 1 == content.used) { ++data_make->cache_arguments.used; *status = f_string_dynamics_increase(fake_default_allocation_small_d, &data_make->cache_arguments); @@ -1116,7 +1136,9 @@ extern "C" { if (F_status_is_error(status)) return status; - return F_true; + if (value.used) return F_true; + + return F_data_not; } #endif // _di_fake_make_operate_expand_build_ @@ -1215,7 +1237,9 @@ extern "C" { ++data_make->cache_arguments.used; } - return F_true; + if (data_make->cache_2.used) return F_true; + + return F_data_not; } #endif // _di_fake_make_operate_expand_environment_ diff --git a/level_3/fake/c/main/private-make-operate.h b/level_3/fake/c/main/private-make-operate.h index 177c038..ca0ca5c 100644 --- a/level_3/fake/c/main/private-make-operate.h +++ b/level_3/fake/c/main/private-make-operate.h @@ -88,6 +88,7 @@ extern "C" { * The range representing the variable content name string within the data_make->buffer. * * @return + * F_data_not on success, but nothing is added (data length to append is 0). * F_true on success and match expanded. * F_false on no matches to expand. * @@ -116,6 +117,7 @@ extern "C" { * The range representing the variable content name string within the data_make->buffer. * * @return + * F_data_not on success, but nothing is added (data length to append is 0). * F_true on success and match expanded. * F_false on no matches to expand. * -- 1.8.3.1