From 99680bdca6e194971f4e40336d833486fa2693d1 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sun, 6 Feb 2022 11:13:06 -0600 Subject: [PATCH] Progress: Continue mass converting to f_string_static_t. I've noticed several things that need cleaning and improvement, such as: - I should make an f_string_dynamic_partial_rip() and have f_string_dynamic_rip() be consistent with other functions lie f_string_dynamic_append(). - iki_read is a bit sloppy in memory, I need to figure out why (and I imagine other are too). - I've started clearing out old uses of object and content but I am concerned that I overdid the cleanup (I need to re-check some of this in the FSS programs). There will most definitely need to be another cleanup pass on all of the programs focusing on cleaning up and improving the programs before I make my stable releases. For now, I am ignoring those problems so I can better focus on f_string_static_t conversions. Once the programs are updated with the current set of f_string_static_t, I still need to go through all of the remaining level_2 and lower functions to convert many of the functions still using f_string_t that should now be f_string_static_t. --- level_0/f_file/c/file.c | 2 - level_0/f_iki/c/iki.c | 5 -- level_0/f_string/c/string_range.h | 3 +- level_1/fl_utf_file/c/utf_file.c | 4 - level_2/fll_iki/c/iki.c | 4 - level_2/fll_program/c/program.c | 86 ++++++++-------------- level_2/fll_program/c/program.h | 24 +++--- level_3/controller/c/entry/private-entry.c | 2 +- level_3/fake/c/fake.h | 2 +- level_3/fake/c/private-fake.c | 23 +++--- .../fss_basic_list_read/c/fss_basic_list_read.c | 42 +++++------ level_3/fss_basic_list_read/c/private-read.c | 27 +++---- .../fss_basic_list_write/c/fss_basic_list_write.c | 58 +++------------ level_3/fss_basic_read/c/fss_basic_read.c | 35 ++++----- level_3/fss_basic_read/c/private-read.c | 24 +++--- level_3/fss_basic_write/c/fss_basic_write.c | 55 +++----------- .../c/fss_embedded_list_read.c | 35 ++++----- level_3/fss_embedded_list_read/c/private-read.c | 26 +++---- .../c/fss_embedded_list_write.c | 50 +++---------- level_3/fss_embedded_list_write/c/private-write.c | 18 ++--- .../c/fss_extended_list_read.c | 34 ++++----- level_3/fss_extended_list_read/c/private-read.c | 24 +++--- .../c/fss_extended_list_write.c | 47 ++---------- level_3/fss_extended_list_write/c/private-write.c | 16 ++-- level_3/fss_extended_read/c/fss_extended_read.c | 30 ++++---- level_3/fss_extended_write/c/fss_extended_write.c | 22 +++--- level_3/fss_identify/c/private-print.c | 2 +- level_3/fss_status_code/c/common.c | 9 +++ level_3/fss_status_code/c/common.h | 40 +++++----- level_3/fss_status_code/c/fss_status_code.c | 29 ++++---- .../fss_status_code/c/private-fss_status_code.c | 35 +++++---- .../fss_status_code/c/private-fss_status_code.h | 8 +- level_3/iki_read/c/common.c | 14 ++++ level_3/iki_read/c/common.h | 22 ++++-- level_3/iki_read/c/iki_read.c | 52 +++++++------ level_3/iki_read/c/private-print.c | 11 +-- level_3/iki_read/c/private-read.c | 82 ++++++++++----------- level_3/iki_read/c/private-read.h | 34 ++------- level_3/iki_write/c/common.h | 6 +- level_3/iki_write/c/iki_write.c | 26 ++----- level_3/iki_write/c/private-write.c | 2 - level_3/status_code/c/common.h | 10 +-- level_3/status_code/c/private-status_code.c | 43 +++++------ level_3/status_code/c/private-status_code.h | 8 +- level_3/status_code/c/status_code.c | 19 +++-- 45 files changed, 482 insertions(+), 668 deletions(-) diff --git a/level_0/f_file/c/file.c b/level_0/f_file/c/file.c index b774612..c696416 100644 --- a/level_0/f_file/c/file.c +++ b/level_0/f_file/c/file.c @@ -2233,7 +2233,6 @@ extern "C" { f_status_t f_file_stream_write(const f_file_t file, const f_string_static_t buffer, f_array_length_t *written) { #ifndef _di_level_0_parameter_checking_ if (!file.size_write) return F_status_set_error(F_parameter); - if (buffer.used > buffer.size) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!file.stream) { @@ -2279,7 +2278,6 @@ extern "C" { f_status_t f_file_stream_write_block(const f_file_t file, const f_string_static_t buffer, f_array_length_t *written) { #ifndef _di_level_0_parameter_checking_ if (!file.size_write) return F_status_set_error(F_parameter); - if (buffer.used > buffer.size) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (!file.stream) { diff --git a/level_0/f_iki/c/iki.c b/level_0/f_iki/c/iki.c index 81d00cb..1a44373 100644 --- a/level_0/f_iki/c/iki.c +++ b/level_0/f_iki/c/iki.c @@ -21,7 +21,6 @@ extern "C" { #ifndef _di_f_iki_content_partial_is_ 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 (content.used > content.size) return F_status_set_error(F_parameter); if (range.start > range.stop) return F_status_set_error(F_parameter); if (range.start >= content.used) return F_status_set_error(F_parameter); if (!quote.used) return F_status_set_error(F_parameter); @@ -34,9 +33,6 @@ extern "C" { #ifndef _di_f_iki_object_is_ f_status_t f_iki_object_is(const f_string_static_t object) { - #ifndef _di_level_0_parameter_checking_ - if (object.used > object.size) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ const f_string_range_t range = macro_f_string_range_t_initialize(object.used); @@ -47,7 +43,6 @@ extern "C" { #ifndef _di_f_iki_object_partial_is_ f_status_t f_iki_object_partial_is(const f_string_static_t object, const f_string_range_t range) { #ifndef _di_level_0_parameter_checking_ - if (object.used > object.size) return F_status_set_error(F_parameter); if (range.start > range.stop) return F_status_set_error(F_parameter); if (range.start >= object.used) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ diff --git a/level_0/f_string/c/string_range.h b/level_0/f_string/c/string_range.h index 866c9c7..dddae56 100644 --- a/level_0/f_string/c/string_range.h +++ b/level_0/f_string/c/string_range.h @@ -23,8 +23,6 @@ extern "C" { * Therefore, a range from 0 to 0 would be include position 0. * Set start to some value larger than stop to designate that there is no range (such as start = 1, stop = 0). * - * A special macro_f_string_range_t_initialize() is provided for the special purpose of easily initialize a static string range. - * * start: the start position. * stop: the stop position. */ @@ -37,6 +35,7 @@ extern "C" { #define f_string_range_t_initialize { 1, 0 } #define macro_f_string_range_t_initialize(length) { length ? 0 : 1, length ? length - 1 : 0 } + #define macro_f_string_range_t_initialize2(start, stop) { start, stop } #define macro_f_string_range_t_clear(range) \ range.start = 1; \ diff --git a/level_1/fl_utf_file/c/utf_file.c b/level_1/fl_utf_file/c/utf_file.c index d15f40f..40c2ab7 100644 --- a/level_1/fl_utf_file/c/utf_file.c +++ b/level_1/fl_utf_file/c/utf_file.c @@ -205,7 +205,6 @@ extern "C" { f_status_t fl_utf_file_write(const f_file_t file, const f_utf_string_static_t buffer, f_array_length_t *written) { #ifndef _di_level_0_parameter_checking_ if (!file.size_write) return F_status_set_error(F_parameter); - if (buffer.used > buffer.size) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (file.id < 0) { @@ -237,7 +236,6 @@ extern "C" { f_status_t fl_utf_file_write_block(const f_file_t file, const f_utf_string_static_t buffer, f_array_length_t *written) { #ifndef _di_level_0_parameter_checking_ if (!file.size_write) return F_status_set_error(F_parameter); - if (buffer.used > buffer.size) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (file.id < 0) { @@ -275,7 +273,6 @@ extern "C" { f_status_t fl_utf_file_write_until(const f_file_t file, const f_utf_string_static_t buffer, const f_array_length_t total, f_array_length_t *written) { #ifndef _di_level_0_parameter_checking_ if (!file.size_write) return F_status_set_error(F_parameter); - if (buffer.used > buffer.size) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ if (file.id < 0) { @@ -313,7 +310,6 @@ extern "C" { f_status_t fl_utf_file_write_range(const f_file_t file, const f_utf_string_static_t buffer, const f_string_range_t range, f_array_length_t *written) { #ifndef _di_level_0_parameter_checking_ if (!file.size_write) return F_status_set_error(F_parameter); - if (buffer.used > buffer.size) return F_status_set_error(F_parameter); if (range.stop < range.start) return F_status_set_error(F_parameter); if (range.start >= buffer.used) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ diff --git a/level_2/fll_iki/c/iki.c b/level_2/fll_iki/c/iki.c index 00ed119..2af1dc2 100644 --- a/level_2/fll_iki/c/iki.c +++ b/level_2/fll_iki/c/iki.c @@ -8,7 +8,6 @@ extern "C" { #ifndef _di_fll_iki_content_escape_ f_status_t fll_iki_content_escape(const f_string_static_t content, const f_string_static_t quote, f_string_dynamic_t *escaped) { #ifndef _di_level_2_parameter_checking_ - if (content.used > content.size) return F_status_set_error(F_parameter); 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 (escaped->used > escaped->size) return F_status_set_error(F_parameter); @@ -23,7 +22,6 @@ extern "C" { #ifndef _di_fll_iki_content_partial_escape_ f_status_t fll_iki_content_partial_escape(const f_string_static_t content, const f_string_range_t range, const f_string_static_t quote, f_string_dynamic_t *escaped) { #ifndef _di_level_2_parameter_checking_ - if (content.used > content.size) return F_status_set_error(F_parameter); if (range.start > range.stop) return F_status_set_error(F_parameter); if (range.start >= content.used) return F_status_set_error(F_parameter); if (!quote.used) return F_status_set_error(F_parameter); @@ -38,7 +36,6 @@ extern "C" { #ifndef _di_fll_iki_content_partial_unescape_ f_status_t fll_iki_content_partial_unescape(const f_string_static_t content, const f_string_range_t range, const f_string_static_t quote, f_string_dynamic_t *unescaped) { #ifndef _di_level_2_parameter_checking_ - if (content.used > content.size) return F_status_set_error(F_parameter); if (range.start > range.stop) return F_status_set_error(F_parameter); if (range.start >= content.used) return F_status_set_error(F_parameter); if (!quote.used) return F_status_set_error(F_parameter); @@ -53,7 +50,6 @@ extern "C" { #ifndef _di_fll_iki_content_unescape_ f_status_t fll_iki_content_unescape(const f_string_static_t content, const f_string_static_t quote, f_string_dynamic_t *unescaped) { #ifndef _di_level_2_parameter_checking_ - if (content.used > content.size) return F_status_set_error(F_parameter); 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 (unescaped->used > unescaped->size) return F_status_set_error(F_parameter); diff --git a/level_2/fll_program/c/program.c b/level_2/fll_program/c/program.c index bd5fc68..f2b89ec 100644 --- a/level_2/fll_program/c/program.c +++ b/level_2/fll_program/c/program.c @@ -127,35 +127,32 @@ extern "C" { #endif // _di_fll_program_parameter_process_empty_ #ifndef _di_fll_program_parameter_additional_append_ - f_status_t fll_program_parameter_additional_append(const f_string_t *argv, const f_array_lengths_t values, f_string_dynamics_t *destination) { + f_status_t fll_program_parameter_additional_append(const f_string_static_t *arguments, const f_array_lengths_t values, f_string_dynamics_t *destination) { #ifndef _di_level_2_parameter_checking_ - if (!argv) return F_status_set_error(F_parameter); + if (!arguments) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_2_parameter_checking_ f_status_t status = F_none; - f_array_length_t length = 0; const f_array_length_t start = destination->used; for (f_array_length_t i = 0; i < values.used; ++i) { - length = strnlen(argv[values.array[i]], F_console_parameter_size_d); + if (arguments[values.array[i]].used) { + status = f_string_dynamics_increase(F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) break; - if (length > 0) { - f_string_dynamic_t ripped = f_string_dynamic_t_initialize; + destination->array[destination->used].used = 0; - status = f_string_append(argv[values.array[i]], length, &ripped); - if (F_status_is_error(status)) return status; + status = f_string_dynamic_append(arguments[values.array[i]], &destination->array[destination->used]); + if (F_status_is_error(status)) break; if (status == F_data_not) { status = F_none; } else { - macro_f_memory_structure_increment(status, (*destination), 1, F_memory_default_allocation_small_d, macro_f_string_dynamics_t_resize, F_array_too_large); - if (F_status_is_error(status)) break; - - destination->array[destination->used++] = ripped; + ++destination->used; } } } // for @@ -169,24 +166,21 @@ extern "C" { #endif // _di_fll_program_parameter_additional_append_ #ifndef _di_fll_program_parameter_additional_mash_ - f_status_t fll_program_parameter_additional_mash(const f_string_static_t glue, const f_string_t *argv, const f_array_lengths_t values, f_string_dynamic_t *destination) { + f_status_t fll_program_parameter_additional_mash(const f_string_static_t glue, const f_string_static_t *arguments, const f_array_lengths_t values, f_string_dynamic_t *destination) { #ifndef _di_level_2_parameter_checking_ - if (!argv) return F_status_set_error(F_parameter); + if (!arguments) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_2_parameter_checking_ f_status_t status = F_none; - f_array_length_t length = 0; const f_array_length_t start = destination->used; for (f_array_length_t i = 0; i < values.used; ++i) { - length = strnlen(argv[values.array[i]], F_console_parameter_size_d); - - if (length > 0) { - status = f_string_mash(glue.string, glue.used, argv[values.array[i]], length, destination); - if (F_status_is_error(status)) return F_status_set_error(F_string_too_large); + if (arguments[values.array[i]].used) { + status = f_string_dynamic_mash(glue, arguments[values.array[i]], destination); + if (F_status_is_error(status)) break; } } // for @@ -199,34 +193,31 @@ extern "C" { #endif // _di_fll_program_parameter_additional_mash_ #ifndef _di_fll_program_parameter_additional_rip_ - f_status_t fll_program_parameter_additional_rip(const f_string_t *argv, const f_array_lengths_t values, f_string_dynamics_t *destination) { + f_status_t fll_program_parameter_additional_rip(const f_string_static_t *arguments, const f_array_lengths_t values, f_string_dynamics_t *destination) { #ifndef _di_level_2_parameter_checking_ - if (!argv) return F_status_set_error(F_parameter); + if (!arguments) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_2_parameter_checking_ f_status_t status = F_none; - f_array_length_t length = 0; const f_array_length_t start = destination->used; for (f_array_length_t i = 0; i < values.used; ++i) { - length = strnlen(argv[values.array[i]], F_console_parameter_size_d); + if (arguments[values.array[i]].used) { + status = f_string_dynamics_increase(F_memory_default_allocation_small_d, destination); + if (F_status_is_error(status)) break; - if (length) { - f_string_dynamic_t ripped = f_string_dynamic_t_initialize; + destination->array[destination->used].used = 0; - status = fl_string_rip(argv[values.array[i]], length, &ripped); - if (F_status_is_error(status)) return status; + status = fl_string_rip(arguments[values.array[i]].string, arguments[values.array[i]].used, &destination->array[destination->used]); + if (F_status_is_error(status)) break; if (status == F_data_not) { status = F_none; } else { - macro_f_string_dynamics_t_increase(status, F_memory_default_allocation_small_d, (*destination)); - if (F_status_is_error(status)) return status; - - destination->array[destination->used++] = ripped; + ++destination->used; } } } // for @@ -240,46 +231,33 @@ extern "C" { #endif // _di_fll_program_parameter_additional_rip_ #ifndef _di_fll_program_parameter_additional_rip_mash_ - f_status_t fll_program_parameter_additional_rip_mash(const f_string_static_t glue, const f_string_t *argv, const f_array_lengths_t values, f_string_dynamic_t *destination) { + f_status_t fll_program_parameter_additional_rip_mash(const f_string_static_t glue, const f_string_static_t *arguments, const f_array_lengths_t values, f_string_dynamic_t *destination) { #ifndef _di_level_2_parameter_checking_ - if (!argv) return F_status_set_error(F_parameter); + if (!arguments) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_2_parameter_checking_ f_status_t status = F_none; - f_array_length_t length = 0; const f_array_length_t start = destination->used; f_string_dynamic_t ripped = f_string_dynamic_t_initialize; for (f_array_length_t i = 0; i < values.used; ++i) { - length = strnlen(argv[values.array[i]], F_console_parameter_size_d); - - if (length > 0) { - status = fl_string_rip(argv[values.array[i]], length, &ripped); + if (arguments[values.array[i]].used) { + ripped.used = 0; - if (F_status_is_error(status)) { - f_string_dynamic_resize(0, &ripped); + status = fl_string_rip(arguments[values.array[i]].string, arguments[values.array[i]].used, &ripped); + if (F_status_is_error(status)) break; - return status; - } - - if (ripped.used > 0) { + if (ripped.used) { status = f_string_dynamic_mash(glue, ripped, destination); - - if (F_status_is_error(status)) { - status = f_string_dynamic_resize(0, &ripped); - - return F_status_set_error(F_string_too_large); - } + if (F_status_is_error(status)) break; } } } // for - if (ripped.size) { - f_string_dynamic_resize(0, &ripped); - } + f_string_dynamic_resize(0, &ripped); if (status == F_none && start == destination->used) { return F_data_not; diff --git a/level_2/fll_program/c/program.h b/level_2/fll_program/c/program.h index d2cd575..694a5c9 100644 --- a/level_2/fll_program/c/program.h +++ b/level_2/fll_program/c/program.h @@ -242,7 +242,7 @@ extern "C" { * * Empty console parameters are ignored. * - * @param argv + * @param arguments * The program argument array to parse. * The caller must guarantee that the values.used does not exceed the argv length. * @param values @@ -258,12 +258,12 @@ extern "C" { * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_string_append(). + * Errors (with error bit) from: f_string_dynamic_append(). * - * @see f_string_append() + * @see f_string_dynamic_append() */ #ifndef _di_fll_program_parameter_additional_append_ - extern f_status_t fll_program_parameter_additional_append(const f_string_t *argv, const f_array_lengths_t values, f_string_dynamics_t *destination); + extern f_status_t fll_program_parameter_additional_append(const f_string_static_t *arguments, const f_array_lengths_t values, f_string_dynamics_t *destination); #endif // _di_fll_program_parameter_additional_append_ /** @@ -271,7 +271,7 @@ extern "C" { * * @param glue * A string to append between the source and destination, such as a space: ' '. - * @param argv + * @param arguments * The program argument array to parse. * The caller must guarantee that the values.used does not exceed the argv length. * @param values @@ -287,12 +287,12 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. * - * Errors (with error bit) from: f_string_mash(). + * Errors (with error bit) from: f_string_dynamic_mash(). * - * @see f_string_mash() + * @see f_string_dynamic_mash() */ #ifndef _di_fll_program_parameter_additional_mash_ - extern f_status_t fll_program_parameter_additional_mash(const f_string_static_t glue, const f_string_t *argv, const f_array_lengths_t values, f_string_dynamic_t *destination); + extern f_status_t fll_program_parameter_additional_mash(const f_string_static_t glue, const f_string_static_t *arguments, const f_array_lengths_t values, f_string_dynamic_t *destination); #endif // _di_fll_program_parameter_additional_mash_ /** @@ -300,7 +300,7 @@ extern "C" { * * The console parameters are trimmed. * - * @param argv + * @param arguments * The program argument array to parse. * The caller must guarantee that the values.used does not exceed the argv length. * @param values @@ -320,7 +320,7 @@ extern "C" { * @see fl_string_rip() */ #ifndef _di_fll_program_parameter_additional_rip_ - extern f_status_t fll_program_parameter_additional_rip(const f_string_t *argv, const f_array_lengths_t values, f_string_dynamics_t *destination); + extern f_status_t fll_program_parameter_additional_rip(const f_string_static_t *arguments, const f_array_lengths_t values, f_string_dynamics_t *destination); #endif // _di_fll_program_parameter_additional_rip_ /** @@ -330,7 +330,7 @@ extern "C" { * * @param glue * A string to append between the source and destination, such as a space: ' '. - * @param argv + * @param arguments * The program argument array to parse. * @param values * The string locations where the console parameters are found. @@ -352,7 +352,7 @@ extern "C" { * @see fl_string_rip() */ #ifndef _di_fll_program_parameter_additional_rip_mash_ - extern f_status_t fll_program_parameter_additional_rip_mash(const f_string_static_t glue, const f_string_t *argv, const f_array_lengths_t values, f_string_dynamic_t *destination); + extern f_status_t fll_program_parameter_additional_rip_mash(const f_string_static_t glue, const f_string_static_t *arguments, const f_array_lengths_t values, f_string_dynamic_t *destination); #endif // _di_fll_program_parameter_additional_rip_mash_ /** diff --git a/level_3/controller/c/entry/private-entry.c b/level_3/controller/c/entry/private-entry.c index cf89189..d68c9c4 100644 --- a/level_3/controller/c/entry/private-entry.c +++ b/level_3/controller/c/entry/private-entry.c @@ -417,7 +417,7 @@ extern "C" { if (F_status_is_error(status)) { // @todo instead call: fll_error_file_print(). - // fll_error_file_print(main->error, F_status_set_fine(status), "fll_path_canonical", F_true, arguments->argv[location], f_file_operation_verify_s, fll_error_file_type_path_e); + // fll_error_file_print(main->error, F_status_set_fine(status), "fll_path_canonical", F_true, argv[index], f_file_operation_verify_s, fll_error_file_type_path_e); controller_entry_print_error(is_entry, global.main->error, cache->action, F_status_set_fine(status), "fll_path_canonical", F_true, global.thread); action->status = status; diff --git a/level_3/fake/c/fake.h b/level_3/fake/c/fake.h index 8ffd116..d9087b5 100644 --- a/level_3/fake/c/fake.h +++ b/level_3/fake/c/fake.h @@ -36,7 +36,7 @@ * The "libraries/" and "programs/" directories contains the sub-directories "script/", "shared/", and "static/". * The "libraries/" directory will contain compiled libraries or library-like scripts in their respective sub-directories. * The "objects/" directory will contain any compile object files. - * The "progams/" directory will contain compiled programs or program-like scripts in their respective sub-directories. + * The "programs/" directory will contain compiled programs or program-like scripts in their respective sub-directories. * The "settings/" directory contains all configuration data, such as files commonly found under /etc in a standard GNU Linux system. * The "stage/" directory will contain build-time data. */ diff --git a/level_3/fake/c/private-fake.c b/level_3/fake/c/private-fake.c index cdc8187..3de20df 100644 --- a/level_3/fake/c/private-fake.c +++ b/level_3/fake/c/private-fake.c @@ -204,19 +204,18 @@ extern "C" { return F_status_set_error(F_parameter); } - f_array_length_t location = main->parameters.array[parameters_id[i]].values.array[0]; - f_array_length_t length = strnlen(arguments->argv[location], F_console_parameter_size_d); + f_array_length_t index = main->parameters.array[parameters_id[i]].values.array[0]; - if (length > 0) { + if (argv[index].used) { if (parameters_validate_word[i]) { f_array_length_t j = 0; f_array_length_t width_max = 0; - for (j = 0; j < length; ++j) { + for (j = 0; j < argv[index].used; ++j) { - width_max = length - j; + width_max = argv[index].used - j; - status = f_utf_is_word_dash_plus(arguments->argv[location] + j, width_max, F_false); + status = f_utf_is_word_dash_plus(argv[index] + j, width_max, F_false); if (F_status_is_error(status)) { if (fll_error_print(main->error, F_status_set_fine(status), "f_utf_is_word_dash_plus", F_false) == F_known_not && main->error.verbosity != f_console_verbosity_quiet_e) { @@ -239,7 +238,7 @@ extern "C" { fl_print_format("%r%[%QThe '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fake_long_process_s, main->error.notable); fl_print_format("%[' parameters value '%]", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - fl_print_format("%[%S%]", main->error.to.stream, main->error.notable, arguments->argv[location], main->error.notable); + fl_print_format("%[%S%]", main->error.to.stream, main->error.notable, argv[index], main->error.notable); fl_print_format("%[' contains non-word, non-dash, and non-plus characters.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); funlockfile(main->error.to.stream); @@ -250,7 +249,7 @@ extern "C" { } // for } - status = f_string_append(arguments->argv[location], length, parameters_value[i]); + status = f_string_append(argv[index], argv[index].used, parameters_value[i]); if (F_status_is_error(status)) { if (status == F_status_set_error(F_string_too_large)) { @@ -275,7 +274,7 @@ extern "C" { } } - if (length == 0 || status == F_data_not) { + if (!argv[index].used || status == F_data_not) { if (main->error.verbosity != f_console_verbosity_quiet_e) { flockfile(main->error.to.stream); @@ -350,7 +349,7 @@ extern "C" { return F_status_set_error(F_parameter); } - status = fl_console_parameter_to_string_dynamic_directory(arguments->argv[main->parameters.array[parameters_id[i]].values.array[0]], parameters_value[i]); + status = fl_console_parameter_to_string_dynamic_directory(argv[main->parameters.array[parameters_id[i]].values.array[0]], parameters_value[i]); if (F_status_is_error(status)) { if (fll_error_print(main->error, F_status_set_fine(status), "fl_console_parameter_to_string_dynamic_directory", F_false) == F_known_not && main->error.verbosity != f_console_verbosity_quiet_e) { @@ -389,7 +388,7 @@ extern "C" { } if (main->parameters.array[fake_parameter_define_e].result == f_console_result_additional_e) { - status = fll_program_parameter_additional_rip(arguments->argv, main->parameters.array[fake_parameter_define_e].values, &main->define); + status = fll_program_parameter_additional_rip(argv, main->parameters.array[fake_parameter_define_e].values, &main->define); if (F_status_is_error(status)) { if (fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_additional_rip", F_false) == F_known_not && main->error.verbosity != f_console_verbosity_quiet_e) { @@ -411,7 +410,7 @@ extern "C" { return F_status_set_error(F_parameter); } else if (main->parameters.array[fake_parameter_mode_e].result == f_console_result_additional_e) { - status = fll_program_parameter_additional_rip(arguments->argv, main->parameters.array[fake_parameter_mode_e].values, &main->mode); + status = fll_program_parameter_additional_rip(argv, main->parameters.array[fake_parameter_mode_e].values, &main->mode); if (F_status_is_error(status)) { if (fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_additional_rip", F_false) == F_known_not && main->error.verbosity != f_console_verbosity_quiet_e) { diff --git a/level_3/fss_basic_list_read/c/fss_basic_list_read.c b/level_3/fss_basic_list_read/c/fss_basic_list_read.c index e86418c..a3ced28 100644 --- a/level_3/fss_basic_list_read/c/fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/fss_basic_list_read.c @@ -352,7 +352,7 @@ extern "C" { } if (F_status_is_error_not(status) && main->parameters.array[fss_basic_list_read_parameter_delimit_e].result == f_console_result_additional_e) { - f_array_length_t location = 0; + f_array_length_t index = 0; f_array_length_t length = 0; uint16_t signal_check = 0; @@ -371,8 +371,8 @@ extern "C" { signal_check = 0; } - location = main->parameters.array[fss_basic_list_read_parameter_delimit_e].values.array[i]; - length = strnlen(arguments->argv[location], F_console_parameter_size_d); + index = main->parameters.array[fss_basic_list_read_parameter_delimit_e].values.array[i]; + length = argv[index].used; if (!length) { flockfile(main->error.to.stream); @@ -387,13 +387,13 @@ extern "C" { break; } - else if (fl_string_compare(arguments->argv[location], fss_basic_list_read_delimit_mode_name_none_s, length, fss_basic_list_read_delimit_mode_name_none_s_length) == F_equal_to) { + else if (fl_string_dynamic_compare_string(fss_basic_list_read_delimit_mode_name_none_s.string, argv[index], fss_basic_list_read_delimit_mode_name_none_s.used) == F_equal_to) { data.delimit_mode = fss_basic_list_read_delimit_mode_none_e; } - else if (fl_string_compare(arguments->argv[location], fss_basic_list_read_delimit_mode_name_all_s, length, fss_basic_list_read_delimit_mode_name_all_s_length) == F_equal_to) { + else if (fl_string_dynamic_compare_string(fss_basic_list_read_delimit_mode_name_all_s.string, argv[index], fss_basic_list_read_delimit_mode_name_all_s.used) == F_equal_to) { data.delimit_mode = fss_basic_list_read_delimit_mode_all_e; } - else if (fl_string_compare(arguments->argv[location], fss_basic_list_read_delimit_mode_name_object_s, length, fss_basic_list_read_delimit_mode_name_object_s_length) == F_equal_to) { + else if (fl_string_dynamic_compare_string(fss_basic_list_read_delimit_mode_name_object_s.string, argv[index], fss_basic_list_read_delimit_mode_name_object_s.used) == F_equal_to) { switch (data.delimit_mode) { case 0: data.delimit_mode = fss_basic_list_read_delimit_mode_object_e; @@ -430,7 +430,7 @@ extern "C" { data.delimit_mode = fss_basic_list_read_delimit_mode_content_object_e; } - if (arguments->argv[location][length - 1] == fss_basic_list_read_delimit_mode_name_greater_s.string[0]) { + if (argv[index][length - 1] == fss_basic_list_read_delimit_mode_name_greater_s.string[0]) { if (!(data.delimit_mode == fss_basic_list_read_delimit_mode_none_e || data.delimit_mode == fss_basic_list_read_delimit_mode_all_e)) { if (data.delimit_mode == fss_basic_list_read_delimit_mode_content_object_e) { data.delimit_mode = fss_basic_list_read_delimit_mode_content_greater_object_e; @@ -443,7 +443,7 @@ extern "C" { // Shorten the length to better convert the remainder to a number. --length; } - else if (arguments->argv[location][length - 1] == fss_basic_list_read_delimit_mode_name_lesser_s.string[0]) { + else if (argv[index][length - 1] == fss_basic_list_read_delimit_mode_name_lesser_s.string[0]) { if (!(data.delimit_mode == fss_basic_list_read_delimit_mode_none_e || data.delimit_mode == fss_basic_list_read_delimit_mode_all_e)) { if (data.delimit_mode == fss_basic_list_read_delimit_mode_content_object_e) { data.delimit_mode = fss_basic_list_read_delimit_mode_content_lesser_object_e; @@ -460,14 +460,14 @@ extern "C" { f_string_range_t range = macro_f_string_range_t_initialize(length); // Ignore leading plus sign. - if (arguments->argv[location][0] == '+') { + if (argv[index][0] == f_string_ascii_plus_s[0]) { ++range.start; } - status = fl_conversion_string_to_number_unsigned(arguments->argv[location], range, &data.delimit_depth); + status = fl_conversion_string_to_number_unsigned(argv[index].string, range, &data.delimit_depth); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_list_read_long_delimit_s, arguments->argv[location]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_list_read_long_delimit_s, argv[index]); break; } @@ -546,10 +546,10 @@ extern "C" { // This standard is newline sensitive, when appending files to the buffer if the file lacks a final newline then this could break the format for files appended thereafter. // Guarantee that a newline exists at the end of the buffer. - status = f_string_append_assure(f_string_eol_s, 1, &data.buffer); + status = f_string_dynamic_append_assure(f_string_eol_s, &data.buffer); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_string_append_assure", F_true, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_append_assure", F_true, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); } } else { @@ -578,10 +578,10 @@ extern "C" { file.stream = 0; file.id = -1; - status = f_file_stream_open(arguments->argv[main->parameters.remaining.array[i]], 0, &file); + status = f_file_stream_open(argv[main->parameters.remaining.array[i]], 0, &file); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, arguments->argv[main->parameters.remaining.array[i]], f_file_operation_open_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_open_s, fll_error_file_type_file_e); break; } @@ -590,7 +590,7 @@ extern "C" { status = f_file_size_by_id(file.id, &size_file); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, arguments->argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); break; } @@ -599,7 +599,7 @@ extern "C" { status = f_string_dynamic_resize(data.buffer.size + size_file, &data.buffer); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_resize", F_true, arguments->argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_resize", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); break; } @@ -607,20 +607,20 @@ extern "C" { status = f_file_stream_read(file, &data.buffer); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read", F_true, arguments->argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); break; } else if (data.buffer.used > data.files.array[data.files.used].range.start) { - data.files.array[data.files.used].name = arguments->argv[main->parameters.remaining.array[i]]; + data.files.array[data.files.used].name = argv[main->parameters.remaining.array[i]]; data.files.array[data.files.used++].range.stop = data.buffer.used - 1; // This standard is newline sensitive, when appending files to the buffer if the file lacks a final newline then this could break the format for files appended thereafter. // Guarantee that a newline exists at the end of the buffer. - status = f_string_append_assure(f_string_eol_s, 1, &data.buffer); + status = f_string_dynamic_append_assure(f_string_eol_s, &data.buffer); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_string_append_assure", F_true, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_append_assure", F_true, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); } } } diff --git a/level_3/fss_basic_list_read/c/private-read.c b/level_3/fss_basic_list_read/c/private-read.c index 928ea68..e26fbc5 100644 --- a/level_3/fss_basic_list_read/c/private-read.c +++ b/level_3/fss_basic_list_read/c/private-read.c @@ -108,12 +108,12 @@ extern "C" { else { position_depth = main->parameters.array[fss_basic_list_read_parameter_depth_e].values.array[i]; - const f_string_range_t range = macro_f_string_range_t_initialize(strlen(arguments->argv[position_depth])); + const f_string_range_t range = macro_f_string_range_t_initialize(strlen(argv[position_depth])); - status = fl_conversion_string_to_number_unsigned(arguments->argv[position_depth], range, &data->depths.array[i].depth); + status = fl_conversion_string_to_number_unsigned(argv[position_depth].string, range, &data->depths.array[i].depth); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_list_read_long_depth_s, arguments->argv[position_depth]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_list_read_long_depth_s, argv[position_depth]); return status; } @@ -132,12 +132,12 @@ extern "C" { data->depths.array[i].index_at = main->parameters.array[fss_basic_list_read_parameter_at_e].values.array[position_at]; - const f_string_range_t range = macro_f_string_range_t_initialize(strlen(arguments->argv[data->depths.array[i].index_at])); + const f_string_range_t range = macro_f_string_range_t_initialize(argv[data->depths.array[i].index_at].used); - status = fl_conversion_string_to_number_unsigned(arguments->argv[data->depths.array[i].index_at], range, &data->depths.array[i].value_at); + status = fl_conversion_string_to_number_unsigned(argv[data->depths.array[i].index_at].string, range, &data->depths.array[i].value_at); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_list_read_long_at_s, arguments->argv[data->depths.array[i].index_at]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_list_read_long_at_s, argv[data->depths.array[i].index_at]); return status; } @@ -158,14 +158,14 @@ extern "C" { data->depths.array[i].index_name = main->parameters.array[fss_basic_list_read_parameter_name_e].values.array[position_name]; if (main->parameters.array[fss_basic_list_read_parameter_trim_e].result == f_console_result_found_e) { - status = fl_string_rip(arguments->argv[data->depths.array[i].index_name], strlen(arguments->argv[data->depths.array[i].index_name]), &data->depths.array[i].value_name); + status = fl_string_dynamic_rip(argv[data->depths.array[i].index_name], &data->depths.array[i].value_name); } else { - status = f_string_append(arguments->argv[data->depths.array[i].index_name], strlen(arguments->argv[data->depths.array[i].index_name]), &data->depths.array[i].value_name); + status = f_string_dynamic_append(argv[data->depths.array[i].index_name], &data->depths.array[i].value_name); } if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), main->parameters.array[fss_basic_list_read_parameter_trim_e].result == f_console_result_found_e ? "fl_string_rip" : "f_string_append", F_true); + fll_error_print(main->error, F_status_set_fine(status), main->parameters.array[fss_basic_list_read_parameter_trim_e].result == f_console_result_found_e ? "fl_string_dynamic_rip" : "f_string_dynamic_append", F_true); return status; } @@ -200,7 +200,8 @@ extern "C" { return F_status_set_error(F_parameter); } - else if (data->depths.array[i].depth > data->depths.array[j].depth) { + + if (data->depths.array[i].depth > data->depths.array[j].depth) { if (main->error.verbosity != f_console_verbosity_quiet_e) { flockfile(main->error.to.stream); @@ -285,12 +286,12 @@ extern "C" { if (main->parameters.array[parameter].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].values.used - 1]; - const f_string_range_t range = macro_f_string_range_t_initialize(strnlen(arguments->argv[index], F_console_parameter_size_d)); + const f_string_range_t range = macro_f_string_range_t_initialize(main->argv[index].used); - const f_status_t status = fl_conversion_string_to_number_unsigned(arguments->argv[index], range, number); + const f_status_t status = fl_conversion_string_to_number_unsigned(main->argv[index].string, range, number); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, name, arguments->argv[index]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, name, main->argv[index]); return status; } diff --git a/level_3/fss_basic_list_write/c/fss_basic_list_write.c b/level_3/fss_basic_list_write/c/fss_basic_list_write.c index 13aec61..b2dde6b 100644 --- a/level_3/fss_basic_list_write/c/fss_basic_list_write.c +++ b/level_3/fss_basic_list_write/c/fss_basic_list_write.c @@ -178,14 +178,14 @@ extern "C" { status = F_status_set_error(F_parameter); } else { - const f_array_length_t location = main->parameters.array[fss_basic_list_write_parameter_file_e].values.array[0]; + const f_array_length_t index = main->parameters.array[fss_basic_list_write_parameter_file_e].values.array[0]; output.id = -1; output.stream = 0; - status = f_file_stream_open(arguments->argv[location], 0, &output); + status = f_file_stream_open(argv[index], f_string_static_empty_s, &output); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, arguments->argv[location], f_file_operation_open_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, argv[index], f_file_operation_open_s, fll_error_file_type_file_e); } } } @@ -324,18 +324,13 @@ extern "C" { } else if (main->parameters.array[fss_basic_list_write_parameter_prepend_e].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[fss_basic_list_write_parameter_prepend_e].values.array[main->parameters.array[fss_basic_list_write_parameter_prepend_e].values.used - 1]; - const f_array_length_t length = strnlen(arguments->argv[index], F_console_parameter_size_d); - if (length) { - f_string_range_t range = macro_f_string_range_t_initialize(length); + if (argv[index].used) { + f_string_range_t range = macro_f_string_range_t_initialize(argv[index].used); - main->prepend.string = arguments->argv[index]; - main->prepend.used = length; - main->prepend.size = length; + for (; range.start < argv[index].used; ++range.start) { - for (; range.start < length; range.start++) { - - status = f_fss_is_space(main->prepend, range); + status = f_fss_is_space(argv[index], range); if (F_status_is_error(status)) break; if (status == F_false) { @@ -419,12 +414,8 @@ extern "C" { } f_string_dynamic_t buffer = f_string_dynamic_t_initialize; - f_string_dynamic_t object = f_string_dynamic_t_initialize; - f_string_dynamic_t content = f_string_dynamic_t_initialize; if (F_status_is_error_not(status)) { - f_string_dynamic_t escaped = f_string_dynamic_t_initialize; - if (main->process_pipe) { status = fss_basic_list_write_process_pipe(main, output, quote, &buffer); @@ -452,11 +443,7 @@ extern "C" { break; } - object.string = arguments->argv[main->parameters.array[fss_basic_list_write_parameter_object_e].values.array[i]]; - object.used = strnlen(object.string, F_console_parameter_size_d); - object.size = object.used; - - status = fss_basic_list_write_process(main, output, quote, &object, 0, &buffer); + status = fss_basic_list_write_process(main, output, quote, &argv[main->parameters.array[fss_basic_list_write_parameter_object_e].values.array[i]], 0, &buffer); if (F_status_is_error(status)) break; } // for } @@ -469,11 +456,7 @@ extern "C" { break; } - content.string = arguments->argv[main->parameters.array[fss_basic_list_write_parameter_content_e].values.array[i]]; - content.used = strnlen(content.string, F_console_parameter_size_d); - content.size = content.used; - - status = fss_basic_list_write_process(main, output, quote, 0, &content, &buffer); + status = fss_basic_list_write_process(main, output, quote, 0, &argv[main->parameters.array[fss_basic_list_write_parameter_content_e].values.array[i]], &buffer); if (F_status_is_error(status)) break; } // for } @@ -487,15 +470,7 @@ extern "C" { break; } - object.string = arguments->argv[main->parameters.array[fss_basic_list_write_parameter_object_e].values.array[i]]; - object.used = strnlen(object.string, F_console_parameter_size_d); - object.size = object.used; - - content.string = arguments->argv[main->parameters.array[fss_basic_list_write_parameter_content_e].values.array[i]]; - content.used = strnlen(content.string, F_console_parameter_size_d); - content.size = content.used; - - status = fss_basic_list_write_process(main, output, quote, &object, &content, &buffer); + status = fss_basic_list_write_process(main, output, quote, &argv[main->parameters.array[fss_basic_list_write_parameter_object_e].values.array[i]], &argv[main->parameters.array[fss_basic_list_write_parameter_content_e].values.array[i]], &buffer); if (F_status_is_error(status)) break; } // for } @@ -516,17 +491,6 @@ extern "C" { fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); } } - - f_string_dynamic_resize(0, &escaped); - - // Object and content, though being a "dynamic" type, is being used statically, so clear them up to avoid invalid free(). - object.string = 0; - object.used = 0; - object.size = 0; - - content.string = 0; - content.used = 0; - content.size = 0; } if (main->parameters.array[fss_basic_list_write_parameter_file_e].result == f_console_result_additional_e) { @@ -543,8 +507,6 @@ extern "C" { } f_string_dynamic_resize(0, &buffer); - f_string_dynamic_resize(0, &object); - f_string_dynamic_resize(0, &content); fss_basic_list_write_main_delete(main); return status; diff --git a/level_3/fss_basic_read/c/fss_basic_read.c b/level_3/fss_basic_read/c/fss_basic_read.c index f687e15..5febba1 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -352,7 +352,7 @@ extern "C" { } if (F_status_is_error_not(status) && main->parameters.array[fss_basic_read_parameter_delimit_e].result == f_console_result_additional_e) { - f_array_length_t location = 0; + f_array_length_t index = 0; f_array_length_t length = 0; // Set the value to 0 to allow for detecting mode based on what is provided. @@ -366,8 +366,8 @@ extern "C" { break; } - location = main->parameters.array[fss_basic_read_parameter_delimit_e].values.array[i]; - length = strnlen(arguments->argv[location], F_console_parameter_size_d); + index = main->parameters.array[fss_basic_read_parameter_delimit_e].values.array[i]; + length = argv[index].used; if (!length) { flockfile(main->error.to.stream); @@ -382,13 +382,13 @@ extern "C" { break; } - else if (fl_string_compare(arguments->argv[location], fss_basic_read_delimit_mode_name_none_s, length, fss_basic_read_delimit_mode_name_none_s_length) == F_equal_to) { + else if (fl_string_dynamic_compare_string(fss_basic_read_delimit_mode_name_none_s.string, argv[index], fss_basic_read_delimit_mode_name_none_s.used) == F_equal_to) { data.delimit_mode = fss_basic_read_delimit_mode_none_e; } - else if (fl_string_compare(arguments->argv[location], fss_basic_read_delimit_mode_name_all_s, length, fss_basic_read_delimit_mode_name_all_s_length) == F_equal_to) { + else if (fl_string_dynamic_compare_string(fss_basic_read_delimit_mode_name_all_s.string, argv[index], fss_basic_read_delimit_mode_name_all_s.used) == F_equal_to) { data.delimit_mode = fss_basic_read_delimit_mode_all_e; } - else if (fl_string_compare(arguments->argv[location], fss_basic_read_delimit_mode_name_object_s, length, fss_basic_read_delimit_mode_name_object_s_length) == F_equal_to) { + else if (fl_string_dynamic_compare_string(fss_basic_read_delimit_mode_name_object_s.string, argv[index], fss_basic_read_delimit_mode_name_object_s.used) == F_equal_to) { switch (data.delimit_mode) { case 0: data.delimit_mode = fss_basic_read_delimit_mode_object_e; @@ -425,7 +425,7 @@ extern "C" { data.delimit_mode = fss_basic_read_delimit_mode_content_object_e; } - if (arguments->argv[location][length - 1] == fss_basic_read_delimit_mode_name_greater_s.string[0]) { + if (argv[index][length - 1] == fss_basic_read_delimit_mode_name_greater_s.string[0]) { if (!(data.delimit_mode == fss_basic_read_delimit_mode_none_e || data.delimit_mode == fss_basic_read_delimit_mode_all_e)) { if (data.delimit_mode == fss_basic_read_delimit_mode_content_object_e) { data.delimit_mode = fss_basic_read_delimit_mode_content_greater_object_e; @@ -438,7 +438,7 @@ extern "C" { // Shorten the length to better convert the remainder to a number. --length; } - else if (arguments->argv[location][length - 1] == fss_basic_read_delimit_mode_name_lesser_s.string[0]) { + else if (argv[index][length - 1] == fss_basic_read_delimit_mode_name_lesser_s.string[0]) { if (!(data.delimit_mode == fss_basic_read_delimit_mode_none_e || data.delimit_mode == fss_basic_read_delimit_mode_all_e)) { if (data.delimit_mode == fss_basic_read_delimit_mode_content_object_e) { data.delimit_mode = fss_basic_read_delimit_mode_content_lesser_object_e; @@ -455,14 +455,14 @@ extern "C" { f_string_range_t range = macro_f_string_range_t_initialize(length); // Ignore leading plus sign. - if (arguments->argv[location][0] == '+') { + if (argv[index][0] == '+') { ++range.start; } - status = fl_conversion_string_to_number_unsigned(arguments->argv[location], range, &data.delimit_depth); + status = fl_conversion_string_to_number_unsigned(argv[index].string, range, &data.delimit_depth); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_read_long_delimit_s, arguments->argv[location]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_read_long_delimit_s, argv[index]); break; } @@ -560,6 +560,7 @@ extern "C" { if (fss_basic_read_signal_received(main)) { status = F_status_set_error(F_signal); + break; } @@ -567,10 +568,10 @@ extern "C" { file.stream = 0; file.id = -1; - status = f_file_stream_open(arguments->argv[main->parameters.remaining.array[i]], 0, &file); + status = f_file_stream_open(argv[main->parameters.remaining.array[i]], 0, &file); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, arguments->argv[main->parameters.remaining.array[i]], f_file_operation_open_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_open_s, fll_error_file_type_file_e); break; } @@ -579,7 +580,7 @@ extern "C" { status = f_file_size_by_id(file.id, &size_file); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, arguments->argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); break; } @@ -588,7 +589,7 @@ extern "C" { status = f_string_dynamic_resize(data.buffer.size + size_file, &data.buffer); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_resize", F_true, arguments->argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_resize", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); break; } @@ -596,13 +597,13 @@ extern "C" { status = f_file_stream_read(file, &data.buffer); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read", F_true, arguments->argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); break; } if (data.buffer.used > data.files.array[data.files.used].range.start) { - data.files.array[data.files.used].name = arguments->argv[main->parameters.remaining.array[i]]; + data.files.array[data.files.used].name = argv[main->parameters.remaining.array[i]]; data.files.array[data.files.used++].range.stop = data.buffer.used - 1; // This standard is newline sensitive, when appending files to the buffer if the file lacks a final newline then this could break the format for files appended thereafter. diff --git a/level_3/fss_basic_read/c/private-read.c b/level_3/fss_basic_read/c/private-read.c index 3089404..7643acc 100644 --- a/level_3/fss_basic_read/c/private-read.c +++ b/level_3/fss_basic_read/c/private-read.c @@ -80,12 +80,12 @@ extern "C" { else { position_depth = main->parameters.array[fss_basic_read_parameter_depth_e].values.array[i]; - const f_string_range_t range = macro_f_string_range_t_initialize(strlen(arguments->argv[position_depth])); + const f_string_range_t range = macro_f_string_range_t_initialize(strlen(argv[position_depth])); - status = fl_conversion_string_to_number_unsigned(arguments->argv[position_depth], range, &data->depths.array[i].depth); + status = fl_conversion_string_to_number_unsigned(argv[position_depth], range, &data->depths.array[i].depth); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_read_long_depth_s, arguments->argv[position_depth]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_read_long_depth_s, argv[position_depth]); return status; } @@ -104,12 +104,12 @@ extern "C" { data->depths.array[i].index_at = main->parameters.array[fss_basic_read_parameter_at_e].values.array[position_at]; - const f_string_range_t range = macro_f_string_range_t_initialize(strlen(arguments->argv[data->depths.array[i].index_at])); + const f_string_range_t range = macro_f_string_range_t_initialize(strlen(argv[data->depths.array[i].index_at])); - status = fl_conversion_string_to_number_unsigned(arguments->argv[data->depths.array[i].index_at], range, &data->depths.array[i].value_at); + status = fl_conversion_string_to_number_unsigned(argv[data->depths.array[i].index_at], range, &data->depths.array[i].value_at); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_read_long_at_s, arguments->argv[data->depths.array[i].index_at]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_basic_read_long_at_s, argv[data->depths.array[i].index_at]); return status; } @@ -130,14 +130,14 @@ extern "C" { data->depths.array[i].index_name = main->parameters.array[fss_basic_read_parameter_name_e].values.array[position_name]; if (main->parameters.array[fss_basic_read_parameter_trim_e].result == f_console_result_found_e) { - status = fl_string_rip(arguments->argv[data->depths.array[i].index_name], strlen(arguments->argv[data->depths.array[i].index_name]), &data->depths.array[i].value_name); + status = fl_string_dynamic_rip(argv[data->depths.array[i].index_name], &data->depths.array[i].value_name); } else { - status = f_string_append(arguments->argv[data->depths.array[i].index_name], strlen(arguments->argv[data->depths.array[i].index_name]), &data->depths.array[i].value_name); + status = f_string_dynamic_append(argv[data->depths.array[i].index_name], &data->depths.array[i].value_name); } if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), main->parameters.array[fss_basic_read_parameter_trim_e].result == f_console_result_found_e ? "fl_string_rip" : "f_string_append", F_true); + fll_error_print(main->error, F_status_set_fine(status), main->parameters.array[fss_basic_read_parameter_trim_e].result == f_console_result_found_e ? "fl_string_dynamic_rip" : "f_string_dynamic_append", F_true); return status; } @@ -250,12 +250,12 @@ extern "C" { if (main->parameters.array[parameter].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].values.used - 1]; - const f_string_range_t range = macro_f_string_range_t_initialize(strnlen(arguments->argv[index], F_console_parameter_size_d)); + const f_string_range_t range = macro_f_string_range_t_initialize(strnlen(argv[index], F_console_parameter_size_d)); - const f_status_t status = fl_conversion_string_to_number_unsigned(arguments->argv[index], range, number); + const f_status_t status = fl_conversion_string_to_number_unsigned(argv[index].string, range, number); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, name, arguments->argv[index]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, name, argv[index]); return status; } diff --git a/level_3/fss_basic_write/c/fss_basic_write.c b/level_3/fss_basic_write/c/fss_basic_write.c index 30028a8..5f2ae69 100644 --- a/level_3/fss_basic_write/c/fss_basic_write.c +++ b/level_3/fss_basic_write/c/fss_basic_write.c @@ -176,14 +176,14 @@ extern "C" { status = F_status_set_error(F_parameter); } else { - const f_array_length_t location = main->parameters.array[fss_basic_write_parameter_file_e].values.array[0]; + const f_array_length_t index = main->parameters.array[fss_basic_write_parameter_file_e].values.array[0]; output.id = -1; output.stream = 0; - status = f_file_stream_open(arguments->argv[location], 0, &output); + status = f_file_stream_open(argv[index], f_string_empty_s, &output); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, arguments->argv[location], f_file_operation_open_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, argv[index], f_file_operation_open_s, fll_error_file_type_file_e); } } } @@ -322,16 +322,14 @@ extern "C" { } else if (main->parameters.array[fss_basic_write_parameter_prepend_e].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[fss_basic_write_parameter_prepend_e].values.array[main->parameters.array[fss_basic_write_parameter_prepend_e].values.used - 1]; - const f_array_length_t length = strnlen(arguments->argv[index], F_console_parameter_size_d); // Even though this standard does not utilize this parameter, provide the validation for consistency. - if (length) { - f_string_range_t range = macro_f_string_range_t_initialize(length); - const f_string_static_t prepend = macro_f_string_static_t_initialize2(arguments->argv[index], length); + if (argv[index].used) { + f_string_range_t range = macro_f_string_range_t_initialize(argv[index].used); - for (; range.start < length; range.start++) { + for (; range.start < argv[index].used; ++range.start) { - status = f_fss_is_space(prepend, range); + status = f_fss_is_space(argv[index], range); if (F_status_is_error(status)) break; if (status == F_false) { @@ -415,12 +413,8 @@ extern "C" { } f_string_dynamic_t buffer = f_string_dynamic_t_initialize; - f_string_dynamic_t object = f_string_dynamic_t_initialize; - f_string_dynamic_t content = f_string_dynamic_t_initialize; if (F_status_is_error_not(status)) { - f_string_dynamic_t escaped = f_string_dynamic_t_initialize; - if (main->process_pipe) { status = fss_basic_write_process_pipe(main, output, quote, &buffer); @@ -449,11 +443,7 @@ extern "C" { break; } - object.string = arguments->argv[main->parameters.array[fss_basic_write_parameter_object_e].values.array[i]]; - object.used = strnlen(object.string, F_console_parameter_size_d); - object.size = object.used; - - status = fss_basic_write_process(main, output, quote, &object, 0, &buffer); + status = fss_basic_write_process(main, output, quote, &argv[main->parameters.array[fss_basic_write_parameter_object_e].values.array[i]], 0, &buffer); if (F_status_is_error(status)) break; } // for } @@ -468,11 +458,7 @@ extern "C" { break; } - content.string = arguments->argv[main->parameters.array[fss_basic_write_parameter_content_e].values.array[i]]; - content.used = strnlen(content.string, F_console_parameter_size_d); - content.size = content.used; - - status = fss_basic_write_process(main, output, quote, 0, &content, &buffer); + status = fss_basic_write_process(main, output, quote, 0, &argv[main->parameters.array[fss_basic_write_parameter_content_e].values.array[i]], &buffer); if (F_status_is_error(status)) break; } // for } @@ -485,15 +471,7 @@ extern "C" { break; } - object.string = arguments->argv[main->parameters.array[fss_basic_write_parameter_object_e].values.array[i]]; - object.used = strnlen(object.string, F_console_parameter_size_d); - object.size = object.used; - - content.string = arguments->argv[main->parameters.array[fss_basic_write_parameter_content_e].values.array[i]]; - content.used = strnlen(content.string, F_console_parameter_size_d); - content.size = content.used; - - status = fss_basic_write_process(main, output, quote, &object, &content, &buffer); + status = fss_basic_write_process(main, output, quote, &argv[main->parameters.array[fss_basic_write_parameter_object_e].values.array[i]], &argv[main->parameters.array[fss_basic_write_parameter_content_e].values.array[i]], &buffer); if (F_status_is_error(status)) break; } // for } @@ -514,17 +492,6 @@ extern "C" { fll_print_dynamic_raw(f_string_eol_s, main->output.to.stream); } } - - f_string_dynamic_resize(0, &escaped); - - // Object and content, though being a "dynamic" type, is being used statically, so clear them up to avoid invalid free(). - object.string = 0; - object.used = 0; - object.size = 0; - - content.string = 0; - content.used = 0; - content.size = 0; } if (main->parameters.array[fss_basic_write_parameter_file_e].result == f_console_result_additional_e) { @@ -541,8 +508,6 @@ extern "C" { } f_string_dynamic_resize(0, &buffer); - f_string_dynamic_resize(0, &object); - f_string_dynamic_resize(0, &content); fss_basic_write_main_delete(main); return status; diff --git a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c index 09d713d..dce5909 100644 --- a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c +++ b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c @@ -337,10 +337,10 @@ extern "C" { status = F_status_set_error(F_parameter); } else if (main->parameters.array[fss_embedded_list_read_parameter_delimit_e].result == f_console_result_additional_e) { - const f_array_length_t location = main->parameters.array[fss_embedded_list_read_parameter_delimit_e].values.array[0]; - f_array_length_t length = strnlen(arguments->argv[location], F_console_parameter_size_d); + const f_array_length_t index = main->parameters.array[fss_embedded_list_read_parameter_delimit_e].values.array[0]; + f_array_length_t length = argv[index].used; - if (length == 0) { + if (!length) { flockfile(main->error.to.stream); fl_print_format("%r%[%QThe value for the parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); @@ -351,22 +351,22 @@ extern "C" { status = F_status_set_error(F_parameter); } - else if (fl_string_compare(arguments->argv[location], fss_embedded_list_read_delimit_mode_name_none_s, length, fss_embedded_list_read_delimit_mode_name_none_s_length) == F_equal_to) { + else if (fl_string_dynamic_compare_string(fss_embedded_list_read_delimit_mode_name_none_s.string, argv[index], fss_embedded_list_read_delimit_mode_name_none_s.used) == F_equal_to) { main->delimit_mode = fss_embedded_list_read_delimit_mode_none_e; } - else if (fl_string_compare(arguments->argv[location], fss_embedded_list_read_delimit_mode_name_all_s, length, fss_embedded_list_read_delimit_mode_name_all_s_length) == F_equal_to) { + else if (fl_string_dynamic_compare_string(fss_embedded_list_read_delimit_mode_name_all_s.string, argv[index], fss_embedded_list_read_delimit_mode_name_all_s.used) == F_equal_to) { main->delimit_mode = fss_embedded_list_read_delimit_mode_all_e; } else { main->delimit_mode = fss_embedded_list_read_delimit_mode_depth_e; - if (arguments->argv[location][length - 1] == fss_embedded_list_read_delimit_mode_name_greater_s.string[0]) { + if (argv[index][length - 1] == fss_embedded_list_read_delimit_mode_name_greater_s.string[0]) { main->delimit_mode = fss_embedded_list_read_delimit_mode_depth_greater_e; // Shorten the length to better convert the remainder to a number. --length; } - else if (arguments->argv[location][length - 1] == fss_embedded_list_read_delimit_mode_name_lesser_s.string[0]) { + else if (argv[index][length - 1] == fss_embedded_list_read_delimit_mode_name_lesser_s.string[0]) { main->delimit_mode = fss_embedded_list_read_delimit_mode_depth_lesser_e; // Shorten the length to better convert the remainder to a number. @@ -376,14 +376,14 @@ extern "C" { f_string_range_t range = macro_f_string_range_t_initialize(length); // Ignore leading plus sign. - if (arguments->argv[location][0] == '+') { + if (argv[index][0] == f_string_ascii_plus_s[0]) { ++range.start; } - status = fl_conversion_string_to_number_unsigned(arguments->argv[location], range, &main->delimit_depth); + status = fl_conversion_string_to_number_unsigned(argv[index].string, range, &main->delimit_depth); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_embedded_list_read_long_delimit_s, arguments->argv[location]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_embedded_list_read_long_delimit_s, argv[index]); } } } @@ -445,17 +445,18 @@ extern "C" { if (fss_embedded_list_read_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } f_file_t file = f_file_t_initialize; - status = f_file_open(arguments->argv[main->parameters.remaining.array[i]], 0, &file); + status = f_file_open(argv[main->parameters.remaining.array[i]], f_string_empty_s, &file); main->quantity.total = original_size; if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_open", F_true, arguments->argv[main->parameters.remaining.array[i]], f_file_operation_open_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_open", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_open_s, fll_error_file_type_file_e); break; } @@ -463,7 +464,7 @@ extern "C" { if (!main->quantity.total) { status = f_file_size_by_id(file.id, &main->quantity.total); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, arguments->argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); f_file_stream_close(F_true, &file); @@ -473,7 +474,7 @@ extern "C" { // Skip past empty files. if (!main->quantity.total) { if (main->parameters.array[fss_embedded_list_read_parameter_total_e].result == f_console_result_found_e) { - fll_print_format("0%r", main->output.to.stream, f_string_eol_s); + fll_print_format("%r%r", main->output.to.stream, f_string_ascii_0_s, f_string_eol_s); } f_file_stream_close(F_true, &file); @@ -487,15 +488,15 @@ extern "C" { f_file_stream_close(F_true, &file); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_read_until", F_true, arguments->argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_read_until", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); break; } - status = fss_embedded_list_read_main_process_file(main, arguments, arguments->argv[main->parameters.remaining.array[i]], depths, &objects_delimits, &contents_delimits, &comments); + status = fss_embedded_list_read_main_process_file(main, arguments, argv[main->parameters.remaining.array[i]], depths, &objects_delimits, &contents_delimits, &comments); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "fss_embedded_list_read_main_process_file", F_true, arguments->argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "fss_embedded_list_read_main_process_file", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); break; } diff --git a/level_3/fss_embedded_list_read/c/private-read.c b/level_3/fss_embedded_list_read/c/private-read.c index 10c1bcc..1cd96d4 100644 --- a/level_3/fss_embedded_list_read/c/private-read.c +++ b/level_3/fss_embedded_list_read/c/private-read.c @@ -133,12 +133,12 @@ extern "C" { } if (values_type[i] == fss_embedded_list_read_parameter_depth_e || values_type[i] == fss_embedded_list_read_parameter_at_e) { - const f_string_range_t range = macro_f_string_range_t_initialize(strlen(arguments->argv[values_order[i]])); + const f_string_range_t range = macro_f_string_range_t_initialize(strlen(argv[values_order[i]])); - status = fl_conversion_string_to_number_unsigned(arguments->argv[values_order[i]], range, &number); + status = fl_conversion_string_to_number_unsigned(argv[values_order[i]], range, &number); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_embedded_list_read_long_depth_s, arguments->argv[values_order[i]]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_embedded_list_read_long_depth_s, argv[values_order[i]]); return status; } @@ -172,7 +172,7 @@ extern "C" { depths->array[depths->used].value_name.used = 0; if (main->parameters.array[fss_embedded_list_read_parameter_trim_e].result == f_console_result_found_e) { - status = fl_string_rip(arguments->argv[values_order[i]], strnlen(arguments->argv[values_order[i]], F_console_parameter_size_d), &depths->array[depths->used].value_name); + status = fl_string_rip(argv[values_order[i]], strnlen(argv[values_order[i]], F_console_parameter_size_d), &depths->array[depths->used].value_name); if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "fl_string_rip", F_true); @@ -181,7 +181,7 @@ extern "C" { } } else { - status = f_string_append(arguments->argv[values_order[i]], strnlen(arguments->argv[values_order[i]], F_console_parameter_size_d), &depths->array[depths->used].value_name); + status = f_string_append(argv[values_order[i]], strnlen(argv[values_order[i]], F_console_parameter_size_d), &depths->array[depths->used].value_name); if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "f_string_append", F_true); @@ -288,7 +288,7 @@ extern "C" { // Requested depths cannot be greater than contents depth. if (depths.used > main->nest.used) { if (main->parameters.array[fss_embedded_list_read_parameter_total_e].result == f_console_result_found_e) { - fll_print_format("0%r", main->output.to.stream, f_string_eol_s); + fll_print_format("%r%r", main->output.to.stream, f_string_ascii_0_s, f_string_eol_s); return F_none; } @@ -301,18 +301,18 @@ extern "C" { if (main->parameters.array[fss_embedded_list_read_parameter_select_e].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[fss_embedded_list_read_parameter_select_e].values.array[main->parameters.array[fss_embedded_list_read_parameter_select_e].values.used - 1]; - const f_string_range_t range = macro_f_string_range_t_initialize(strlen(arguments->argv[index])); + const f_string_range_t range = macro_f_string_range_t_initialize(argv[index]); - status = fl_conversion_string_to_number_unsigned(arguments->argv[index], range, &select); + status = fl_conversion_string_to_number_unsigned(argv[index].string, range, &select); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_embedded_list_read_long_select_s, arguments->argv[index]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_embedded_list_read_long_select_s, argv[index]); return status; } // This standard does not support multiple content groups. - if (select > 0) { + if (select) { return F_none; } } @@ -322,12 +322,12 @@ extern "C" { if (main->parameters.array[fss_embedded_list_read_parameter_line_e].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[fss_embedded_list_read_parameter_line_e].values.array[main->parameters.array[fss_embedded_list_read_parameter_line_e].values.used - 1]; - const f_string_range_t range = macro_f_string_range_t_initialize(strlen(arguments->argv[index])); + const f_string_range_t range = macro_f_string_range_t_initialize(argv[index].used); - status = fl_conversion_string_to_number_unsigned(arguments->argv[index], range, &line); + status = fl_conversion_string_to_number_unsigned(argv[index].string, range, &line); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_embedded_list_read_long_line_s, arguments->argv[index]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_embedded_list_read_long_line_s, argv[index]); return status; } diff --git a/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c b/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c index 7630190..0e50f93 100644 --- a/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c +++ b/level_3/fss_embedded_list_write/c/fss_embedded_list_write.c @@ -179,14 +179,14 @@ extern "C" { status = F_status_set_error(F_parameter); } else { - const f_array_length_t location = main->parameters.array[fss_embedded_list_write_parameter_file_e].values.array[0]; + const f_array_length_t index = main->parameters.array[fss_embedded_list_write_parameter_file_e].values.array[0]; output.id = -1; output.stream = 0; - status = f_file_stream_open(arguments->argv[location], 0, &output); + status = f_file_stream_open(argv[index], f_string_empty_s, &output); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, arguments->argv[location], f_file_operation_open_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, argv[index], f_file_operation_open_s, fll_error_file_type_file_e); } } } @@ -325,12 +325,11 @@ extern "C" { } else if (main->parameters.array[fss_embedded_list_write_parameter_prepend_e].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[fss_embedded_list_write_parameter_prepend_e].values.array[main->parameters.array[fss_embedded_list_write_parameter_prepend_e].values.used - 1]; - const f_array_length_t length = strnlen(arguments->argv[index], F_console_parameter_size_d); - if (length) { - f_string_range_t range = macro_f_string_range_t_initialize(length); + if (argv[index].used) { + f_string_range_t range = macro_f_string_range_t_initialize(argv[index].used); - for (; range.start < length; ++range.start) { + for (; range.start < argv[index].used; ++range.start) { status = f_fss_is_space(main->parameter->arguments.array[index], range); if (F_status_is_error(status)) break; @@ -416,11 +415,8 @@ extern "C" { } f_string_dynamic_t buffer = f_string_dynamic_t_initialize; - f_string_dynamic_t object = f_string_dynamic_t_initialize; - f_string_dynamic_t content = f_string_dynamic_t_initialize; if (F_status_is_error_not(status)) { - f_string_dynamic_t escaped = f_string_dynamic_t_initialize; f_string_ranges_t ignore = f_string_ranges_t_initialize; if (main->process_pipe) { @@ -452,11 +448,7 @@ extern "C" { break; } - object.string = arguments->argv[main->parameters.array[fss_embedded_list_write_parameter_object_e].values.array[i]]; - object.used = strnlen(object.string, F_console_parameter_size_d); - object.size = object.used; - - status = fss_embedded_list_write_process(main, output, quote, &object, 0, 0, &buffer); + status = fss_embedded_list_write_process(main, output, quote, &argv[main->parameters.array[fss_embedded_list_write_parameter_object_e].values.array[i]], 0, 0, &buffer); if (F_status_is_error(status)) break; } // for } @@ -472,11 +464,7 @@ extern "C" { status = fss_embedded_list_write_process_parameter_ignore(main, arguments, main->parameters.array[fss_embedded_list_write_parameter_content_e].locations, i, &ignore); if (F_status_is_error(status)) break; - content.string = arguments->argv[main->parameters.array[fss_embedded_list_write_parameter_content_e].values.array[i]]; - content.used = strnlen(content.string, F_console_parameter_size_d); - content.size = content.used; - - status = fss_embedded_list_write_process(main, output, quote, 0, &content, &ignore, &buffer); + status = fss_embedded_list_write_process(main, output, quote, 0, &argv[main->parameters.array[fss_embedded_list_write_parameter_content_e].values.array[i]], &ignore, &buffer); if (F_status_is_error(status)) break; } // for } @@ -493,15 +481,7 @@ extern "C" { status = fss_embedded_list_write_process_parameter_ignore(main, arguments, main->parameters.array[fss_embedded_list_write_parameter_content_e].locations, i, &ignore); if (F_status_is_error(status)) break; - object.string = arguments->argv[main->parameters.array[fss_embedded_list_write_parameter_object_e].values.array[i]]; - object.used = strnlen(object.string, F_console_parameter_size_d); - object.size = object.used; - - content.string = arguments->argv[main->parameters.array[fss_embedded_list_write_parameter_content_e].values.array[i]]; - content.used = strnlen(content.string, F_console_parameter_size_d); - content.size = content.used; - - status = fss_embedded_list_write_process(main, output, quote, &object, &content, &ignore, &buffer); + status = fss_embedded_list_write_process(main, output, quote, &argv[main->parameters.array[fss_embedded_list_write_parameter_object_e].values.array[i]], &argv[main->parameters.array[fss_embedded_list_write_parameter_content_e].values.array[i]], &ignore, &buffer); if (F_status_is_error(status)) break; } // for } @@ -523,17 +503,7 @@ extern "C" { } } - f_string_dynamic_resize(0, &escaped); macro_f_string_ranges_t_delete_simple(ignore); - - // Object and content, though being a "dynamic" type, is being used statically, so clear them up to avoid invalid free(). - object.string = 0; - object.used = 0; - object.size = 0; - - content.string = 0; - content.used = 0; - content.size = 0; } if (main->parameters.array[fss_embedded_list_write_parameter_file_e].result == f_console_result_additional_e) { @@ -550,8 +520,6 @@ extern "C" { } f_string_dynamic_resize(0, &buffer); - f_string_dynamic_resize(0, &object); - f_string_dynamic_resize(0, &content); fss_embedded_list_write_main_delete(main); return status; diff --git a/level_3/fss_embedded_list_write/c/private-write.c b/level_3/fss_embedded_list_write/c/private-write.c index 73f72cf..46bf8c5 100644 --- a/level_3/fss_embedded_list_write/c/private-write.c +++ b/level_3/fss_embedded_list_write/c/private-write.c @@ -402,17 +402,17 @@ extern "C" { index = main->parameters.array[fss_embedded_list_write_parameter_ignore_e].values.array[i * 2]; range.start = 0; - range.stop = strnlen(arguments->argv[index], F_console_parameter_size_d) - 1; + range.stop = argv[index].used - 1; // allow and ignore the positive sign. - if (range.stop > 0 && arguments->argv[index][0] == '+') { + if (range.stop && argv[index][0] == f_string_ascii_plus_s[0]) { range.start = 1; } - status = fl_conversion_string_to_number_unsigned(arguments->argv[index], range, &number); + status = fl_conversion_string_to_number_unsigned(argv[index].string, range, &number); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_embedded_list_write_long_ignore_s, arguments->argv[index]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_embedded_list_write_long_ignore_s, argv[index]); return status; } @@ -422,17 +422,17 @@ extern "C" { index = main->parameters.array[fss_embedded_list_write_parameter_ignore_e].values.array[(i * 2) + 1]; range.start = 0; - range.stop = strnlen(arguments->argv[index], F_console_parameter_size_d) - 1; + range.stop = argv[index].used - 1; - // allow and ignore the positive sign. - if (range.stop > 0 && arguments->argv[index][0] == '+') { + // Allow and ignore the positive sign. + if (range.stop && argv[index][0] == f_string_ascii_plus_s[0]) { range.start = 1; } - status = fl_conversion_string_to_number_unsigned(arguments->argv[index], range, &number); + status = fl_conversion_string_to_number_unsigned(argv[index].string, range, &number); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_embedded_list_write_long_ignore_s, arguments->argv[index]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_embedded_list_write_long_ignore_s, argv[index]); return status; } diff --git a/level_3/fss_extended_list_read/c/fss_extended_list_read.c b/level_3/fss_extended_list_read/c/fss_extended_list_read.c index f31ace0..9dcb748 100644 --- a/level_3/fss_extended_list_read/c/fss_extended_list_read.c +++ b/level_3/fss_extended_list_read/c/fss_extended_list_read.c @@ -352,7 +352,7 @@ extern "C" { } if (F_status_is_error_not(status) && main->parameters.array[fss_extended_list_read_parameter_delimit_e].result == f_console_result_additional_e) { - f_array_length_t location = 0; + f_array_length_t index = 0; f_array_length_t length = 0; // Set the value to 0 to allow for detecting mode based on what is provided. @@ -366,8 +366,8 @@ extern "C" { break; } - location = main->parameters.array[fss_extended_list_read_parameter_delimit_e].values.array[i]; - length = strnlen(arguments->argv[location], F_console_parameter_size_d); + index = main->parameters.array[fss_extended_list_read_parameter_delimit_e].values.array[i]; + length = argv[index].used; if (!length) { flockfile(main->error.to.stream); @@ -382,13 +382,13 @@ extern "C" { break; } - else if (fl_string_compare(arguments->argv[location], fss_extended_list_read_delimit_mode_name_none_s, length, fss_extended_list_read_delimit_mode_name_none_s_length) == F_equal_to) { + else if (fl_string_dynamic_compare_string(fss_extended_list_read_delimit_mode_name_none_s.string, argv[index], fss_extended_list_read_delimit_mode_name_none_s.used) == F_equal_to) { data.delimit_mode = fss_extended_list_read_delimit_mode_none_e; } - else if (fl_string_compare(arguments->argv[location], fss_extended_list_read_delimit_mode_name_all_s, length, fss_extended_list_read_delimit_mode_name_all_s_length) == F_equal_to) { + else if (fl_string_dynamic_compare_string(fss_extended_list_read_delimit_mode_name_all_s.string, argv[index], fss_extended_list_read_delimit_mode_name_all_s.used) == F_equal_to) { data.delimit_mode = fss_extended_list_read_delimit_mode_all_e; } - else if (fl_string_compare(arguments->argv[location], fss_extended_list_read_delimit_mode_name_object_s, length, fss_extended_list_read_delimit_mode_name_object_s_length) == F_equal_to) { + else if (fl_string_dynamic_compare_string(fss_extended_list_read_delimit_mode_name_object_s.string, argv[index], fss_extended_list_read_delimit_mode_name_object_s.used) == F_equal_to) { switch (data.delimit_mode) { case 0: data.delimit_mode = fss_extended_list_read_delimit_mode_object_e; @@ -425,7 +425,7 @@ extern "C" { data.delimit_mode = fss_extended_list_read_delimit_mode_content_object_e; } - if (arguments->argv[location][length - 1] == fss_extended_list_read_delimit_mode_name_greater_s.string[0]) { + if (argv[index][length - 1] == fss_extended_list_read_delimit_mode_name_greater_s.string[0]) { if (!(data.delimit_mode == fss_extended_list_read_delimit_mode_none_e || data.delimit_mode == fss_extended_list_read_delimit_mode_all_e)) { if (data.delimit_mode == fss_extended_list_read_delimit_mode_content_object_e) { data.delimit_mode = fss_extended_list_read_delimit_mode_content_greater_object_e; @@ -438,7 +438,7 @@ extern "C" { // Shorten the length to better convert the remainder to a number. --length; } - else if (arguments->argv[location][length - 1] == fss_extended_list_read_delimit_mode_name_lesser_s.string[0]) { + else if (argv[index][length - 1] == fss_extended_list_read_delimit_mode_name_lesser_s.string[0]) { if (!(data.delimit_mode == fss_extended_list_read_delimit_mode_none_e || data.delimit_mode == fss_extended_list_read_delimit_mode_all_e)) { if (data.delimit_mode == fss_extended_list_read_delimit_mode_content_object_e) { data.delimit_mode = fss_extended_list_read_delimit_mode_content_lesser_object_e; @@ -455,14 +455,14 @@ extern "C" { f_string_range_t range = macro_f_string_range_t_initialize(length); // Ignore leading plus sign. - if (arguments->argv[location][0] == '+') { + if (argv[index][0] == f_string_ascii_plus_s[0]) { ++range.start; } - status = fl_conversion_string_to_number_unsigned(arguments->argv[location], range, &data.delimit_depth); + status = fl_conversion_string_to_number_unsigned(argv[index].string, range, &data.delimit_depth); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_list_read_long_delimit_s, arguments->argv[location]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_list_read_long_delimit_s, argv[index]); break; } @@ -568,10 +568,10 @@ extern "C" { file.stream = 0; file.id = -1; - status = f_file_stream_open(arguments->argv[main->parameters.remaining.array[i]], 0, &file); + status = f_file_stream_open(argv[main->parameters.remaining.array[i]], 0, &file); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, arguments->argv[main->parameters.remaining.array[i]], f_file_operation_open_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_open_s, fll_error_file_type_file_e); break; } @@ -580,7 +580,7 @@ extern "C" { status = f_file_size_by_id(file.id, &size_file); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, arguments->argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); break; } @@ -589,7 +589,7 @@ extern "C" { status = f_string_dynamic_resize(data.buffer.size + size_file, &data.buffer); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_resize", F_true, arguments->argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_resize", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); break; } @@ -597,12 +597,12 @@ extern "C" { status = f_file_stream_read(file, &data.buffer); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read", F_true, arguments->argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); break; } else if (data.buffer.used > data.files.array[data.files.used].range.start) { - data.files.array[data.files.used].name = arguments->argv[main->parameters.remaining.array[i]]; + data.files.array[data.files.used].name = argv[main->parameters.remaining.array[i]]; data.files.array[data.files.used++].range.stop = data.buffer.used - 1; // This standard is newline sensitive, when appending files to the buffer if the file lacks a final newline then this could break the format for files appended thereafter. diff --git a/level_3/fss_extended_list_read/c/private-read.c b/level_3/fss_extended_list_read/c/private-read.c index 0a747b9..b8f813b 100644 --- a/level_3/fss_extended_list_read/c/private-read.c +++ b/level_3/fss_extended_list_read/c/private-read.c @@ -103,12 +103,12 @@ extern "C" { else { position_depth = main->parameters.array[fss_extended_list_read_parameter_depth_e].values.array[i]; - const f_string_range_t range = macro_f_string_range_t_initialize(strlen(arguments->argv[position_depth])); + const f_string_range_t range = macro_f_string_range_t_initialize(argv[position_depth].used); - status = fl_conversion_string_to_number_unsigned(arguments->argv[position_depth], range, &data->depths.array[i].depth); + status = fl_conversion_string_to_number_unsigned(argv[position_depth].string, range, &data->depths.array[i].depth); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_list_read_long_depth_s, arguments->argv[position_depth]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_list_read_long_depth_s, argv[position_depth]); return status; } @@ -127,12 +127,12 @@ extern "C" { data->depths.array[i].index_at = main->parameters.array[fss_extended_list_read_parameter_at_e].values.array[position_at]; - const f_string_range_t range = macro_f_string_range_t_initialize(strlen(arguments->argv[data->depths.array[i].index_at])); + const f_string_range_t range = macro_f_string_range_t_initialize(argv[data->depths.array[i].index_at].used); - status = fl_conversion_string_to_number_unsigned(arguments->argv[data->depths.array[i].index_at], range, &data->depths.array[i].value_at); + status = fl_conversion_string_to_number_unsigned(argv[data->depths.array[i].index_at].string, range, &data->depths.array[i].value_at); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_list_read_long_at_s, arguments->argv[data->depths.array[i].index_at]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_list_read_long_at_s, argv[data->depths.array[i].index_at]); return status; } @@ -153,14 +153,14 @@ extern "C" { data->depths.array[i].index_name = main->parameters.array[fss_extended_list_read_parameter_name_e].values.array[position_name]; if (main->parameters.array[fss_extended_list_read_parameter_trim_e].result == f_console_result_found_e) { - status = fl_string_rip(arguments->argv[data->depths.array[i].index_name], strlen(arguments->argv[data->depths.array[i].index_name]), &data->depths.array[i].value_name); + status = fl_string_dynamic_rip(argv[data->depths.array[i].index_name], &data->depths.array[i].value_name); } else { - status = f_string_append(arguments->argv[data->depths.array[i].index_name], strlen(arguments->argv[data->depths.array[i].index_name]), &data->depths.array[i].value_name); + status = f_string_dynamic_append(argv[data->depths.array[i].index_name], &data->depths.array[i].value_name); } if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), main->parameters.array[fss_extended_list_read_parameter_trim_e].result == f_console_result_found_e ? "fl_string_rip" : "f_string_append", F_true); + fll_error_print(main->error, F_status_set_fine(status), main->parameters.array[fss_extended_list_read_parameter_trim_e].result == f_console_result_found_e ? "fl_string_dynamic_rip" : "f_string_dynamic_append", F_true); return status; } @@ -272,12 +272,12 @@ extern "C" { if (main->parameters.array[parameter].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].values.used - 1]; - const f_string_range_t range = macro_f_string_range_t_initialize(strnlen(arguments->argv[index], F_console_parameter_size_d)); + const f_string_range_t range = macro_f_string_range_t_initialize(argv[index].used); - const f_status_t status = fl_conversion_string_to_number_unsigned(arguments->argv[index], range, number); + const f_status_t status = fl_conversion_string_to_number_unsigned(argv[index].string, range, number); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, name, arguments->argv[index]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, name, argv[index]); return status; } diff --git a/level_3/fss_extended_list_write/c/fss_extended_list_write.c b/level_3/fss_extended_list_write/c/fss_extended_list_write.c index 6e4217c..77b60ea 100644 --- a/level_3/fss_extended_list_write/c/fss_extended_list_write.c +++ b/level_3/fss_extended_list_write/c/fss_extended_list_write.c @@ -179,14 +179,14 @@ extern "C" { status = F_status_set_error(F_parameter); } else { - const f_array_length_t location = main->parameters.array[fss_extended_list_write_parameter_file_e].values.array[0]; + const f_array_length_t index = main->parameters.array[fss_extended_list_write_parameter_file_e].values.array[0]; output.id = -1; output.stream = 0; - status = f_file_stream_open(arguments->argv[location], 0, &output); + status = f_file_stream_open(argv[index], f_string_empty_s, &output); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, arguments->argv[location], f_file_operation_open_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, argv[index], f_file_operation_open_s, fll_error_file_type_file_e); } } } @@ -324,12 +324,12 @@ extern "C" { } else if (main->parameters.array[fss_extended_list_write_parameter_prepend_e].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[fss_extended_list_write_parameter_prepend_e].values.array[main->parameters.array[fss_extended_list_write_parameter_prepend_e].values.used - 1]; - const f_array_length_t length = strnlen(arguments->argv[index], F_console_parameter_size_d); + const f_array_length_t length = strnlen(argv[index], F_console_parameter_size_d); if (length) { f_string_range_t range = macro_f_string_range_t_initialize(length); - main->prepend.string = arguments->argv[index]; + main->prepend.string = argv[index]; main->prepend.used = length; main->prepend.size = length; @@ -419,11 +419,8 @@ extern "C" { } f_string_dynamic_t buffer = f_string_dynamic_t_initialize; - f_string_dynamic_t object = f_string_dynamic_t_initialize; - f_string_dynamic_t content = f_string_dynamic_t_initialize; if (F_status_is_error_not(status)) { - f_string_dynamic_t escaped = f_string_dynamic_t_initialize; f_string_ranges_t ignore = f_string_ranges_t_initialize; if (main->process_pipe) { @@ -455,11 +452,7 @@ extern "C" { break; } - object.string = arguments->argv[main->parameters.array[fss_extended_list_write_parameter_object_e].values.array[i]]; - object.used = strnlen(object.string, F_console_parameter_size_d); - object.size = object.used; - - status = fss_extended_list_write_process(main, output, quote, &object, 0, 0, &buffer); + status = fss_extended_list_write_process(main, output, quote, &argv[main->parameters.array[fss_extended_list_write_parameter_object_e].values.array[i]], 0, 0, &buffer); if (F_status_is_error(status)) break; } // for } @@ -475,11 +468,7 @@ extern "C" { status = fss_extended_list_write_process_parameter_ignore(main, arguments, main->parameters.array[fss_extended_list_write_parameter_content_e].locations, i, &ignore); if (F_status_is_error(status)) break; - content.string = arguments->argv[main->parameters.array[fss_extended_list_write_parameter_content_e].values.array[i]]; - content.used = strnlen(content.string, F_console_parameter_size_d); - content.size = content.used; - - status = fss_extended_list_write_process(main, output, quote, 0, &content, &ignore, &buffer); + status = fss_extended_list_write_process(main, output, quote, 0, &argv[main->parameters.array[fss_extended_list_write_parameter_content_e].values.array[i]], &ignore, &buffer); if (F_status_is_error(status)) break; } // for } @@ -496,15 +485,7 @@ extern "C" { status = fss_extended_list_write_process_parameter_ignore(main, arguments, main->parameters.array[fss_extended_list_write_parameter_content_e].locations, i, &ignore); if (F_status_is_error(status)) break; - object.string = arguments->argv[main->parameters.array[fss_extended_list_write_parameter_object_e].values.array[i]]; - object.used = strnlen(object.string, F_console_parameter_size_d); - object.size = object.used; - - content.string = arguments->argv[main->parameters.array[fss_extended_list_write_parameter_content_e].values.array[i]]; - content.used = strnlen(content.string, F_console_parameter_size_d); - content.size = content.used; - - status = fss_extended_list_write_process(main, output, quote, &object, &content, &ignore, &buffer); + status = fss_extended_list_write_process(main, output, quote, &argv[main->parameters.array[fss_extended_list_write_parameter_object_e].values.array[i]], &argv[main->parameters.array[fss_extended_list_write_parameter_content_e].values.array[i]], &ignore, &buffer); if (F_status_is_error(status)) break; } // for } @@ -526,17 +507,7 @@ extern "C" { } } - f_string_dynamic_resize(0, &escaped); macro_f_string_ranges_t_delete_simple(ignore); - - // Object and content, though being a "dynamic" type, is being used statically, so clear them up to avoid invalid free(). - object.string = 0; - object.used = 0; - object.size = 0; - - content.string = 0; - content.used = 0; - content.size = 0; } if (main->parameters.array[fss_extended_list_write_parameter_file_e].result == f_console_result_additional_e) { @@ -553,8 +524,6 @@ extern "C" { } f_string_dynamic_resize(0, &buffer); - f_string_dynamic_resize(0, &object); - f_string_dynamic_resize(0, &content); fss_extended_list_write_main_delete(main); return status; diff --git a/level_3/fss_extended_list_write/c/private-write.c b/level_3/fss_extended_list_write/c/private-write.c index d74149a..2c3d4aa 100644 --- a/level_3/fss_extended_list_write/c/private-write.c +++ b/level_3/fss_extended_list_write/c/private-write.c @@ -399,17 +399,17 @@ extern "C" { index = main->parameters.array[fss_extended_list_write_parameter_ignore_e].values.array[i * 2]; range.start = 0; - range.stop = strnlen(arguments->argv[index], F_console_parameter_size_d) - 1; + range.stop = strnlen(argv[index], F_console_parameter_size_d) - 1; // allow and ignore the positive sign. - if (range.stop > 0 && arguments->argv[index][0] == '+') { + if (range.stop > 0 && argv[index][0] == '+') { range.start = 1; } - status = fl_conversion_string_to_number_unsigned(arguments->argv[index], range, &number); + status = fl_conversion_string_to_number_unsigned(argv[index].string, range, &number); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_list_write_long_ignore_s, arguments->argv[index]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_list_write_long_ignore_s, argv[index]); return status; } @@ -419,17 +419,17 @@ extern "C" { index = main->parameters.array[fss_extended_list_write_parameter_ignore_e].values.array[(i * 2) + 1]; range.start = 0; - range.stop = strnlen(arguments->argv[index], F_console_parameter_size_d) - 1; + range.stop = strnlen(argv[index], F_console_parameter_size_d) - 1; // allow and ignore the positive sign. - if (range.stop > 0 && arguments->argv[index][0] == '+') { + if (range.stop > 0 && argv[index][0] == '+') { range.start = 1; } - status = fl_conversion_string_to_number_unsigned(arguments->argv[index], range, &number); + status = fl_conversion_string_to_number_unsigned(argv[index].string, range, &number); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_list_write_long_ignore_s, arguments->argv[index]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_list_write_long_ignore_s, argv[index]); return status; } diff --git a/level_3/fss_extended_read/c/fss_extended_read.c b/level_3/fss_extended_read/c/fss_extended_read.c index 0db7da4..c303b3d 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ b/level_3/fss_extended_read/c/fss_extended_read.c @@ -369,7 +369,7 @@ extern "C" { } location = main->parameters.array[fss_extended_read_parameter_delimit_e].values.array[i]; - length = strnlen(arguments->argv[location], F_console_parameter_size_d); + length = strnlen(argv[location], F_console_parameter_size_d); if (!length) { flockfile(main->error.to.stream); @@ -384,13 +384,13 @@ extern "C" { break; } - else if (fl_string_compare(arguments->argv[location], fss_extended_read_delimit_mode_name_none, length, fss_extended_read_delimit_mode_name_none_length) == F_equal_to) { + else if (fl_string_compare(argv[location], fss_extended_read_delimit_mode_name_none, length, fss_extended_read_delimit_mode_name_none_length) == F_equal_to) { data.delimit_mode = fss_extended_read_delimit_mode_none_e; } - else if (fl_string_compare(arguments->argv[location], fss_extended_read_delimit_mode_name_all, length, fss_extended_read_delimit_mode_name_all_length) == F_equal_to) { + else if (fl_string_compare(argv[location], fss_extended_read_delimit_mode_name_all, length, fss_extended_read_delimit_mode_name_all_length) == F_equal_to) { data.delimit_mode = fss_extended_read_delimit_mode_all_e; } - else if (fl_string_compare(arguments->argv[location], fss_extended_read_delimit_mode_name_object, length, fss_extended_read_delimit_mode_name_object_length) == F_equal_to) { + else if (fl_string_compare(argv[location], fss_extended_read_delimit_mode_name_object, length, fss_extended_read_delimit_mode_name_object_length) == F_equal_to) { switch (data.delimit_mode) { case 0: data.delimit_mode = fss_extended_read_delimit_mode_object_e; @@ -427,7 +427,7 @@ extern "C" { data.delimit_mode = fss_extended_read_delimit_mode_content_object_e; } - if (arguments->argv[location][length - 1] == fss_extended_read_delimit_mode_name_greater[0]) { + if (argv[location][length - 1] == fss_extended_read_delimit_mode_name_greater[0]) { if (!(data.delimit_mode == fss_extended_read_delimit_mode_none_e || data.delimit_mode == fss_extended_read_delimit_mode_all_e)) { if (data.delimit_mode == fss_extended_read_delimit_mode_content_object_e) { data.delimit_mode = fss_extended_read_delimit_mode_content_greater_object_e; @@ -440,7 +440,7 @@ extern "C" { // Shorten the length to better convert the remainder to a number. --length; } - else if (arguments->argv[location][length - 1] == fss_extended_read_delimit_mode_name_lesser[0]) { + else if (argv[location][length - 1] == fss_extended_read_delimit_mode_name_lesser[0]) { if (!(data.delimit_mode == fss_extended_read_delimit_mode_none_e || data.delimit_mode == fss_extended_read_delimit_mode_all_e)) { if (data.delimit_mode == fss_extended_read_delimit_mode_content_object_e) { data.delimit_mode = fss_extended_read_delimit_mode_content_lesser_object_e; @@ -457,14 +457,14 @@ extern "C" { f_string_range_t range = macro_f_string_range_t_initialize(length); // Ignore leading plus sign. - if (arguments->argv[location][0] == '+') { + if (argv[location][0] == '+') { ++range.start; } - status = fl_conversion_string_to_number_unsigned(arguments->argv[location], range, &data.delimit_depth); + status = fl_conversion_string_to_number_unsigned(argv[location], range, &data.delimit_depth); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_read_long_delimit_s, arguments->argv[location]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, fss_extended_read_long_delimit_s, argv[location]); break; } @@ -574,10 +574,10 @@ extern "C" { file.stream = 0; file.id = -1; - status = f_file_stream_open(arguments->argv[main->parameters.remaining.array[i]], 0, &file); + status = f_file_stream_open(argv[main->parameters.remaining.array[i]], 0, &file); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, arguments->argv[main->parameters.remaining.array[i]], f_file_operation_open_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_open_s, fll_error_file_type_file_e); break; } @@ -586,7 +586,7 @@ extern "C" { status = f_file_size_by_id(file.id, &size_file); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, arguments->argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); break; } @@ -595,7 +595,7 @@ extern "C" { status = f_string_dynamic_resize(data.buffer.size + size_file, &data.buffer); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_resize", F_true, arguments->argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_string_dynamic_resize", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); break; } @@ -603,13 +603,13 @@ extern "C" { status = f_file_stream_read(file, &data.buffer); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read", F_true, arguments->argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_read", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_read_s, fll_error_file_type_file_e); break; } if (data.buffer.used > data.files.array[data.files.used].range.start) { - data.files.array[data.files.used].name = arguments->argv[main->parameters.remaining.array[i]]; + data.files.array[data.files.used].name = argv[main->parameters.remaining.array[i]]; data.files.array[data.files.used++].range.stop = data.buffer.used - 1; // This standard is newline sensitive, when appending files to the buffer if the file lacks a final newline then this could break the format for files appended thereafter. diff --git a/level_3/fss_extended_write/c/fss_extended_write.c b/level_3/fss_extended_write/c/fss_extended_write.c index 71a1691..0cb75cf 100644 --- a/level_3/fss_extended_write/c/fss_extended_write.c +++ b/level_3/fss_extended_write/c/fss_extended_write.c @@ -175,14 +175,14 @@ extern "C" { status = F_status_set_error(F_parameter); } else { - const f_array_length_t location = main->parameters.array[fss_extended_write_parameter_file_e].values.array[0]; + const f_array_length_t index = main->parameters.array[fss_extended_write_parameter_file_e].values.array[0]; output.id = -1; output.stream = 0; - status = f_file_stream_open(arguments->argv[location], 0, &output); + status = f_file_stream_open(argv[index], f_string_empty_s, &output); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, arguments->argv[location], f_file_operation_open_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, argv[index], f_file_operation_open_s, fll_error_file_type_file_e); } } } @@ -334,16 +334,14 @@ extern "C" { } else if (main->parameters.array[fss_extended_write_parameter_prepend_e].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[fss_extended_write_parameter_prepend_e].values.array[main->parameters.array[fss_extended_write_parameter_prepend_e].values.used - 1]; - const f_array_length_t length = strnlen(arguments->argv[index], F_console_parameter_size_d); // Even though this standard does not utilize this parameter, provide the validation for consistency. - if (length) { - f_string_range_t range = macro_f_string_range_t_initialize(length); - const f_string_static_t prepend = macro_f_string_static_t_initialize2(arguments->argv[index], length); + if (argv[index].used) { + f_string_range_t range = macro_f_string_range_t_initialize(argv[index].used); for (; range.start < length; ++range.start) { - status = f_fss_is_space(prepend, range); + status = f_fss_is_space(argv[index], range); if (F_status_is_error(status)) break; if (status == F_false) { @@ -466,7 +464,7 @@ extern "C" { signal_check = 0; } - object.string = arguments->argv[main->parameters.array[fss_extended_write_parameter_object_e].values.array[i]]; + object.string = argv[main->parameters.array[fss_extended_write_parameter_object_e].values.array[i]]; object.used = strnlen(object.string, F_console_parameter_size_d); object.size = object.used; @@ -491,7 +489,7 @@ extern "C" { for (; i < main->parameters.array[fss_extended_write_parameter_content_e].values.used; ++i) { - contents.array[contents.used].string = arguments->argv[main->parameters.array[fss_extended_write_parameter_content_e].values.array[i]]; + contents.array[contents.used].string = argv[main->parameters.array[fss_extended_write_parameter_content_e].values.array[i]]; contents.array[contents.used].used = strnlen(contents.array[contents.used].string, F_console_parameter_size_d); contents.array[contents.used].size = contents.array[contents.used].used; ++contents.used; @@ -535,7 +533,7 @@ extern "C" { object_next = main->parameters.array[fss_extended_write_parameter_object_e].locations.array[i + 1]; } - object.string = arguments->argv[main->parameters.array[fss_extended_write_parameter_object_e].values.array[i]]; + object.string = argv[main->parameters.array[fss_extended_write_parameter_object_e].values.array[i]]; object.used = strnlen(object.string, F_console_parameter_size_d); object.size = object.used; @@ -561,7 +559,7 @@ extern "C" { contents.array[contents.used].used = 0; } - status = f_string_append(arguments->argv[main->parameters.array[fss_extended_write_parameter_content_e].values.array[j]], strnlen(arguments->argv[main->parameters.array[fss_extended_write_parameter_content_e].values.array[j]], F_console_parameter_size_d), &contents.array[contents.used]); + status = f_string_append(argv[main->parameters.array[fss_extended_write_parameter_content_e].values.array[j]], strnlen(argv[main->parameters.array[fss_extended_write_parameter_content_e].values.array[j]], F_console_parameter_size_d), &contents.array[contents.used]); if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "f_string_append", F_true); diff --git a/level_3/fss_identify/c/private-print.c b/level_3/fss_identify/c/private-print.c index 4be9196..bc8b53b 100644 --- a/level_3/fss_identify/c/private-print.c +++ b/level_3/fss_identify/c/private-print.c @@ -15,7 +15,7 @@ extern "C" { f_print(id.name, id.used, main->output.to.stream); if (main->parameters.array[fss_identify_parameter_object_e].result != f_console_result_found_e || main->parameters.array[fss_identify_parameter_content_e].result == f_console_result_found_e) { - f_print_terminated(f_fss_type_header_part5_s, main->output.to.stream); + f_print_dynamic_raw(f_fss_type_header_part5_s, main->output.to.stream); } } diff --git a/level_3/fss_status_code/c/common.c b/level_3/fss_status_code/c/common.c index f9744fd..3b5d980 100644 --- a/level_3/fss_status_code/c/common.c +++ b/level_3/fss_status_code/c/common.c @@ -4,6 +4,15 @@ extern "C" { #endif +#ifndef _di_fss_status_code_program_version_ + const f_string_static_t fss_status_code_program_version_s = macro_f_string_static_t_initialize(FSS_STATUS_CODE_program_version_s, 0, FSS_STATUS_CODE_program_version_s_length); +#endif // _di_fss_status_code_program_version_ + +#ifndef _di_fss_status_code_program_name_ + const f_string_static_t fss_status_code_program_name_s = macro_f_string_static_t_initialize(FSS_STATUS_CODE_program_name_s, 0, FSS_STATUS_CODE_program_name_s_length); + const f_string_static_t fss_status_code_program_name_long_s = macro_f_string_static_t_initialize(FSS_STATUS_CODE_program_name_long_s, 0, FSS_STATUS_CODE_program_name_long_s_length); +#endif // _di_fss_status_code_program_name_ + #ifndef _di_fss_status_code_program_help_parameters_ const f_string_static_t fss_status_code_program_help_parameters_s = macro_f_string_static_t_initialize(FSS_STATUS_CODE_program_help_parameters_s, 0, FSS_STATUS_CODE_program_help_parameters_s_length); #endif // _di_fss_status_code_program_help_parameters_ diff --git a/level_3/fss_status_code/c/common.h b/level_3/fss_status_code/c/common.h index b9855df..12246be 100644 --- a/level_3/fss_status_code/c/common.h +++ b/level_3/fss_status_code/c/common.h @@ -20,25 +20,27 @@ extern "C" { * The program version. */ #ifndef _di_fss_status_code_program_version_ - #define FSS_STATUS_code_program_version_major_s F_string_ascii_0_s - #define FSS_STATUS_code_program_version_minor_s F_string_ascii_5_s - #define FSS_STATUS_code_program_version_micro_s F_string_ascii_8_s + #define FSS_STATUS_CODE_program_version_major_s F_string_ascii_0_s + #define FSS_STATUS_CODE_program_version_minor_s F_string_ascii_5_s + #define FSS_STATUS_CODE_program_version_micro_s F_string_ascii_8_s - #define FSS_STATUS_code_program_version_major_s_length F_string_ascii_0_s_length - #define FSS_STATUS_code_program_version_minor_s_length F_string_ascii_5_s_length - #define FSS_STATUS_code_program_version_micro_s_length F_string_ascii_8_s_length + #define FSS_STATUS_CODE_program_version_major_s_length F_string_ascii_0_s_length + #define FSS_STATUS_CODE_program_version_minor_s_length F_string_ascii_5_s_length + #define FSS_STATUS_CODE_program_version_micro_s_length F_string_ascii_8_s_length - #if !(defined(FSS_STATUS_program_version_nano_prefix_s) && defined(FSS_STATUS_program_version_nano_prefix_s_length)) - #define FSS_STATUS_program_version_nano_prefix_s - #define FSS_STATUS_program_version_nano_prefix_s_length 0 - #endif // !(defined(FSS_STATUS_program_version_nano_prefix_s) && defined(FSS_STATUS_program_version_nano_prefix_s_length)) + #if !(defined(FSS_STATUS_CODE_program_version_nano_prefix_s) && defined(FSS_STATUS_CODE_program_version_nano_prefix_s_length)) + #define FSS_STATUS_CODE_program_version_nano_prefix_s + #define FSS_STATUS_CODE_program_version_nano_prefix_s_length 0 + #endif // !(defined(FSS_STATUS_CODE_program_version_nano_prefix_s) && defined(FSS_STATUS_CODE_program_version_nano_prefix_s_length)) - #if !(defined(FSS_STATUS_program_version_nano_s) && defined(FSS_STATUS_program_version_nano_s_length)) - #define FSS_STATUS_program_version_nano_s - #define FSS_STATUS_program_version_nano_s_length 0 - #endif // !(defined(FSS_STATUS_program_version_nano_s) && defined(FSS_STATUS_program_version_nano_s_length)) + #if !(defined(FSS_STATUS_CODE_program_version_nano_s) && defined(FSS_STATUS_CODE_program_version_nano_s_length)) + #define FSS_STATUS_CODE_program_version_nano_s + #define FSS_STATUS_CODE_program_version_nano_s_length 0 + #endif // !(defined(FSS_STATUS_CODE_program_version_nano_s) && defined(FSS_STATUS_CODE_program_version_nano_s_length)) - #define FSS_STATUS_code_program_version_length_s FSS_STATUS_code_program_version_major_s F_string_ascii_period_s FSS_STATUS_code_program_version_minor_s F_string_ascii_period_s FSS_STATUS_code_program_version_micro_s FSS_STATUS_code_program_version_nano_prefix_s FSS_STATUS_code_program_version_nano_s + #define FSS_STATUS_CODE_program_version_s FSS_STATUS_CODE_program_version_major_s F_string_ascii_period_s FSS_STATUS_CODE_program_version_minor_s F_string_ascii_period_s FSS_STATUS_CODE_program_version_micro_s FSS_STATUS_CODE_program_version_nano_prefix_s FSS_STATUS_CODE_program_version_nano_s + + #define FSS_STATUS_CODE_program_version_s_length FSS_STATUS_CODE_program_version_major_s_length + F_string_ascii_period_s_length + FSS_STATUS_CODE_program_version_minor_s_length + F_string_ascii_period_s_length + FSS_STATUS_CODE_program_version_micro_s_length + FSS_STATUS_CODE_program_version_nano_prefix_s_length + FSS_STATUS_CODE_program_version_nano_s_length extern const f_string_static_t fss_status_code_program_version_s; #endif // _di_fss_status_code_program_version_ @@ -47,11 +49,11 @@ extern "C" { * The program name. */ #ifndef _di_fss_status_code_program_name_ - #define FSS_STATUS_code_program_name_s "FSS_STATUS_code" - #define FSS_STATUS_code_program_name_long_s "FSS Status Code" + #define FSS_STATUS_CODE_program_name_s "fss_status_code" + #define FSS_STATUS_CODE_program_name_long_s "FSS Status Code" - #define FSS_STATUS_CODE_program_name_s_length - #define FSS_STATUS_CODE_program_name_long_s_length + #define FSS_STATUS_CODE_program_name_s_length 15 + #define FSS_STATUS_CODE_program_name_long_s_length 15 const f_string_static_t fss_status_code_program_name_s; const f_string_static_t fss_status_code_program_name_long_s; diff --git a/level_3/fss_status_code/c/fss_status_code.c b/level_3/fss_status_code/c/fss_status_code.c index c3247ec..95eb9f1 100644 --- a/level_3/fss_status_code/c/fss_status_code.c +++ b/level_3/fss_status_code/c/fss_status_code.c @@ -6,15 +6,6 @@ extern "C" { #endif -#ifndef _di_fss_status_code_program_version_ - const f_string_static_t fss_status_code_program_version_s = macro_f_string_static_t_initialize(FSS_STATUS_CODE_program_version_s, 0, FSS_STATUS_CODE_program_version_s_length); -#endif // _di_fss_status_code_program_version_ - -#ifndef _di_fss_status_code_program_name_ - const f_string_static_t fss_status_code_program_name_s = macro_f_string_static_t_initialize(FSS_STATUS_CODE_program_name_s, 0, FSS_STATUS_CODE_program_name_s_length); - const f_string_static_t fss_status_code_program_name_long_s = macro_f_string_static_t_initialize(FSS_STATUS_CODE_program_name_long_s, 0, FSS_STATUS_CODE_program_name_long_s_length); -#endif // _di_fss_status_code_program_name_ - #ifndef _di_fss_status_code_print_help_ f_status_t fss_status_code_print_help(const f_file_t file, const f_color_context_t context) { @@ -84,6 +75,7 @@ extern "C" { if (F_status_is_error(status)) { fss_status_code_main_delete(main); + return F_status_set_error(status); } } @@ -98,6 +90,7 @@ extern "C" { if (F_status_is_error(status)) { fss_status_code_main_delete(main); + return status; } @@ -131,6 +124,7 @@ extern "C" { fss_status_code_print_help(main->output.to, main->context); fss_status_code_main_delete(main); + return F_none; } @@ -138,6 +132,7 @@ extern "C" { fll_program_print_version(main->output.to, fss_status_code_program_version_s); fss_status_code_main_delete(main); + return F_none; } @@ -154,9 +149,11 @@ extern "C" { funlockfile(main->error.to.stream); fss_status_code_main_delete(main); + return F_status_set_error(status); } - else if (main->parameters.array[fss_status_code_parameter_is_fine_e].result == f_console_result_found_e) { + + if (main->parameters.array[fss_status_code_parameter_is_fine_e].result == f_console_result_found_e) { flockfile(main->error.to.stream); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); @@ -168,6 +165,7 @@ extern "C" { funlockfile(main->error.to.stream); fss_status_code_main_delete(main); + return F_status_set_error(status); } } @@ -183,6 +181,7 @@ extern "C" { funlockfile(main->error.to.stream); fss_status_code_main_delete(main); + return F_status_set_error(status); } @@ -190,6 +189,7 @@ extern "C" { fll_print_format("%[You failed to specify an error code.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); fss_status_code_main_delete(main); + return F_status_set_error(F_parameter); } @@ -210,13 +210,14 @@ extern "C" { if (!((++signal_check) % fss_status_code_signal_check_d)) { if (fss_status_code_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } signal_check = 0; } - status2 = fss_status_code_process_check(main, arguments->argv[main->parameters.remaining.array[i]]); + status2 = fss_status_code_process_check(main, argv[main->parameters.remaining.array[i]]); if (F_status_is_error(status2) && status == F_none) { status = status2; @@ -241,13 +242,14 @@ extern "C" { if (!((++signal_check) % fss_status_code_signal_check_d)) { if (fss_status_code_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } signal_check = 0; } - status2 = fss_status_code_process_number(main, arguments->argv[main->parameters.remaining.array[i]]); + status2 = fss_status_code_process_number(main, argv[main->parameters.remaining.array[i]]); if (F_status_is_error(status2) && status == F_none) { status = status2; @@ -272,13 +274,14 @@ extern "C" { if (!((++signal_check) % fss_status_code_signal_check_d)) { if (fss_status_code_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } signal_check = 0; } - status2 = fss_status_code_process_normal(main, arguments->argv[main->parameters.remaining.array[i]]); + status2 = fss_status_code_process_normal(main, argv[main->parameters.remaining.array[i]]); if (F_status_is_error(status2) && status == F_none) { status = status2; diff --git a/level_3/fss_status_code/c/private-fss_status_code.c b/level_3/fss_status_code/c/private-fss_status_code.c index 2b0f84a..df6c258 100644 --- a/level_3/fss_status_code/c/private-fss_status_code.c +++ b/level_3/fss_status_code/c/private-fss_status_code.c @@ -7,7 +7,7 @@ extern "C" { #endif #ifndef _di_fss_status_code_process_check_ - f_status_t fss_status_code_process_check(fll_program_data_t * const main, const f_string_t value) { + f_status_t fss_status_code_process_check(fll_program_data_t * const main, const f_string_static_t value) { f_number_unsigned_t number = 0; @@ -18,30 +18,30 @@ extern "C" { if (main->parameters.array[fss_status_code_parameter_is_error_e].result == f_console_result_found_e) { if (F_status_is_error(number)) { - f_print_terminated(f_status_true_s, main->output.to.stream); + f_print_dynamic_raw(f_status_true_s, main->output.to.stream); } else { - f_print_terminated(f_status_false_s, main->output.to.stream); + f_print_dynamic_raw(f_status_false_s, main->output.to.stream); } f_print_dynamic_raw(f_string_eol_s, main->output.to.stream); } else if (main->parameters.array[fss_status_code_parameter_is_warning_e].result == f_console_result_found_e) { if (F_status_is_warning(number)) { - f_print_terminated(f_status_true_s, main->output.to.stream); + f_print_dynamic_raw(f_status_true_s, main->output.to.stream); } else { - f_print_terminated(f_status_false_s, main->output.to.stream); + f_print_dynamic_raw(f_status_false_s, main->output.to.stream); } f_print_dynamic_raw(f_string_eol_s, main->output.to.stream); } else if (main->parameters.array[fss_status_code_parameter_is_fine_e].result == f_console_result_found_e) { if (F_status_is_fine(number)) { - f_print_terminated(f_status_true_s, main->output.to.stream); + f_print_dynamic_raw(f_status_true_s, main->output.to.stream); } else { - f_print_terminated(f_status_false_s, main->output.to.stream); + f_print_dynamic_raw(f_status_false_s, main->output.to.stream); } f_print_dynamic_raw(f_string_eol_s, main->output.to.stream); @@ -52,16 +52,16 @@ extern "C" { #endif // _di_fss_status_code_process_check_ #ifndef _di_fss_status_code_process_number_ - f_status_t fss_status_code_process_number(fll_program_data_t * const main, const f_string_t value) { + f_status_t fss_status_code_process_number(fll_program_data_t * const main, const f_string_static_t value) { f_status_t status = F_none; { - const f_string_range_t range = macro_f_string_range_t_initialize(strlen(value)); + const f_string_range_t range = macro_f_string_range_t_initialize(value.used); f_number_unsigned_t number = 0; - status = fl_conversion_string_to_number_unsigned(value, range, &number); + status = fl_conversion_string_to_number_unsigned(value.string, range, &number); if (status == F_none) { fl_print_format("%[invalid name%]%r", main->output.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); @@ -110,17 +110,16 @@ extern "C" { #endif // _di_fss_status_code_process_number_ #ifndef _di_fss_status_code_process_normal_ - f_status_t fss_status_code_process_normal(fll_program_data_t * const main, const f_string_t value) { + f_status_t fss_status_code_process_normal(fll_program_data_t * const main, const f_string_static_t value) { f_number_unsigned_t number = 0; f_status_t status = fss_status_code_convert_number(main, value, &number); if (F_status_is_error(status)) return status; - const f_status_t code = (f_status_t) number; - f_string_t string = 0; + f_string_static_t name = f_string_static_t_initialize; - status = fll_fss_status_string_to(code, &string); + status = fll_fss_status_string_to((f_status_t) number, &name); if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_data) { @@ -133,18 +132,18 @@ extern "C" { return status; } - fl_print_format("%S%r", main->output.to.stream, string, f_string_eol_s); + fl_print_format("%Q%r", main->output.to.stream, name, f_string_eol_s); return F_none; } #endif // _di_fss_status_code_process_normal_ #ifndef _di_fss_status_code_convert_number_ - f_status_t fss_status_code_convert_number(fll_program_data_t * const main, const f_string_t value, f_number_unsigned_t *number) { + f_status_t fss_status_code_convert_number(fll_program_data_t * const main, const f_string_static_t value, f_number_unsigned_t *number) { - const f_string_range_t range = macro_f_string_range_t_initialize(strlen(value)); + const f_string_range_t range = macro_f_string_range_t_initialize(value.used); - f_status_t status = fl_conversion_string_to_number_unsigned(value, range, number); + f_status_t status = fl_conversion_string_to_number_unsigned(value.string, range, number); if (*number > F_status_size_max_with_signal) { fl_print_format("%[out of range%]%r", main->output.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); diff --git a/level_3/fss_status_code/c/private-fss_status_code.h b/level_3/fss_status_code/c/private-fss_status_code.h index 648718d..a4f53d3 100644 --- a/level_3/fss_status_code/c/private-fss_status_code.h +++ b/level_3/fss_status_code/c/private-fss_status_code.h @@ -34,7 +34,7 @@ extern "C" { * @see fss_status_code_convert_number() */ #ifndef _di_fss_status_code_process_check_ - extern f_status_t fss_status_code_process_check(fll_program_data_t * const main, const f_string_t value) F_attribute_visibility_internal_d; + extern f_status_t fss_status_code_process_check(fll_program_data_t * const main, const f_string_static_t value) F_attribute_visibility_internal_d; #endif // _di_fss_status_code_process_check_ /** @@ -56,7 +56,7 @@ extern "C" { * @see fll_fss_status_string_from() */ #ifndef _di_fss_status_code_process_number_ - extern f_status_t fss_status_code_process_number(fll_program_data_t * const main, const f_string_t value) F_attribute_visibility_internal_d; + extern f_status_t fss_status_code_process_number(fll_program_data_t * const main, const f_string_static_t value) F_attribute_visibility_internal_d; #endif // _di_fss_status_code_process_number_ /** @@ -83,7 +83,7 @@ extern "C" { * @see fss_status_code_convert_number() */ #ifndef _di_fss_status_code_process_normal_ - extern f_status_t fss_status_code_process_normal(fll_program_data_t * const main, const f_string_t value) F_attribute_visibility_internal_d; + extern f_status_t fss_status_code_process_normal(fll_program_data_t * const main, const f_string_static_t value) F_attribute_visibility_internal_d; #endif // _di_fss_status_code_process_normal_ /** @@ -111,7 +111,7 @@ extern "C" { * @see fl_console_parameter_to_number_unsigned() */ #ifndef _di_fss_status_code_convert_number_ - extern f_status_t fss_status_code_convert_number(fll_program_data_t * const main, const f_string_t value, f_number_unsigned_t *number) F_attribute_visibility_internal_d; + extern f_status_t fss_status_code_convert_number(fll_program_data_t * const main, const f_string_static_t value, f_number_unsigned_t *number) F_attribute_visibility_internal_d; #endif // _di_fss_status_code_convert_number_ #ifdef __cplusplus diff --git a/level_3/iki_read/c/common.c b/level_3/iki_read/c/common.c index 5f2872c..44a8021 100644 --- a/level_3/iki_read/c/common.c +++ b/level_3/iki_read/c/common.c @@ -35,6 +35,20 @@ extern "C" { const f_string_static_t iki_read_long_whole_s = macro_f_string_static_t_initialize(IKI_READ_long_whole_s, 0, IKI_READ_long_whole_s_length); #endif // _di_iki_read_parameters_ +#ifndef _di_iki_read_substitution_t_ + #define IKI_READ_substitution_vocabulary_s "vocabulary" + #define IKI_READ_substitution_replace_s "replace" + #define IKI_READ_substitution_with_s "with" + + #define IKI_READ_substitution_vocabulary_s_length 10 + #define IKI_READ_substitution_replace_s_length 7 + #define IKI_READ_substitution_with_s_length 4 + + const f_string_static_t iki_read_substitution_vocabulary_s = macro_f_string_static_t_initialize(IKI_READ_substitution_vocabulary_s, 0, IKI_READ_substitution_vocabulary_s_length); + const f_string_static_t iki_read_substitution_replace_s = macro_f_string_static_t_initialize(IKI_READ_substitution_replace_s, 0, IKI_READ_substitution_replace_s_length); + const f_string_static_t iki_read_substitution_with_s = macro_f_string_static_t_initialize(IKI_READ_substitution_with_s, 0, IKI_READ_substitution_with_s_length); +#endif // _di_iki_read_substitution_t_ + #ifndef _di_iki_read_main_delete_ f_status_t iki_read_main_delete(iki_read_main_t * const main) { diff --git a/level_3/iki_read/c/common.h b/level_3/iki_read/c/common.h index 012f9a5..2149dad 100644 --- a/level_3/iki_read/c/common.h +++ b/level_3/iki_read/c/common.h @@ -40,7 +40,7 @@ extern "C" { #define IKI_READ_program_version_s IKI_READ_program_version_major_s F_string_ascii_period_s IKI_READ_program_version_minor_s F_string_ascii_period_s IKI_READ_program_version_micro_s IKI_READ_program_version_nano_prefix_s IKI_READ_program_version_nano_s - #define IKI_READ_program_version_s_length iki_read_program_version_major_s_length + F_string_ascii_period_s iki_read_program_version_minor_s_length + F_string_ascii_period_s_length + iki_read_program_version_micro_s_length + iki_read_program_version_nano_prefix_s_length + iki_read_program_version_nano_s_length + #define IKI_READ_program_version_s_length IKI_READ_program_version_major_s_length + F_string_ascii_period_s_length + IKI_READ_program_version_minor_s_length + F_string_ascii_period_s_length + IKI_READ_program_version_micro_s_length + IKI_READ_program_version_nano_prefix_s_length + IKI_READ_program_version_nano_s_length extern const f_string_static_t iki_read_program_version_s; #endif // _di_iki_read_program_version_ @@ -52,8 +52,8 @@ extern "C" { #define IKI_READ_program_name_s "iki_read" #define IKI_READ_program_name_long_s "IKI Read" - #define IKI_READ_program_name_s_length 9 - #define IKI_READ_program_name_long_s_length 9 + #define IKI_READ_program_name_s_length 8 + #define IKI_READ_program_name_long_s_length 8 extern const f_string_static_t iki_read_program_name_s; extern const f_string_static_t iki_read_program_name_long_s; @@ -185,9 +185,17 @@ extern "C" { #endif // _di_iki_read_parameters_ #ifndef _di_iki_read_substitution_t_ - #define iki_read_substitution_vocabulary_s "vocabulary" - #define iki_read_substitution_replace_s "replace" - #define iki_read_substitution_with_s "with" + #define IKI_READ_substitution_vocabulary_s "vocabulary" + #define IKI_READ_substitution_replace_s "replace" + #define IKI_READ_substitution_with_s "with" + + #define IKI_READ_substitution_vocabulary_s_length 10 + #define IKI_READ_substitution_replace_s_length 7 + #define IKI_READ_substitution_with_s_length 4 + + extern const f_string_static_t iki_read_substitution_vocabulary_s; + extern const f_string_static_t iki_read_substitution_replace_s; + extern const f_string_static_t iki_read_substitution_with_s; typedef struct { f_string_static_t replace; @@ -230,7 +238,6 @@ extern "C" { * The main program data. * * parameters: The state of pre-defined parameters passed to the program. - * remaining: The remaining, non-pre-defined parameters, passed to the program. * process_pipe: Designate whether or not to process the input pipe. * output: The output file for general printing. * error: The output file for error printing. @@ -267,7 +274,6 @@ extern "C" { #define iki_read_main_t_initialize \ { \ f_console_parameters_t_initialize, \ - f_array_lengths_t_initialize, \ F_false, \ fl_print_t_initialize, \ macro_fl_print_t_initialize_error(), \ diff --git a/level_3/iki_read/c/iki_read.c b/level_3/iki_read/c/iki_read.c index 8c5b5a0..39ba5a2 100644 --- a/level_3/iki_read/c/iki_read.c +++ b/level_3/iki_read/c/iki_read.c @@ -46,14 +46,14 @@ extern "C" { fl_print_format(" %[Notes:%]%r", file.stream, context.set.important, context.set.important, f_string_eol_s); fl_print_format(" This program will find and print variables, vocabularies, or content following the IKI standard, without focusing on any particular vocabulary specification.%r%r", file.stream, f_string_eol_s, f_string_eol_s); - fl_print_format(" This %[%r%s%] option, requires 3 additional parameters:", file.stream, context.set.notable, f_console_symbol_long_enable_s, iki_read_long_substitute_s, context.set.notable); - fl_print_format(" %[<%]%s%[>%]", file.stream, context.set.notable, context.set.notable, iki_read_substitution_vocabulary_s, context.set.notable, context.set.notable); - fl_print_format(" %[<%]%s%[>%]", file.stream, context.set.notable, context.set.notable, iki_read_substitution_replace_s, context.set.notable, context.set.notable); - fl_print_format(" %[<%]%s%[>%].%r", file.stream, context.set.notable, context.set.notable, iki_read_substitution_with_s, context.set.notable, context.set.notable, f_string_eol_s); + fl_print_format(" This %[%r%r%] option, requires 3 additional parameters:", file.stream, context.set.notable, f_console_symbol_long_enable_s, iki_read_long_substitute_s, context.set.notable); + fl_print_format(" %[<%]%r%[>%]", file.stream, context.set.notable, context.set.notable, iki_read_substitution_vocabulary_s, context.set.notable, context.set.notable); + fl_print_format(" %[<%]%r%[>%]", file.stream, context.set.notable, context.set.notable, iki_read_substitution_replace_s, context.set.notable, context.set.notable); + fl_print_format(" %[<%]%r%[>%].%r", file.stream, context.set.notable, context.set.notable, iki_read_substitution_with_s, context.set.notable, context.set.notable, f_string_eol_s); - fl_print_format(" %[%s%]: The name of the vocabulary whose content is to be substituted.%r", file.stream, context.set.notable, iki_read_substitution_vocabulary_s, context.set.notable, f_string_eol_s); - fl_print_format(" %[%s%]: The content matching this exact string will be substituted.%r", file.stream, context.set.notable, iki_read_substitution_replace_s, context.set.notable, f_string_eol_s); - fl_print_format(" %[%s%]: The new string to use as the substitute.%r%r", file.stream, context.set.notable, iki_read_substitution_with_s, context.set.notable, f_string_eol_s, f_string_eol_s); + fl_print_format(" %[%r%]: The name of the vocabulary whose content is to be substituted.%r", file.stream, context.set.notable, iki_read_substitution_vocabulary_s, context.set.notable, f_string_eol_s); + fl_print_format(" %[%r%]: The content matching this exact string will be substituted.%r", file.stream, context.set.notable, iki_read_substitution_replace_s, context.set.notable, f_string_eol_s); + fl_print_format(" %[%r%]: The new string to use as the substitute.%r%r", file.stream, context.set.notable, iki_read_substitution_with_s, context.set.notable, f_string_eol_s, f_string_eol_s); fl_print_format(" The vocabulary and replacement are case-sensitive and must exactly match.%r%r", file.stream, f_string_eol_s, f_string_eol_s); @@ -187,14 +187,14 @@ extern "C" { } else if (main->parameters.array[iki_read_parameter_at_e].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[iki_read_parameter_at_e].values.array[main->parameters.array[iki_read_parameter_at_e].values.used - 1]; - const f_string_range_t range = macro_f_string_range_t_initialize(strlen(arguments->argv[index])); + const f_string_range_t range = macro_f_string_range_t_initialize(argv[index].used); f_number_unsigned_t number = 0; - status = fl_conversion_string_to_number_unsigned(arguments->argv[index], range, &number); + status = fl_conversion_string_to_number_unsigned(argv[index].string, range, &number); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, F_console_symbol_long_enable_s iki_read_long_at_s, arguments->argv[index]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, iki_read_long_at_s, argv[index]); status = F_status_set_error(F_parameter); } @@ -233,14 +233,14 @@ extern "C" { } else if (main->parameters.array[iki_read_parameter_line_e].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[iki_read_parameter_line_e].values.array[main->parameters.array[iki_read_parameter_line_e].values.used - 1]; - const f_string_range_t range = macro_f_string_range_t_initialize(strlen(arguments->argv[index])); + const f_string_range_t range = macro_f_string_range_t_initialize(argv[index].used); f_number_unsigned_t number = 0; - status = fl_conversion_string_to_number_unsigned(arguments->argv[index], range, &number); + status = fl_conversion_string_to_number_unsigned(argv[index].string, range, &number); if (F_status_is_error(status)) { - fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, F_console_symbol_long_enable_s iki_read_long_line_s, arguments->argv[index]); + fll_error_parameter_integer_print(main->error, F_status_set_fine(status), "fl_conversion_string_to_number_unsigned", F_true, iki_read_long_line_s, argv[index]); status = F_status_set_error(F_parameter); } @@ -384,7 +384,8 @@ extern "C" { main->mode = iki_read_mode_total_e; } else { - // this is the default behavior, so there is no reason to check for the -c/--content parameter. + + // This is the default behavior, so there is no reason to check for the -c/--content parameter. main->mode = iki_read_mode_content_e; } @@ -424,10 +425,10 @@ extern "C" { status = f_file_read(file, &main->buffer); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_read", F_true, "-", f_file_operation_process_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_read", F_true, f_string_ascii_minus_s, f_file_operation_process_s, fll_error_file_type_file_e); } else { - status = iki_read_process_buffer(main, arguments, "-"); + status = iki_read_process_buffer(main); } // Clear buffers before continuing. @@ -435,15 +436,16 @@ extern "C" { } if (F_status_is_fine(status) && main->parameters.remaining.used > 0) { - f_array_length_t i = 0; + uint16_t signal_check = 0; f_array_length_t total = 0; f_file_t file = f_file_t_initialize; - for (uint16_t signal_check = 0; i < main->parameters.remaining.used; ++i) { + for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { if (!((++signal_check) % iki_read_signal_check_d)) { if (iki_read_signal_received(main)) { status = F_status_set_error(F_interrupt); + break; } @@ -453,25 +455,28 @@ extern "C" { macro_f_file_t_reset(file); total = 0; - status = f_file_open(arguments->argv[main->parameters.remaining.array[i]], 0, &file); + status = f_file_open(argv[main->parameters.remaining.array[i]], 0, &file); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_open", F_true, arguments->argv[main->parameters.remaining.array[i]], f_file_operation_process_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_open", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_process_s, fll_error_file_type_file_e); + break; } status = f_file_size_by_id(file.id, &total); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, arguments->argv[main->parameters.remaining.array[i]], f_file_operation_process_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_size_by_id", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_process_s, fll_error_file_type_file_e); f_file_stream_close(F_true, &file); + break; } // Skip past empty files. if (!total) { f_file_stream_close(F_true, &file); + continue; } @@ -480,11 +485,12 @@ extern "C" { f_file_stream_close(F_true, &file); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_read_until", F_true, arguments->argv[main->parameters.remaining.array[i]], f_file_operation_process_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_read_until", F_true, argv[main->parameters.remaining.array[i]], f_file_operation_process_s, fll_error_file_type_file_e); + break; } - status = iki_read_process_buffer(main, arguments, arguments->argv[main->parameters.remaining.array[i]]); + status = iki_read_process_buffer(main); if (F_status_is_error(status)) break; // Clear buffers before repeating the loop. diff --git a/level_3/iki_read/c/private-print.c b/level_3/iki_read/c/private-print.c index b995e85..a268364 100644 --- a/level_3/iki_read/c/private-print.c +++ b/level_3/iki_read/c/private-print.c @@ -10,17 +10,11 @@ extern "C" { void iki_read_substitutions_print(iki_read_main_t * const main, const iki_data_t iki_data, const f_string_ranges_t ranges, const iki_read_substitutions_t substitutions, const f_array_length_t index, const bool content_only) { f_status_t status = F_none; - f_array_length_t i = 0; - f_string_range_t range = f_string_range_t_initialize; - - range.start = 0; for (; i < substitutions.used; ++i) { - range.stop = substitutions.array[i].replace.used - 1; - - status = fl_string_dynamic_partial_compare(substitutions.array[i].replace, main->buffer, range, iki_data.content.array[index]); + status = fl_string_dynamic_partial_compare_string(substitutions.array[i].replace.string, main->buffer, substitutions.array[i].replace.used, iki_data.content.array[index]); if (status == F_equal_to) break; } // for @@ -29,8 +23,7 @@ extern "C" { f_print_dynamic(substitutions.array[i].with, main->output.to.stream); } else { - range.start = iki_data.variable.array[index].start; - range.stop = iki_data.content.array[index].start - 1; + f_string_range_t range = macro_f_string_range_t_initialize2(iki_data.variable.array[index].start, iki_data.content.array[index].start - 1); f_print_dynamic_partial(main->buffer, range, main->output.to.stream); diff --git a/level_3/iki_read/c/private-read.c b/level_3/iki_read/c/private-read.c index e9416ee..7e3b3a8 100644 --- a/level_3/iki_read/c/private-read.c +++ b/level_3/iki_read/c/private-read.c @@ -8,7 +8,7 @@ extern "C" { #endif #ifndef _di_iki_read_process_at_ - f_status_t iki_read_process_at(iki_read_main_t * const main, const f_string_t file_name, f_string_range_t *range) { + f_status_t iki_read_process_at(iki_read_main_t * const main, f_string_range_t *range) { if (main->parameters.array[iki_read_parameter_line_e].result != f_console_result_additional_e) { return F_false; @@ -36,7 +36,7 @@ extern "C" { #endif // _di_iki_read_process_at_ #ifndef _di_iki_read_process_buffer_ - f_status_t iki_read_process_buffer(iki_read_main_t * const main, const f_console_arguments_t *arguments, const f_string_t file_name) { + f_status_t iki_read_process_buffer(iki_read_main_t * const main) { f_status_t status = F_none; iki_data_t iki_data = iki_data_t_initialize; @@ -44,7 +44,7 @@ extern "C" { if (main->parameters.array[iki_read_parameter_whole_e].result == f_console_result_found_e) { f_string_range_t buffer_range = macro_f_string_range_t_initialize(main->buffer.used); - status = iki_read_process_at(main, file_name, &buffer_range); + status = iki_read_process_at(main, &buffer_range); if (status == F_true) { if (buffer_range.start > main->buffer.used) { @@ -56,22 +56,22 @@ extern "C" { } if (main->mode == iki_read_mode_content_e) { - status = iki_read_process_buffer_ranges_whole(main, arguments, file_name, buffer_range, &iki_data, &iki_data.content); + status = iki_read_process_buffer_ranges_whole(main, buffer_range, &iki_data, &iki_data.content); } else if (main->mode == iki_read_mode_literal_e) { - status = iki_read_process_buffer_ranges_whole(main, arguments, file_name, buffer_range, &iki_data, &iki_data.variable); + status = iki_read_process_buffer_ranges_whole(main, buffer_range, &iki_data, &iki_data.variable); } else if (main->mode == iki_read_mode_object_e) { - status = iki_read_process_buffer_ranges_whole(main, arguments, file_name, buffer_range, &iki_data, &iki_data.vocabulary); + status = iki_read_process_buffer_ranges_whole(main, buffer_range, &iki_data, &iki_data.vocabulary); } } else if (main->mode == iki_read_mode_total_e) { - status = iki_read_process_buffer_total(main, arguments, file_name, &iki_data); + status = iki_read_process_buffer_total(main, &iki_data); } else { f_string_range_t buffer_range = macro_f_string_range_t_initialize(main->buffer.used); - status = iki_read_process_at(main, file_name, &buffer_range); + status = iki_read_process_at(main, &buffer_range); if (status == F_true && buffer_range.start > main->buffer.used || status == F_data_not) { macro_iki_data_t_delete_simple(iki_data); @@ -80,13 +80,13 @@ extern "C" { } if (main->mode == iki_read_mode_content_e) { - status = iki_read_process_buffer_ranges(main, arguments, file_name, &buffer_range, &iki_data, &iki_data.content); + status = iki_read_process_buffer_ranges(main, &buffer_range, &iki_data, &iki_data.content); } else if (main->mode == iki_read_mode_literal_e) { - status = iki_read_process_buffer_ranges(main, arguments, file_name, &buffer_range, &iki_data, &iki_data.variable); + status = iki_read_process_buffer_ranges(main, &buffer_range, &iki_data, &iki_data.variable); } else if (main->mode == iki_read_mode_object_e) { - status = iki_read_process_buffer_ranges(main, arguments, file_name, &buffer_range, &iki_data, &iki_data.vocabulary); + status = iki_read_process_buffer_ranges(main, &buffer_range, &iki_data, &iki_data.vocabulary); } } @@ -97,7 +97,7 @@ extern "C" { #endif // _di_iki_read_process_buffer_ #ifndef _di_iki_read_process_buffer_ranges_ - f_status_t iki_read_process_buffer_ranges(iki_read_main_t * const main, const f_console_arguments_t *arguments, const f_string_t file_name, f_string_range_t *buffer_range, iki_data_t *iki_data, f_string_ranges_t *ranges) { + f_status_t iki_read_process_buffer_ranges(iki_read_main_t * const main, f_string_range_t *buffer_range, iki_data_t *iki_data, f_string_ranges_t *ranges) { f_status_t status = F_none; @@ -126,7 +126,7 @@ extern "C" { memset(substitutionss, 0, sizeof(iki_read_substitutions_t) * iki_data->variable.used); if (main->mode == iki_read_mode_literal_e || main->mode == iki_read_mode_content_e) { - status = iki_read_substitutions_identify(main, arguments, file_name, &iki_data->vocabulary, substitutionss); + status = iki_read_substitutions_identify(main, &iki_data->vocabulary, substitutionss); if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "iki_read_substitutions_identify", F_true); @@ -153,10 +153,10 @@ extern "C" { index = main->parameters.array[iki_read_parameter_name_e].values.array[i]; name.used = 0; - status = f_string_append_nulless(arguments->argv[index], strlen(arguments->argv[index]), &name); + status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &name); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_append_nulless", F_true); + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_append_nulless", F_true); for (f_array_length_t i = 0; i < iki_data->variable.used; ++i) { macro_iki_read_substitutions_t_delete_simple(substitutionss[i]); @@ -197,8 +197,12 @@ extern "C" { f_string_dynamic_resize(0, &name); - if (unmatched) status = F_data_not; - else status = F_none; + if (unmatched) { + status = F_data_not; + } + else { + status = F_none; + } } else if (ranges->used) { if (main->parameters.array[iki_read_parameter_at_e].result == f_console_result_additional_e) { @@ -255,7 +259,7 @@ extern "C" { #endif // _di_iki_read_process_buffer_ranges_ #ifndef _di_iki_read_process_buffer_ranges_whole_ - f_status_t iki_read_process_buffer_ranges_whole(iki_read_main_t * const main, const f_console_arguments_t *arguments, const f_string_t file_name, const f_string_range_t buffer_range, iki_data_t *iki_data, f_string_ranges_t *ranges) { + f_status_t iki_read_process_buffer_ranges_whole(iki_read_main_t * const main, const f_string_range_t buffer_range, iki_data_t *iki_data, f_string_ranges_t *ranges) { f_status_t status = F_none; f_string_range_t range = buffer_range; @@ -289,7 +293,7 @@ extern "C" { memset(substitutionss, 0, sizeof(iki_read_substitutions_t) * iki_data->variable.used); if (main->mode == iki_read_mode_literal_e || main->mode == iki_read_mode_content_e) { - status = iki_read_substitutions_identify(main, arguments, file_name, &iki_data->vocabulary, substitutionss); + status = iki_read_substitutions_identify(main, &iki_data->vocabulary, substitutionss); if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "iki_read_substitutions_identify", F_true); @@ -313,18 +317,14 @@ extern "C" { if (main->parameters.array[iki_read_parameter_name_e].result == f_console_result_additional_e) { f_array_length_t i = 0; f_array_length_t j = 0; - f_array_length_t length_argument = 0; for (f_array_length_t index = 0; i < main->parameters.array[iki_read_parameter_name_e].values.used; ++i) { index = main->parameters.array[iki_read_parameter_name_e].values.array[i]; - length_argument = strnlen(arguments->argv[index], F_console_parameter_size_d); for (j = 0, name_missed = F_true; j < names.used; ++j) { - status = fl_string_compare(arguments->argv[index], names.array[j].string, length_argument, names.array[j].used); - - if (status == F_equal_to) { + if (fl_string_dynamic_compare(main->parameters.arguments.array[index], names.array[j]) == F_equal_to) { name_missed = F_false; break; @@ -340,10 +340,10 @@ extern "C" { break; } - status = f_string_append_nulless(arguments->argv[index], length_argument, &names.array[names.used]); + status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &names.array[names.used]); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_append_nulless", F_true); + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_append_nulless", F_true); break; } @@ -451,22 +451,22 @@ extern "C" { #endif // _di_iki_read_process_buffer_ranges_whole_ #ifndef _di_iki_read_process_buffer_total_ - f_status_t iki_read_process_buffer_total(iki_read_main_t * const main, const f_console_arguments_t *arguments, const f_string_t file_name, iki_data_t *iki_data) { + f_status_t iki_read_process_buffer_total(iki_read_main_t * const main, iki_data_t *iki_data) { f_status_t status = F_none; f_string_range_t range = macro_f_string_range_t_initialize(main->buffer.used); - status = iki_read_process_at(main, file_name, &range); + status = iki_read_process_at(main, &range); if (status == F_true) { if (range.start > main->buffer.used) { - fll_print_format("0%r", main->output.to.stream, f_string_eol_s); + fll_print_format("%r%r", main->output.to.stream, f_string_ascii_0_s, f_string_eol_s); return F_none; } } else if (status == F_data_not) { - fll_print_format("0%r", main->output.to.stream, f_string_eol_s); + fll_print_format("%r%r", main->output.to.stream, f_string_ascii_0_s, f_string_eol_s); return F_none; } @@ -513,12 +513,13 @@ extern "C" { index = main->parameters.array[iki_read_parameter_name_e].values.array[i]; name.used = 0; - status = f_string_append_nulless(arguments->argv[index], strlen(arguments->argv[index]), &name); + status = f_string_dynamic_append_nulless(main->parameters.arguments.array[index], &name); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_append_nulless", F_true); + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_append_nulless", F_true); f_string_dynamic_resize(0, &name); + return status; } @@ -555,7 +556,7 @@ extern "C" { #endif // _di_iki_read_process_buffer_total_ #ifndef _di_iki_read_substitutions_identify_ - f_status_t iki_read_substitutions_identify(iki_read_main_t * const main, const f_console_arguments_t *arguments, const f_string_t file_name, f_iki_vocabulary_t *vocabulary, iki_read_substitutions_t *substitutionss) { + f_status_t iki_read_substitutions_identify(iki_read_main_t * const main, f_iki_vocabulary_t *vocabulary, iki_read_substitutions_t *substitutionss) { if (main->parameters.array[iki_read_parameter_substitute_e].result != f_console_result_additional_e) { return F_none; @@ -569,33 +570,24 @@ extern "C" { f_array_length_t index = 0; f_array_length_t index_2 = 0; - f_array_length_t length = 0; - f_console_parameter_t *parameter = &main->parameters.array[iki_read_parameter_substitute_e]; for (; i < parameter->values.used; i += 3) { index = parameter->values.array[i]; - length = strnlen(arguments->argv[index], F_console_parameter_size_d); for (j = 0; j < vocabulary->used; ++j) { - status = fl_string_compare(arguments->argv[index], main->buffer.string + vocabulary->array[j].start, length, (vocabulary->array[j].stop - vocabulary->array[j].start) + 1); - - if (status == F_equal_to) { + if (fl_string_dynamic_partial_compare_string(main->parameters.arguments.array[index].string, main->buffer, main->parameters.arguments.array[index].used, vocabulary->array[j]) == F_equal_to) { macro_f_memory_structure_increment(status, substitutionss[j], 1, F_iki_default_allocation_step_d, macro_iki_read_substitutions_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; index = parameter->values.array[i + 1]; index_2 = substitutionss[j].used; - substitutionss[j].array[index_2].replace.string = arguments->argv[index]; - substitutionss[j].array[index_2].replace.used = strnlen(arguments->argv[index], F_console_parameter_size_d); - substitutionss[j].array[index_2].replace.size = substitutionss[j].array[index_2].replace.used; + substitutionss[j].array[index_2].replace = main->parameters.arguments.array[index]; index = parameter->values.array[i + 2]; - substitutionss[j].array[index_2].with.string = arguments->argv[index]; - substitutionss[j].array[index_2].with.used = strnlen(arguments->argv[index], F_console_parameter_size_d); - substitutionss[j].array[index_2].with.size = substitutionss[j].array[index_2].with.used; + substitutionss[j].array[index_2].with = main->parameters.arguments.array[index]; ++substitutionss[j].used; } diff --git a/level_3/iki_read/c/private-read.h b/level_3/iki_read/c/private-read.h index 5fa6fe1..71348e5 100644 --- a/level_3/iki_read/c/private-read.h +++ b/level_3/iki_read/c/private-read.h @@ -20,8 +20,6 @@ extern "C" { * * @param main * The main program data. - * @param file_name - * The name of the file being processed. * @param range * The range value to represent the --at values. * @@ -33,7 +31,7 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_iki_read_process_at_ - extern f_status_t iki_read_process_at(iki_read_main_t * const main, const f_string_t file_name, f_string_range_t *range) F_attribute_visibility_internal_d; + extern f_status_t iki_read_process_at(iki_read_main_t * const main, f_string_range_t *range) F_attribute_visibility_internal_d; #endif // _di_iki_read_process_at_ /** @@ -41,10 +39,6 @@ extern "C" { * * @param main * The main program data. - * @param arguments - * The console arguments passed to the program. - * @param file_name - * The name of the file being processed. * * @return * F_none on success. @@ -53,7 +47,7 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_iki_read_process_buffer_ - extern f_status_t iki_read_process_buffer(iki_read_main_t * const main, const f_console_arguments_t *arguments, const f_string_t file_name) F_attribute_visibility_internal_d; + extern f_status_t iki_read_process_buffer(iki_read_main_t * const main) F_attribute_visibility_internal_d; #endif // _di_iki_read_process_buffer_ /** @@ -61,10 +55,6 @@ extern "C" { * * @param main * The main program data. - * @param arguments - * The console arguments passed to the program. - * @param file_name - * The name of the file being processed. * @param buffer_range * The range within the buffer to process. * @param iki_data @@ -80,7 +70,7 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_iki_read_process_buffer_ranges_ - extern f_status_t iki_read_process_buffer_ranges(iki_read_main_t * const main, const f_console_arguments_t *arguments, const f_string_t file_name, f_string_range_t *buffer_range, iki_data_t *iki_data, f_string_ranges_t *ranges) F_attribute_visibility_internal_d; + extern f_status_t iki_read_process_buffer_ranges(iki_read_main_t * const main, f_string_range_t *buffer_range, iki_data_t *iki_data, f_string_ranges_t *ranges) F_attribute_visibility_internal_d; #endif // _di_iki_read_process_buffer_ranges_ /** @@ -90,10 +80,6 @@ extern "C" { * * @param main * The main program data. - * @param arguments - * The console arguments passed to the program. - * @param file_name - * The name of the file being processed. * @param buffer_range * The range within the buffer to process. * @param iki_data @@ -109,7 +95,7 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_iki_read_process_buffer_ranges_whole_ - extern f_status_t iki_read_process_buffer_ranges_whole(iki_read_main_t * const main, const f_console_arguments_t *arguments, const f_string_t file_name, const f_string_range_t buffer_range, iki_data_t *iki_data, f_string_ranges_t *ranges) F_attribute_visibility_internal_d; + extern f_status_t iki_read_process_buffer_ranges_whole(iki_read_main_t * const main, const f_string_range_t buffer_range, iki_data_t *iki_data, f_string_ranges_t *ranges) F_attribute_visibility_internal_d; #endif // _di_iki_read_process_buffer_ranges_whole_ /** @@ -117,10 +103,6 @@ extern "C" { * * @param main * The main program data. - * @param arguments - * The console arguments passed to the program. - * @param file_name - * The name of the file being processed. * @param iki_data * The IKI data. * @@ -130,7 +112,7 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_iki_read_process_buffer_total_ - extern f_status_t iki_read_process_buffer_total(iki_read_main_t * const main, const f_console_arguments_t *arguments, const f_string_t file_name, iki_data_t *iki_data) F_attribute_visibility_internal_d; + extern f_status_t iki_read_process_buffer_total(iki_read_main_t * const main, iki_data_t *iki_data) F_attribute_visibility_internal_d; #endif // _di_iki_read_process_buffer_total_ /** @@ -138,10 +120,6 @@ extern "C" { * * @param main * The main program data. - * @param arguments - * The console arguments passed to the program. - * @param file_name - * The name of the file being processed. * @param vocabulary * The ranges representing a vocabulary. * @param substitutionss @@ -153,7 +131,7 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_iki_read_substitutions_identify_ - extern f_status_t iki_read_substitutions_identify(iki_read_main_t * const main, const f_console_arguments_t *arguments, const f_string_t file_name, f_iki_vocabulary_t *vocabulary, iki_read_substitutions_t *substitutionss) F_attribute_visibility_internal_d; + extern f_status_t iki_read_substitutions_identify(iki_read_main_t * const main, f_iki_vocabulary_t *vocabulary, iki_read_substitutions_t *substitutionss) F_attribute_visibility_internal_d; #endif // _di_iki_read_substitutions_identify_ #ifdef __cplusplus diff --git a/level_3/iki_write/c/common.h b/level_3/iki_write/c/common.h index b3d4ba7..3c51aee 100644 --- a/level_3/iki_write/c/common.h +++ b/level_3/iki_write/c/common.h @@ -49,8 +49,8 @@ extern "C" { * The program name. */ #ifndef _di_iki_write_program_name_ - #define iki_write_program_name_s "iki_write" - #define iki_write_program_name_long_s "IKI Write" + #define IKI_WRITE_program_name_s "iki_write" + #define IKI_WRITE_program_name_long_s "IKI Write" #define IKI_WRITE_program_name_s_length 9 #define IKI_WRITE_program_name_long_s_length 9 @@ -149,7 +149,6 @@ extern "C" { * The main program data. * * parameters: The state of pre-defined parameters passed to the program. - * remaining: The remaining, non-pre-defined parameters, passed to the program. * process_pipe: Designate whether or not to process the input pipe. * output: The output file for general printing. * error: The output file for error printing. @@ -180,7 +179,6 @@ extern "C" { #define iki_write_main_t_initialize \ { \ f_console_parameters_t_initialize, \ - f_array_lengths_t_initialize, \ F_false, \ fl_print_t_initialize, \ macro_fl_print_t_initialize_error(), \ diff --git a/level_3/iki_write/c/iki_write.c b/level_3/iki_write/c/iki_write.c index 68d7c8a..326f017 100644 --- a/level_3/iki_write/c/iki_write.c +++ b/level_3/iki_write/c/iki_write.c @@ -172,15 +172,15 @@ extern "C" { status = F_status_set_error(F_parameter); } else { - const f_array_length_t location = main->parameters.array[iki_write_parameter_file_e].values.array[0]; + const f_array_length_t index = main->parameters.array[iki_write_parameter_file_e].values.array[0]; file.id = -1; file.stream = 0; - status = f_file_stream_open(arguments->argv[location], 0, &file); + status = f_file_stream_open(argv[index], f_string_empty_s, &file); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, arguments->argv[location], f_file_operation_open_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, argv[index], f_file_operation_open_s, fll_error_file_type_file_e); } } } @@ -263,18 +263,18 @@ extern "C" { } } - data->quote = f_iki_syntax_quote_double_s.string[0]; + main->quote = f_iki_syntax_quote_double_s; if (F_status_is_error_not(status)) { if (main->parameters.array[iki_write_parameter_double_e].result == f_console_result_found_e) { if (main->parameters.array[iki_write_parameter_single_e].result == f_console_result_found_e) { if (main->parameters.array[iki_write_parameter_double_e].location < main->parameters.array[iki_write_parameter_single_e].location) { - data->quote = f_iki_syntax_quote_single_s.string[0]; + main->quote = f_iki_syntax_quote_single_s; } } } else if (main->parameters.array[iki_write_parameter_single_e].result == f_console_result_found_e) { - data->quote = f_iki_syntax_quote_single_s.string[0]; + main->quote = f_iki_syntax_quote_single_s; } } @@ -315,7 +315,7 @@ extern "C" { status_pipe = f_file_read(pipe, &buffer); if (F_status_is_error(status_pipe)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_read_to", F_true, f_string_ascii_s, f_file_operation_read_s, fll_error_file_type_pipe_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_read_to", F_true, f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e); status = F_status_set_error(F_pipe); @@ -426,8 +426,6 @@ extern "C" { } if (F_status_is_error_not(status)) { - f_string_static_t object = f_string_static_t_initialize; - f_string_static_t content = f_string_static_t_initialize; uint16_t signal_check = 0; for (f_array_length_t i = 0; i < main->parameters.array[iki_write_parameter_object_e].values.used; ++i) { @@ -441,15 +439,7 @@ extern "C" { signal_check = 0; } - object.string = arguments->argv[main->parameters.array[iki_write_parameter_object_e].values.array[i]]; - object.used = strnlen(object.string, F_console_parameter_size_d); - object.size = object.used; - - content.string = arguments->argv[main->parameters.array[iki_write_parameter_content_e].values.array[i]]; - content.used = strnlen(content.string, F_console_parameter_size_d); - content.size = content.used; - - status = iki_write_process(main, file, object, content, &escaped); + status = iki_write_process(main, file, argv[main->parameters.array[iki_write_parameter_object_e].values.array[i]], argv[main->parameters.array[iki_write_parameter_content_e].values.array[i]], &escaped); if (F_status_is_error(status)) break; fll_print_dynamic_raw(f_string_eol_s, file.stream); diff --git a/level_3/iki_write/c/private-write.c b/level_3/iki_write/c/private-write.c index 300ea41..4b7d27e 100644 --- a/level_3/iki_write/c/private-write.c +++ b/level_3/iki_write/c/private-write.c @@ -51,8 +51,6 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "fll_iki_content_escape", F_true); - f_string_dynamic_resize(0, &escaped); - return F_status_set_error(F_failure); } diff --git a/level_3/status_code/c/common.h b/level_3/status_code/c/common.h index fcfb967..34d0161 100644 --- a/level_3/status_code/c/common.h +++ b/level_3/status_code/c/common.h @@ -38,9 +38,9 @@ extern "C" { #define STATUS_CODE_program_version_nano_s_length 0 #endif // !(defined(STATUS_CODE_program_version_nano_s) && defined(STATUS_CODE_program_version_nano_s_length)) - #define STATUS_CODE_progam_version_s STATUS_CODE_program_version_major_s F_string_ascii_period_s STATUS_CODE_program_version_minor_s F_string_ascii_period_s STATUS_CODE_program_version_micro_s STATUS_CODE_progam_version_nano_prefix_s STATUS_CODE_progam_version_nano_s + #define STATUS_CODE_program_version_s STATUS_CODE_program_version_major_s F_string_ascii_period_s STATUS_CODE_program_version_minor_s F_string_ascii_period_s STATUS_CODE_program_version_micro_s STATUS_CODE_program_version_nano_prefix_s STATUS_CODE_program_version_nano_s - #define STATUS_CODE_progam_version_s_length STATUS_CODE_program_version_major_s_length + F_string_ascii_period_s_length + STATUS_CODE_program_version_minor_s_length + F_string_ascii_period_s_length + STATUS_CODE_program_version_micro_s_length + STATUS_CODE_progam_version_nano_prefix_s_length + STATUS_CODE_progam_version_nano_s_length + #define STATUS_CODE_program_version_s_length STATUS_CODE_program_version_major_s_length + F_string_ascii_period_s_length + STATUS_CODE_program_version_minor_s_length + F_string_ascii_period_s_length + STATUS_CODE_program_version_micro_s_length + STATUS_CODE_program_version_nano_prefix_s_length + STATUS_CODE_program_version_nano_s_length extern const f_string_static_t status_code_program_version_s; #endif // _di_status_code_program_version_ @@ -49,11 +49,11 @@ extern "C" { * The program name. */ #ifndef _di_status_code_program_name_ - #define STATUS_CODE_progam_name_s "status_code" - #define STATUS_CODE_progam_name_long_s "FSS Status Code" + #define STATUS_CODE_program_name_s "status_code" + #define STATUS_CODE_program_name_long_s "Status Code" #define STATUS_CODE_program_name_s_length 11 - #define STATUS_CODE_program_name_long_s_length 15 + #define STATUS_CODE_program_name_long_s_length 11 extern const f_string_static_t status_code_program_name_s; extern const f_string_static_t status_code_program_name_long_s; diff --git a/level_3/status_code/c/private-status_code.c b/level_3/status_code/c/private-status_code.c index 29fdfde..6e1fca1 100644 --- a/level_3/status_code/c/private-status_code.c +++ b/level_3/status_code/c/private-status_code.c @@ -7,41 +7,39 @@ extern "C" { #endif #ifndef _di_status_code_process_check_ - f_status_t status_code_process_check(fll_program_data_t * const main, const f_string_t value) { + f_status_t status_code_process_check(fll_program_data_t * const main, const f_string_static_t value) { f_number_unsigned_t number = 0; f_status_t status = status_code_convert_number(main, value, &number); - if (F_status_is_error(status)) { - return status; - } + if (F_status_is_error(status)) return status; if (main->parameters.array[status_code_parameter_is_error_e].result == f_console_result_found_e) { if (F_status_is_error(number)) { - f_print_terminated(f_status_true_s, main->output.to.stream); + f_print_dynamic_raw(f_status_true_s, main->output.to.stream); } else { - f_print_terminated(f_status_false_s, main->output.to.stream); + f_print_dynamic_raw(f_status_false_s, main->output.to.stream); } f_print_dynamic_raw(f_string_eol_s, main->output.to.stream); } else if (main->parameters.array[status_code_parameter_is_warning_e].result == f_console_result_found_e) { if (F_status_is_warning(number)) { - f_print_terminated(f_status_true_s, main->output.to.stream); + f_print_dynamic_raw(f_status_true_s, main->output.to.stream); } else { - f_print_terminated(f_status_false_s, main->output.to.stream); + f_print_dynamic_raw(f_status_false_s, main->output.to.stream); } f_print_dynamic_raw(f_string_eol_s, main->output.to.stream); } else if (main->parameters.array[status_code_parameter_is_fine_e].result == f_console_result_found_e) { if (F_status_is_fine(number)) { - f_print_terminated(f_status_true_s, main->output.to.stream); + f_print_dynamic_raw(f_status_true_s, main->output.to.stream); } else { - f_print_terminated(f_status_false_s, main->output.to.stream); + f_print_dynamic_raw(f_status_false_s, main->output.to.stream); } f_print_dynamic_raw(f_string_eol_s, main->output.to.stream); @@ -52,16 +50,16 @@ extern "C" { #endif // _di_status_code_process_check_ #ifndef _di_status_code_process_number_ - f_status_t status_code_process_number(fll_program_data_t * const main, const f_string_t value) { + f_status_t status_code_process_number(fll_program_data_t * const main, const f_string_static_t value) { f_status_t status = F_none; { - const f_string_range_t range = macro_f_string_range_t_initialize(strlen(value)); + const f_string_range_t range = macro_f_string_range_t_initialize(value.used); f_number_unsigned_t number = 0; - status = fl_conversion_string_to_number_unsigned(value, range, &number); + status = fl_conversion_string_to_number_unsigned(value.string, range, &number); if (status == F_none) { fl_print_format("%[invalid name%]%r", main->output.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); @@ -104,19 +102,16 @@ extern "C" { #endif // _di_status_code_process_number_ #ifndef _di_status_code_process_normal_ - f_status_t status_code_process_normal(fll_program_data_t * const main, const f_string_t value) { + f_status_t status_code_process_normal(fll_program_data_t * const main, const f_string_static_t value) { f_number_unsigned_t number = 0; f_status_t status = status_code_convert_number(main, value, &number); - if (F_status_is_error(status)) { - return status; - } + if (F_status_is_error(status)) return status; - const f_status_t code = (f_status_t) number; - f_string_static_t name = 0; + f_string_static_t name = f_string_static_t_initialize; - status = f_status_string_to(code, &name); + status = f_status_string_to((f_status_t) number, &name); if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_data) { @@ -129,18 +124,18 @@ extern "C" { return status; } - fl_print_format("%S%r", main->output.to.stream, name, f_string_eol_s); + fl_print_format("%Q%r", main->output.to.stream, name, f_string_eol_s); return F_none; } #endif // _di_status_code_process_normal_ #ifndef _di_status_code_convert_number_ - f_status_t status_code_convert_number(fll_program_data_t * const main, const f_string_t value, f_number_unsigned_t *number) { + f_status_t status_code_convert_number(fll_program_data_t * const main, const f_string_static_t value, f_number_unsigned_t *number) { - const f_string_range_t range = macro_f_string_range_t_initialize(strlen(value)); + const f_string_range_t range = macro_f_string_range_t_initialize(value.used); - f_status_t status = fl_conversion_string_to_number_unsigned(value, range, number); + f_status_t status = fl_conversion_string_to_number_unsigned(value.string, range, number); if (*number > F_status_size_max_with_signal) { fl_print_format("%[out of range%]%r", main->output.to.stream, main->context.set.error, main->context.set.error, f_string_eol_s); diff --git a/level_3/status_code/c/private-status_code.h b/level_3/status_code/c/private-status_code.h index d2da737..632a9b8 100644 --- a/level_3/status_code/c/private-status_code.h +++ b/level_3/status_code/c/private-status_code.h @@ -34,7 +34,7 @@ extern "C" { * @see fss_status_code_convert_number() */ #ifndef _di_status_code_process_check_ - extern f_status_t status_code_process_check(fll_program_data_t * const main, const f_string_t value) F_attribute_visibility_internal_d; + extern f_status_t status_code_process_check(fll_program_data_t * const main, const f_string_static_t value) F_attribute_visibility_internal_d; #endif // _di_status_code_process_check_ /** @@ -56,7 +56,7 @@ extern "C" { * @see fll_fss_status_string_from() */ #ifndef _di_status_code_process_number_ - extern f_status_t status_code_process_number(fll_program_data_t * const main, const f_string_t value) F_attribute_visibility_internal_d; + extern f_status_t status_code_process_number(fll_program_data_t * const main, const f_string_static_t value) F_attribute_visibility_internal_d; #endif // _di_status_code_process_number_ /** @@ -83,7 +83,7 @@ extern "C" { * @see fss_status_code_convert_number() */ #ifndef _di_status_code_process_normal_ - extern f_status_t status_code_process_normal(fll_program_data_t * const main, const f_string_t value) F_attribute_visibility_internal_d; + extern f_status_t status_code_process_normal(fll_program_data_t * const main, const f_string_static_t value) F_attribute_visibility_internal_d; #endif // _di_status_code_process_normal_ /** @@ -111,7 +111,7 @@ extern "C" { * @see fl_console_parameter_to_number_unsigned() */ #ifndef _di_status_code_convert_number_ - extern f_status_t status_code_convert_number(fll_program_data_t * const main, const f_string_t value, f_number_unsigned_t *number) F_attribute_visibility_internal_d; + extern f_status_t status_code_convert_number(fll_program_data_t * const main, const f_string_static_t value, f_number_unsigned_t *number) F_attribute_visibility_internal_d; #endif // _di_status_code_convert_number_ #ifdef __cplusplus diff --git a/level_3/status_code/c/status_code.c b/level_3/status_code/c/status_code.c index c96880f..6467021 100644 --- a/level_3/status_code/c/status_code.c +++ b/level_3/status_code/c/status_code.c @@ -11,7 +11,7 @@ extern "C" { flockfile(file.stream); - fll_program_print_help_header(file, context, status_code_progam_name_long_s, status_code_progam_version_s); + fll_program_print_help_header(file, context, status_code_program_name_long_s, status_code_program_version_s); fll_program_print_help_option(file, context, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print this help message."); fll_program_print_help_option(file, context, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_disable_s, f_console_symbol_long_disable_s, " Output using colors that show up better on dark backgrounds."); @@ -30,7 +30,7 @@ extern "C" { fll_program_print_help_option(file, context, status_code_short_is_error_s, status_code_long_is_error_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Print F_true if the error code is an error, F_false otherwise."); fll_program_print_help_option(file, context, status_code_short_number_s, status_code_long_number_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, " Convert status code name to number."); - fll_program_print_help_usage(file, context, status_code_progam_name_s, status_code_program_help_parameters_s); + fll_program_print_help_usage(file, context, status_code_program_name_s, status_code_program_help_parameters_s); funlockfile(file.stream); @@ -90,6 +90,7 @@ extern "C" { if (F_status_is_error(status)) { status_code_main_delete(main); + return status; } @@ -128,7 +129,7 @@ extern "C" { } if (main->parameters.array[status_code_parameter_version_e].result == f_console_result_found_e) { - fll_program_print_version(main->output.to, status_code_progam_version_s); + fll_program_print_version(main->output.to, status_code_program_version_s); status_code_main_delete(main); @@ -151,7 +152,8 @@ extern "C" { return F_status_set_error(status); } - else if (main->parameters.array[status_code_parameter_is_fine_e].result == f_console_result_found_e) { + + if (main->parameters.array[status_code_parameter_is_fine_e].result == f_console_result_found_e) { flockfile(main->error.to.stream); fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); @@ -208,13 +210,14 @@ extern "C" { if (!((++signal_check) % status_code_signal_check_d)) { if (status_code_signal_received(main)) { status = F_status_set_error(F_signal); + break; } signal_check = 0; } - status2 = status_code_process_check(main, arguments->argv[main->parameters.remaining.array[i]]); + status2 = status_code_process_check(main, argv[main->parameters.remaining.array[i]]); if (F_status_is_error(status2) && status == F_none) { status = status2; @@ -239,13 +242,14 @@ extern "C" { if (!((++signal_check) % status_code_signal_check_d)) { if (status_code_signal_received(main)) { status = F_status_set_error(F_signal); + break; } signal_check = 0; } - status2 = status_code_process_number(main, arguments->argv[main->parameters.remaining.array[i]]); + status2 = status_code_process_number(main, argv[main->parameters.remaining.array[i]]); if (F_status_is_error(status2) && status == F_none) { status = status2; @@ -270,13 +274,14 @@ extern "C" { if (!((++signal_check) % status_code_signal_check_d)) { if (status_code_signal_received(main)) { status = F_status_set_error(F_signal); + break; } signal_check = 0; } - status2 = status_code_process_normal(main, arguments->argv[main->parameters.remaining.array[i]]); + status2 = status_code_process_normal(main, argv[main->parameters.remaining.array[i]]); if (F_status_is_error(status2) && status == F_none) { status = status2; -- 1.8.3.1