From: Kevin Day Date: Mon, 22 Jun 2020 02:58:21 +0000 (-0500) Subject: Update: add missing dependencies, changes to iki X-Git-Tag: 0.5.0~141 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=b7d0463052ee842c93d680ac0d2cf705fa6a72a3;p=fll Update: add missing dependencies, changes to iki In a previous commit I seem to have forgotten to include the build settings changes. Fix some minor mistakes in iki. In particular, I forgot to increment the range->start after identifying where content would begin (which prevented it from working at all). Add f_iki_variable to store the range for the entire variable. This will allow for easy removal when substituting (which is one of the design intentions, so I need to cover this use case!). --- diff --git a/build/level_1/settings b/build/level_1/settings index 99caa30..82170e8 100644 --- a/build/level_1/settings +++ b/build/level_1/settings @@ -20,9 +20,9 @@ build_language c build_linker ar build_libraries -lc build_libraries-level -lfll_0 -build_sources_library color.c console.c directory.c private-directory.c fss.c private-fss.c fss_basic.c fss_basic_list.c fss_extended.c fss_extended_list.c print.c status.c string.c private-string.c utf.c private-utf.c utf_file.c private-utf_file.c +build_sources_library color.c console.c directory.c private-directory.c fss.c private-fss.c fss_basic.c fss_basic_list.c fss_extended.c fss_extended_list.c iki.c print.c status.c string.c private-string.c utf.c private-utf.c utf_file.c private-utf_file.c build_sources_program -build_sources_headers color.h console.h directory.h fss.h fss_basic.h fss_basic_list.h fss_extended.h fss_extended_list.h fss_macro.h fss_status.h print.h status.h string.h utf.h utf_file.h +build_sources_headers color.h console.h directory.h fss.h fss_basic.h fss_basic_list.h fss_extended.h fss_extended_list.h fss_macro.h fss_status.h iki.h print.h status.h string.h utf.h utf_file.h build_sources_script build_sources_setting build_script yes diff --git a/build/monolithic/settings b/build/monolithic/settings index 341ff3c..8edfee6 100644 --- a/build/monolithic/settings +++ b/build/monolithic/settings @@ -20,9 +20,9 @@ build_language c build_linker ar build_libraries -lc build_libraries-monolithic -build_sources_library level_0/console.c level_0/conversion.c level_0/directory.c level_0/private-directory.c level_0/environment.c level_0/private-environment.c level_0/file.c level_0/private-file.c level_0/fss.c level_0/iki.c level_0/memory.c level_0/path.c level_0/pipe.c level_0/print.c level_0/serialize.c level_0/private-serialize.c level_0/socket.c level_0/utf.c level_0/private-utf.c level_1/color.c level_1/console.c level_1/directory.c level_1/private-directory.c level_1/fss.c level_1/private-fss.c level_1/fss_basic.c level_1/fss_basic_list.c level_1/fss_extended.c level_1/fss_extended_list.c level_1/print.c level_1/status.c level_1/string.c level_1/private-string.c level_1/utf.c level_1/private-utf.c level_1/utf_file.c level_1/private-utf_file.c level_2/execute.c level_2/private-execute.c level_2/file.c level_2/fss.c level_2/fss_basic.c level_2/fss_basic_list.c level_2/fss_extended.c level_2/fss_extended_list.c level_2/fss_status.c level_2/program.c level_2/status.c +build_sources_library level_0/console.c level_0/conversion.c level_0/directory.c level_0/private-directory.c level_0/environment.c level_0/private-environment.c level_0/file.c level_0/private-file.c level_0/fss.c level_0/iki.c level_0/memory.c level_0/path.c level_0/pipe.c level_0/print.c level_0/serialize.c level_0/private-serialize.c level_0/socket.c level_0/utf.c level_0/private-utf.c level_1/color.c level_1/console.c level_1/directory.c level_1/private-directory.c level_1/fss.c level_1/private-fss.c level_1/fss_basic.c level_1/fss_basic_list.c level_1/fss_extended.c level_1/fss_extended_list.c level_1/print.c level_1/iki.c level_1/status.c level_1/string.c level_1/private-string.c level_1/utf.c level_1/private-utf.c level_1/utf_file.c level_1/private-utf_file.c level_2/execute.c level_2/private-execute.c level_2/file.c level_2/fss.c level_2/fss_basic.c level_2/fss_basic_list.c level_2/fss_extended.c level_2/fss_extended_list.c level_2/fss_status.c level_2/program.c level_2/status.c build_sources_program -build_sources_headers level_0/color.h level_0/console.h level_0/conversion.h level_0/directory.h level_0/directory_type.h level_0/environment.h level_0/file.h level_0/fss.h level_0/fss-common.h level_0/fss-named.h level_0/fss-nest.h level_0/fss-set.h level_0/iki.h level_0/iki-common.h level_0/iki-common.h level_0/memory.h level_0/memory-structure.h level_0/path.h level_0/pipe.h level_0/print.h level_0/serialize.h level_0/socket.h level_0/status.h level_0/status_array.h level_0/string.h level_0/string-common.h level_0/string-dynamic.h level_0/string-map.h level_0/string-quantity.h level_0/string-range.h level_0/type.h level_0/type_array.h level_0/utf.h level_0/utf-common.h level_1/color.h level_1/console.h level_1/directory.h level_1/fss.h level_1/fss_basic.h level_1/fss_basic_list.h level_1/fss_extended.h level_1/fss_extended_list.h level_1/fss_macro.h level_1/fss_status.h level_1/print.h level_1/status.h level_1/string.h level_1/utf.h level_1/utf_file.h level_2/execute.h level_2/file.h level_2/fss.h level_2/fss_basic.h level_2/fss_basic_list.h level_2/fss_extended.h level_2/fss_extended_list.h level_2/fss_status.h level_2/program.h level_2/status.h +build_sources_headers level_0/color.h level_0/console.h level_0/conversion.h level_0/directory.h level_0/directory_type.h level_0/environment.h level_0/file.h level_0/fss.h level_0/fss-common.h level_0/fss-named.h level_0/fss-nest.h level_0/fss-set.h level_0/iki.h level_0/iki-common.h level_0/iki-common.h level_0/memory.h level_0/memory-structure.h level_0/path.h level_0/pipe.h level_0/print.h level_0/serialize.h level_0/socket.h level_0/status.h level_0/status_array.h level_0/string.h level_0/string-common.h level_0/string-dynamic.h level_0/string-map.h level_0/string-quantity.h level_0/string-range.h level_0/type.h level_0/type_array.h level_0/utf.h level_0/utf-common.h level_1/color.h level_1/console.h level_1/directory.h level_1/fss.h level_1/fss_basic.h level_1/fss_basic_list.h level_1/fss_extended.h level_1/fss_extended_list.h level_1/fss_macro.h level_1/fss_status.h level_1/print.h level_1/iki.h level_1/status.h level_1/string.h level_1/utf.h level_1/utf_file.h level_2/execute.h level_2/file.h level_2/fss.h level_2/fss_basic.h level_2/fss_basic_list.h level_2/fss_extended.h level_2/fss_extended_list.h level_2/fss_status.h level_2/program.h level_2/status.h build_sources_script build_sources_setting build_script yes diff --git a/level_0/f_iki/c/iki-common.h b/level_0/f_iki/c/iki-common.h index 7d970ef..67000ff 100644 --- a/level_0/f_iki/c/iki-common.h +++ b/level_0/f_iki/c/iki-common.h @@ -54,6 +54,32 @@ extern "C" { #endif // _di_iki_vocabulary_0001_ /** + * This holds an array of string ranges that represent the entire vocabulary name, content, and syntax. + * + * array: The array of variable. + * size: Total amount of allocated space. + * used: Total number of allocated spaces used. + */ +#ifndef _di_iki_variable_ + typedef f_string_ranges f_iki_variable; + + #define f_iki_variable_initialize f_string_ranges_initialize + + #define f_macro_iki_variable_clear(variable) f_macro_string_ranges_clear(variable) + + #define f_macro_iki_variable_new(status, variable, length) f_macro_string_ranges_new(status, variable, length) + + #define f_macro_iki_variable_delete(status, variable) f_macro_string_ranges_delete(status, variable) + #define f_macro_iki_variable_destroy(status, variable) f_macro_string_ranges_destroy(status, variable) + + #define f_macro_iki_variable_delete_simple(variable) f_macro_string_ranges_delete_simple(variable) + #define f_macro_iki_variable_destroy_simple(variable) f_macro_string_ranges_destroy_simple(variable) + + #define f_macro_iki_variable_resize(status, variable, new_length) f_macro_string_ranges_resize(status, variable, new_length) + #define f_macro_iki_variable_adjust(status, variable, new_length) f_macro_string_ranges_destroy(status, variable, new_length) +#endif // _di_iki_variable_ + +/** * This holds an array of string ranges that represent the vocabulary names. * * array: The array of vocabulary names. diff --git a/level_0/f_iki/c/iki.c b/level_0/f_iki/c/iki.c index 318437d..0c5c766 100644 --- a/level_0/f_iki/c/iki.c +++ b/level_0/f_iki/c/iki.c @@ -5,16 +5,17 @@ extern "C" { #endif #ifndef _di_f_iki_read_ - f_return_status f_iki_read(f_string_static *buffer, f_string_range *range, f_iki_vocabulary *vocabulary, f_iki_content *content) { - #ifndef _di_level_1_parameter_checking_ + f_return_status f_iki_read(f_string_static *buffer, f_string_range *range, f_iki_variable *variable, f_iki_vocabulary *vocabulary, f_iki_content *content) { + #ifndef _di_level_0_parameter_checking_ if (buffer == 0) return F_status_set_error(F_parameter); if (range == 0) return F_status_set_error(F_parameter); + if (variable == 0) return F_status_set_error(F_parameter); if (vocabulary == 0) return F_status_set_error(F_parameter); if (content == 0) return F_status_set_error(F_parameter); if (buffer->used == 0) return F_status_set_error(F_parameter); if (range->start > range->stop) return F_status_set_error(F_parameter); if (range->start >= buffer->used) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ + #endif // _di_level_0_parameter_checking_ f_status status = F_none; @@ -92,6 +93,7 @@ extern "C" { // found a valid vocabulary name. if (buffer->string[range->start] == f_iki_syntax_quote_single || buffer->string[range->start] == f_iki_syntax_quote_double) { quote = buffer->string[range->start]; + range->start++; break; } @@ -241,18 +243,25 @@ extern "C" { found_vocabulary.start = range->start; } else { - f_macro_iki_allocate_ranges_if_necessary(status, (*vocabulary)); - if (F_status_is_error(status)) { - f_macro_string_lengths_delete(status, delimits); - return status; + f_macro_iki_allocate_ranges_if_necessary(status, (*variable)); + + if (F_status_is_fine(status)) { + f_macro_iki_allocate_ranges_if_necessary(status, (*vocabulary)); + } + + if (F_status_is_fine(status)) { + f_macro_iki_allocate_ranges_if_necessary(status, (*content)); } - f_macro_iki_allocate_ranges_if_necessary(status, (*content)); if (F_status_is_error(status)) { f_macro_string_lengths_delete(status, delimits); return status; } + variable->array[variable->used].start = found_vocabulary.start; + variable->array[variable->used].stop = range->start; + variable->used++; + vocabulary->array[vocabulary->used].start = found_vocabulary.start; vocabulary->array[vocabulary->used].stop = found_vocabulary.stop; vocabulary->used++; diff --git a/level_0/f_iki/c/iki.h b/level_0/f_iki/c/iki.h index 945b22b..2182816 100644 --- a/level_0/f_iki/c/iki.h +++ b/level_0/f_iki/c/iki.h @@ -37,6 +37,11 @@ extern "C" { * This does not verify if the vocabulary name is known. * This only finds a complete vocabulary name and content. * + * This will increment the range after the end of any valud vocabulary and content set. + * + * This will update the buffer at the given range with any placeholders to escaped data. + * Calling this more than once on the same buffer range could result in multiple escaping. + * * @param buffer * The string to process. * @param range @@ -44,6 +49,8 @@ extern "C" { * The start location will be updated as the buffer is being processed. * The start location will represent where the read stopped on return. * A start location past the stop location or buffer used means that the entire range was processed. + * @param variable + * The entire vocabulary name, content, and syntax. * @param vocabulary * The vocabulary name list to store the found vocabulary name. * @param content @@ -51,8 +58,8 @@ extern "C" { * * @return * F_none on success and an IKI vocabulary name was found. - * F_none_stop on success and an IKI vocabulary name was found and stop point was reached. * F_none_eos on success and an IKI vocabulary name was found and end of string was reached. + * F_none_stop on success and an IKI vocabulary name was found and stop point was reached. * F_data_not_eos on success and EOS was reached, but there were no IKI vocabularie names found. * F_data_not_stop on success and stop point was reached, but there were no IKI vocabularie names found. * F_memory_reallocation (with error bit) on memory reallocation error. @@ -60,7 +67,7 @@ extern "C" { * F_string_too_large (with error bit) if a string length is too large to store in the buffer. */ #ifndef _di_f_iki_read_ - extern f_return_status f_iki_read(f_string_static *buffer, f_string_range *range, f_iki_vocabulary *vocabulary, f_iki_content *content); + extern f_return_status f_iki_read(f_string_static *buffer, f_string_range *range, f_iki_variable *variable, f_iki_vocabulary *vocabulary, f_iki_content *content); #endif // _di_f_iki_read_ #ifdef __cplusplus