From 4d810fab135089e01d3706287b9c715aa88400f8 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Tue, 11 Jun 2024 18:22:10 -0500 Subject: [PATCH] Bugfix: Enable missing support for grave (backtick) is IKI. The FSS and IKI standards were previously updated to support grave (backtick). The FSS read and write functions were updated but I apparently didn't do the IKI. The grave (backtick) is now supported. --- level_0/f_iki/c/iki.c | 8 ++++---- level_0/f_iki/c/iki/common.c | 1 + level_0/f_iki/c/iki/common.h | 33 ++++++++++++++++-------------- level_0/f_iki/tests/unit/c/test-iki-read.c | 20 ++++++++++++++---- 4 files changed, 39 insertions(+), 23 deletions(-) diff --git a/level_0/f_iki/c/iki.c b/level_0/f_iki/c/iki.c index a39e5f3..3654e9e 100644 --- a/level_0/f_iki/c/iki.c +++ b/level_0/f_iki/c/iki.c @@ -9,7 +9,7 @@ extern "C" { f_status_t f_iki_content_is(const f_string_static_t content, const f_string_static_t quote) { #ifndef _di_level_0_parameter_checking_ if (!quote.used) return F_status_set_error(F_parameter); - if (quote.string[0] != f_iki_syntax_quote_single_s.string[0] && quote.string[0] != f_iki_syntax_quote_double_s.string[0]) return F_status_set_error(F_parameter); + if (quote.string[0] != f_iki_syntax_quote_single_s.string[0] && quote.string[0] != f_iki_syntax_quote_double_s.string[0] && quote.string[0] != f_iki_syntax_quote_backtick_s.string[0]) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!content.used) { @@ -24,7 +24,7 @@ extern "C" { f_status_t f_iki_content_partial_is(const f_string_static_t content, const f_string_range_t range, const f_string_static_t quote) { #ifndef _di_level_0_parameter_checking_ if (!quote.used) return F_status_set_error(F_parameter); - if (quote.string[0] != f_iki_syntax_quote_single_s.string[0] && quote.string[0] != f_iki_syntax_quote_double_s.string[0]) return F_status_set_error(F_parameter); + if (quote.string[0] != f_iki_syntax_quote_single_s.string[0] && quote.string[0] != f_iki_syntax_quote_double_s.string[0] && quote.string[0] != f_iki_syntax_quote_backtick_s.string[0]) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!content.used) { @@ -194,7 +194,7 @@ extern "C" { if (F_status_is_error(status) || range->start > range->stop || range->start >= buffer->used) break; // Found a valid vocabulary name. - if (buffer->string[range->start] == f_iki_syntax_quote_single_s.string[0] || buffer->string[range->start] == f_iki_syntax_quote_double_s.string[0]) { + if (buffer->string[range->start] == f_iki_syntax_quote_single_s.string[0] || buffer->string[range->start] == f_iki_syntax_quote_double_s.string[0] || buffer->string[range->start] == f_iki_syntax_quote_backtick_s.string[0]) { status = F_true; quote = buffer->string[range->start]; } @@ -232,7 +232,7 @@ extern "C" { if (separator_found) { // Save delimit for a would-be valid IKI that is now delimited. - if (buffer->string[range->start] == f_iki_syntax_quote_single_s.string[0] || buffer->string[range->start] == f_iki_syntax_quote_double_s.string[0]) { + if (buffer->string[range->start] == f_iki_syntax_quote_single_s.string[0] || buffer->string[range->start] == f_iki_syntax_quote_double_s.string[0] || buffer->string[range->start] == f_iki_syntax_quote_backtick_s.string[0]) { status = f_array_lengths_increase(state.step_small, &data->delimits); if (F_status_is_error(status)) break; diff --git a/level_0/f_iki/c/iki/common.c b/level_0/f_iki/c/iki/common.c index 5f9daef..6e20bce 100644 --- a/level_0/f_iki/c/iki/common.c +++ b/level_0/f_iki/c/iki/common.c @@ -8,6 +8,7 @@ extern "C" { #ifndef _di_f_iki_syntax_ const f_string_static_t f_iki_syntax_separator_s = macro_f_string_static_t_initialize(F_iki_syntax_separator_s, 0, F_iki_syntax_separator_s_length); const f_string_static_t f_iki_syntax_placeholder_s = macro_f_string_static_t_initialize(F_iki_syntax_placeholder_s, 0, F_iki_syntax_placeholder_s_length); + const f_string_static_t f_iki_syntax_quote_backtick_s = macro_f_string_static_t_initialize(F_iki_syntax_quote_backtick_s, 0, F_iki_syntax_quote_backtick_s_length); const f_string_static_t f_iki_syntax_quote_double_s = macro_f_string_static_t_initialize(F_iki_syntax_quote_double_s, 0, F_iki_syntax_quote_double_s_length); const f_string_static_t f_iki_syntax_quote_single_s = macro_f_string_static_t_initialize(F_iki_syntax_quote_single_s, 0, F_iki_syntax_quote_single_s_length); const f_string_static_t f_iki_syntax_slash_s = macro_f_string_static_t_initialize(F_iki_syntax_slash_s, 0, F_iki_syntax_slash_s_length); diff --git a/level_0/f_iki/c/iki/common.h b/level_0/f_iki/c/iki/common.h index 727440c..891b25a 100644 --- a/level_0/f_iki/c/iki/common.h +++ b/level_0/f_iki/c/iki/common.h @@ -38,24 +38,27 @@ extern "C" { * IKI-specific syntax. */ #ifndef _di_f_iki_syntax_ - #define F_iki_syntax_separator_s ":" - #define F_iki_syntax_placeholder_s "" - #define F_iki_syntax_quote_double_s "\"" - #define F_iki_syntax_quote_single_s "\'" - #define F_iki_syntax_slash_s "\\" - #define F_iki_syntax_wrap_open_s "[" - #define F_iki_syntax_wrap_close_s "]" - - #define F_iki_syntax_separator_s_length 1 - #define F_iki_syntax_placeholder_s_length 1 - #define F_iki_syntax_quote_double_s_length 1 - #define F_iki_syntax_quote_single_s_length 1 - #define F_iki_syntax_slash_s_length 1 - #define F_iki_syntax_wrap_open_s_length 1 - #define F_iki_syntax_wrap_close_s_length 1 + #define F_iki_syntax_separator_s ":" + #define F_iki_syntax_placeholder_s "" + #define F_iki_syntax_quote_backtick_s "`" + #define F_iki_syntax_quote_double_s "\"" + #define F_iki_syntax_quote_single_s "\'" + #define F_iki_syntax_slash_s "\\" + #define F_iki_syntax_wrap_open_s "[" + #define F_iki_syntax_wrap_close_s "]" + + #define F_iki_syntax_separator_s_length 1 + #define F_iki_syntax_placeholder_s_length 1 + #define F_iki_syntax_quote_backtick_s_length 1 + #define F_iki_syntax_quote_double_s_length 1 + #define F_iki_syntax_quote_single_s_length 1 + #define F_iki_syntax_slash_s_length 1 + #define F_iki_syntax_wrap_open_s_length 1 + #define F_iki_syntax_wrap_close_s_length 1 extern const f_string_static_t f_iki_syntax_separator_s; extern const f_string_static_t f_iki_syntax_placeholder_s; + extern const f_string_static_t f_iki_syntax_quote_backtick_s; extern const f_string_static_t f_iki_syntax_quote_double_s; extern const f_string_static_t f_iki_syntax_quote_single_s; extern const f_string_static_t f_iki_syntax_slash_s; diff --git a/level_0/f_iki/tests/unit/c/test-iki-read.c b/level_0/f_iki/tests/unit/c/test-iki-read.c index 5192254..edf9828 100644 --- a/level_0/f_iki/tests/unit/c/test-iki-read.c +++ b/level_0/f_iki/tests/unit/c/test-iki-read.c @@ -110,6 +110,8 @@ void test__f_iki_read__works(void **state) { macro_f_string_static_t_initialize("IKI Content:\"May have spaces\\\" and' quotes.\"", 0, 44), macro_f_string_static_t_initialize("url:'https://localhost/fake-0.6.11.tar.gz?query=xx¶meter=yyy%20' end.", 0, 73), macro_f_string_static_t_initialize("url:\"https://localhost/fake-0.6.11.tar.gz?query=xx¶meter=yyy%20\" end.", 0, 73), + macro_f_string_static_t_initialize("url:`https://localhost/fake-0.6.11.tar.gz?query=xx¶meter=yyy%20` end.", 0, 73), + macro_f_string_static_t_initialize("iki:'\"`' iki:'`\"'", 0, 17), }; const f_array_length_t matches[] = { @@ -135,6 +137,8 @@ void test__f_iki_read__works(void **state) { 1, 1, 1, + 1, + 2, }; const f_status_t statuss[] = { @@ -160,9 +164,11 @@ void test__f_iki_read__works(void **state) { F_none_stop, F_none, F_none, + F_none, + F_none, }; - const f_string_range_t variables[][22] = { + const f_string_range_t variables[][24] = { { f_string_range_t_initialize, f_string_range_t_initialize }, { f_string_range_t_initialize, f_string_range_t_initialize }, { macro_f_string_range_t_initialize(0, 8), f_string_range_t_initialize }, @@ -185,9 +191,11 @@ void test__f_iki_read__works(void **state) { { macro_f_string_range_t_initialize(4, 43), f_string_range_t_initialize }, { macro_f_string_range_t_initialize(0, 67), f_string_range_t_initialize }, { macro_f_string_range_t_initialize(0, 67), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(0, 67), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(0, 7), macro_f_string_range_t_initialize(9, 16) }, }; - const f_string_range_t vocabularys[][22] = { + const f_string_range_t vocabularys[][24] = { { f_string_range_t_initialize, f_string_range_t_initialize }, { f_string_range_t_initialize, f_string_range_t_initialize }, { macro_f_string_range_t_initialize(0, 2), f_string_range_t_initialize }, @@ -210,9 +218,11 @@ void test__f_iki_read__works(void **state) { { macro_f_string_range_t_initialize(4, 10), f_string_range_t_initialize }, { macro_f_string_range_t_initialize(0, 2), f_string_range_t_initialize }, { macro_f_string_range_t_initialize(0, 2), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(0, 2), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(0, 2), macro_f_string_range_t_initialize(9, 11) }, }; - const f_string_range_t contents[][22] = { + const f_string_range_t contents[][24] = { { f_string_range_t_initialize, f_string_range_t_initialize }, { f_string_range_t_initialize, f_string_range_t_initialize }, { macro_f_string_range_t_initialize(5, 7), f_string_range_t_initialize }, @@ -235,9 +245,11 @@ void test__f_iki_read__works(void **state) { { macro_f_string_range_t_initialize(13, 42), f_string_range_t_initialize }, { macro_f_string_range_t_initialize(5, 66), f_string_range_t_initialize }, { macro_f_string_range_t_initialize(5, 66), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(5, 66), f_string_range_t_initialize }, + { macro_f_string_range_t_initialize(5, 6), macro_f_string_range_t_initialize(14, 15) }, }; - for (uint8_t i = 0; i < 22; ++i) { + for (uint8_t i = 0; i < 24; ++i) { f_string_range_t range = macro_f_string_range_t_initialize2(buffers[i].used); f_iki_data_t iki = f_iki_data_t_initialize; -- 1.8.3.1