]> Kevux Git Server - fll/commitdiff
Bugfix: Console stop is not appending to remaining array.
authorKevin Day <Kevin@kevux.org>
Tue, 17 Jun 2025 01:43:25 +0000 (20:43 -0500)
committerKevin Day <Kevin@kevux.org>
Tue, 17 Jun 2025 01:47:40 +0000 (20:47 -0500)
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.

level_0/f_console/c/console.c
level_0/f_console/c/console.h
level_0/f_console/c/console/common.h

index 50aeb46d15fcee6dec1ce83e17630d7a73621d26..b64dc7ce572c2f959b16c36d6e37b5eb47696b89 100644 (file)
@@ -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 **) &parameters->remaining.array, &parameters->remaining.used, &parameters->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;
+          }
+        }
       }
     }
 
index 51fbaab5b0e89f51d9ccedf0c891e21df469cfc7..8ea56d843bfd28640313e5b64d99f6833e947766 100644 (file)
@@ -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_
index 5dd1db161c16f52b9134583cf4cc2326766bc959..e0fd12a86695ab23ad92de99283bbd9f10a719fe 100644 (file)
@@ -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_