From: Kevin Day Date: Tue, 17 Jun 2025 01:43:25 +0000 (-0500) Subject: Bugfix: Console stop is not appending to remaining array. X-Git-Tag: 0.7.2~6 X-Git-Url: https://www.git.kevux.org/?a=commitdiff_plain;h=9d9f95d9f879ea4ca3477233f9ceb25251ba99f5;p=fll Bugfix: Console stop is not appending to remaining array. Make sure `stop` variable is set to TRUE. Add new types to differentiate between when "stop" has been reached and when "stop" has not been reached. For example, the `f_console_parameter_state_type_wrap_up_stop_e` designates that the "stop" is reached and is performing wrap up. When the type is `f_console_parameter_state_type_wrap_up_e`, then the wrap up is happening with the "stop" being reached. The wrap up is now appending to the remaining array. --- diff --git a/level_0/f_console/c/console.c b/level_0/f_console/c/console.c index 50aeb46..b64dc7c 100644 --- a/level_0/f_console/c/console.c +++ b/level_0/f_console/c/console.c @@ -312,6 +312,8 @@ extern "C" { } // for if (process.found && (parameters->array[i].flag & f_console_flag_stop_d)) { + stop = F_true; + ++process.location; break; @@ -546,6 +548,8 @@ extern "C" { } if ((parameters->array[i].flag & f_console_flag_stop_d) && !process.needs.used) { + stop = F_true; + ++process.location; break; @@ -680,6 +684,8 @@ extern "C" { state->status = F_okay; if (process.found && (parameters->array[i].flag & f_console_flag_stop_d) && !process.needs.used) { + stop = F_true; + ++process.location; break; @@ -718,7 +724,7 @@ extern "C" { // Make sure the entire parameters arguments array is populated. if (parameters->on_match) { - process.type = f_console_parameter_state_type_wrap_up_e; + process.type = stop ? f_console_parameter_state_type_wrap_up_stop_e : f_console_parameter_state_type_wrap_up_e; process.at = 0; parameters->on_match(arguments, (void * const) parameters, &process, data); @@ -730,20 +736,28 @@ extern "C" { if (state->status == F_process) { state->status = F_okay; - for (; process.location < arguments.argc && arguments.argv[process.location]; ++process.location) { + if (process.location < arguments.argc) { + state->status = f_memory_array_increase_by(arguments.argc - process.location, sizeof(f_number_unsigned_t), (void **) ¶meters->remaining.array, ¶meters->remaining.used, ¶meters->remaining.size); - if (state->interrupt) { - state->interrupt((void * const) state, 0); - if (F_status_set_fine(state->status) == F_interrupt) break; - } + if (F_status_is_error_not(state->status)) { + for (; process.location < arguments.argc && arguments.argv[process.location]; ++process.location) { - parameters->arguments.array[parameters->arguments.used].string = arguments.argv[process.location]; - parameters->arguments.array[parameters->arguments.used].used = strnlen(arguments.argv[process.location], F_console_parameter_size_d); - parameters->arguments.array[parameters->arguments.used++].size = 0; - } // for + if (state->interrupt) { + state->interrupt((void * const) state, 0); + if (F_status_set_fine(state->status) == F_interrupt) break; + } - if (F_status_is_error_not(state->status)) { - state->status = process.needs.used ? F_complete_not : F_okay; + parameters->arguments.array[parameters->arguments.used].string = arguments.argv[process.location]; + parameters->arguments.array[parameters->arguments.used].used = strnlen(arguments.argv[process.location], F_console_parameter_size_d); + parameters->arguments.array[parameters->arguments.used++].size = 0; + + parameters->remaining.array[parameters->remaining.used++] = process.location; + } // for + + if (F_status_is_error_not(state->status)) { + state->status = process.needs.used ? F_complete_not : F_okay; + } + } } } diff --git a/level_0/f_console/c/console.h b/level_0/f_console/c/console.h index 51fbaab..8ea56d8 100644 --- a/level_0/f_console/c/console.h +++ b/level_0/f_console/c/console.h @@ -172,14 +172,18 @@ extern "C" { * F_interrupt (with error bit) if an interrupt is received via the state.interrupt callback. * F_parameter (with error bit) if a parameter is invalid. * + * Errors (with error bit) from: f_memory_array_increase(). * Errors (with error bit) from: f_memory_array_increase_by(). + * Errors (with error bit) from: f_memory_array_resize(). * Errors (with error bit) from: f_utf_char_to_character(). * @param data * (optional) A variable passed to the callback, if provided. * * Set to NULL to not use. * + * @see f_memory_array_increase() * @see f_memory_array_increase_by() + * @see f_memory_array_resize() * @see f_utf_char_to_character() */ #ifndef _di_f_console_parameter_process_ diff --git a/level_0/f_console/c/console/common.h b/level_0/f_console/c/console/common.h index 5dd1db1..e0fd12a 100644 --- a/level_0/f_console/c/console/common.h +++ b/level_0/f_console/c/console/common.h @@ -137,6 +137,7 @@ extern "C" { * - simple: Perform simple parameter match processing. * - need: Perform value is needed processing. * - wrap_up: Perform wrap up processing. + * - wrap_up_stop: Perform wrap up processing after "stop" has been identified. */ #ifndef _di_f_console_parameter_state_type_e_ enum { @@ -150,6 +151,7 @@ extern "C" { f_console_parameter_state_type_simple_e, f_console_parameter_state_type_need_e, f_console_parameter_state_type_wrap_up_e, + f_console_parameter_state_type_wrap_up_stop_e, }; // enum #endif // _di_f_console_parameter_state_type_e_