]> Kevux Git Server - fll/commitdiff
Feature: The iki_read should still support the older "--substitute" behavior.
authorKevin Day <thekevinday@gmail.com>
Mon, 24 Oct 2022 02:44:34 +0000 (21:44 -0500)
committerKevin Day <thekevinday@gmail.com>
Mon, 24 Oct 2022 02:44:34 +0000 (21:44 -0500)
The commit bbc7591a040baeca7d19d1d6b644b80ad2e70d01 considered the behavior of --substitute to be incorrect and therefore a bug.

After some consideration I decided that this "bug" would still be useful in certain cases.
The old behavior of "--substitute" where the "--wrap" is ignored is re-created within the new parameter "--reassign".

This is a grey area when it comes to a "bug" and a "feature".
The behavior that is considered a "bug" turned out to be useful and as the behavior is already present it is carried on.

level_3/iki_read/c/common.c
level_3/iki_read/c/common.h
level_3/iki_read/c/iki_read.c
level_3/iki_read/c/private-print.c
level_3/iki_read/c/private-print.h
level_3/iki_read/c/private-read.c
level_3/iki_read/c/private-read.h

index 00af88241dab815f0c5cefc55607101c77cc752e..44a5f9bb04508a96711289506ccce1eb5e00898a 100644 (file)
@@ -20,6 +20,7 @@ extern "C" {
   const f_string_static_t iki_read_short_literal_s = macro_f_string_static_t_initialize(IKI_READ_short_literal_s, 0, IKI_READ_short_literal_s_length);
   const f_string_static_t iki_read_short_name_s = macro_f_string_static_t_initialize(IKI_READ_short_name_s, 0, IKI_READ_short_name_s_length);
   const f_string_static_t iki_read_short_object_s = macro_f_string_static_t_initialize(IKI_READ_short_object_s, 0, IKI_READ_short_object_s_length);
+  const f_string_static_t iki_read_short_reassign_s = macro_f_string_static_t_initialize(IKI_READ_short_reassign_s, 0, IKI_READ_short_reassign_s_length);
   const f_string_static_t iki_read_short_replace_s = macro_f_string_static_t_initialize(IKI_READ_short_replace_s, 0, IKI_READ_short_replace_s_length);
   const f_string_static_t iki_read_short_substitute_s = macro_f_string_static_t_initialize(IKI_READ_short_substitute_s, 0, IKI_READ_short_substitute_s_length);
   const f_string_static_t iki_read_short_total_s = macro_f_string_static_t_initialize(IKI_READ_short_total_s, 0, IKI_READ_short_total_s_length);
@@ -32,6 +33,7 @@ extern "C" {
   const f_string_static_t iki_read_long_literal_s = macro_f_string_static_t_initialize(IKI_READ_long_literal_s, 0, IKI_READ_long_literal_s_length);
   const f_string_static_t iki_read_long_name_s = macro_f_string_static_t_initialize(IKI_READ_long_name_s, 0, IKI_READ_long_name_s_length);
   const f_string_static_t iki_read_long_object_s = macro_f_string_static_t_initialize(IKI_READ_long_object_s, 0, IKI_READ_long_object_s_length);
+  const f_string_static_t iki_read_long_reassign_s = macro_f_string_static_t_initialize(IKI_READ_long_reassign_s, 0, IKI_READ_long_reassign_s_length);
   const f_string_static_t iki_read_long_replace_s = macro_f_string_static_t_initialize(IKI_READ_long_replace_s, 0, IKI_READ_long_replace_s_length);
   const f_string_static_t iki_read_long_substitute_s = macro_f_string_static_t_initialize(IKI_READ_long_substitute_s, 0, IKI_READ_long_substitute_s_length);
   const f_string_static_t iki_read_long_total_s = macro_f_string_static_t_initialize(IKI_READ_long_total_s, 0, IKI_READ_long_total_s_length);
index cabb43b6d13707e7797498e38085317de26a668b..2a100b594519fa02751516c0592b0cf39fb38ce4 100644 (file)
@@ -83,6 +83,7 @@ extern "C" {
   #define IKI_READ_short_literal_s    "L"
   #define IKI_READ_short_name_s       "n"
   #define IKI_READ_short_object_s     "o"
+  #define IKI_READ_short_reassign_s   "R"
   #define IKI_READ_short_replace_s    "r"
   #define IKI_READ_short_substitute_s "s"
   #define IKI_READ_short_total_s      "t"
@@ -95,6 +96,7 @@ extern "C" {
   #define IKI_READ_long_literal_s    "literal"
   #define IKI_READ_long_name_s       "name"
   #define IKI_READ_long_object_s     "object"
+  #define IKI_READ_long_reassign_s   "reassign"
   #define IKI_READ_long_replace_s    "replace"
   #define IKI_READ_long_substitute_s "substitute"
   #define IKI_READ_long_total_s      "total"
@@ -107,6 +109,7 @@ extern "C" {
   #define IKI_READ_short_literal_s_length    1
   #define IKI_READ_short_name_s_length       1
   #define IKI_READ_short_object_s_length     1
+  #define IKI_READ_short_reassign_s_length   1
   #define IKI_READ_short_replace_s_length    1
   #define IKI_READ_short_substitute_s_length 1
   #define IKI_READ_short_total_s_length      1
@@ -119,6 +122,7 @@ extern "C" {
   #define IKI_READ_long_literal_s_length    7
   #define IKI_READ_long_name_s_length       4
   #define IKI_READ_long_object_s_length     6
+  #define IKI_READ_long_reassign_s_length   8
   #define IKI_READ_long_replace_s_length    7
   #define IKI_READ_long_substitute_s_length 10
   #define IKI_READ_long_total_s_length      5
@@ -131,6 +135,7 @@ extern "C" {
   extern const f_string_static_t iki_read_short_literal_s;
   extern const f_string_static_t iki_read_short_name_s;
   extern const f_string_static_t iki_read_short_object_s;
+  extern const f_string_static_t iki_read_short_reassign_s;
   extern const f_string_static_t iki_read_short_replace_s;
   extern const f_string_static_t iki_read_short_substitute_s;
   extern const f_string_static_t iki_read_short_total_s;
@@ -143,6 +148,7 @@ extern "C" {
   extern const f_string_static_t iki_read_long_literal_s;
   extern const f_string_static_t iki_read_long_name_s;
   extern const f_string_static_t iki_read_long_object_s;
+  extern const f_string_static_t iki_read_long_reassign_s;
   extern const f_string_static_t iki_read_long_replace_s;
   extern const f_string_static_t iki_read_long_substitute_s;
   extern const f_string_static_t iki_read_long_total_s;
@@ -167,6 +173,7 @@ extern "C" {
     iki_read_parameter_literal_e,
     iki_read_parameter_name_e,
     iki_read_parameter_object_e,
+    iki_read_parameter_reassign_e,
     iki_read_parameter_replace_e,
     iki_read_parameter_substitute_e,
     iki_read_parameter_total_e,
@@ -192,6 +199,7 @@ extern "C" {
       macro_f_console_parameter_t_initialize(iki_read_short_literal_s.string, iki_read_long_literal_s.string, 0, 0, f_console_type_normal_e), \
       macro_f_console_parameter_t_initialize(iki_read_short_name_s.string, iki_read_long_name_s.string, 0, 1, f_console_type_normal_e), \
       macro_f_console_parameter_t_initialize(iki_read_short_object_s.string, iki_read_long_object_s.string, 0, 0, f_console_type_normal_e), \
+      macro_f_console_parameter_t_initialize(iki_read_short_reassign_s.string, iki_read_long_reassign_s.string, 0, 3, f_console_type_normal_e), \
       macro_f_console_parameter_t_initialize(iki_read_short_replace_s.string, iki_read_long_replace_s.string, 0, 2, f_console_type_normal_e), \
       macro_f_console_parameter_t_initialize(iki_read_short_substitute_s.string, iki_read_long_substitute_s.string, 0, 3, f_console_type_normal_e), \
       macro_f_console_parameter_t_initialize(iki_read_short_total_s.string, iki_read_long_total_s.string, 0, 0, f_console_type_normal_e), \
@@ -199,7 +207,7 @@ extern "C" {
       macro_f_console_parameter_t_initialize(iki_read_short_wrap_s.string, iki_read_long_wrap_s.string, 0, 3, f_console_type_normal_e), \
     }
 
-  #define iki_read_total_parameters_d 21
+  #define iki_read_total_parameters_d 22
 #endif // _di_iki_read_parameters_
 
 #ifndef _di_iki_read_substitution_t_
index e6d5c8384bef23f9850f05432fe227a0f43866bf..aafa77f2d11fa171787b389bb0f45eb703890a3b 100644 (file)
@@ -40,6 +40,7 @@ extern "C" {
 
     f_print_dynamic_raw(f_string_eol_s, file.stream);
 
+    fll_program_print_help_option(file, context, iki_read_short_reassign_s, iki_read_long_reassign_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "  Re-assign the variable for the given name and matching content value with the given string.");
     fll_program_print_help_option(file, context, iki_read_short_replace_s, iki_read_long_replace_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "   Simple substitution, replacing the variable for the given name with the given string.");
     fll_program_print_help_option(file, context, iki_read_short_substitute_s, iki_read_long_substitute_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "Substitute the variable for the given name and matching content value with the given string.");
     fll_program_print_help_option(file, context, iki_read_short_wrap_s, iki_read_long_wrap_s, f_console_symbol_short_enable_s, f_console_symbol_long_enable_s, "      Prepend and append strings for the given name.");
@@ -58,7 +59,8 @@ extern "C" {
 
     fl_print_format("  The vocabulary is case-sensitive and must exactly match.%r%r", file.stream, f_string_eol_s, f_string_eol_s);
 
-    fl_print_format("  The %[%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("  The %[%r%r%] and the", file.stream, context.set.notable, f_console_symbol_long_enable_s, iki_read_long_reassign_s, context.set.notable);
+    fl_print_format(" %[%r%r%] options require 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);
@@ -85,6 +87,10 @@ extern "C" {
     fl_print_format(" %[%r%r%] option substitutes all matching vocabulary names and the", file.stream, context.set.notable, f_console_symbol_long_enable_s, iki_read_long_replace_s, context.set.notable);
     fl_print_format(" %[%r%r%] option substitutes all matching vocabulary names that must also have the given matching content.%r%r", file.stream, context.set.notable, f_console_symbol_long_enable_s, iki_read_long_substitute_s, context.set.notable, f_string_eol_s, f_string_eol_s);
 
+    fl_print_format("  The %[%r%r%]", file.stream, context.set.notable, f_console_symbol_long_enable_s, iki_read_long_reassign_s, context.set.notable);
+    fl_print_format(" option is identical to the %[%r%r%] option", file.stream, context.set.notable, f_console_symbol_long_enable_s, iki_read_long_substitute_s, context.set.notable);
+    fl_print_format(" except that the %[%r%r%] option is ignored (not applied).%r%r", file.stream, context.set.notable, f_console_symbol_long_enable_s, iki_read_long_wrap_s, context.set.notable, f_string_eol_s, f_string_eol_s);
+
     fl_print_format("  The %[%r%r%]", file.stream, context.set.notable, f_console_symbol_long_enable_s, iki_read_long_substitute_s, context.set.notable);
     fl_print_format(" option takes priority over the %[%r%r%] option when matching the same variable.%r%r", file.stream, context.set.notable, f_console_symbol_long_enable_s, iki_read_long_replace_s, context.set.notable, f_string_eol_s, f_string_eol_s);
 
@@ -306,6 +312,30 @@ extern "C" {
         }
       }
 
+      if (main->parameters.array[iki_read_parameter_reassign_e].result != f_console_result_none_e) {
+        if (main->parameters.array[iki_read_parameter_reassign_e].result == f_console_result_found_e || main->parameters.array[iki_read_parameter_reassign_e].values.used % 3 != 0) {
+          if (main->error.verbosity != f_console_verbosity_quiet_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);
+            fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, iki_read_long_reassign_s, main->error.notable);
+            fl_print_format("%[' requires 3 strings.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s);
+
+            funlockfile(main->error.to.stream);
+          }
+
+          status = F_status_set_error(F_parameter);
+        }
+
+        if (main->parameters.array[iki_read_parameter_total_e].result == f_console_result_found_e) {
+          if (main->error.verbosity != f_console_verbosity_quiet_e) {
+            fll_program_parameter_long_print_cannot_use_with(main->error, iki_read_long_reassign_s, iki_read_long_total_s);
+          }
+
+          status = F_status_set_error(F_parameter);
+        }
+      }
+
       if (main->parameters.array[iki_read_parameter_substitute_e].result != f_console_result_none_e) {
         if (main->parameters.array[iki_read_parameter_substitute_e].result == f_console_result_found_e || main->parameters.array[iki_read_parameter_substitute_e].values.used % 3 != 0) {
           if (main->error.verbosity != f_console_verbosity_quiet_e) {
index ecb84324bcdac1d800dc89368ba574f7b1348d91..163f3f2acb98ede0b4afc8c49158dc3599591c1c 100644 (file)
@@ -7,39 +7,72 @@ extern "C" {
 #endif
 
 #ifndef _di_iki_read_substitutions_print_
-  void iki_read_substitutions_print(iki_read_data_t * const data, const f_iki_data_t iki_data, const f_string_ranges_t ranges, const iki_read_substitution_t replacement, const iki_read_substitution_t wraps, const iki_read_substitutions_t substitutions, const f_array_length_t index, const bool content_only) {
+  void iki_read_substitutions_print(iki_read_data_t * const data, const f_iki_data_t iki_data, const f_string_ranges_t ranges, const iki_read_substitution_t replacement, const iki_read_substitution_t wraps, const iki_read_substitutions_t substitutions, const iki_read_substitutions_t reassignments, const f_array_length_t index, const bool content_only) {
 
-    uint8_t matched = F_false;
+    uint8_t matched = 0x0; // 0x0 = no match, 0x1 = match re-assignment, 0x2 = match substitution.
     f_array_length_t at = 0;
+    f_array_length_t i = 0;
 
     // Grab the last (right-most) match.
-    for (f_array_length_t i = 0; i < substitutions.used; ++i) {
+    for (; i < reassignments.used; ++i) {
 
-      if (fl_string_dynamic_partial_compare_string(substitutions.array[i].replace.string, data->buffer, substitutions.array[i].replace.used, iki_data.content.array[index]) == F_equal_to) {
-        matched = F_true;
+      if (fl_string_dynamic_partial_compare_string(reassignments.array[i].replace.string, data->buffer, reassignments.array[i].replace.used, iki_data.content.array[index]) == F_equal_to) {
+        matched = 0x1;
         at = i;
       }
     } // for
 
+    // Grab the last (right-most) match.
+    if (!matched) {
+      for (i = 0; i < substitutions.used; ++i) {
+
+        if (fl_string_dynamic_partial_compare_string(substitutions.array[i].replace.string, data->buffer, substitutions.array[i].replace.used, iki_data.content.array[index]) == F_equal_to) {
+          matched = 0x2;
+          at = i;
+        }
+      } // for
+    }
+
     if (matched) {
       if (content_only) {
-        f_print_dynamic(substitutions.array[at].with, data->main->output.to.stream);
+        if (matched == 0x1) {
+          f_print_dynamic(reassignments.array[at].with, data->main->output.to.stream);
+        }
+        else {
+          // The wraps.replace represents the "before", which is a string to prepend.
+          if (wraps.replace.used) {
+            f_print_dynamic(wraps.replace, data->main->output.to.stream);
+          }
+
+          f_print_dynamic(substitutions.array[at].with, data->main->output.to.stream);
+
+          // The wraps.replace represents the "after", which is a string to append.
+          if (wraps.with.used) {
+            f_print_dynamic(wraps.with, data->main->output.to.stream);
+          }
+        }
       }
       else {
         f_string_range_t range = macro_f_string_range_t_initialize(iki_data.variable.array[index].start, iki_data.content.array[index].start - 1);
 
         f_print_dynamic_partial(data->buffer, range, data->main->output.to.stream);
 
-        // The wraps.replace represents the "before", which is a string to prepend.
-        if (wraps.replace.used) {
-          f_print_dynamic(wraps.replace, data->main->output.to.stream);
+        if (matched == 0x1) {
+          f_print_dynamic(reassignments.array[at].with, data->main->output.to.stream);
         }
+        else {
 
-        f_print_dynamic(substitutions.array[at].with, data->main->output.to.stream);
+          // The wraps.replace represents the "before", which is a string to prepend.
+          if (wraps.replace.used) {
+            f_print_dynamic(wraps.replace, data->main->output.to.stream);
+          }
 
-        // The wraps.replace represents the "after", which is a string to append.
-        if (wraps.with.used) {
-          f_print_dynamic(wraps.with, data->main->output.to.stream);
+          f_print_dynamic(substitutions.array[at].with, data->main->output.to.stream);
+
+          // The wraps.replace represents the "after", which is a string to append.
+          if (wraps.with.used) {
+            f_print_dynamic(wraps.with, data->main->output.to.stream);
+          }
         }
 
         range.start = iki_data.content.array[index].stop + 1;
index 087339bfd35a415d1150902c270e88595be0257b..c1c1580f79d93bb6fa8ac7e9fa11cbdf5f88fa47 100644 (file)
@@ -28,6 +28,8 @@ extern "C" {
  *   This is only performed when substitutions has no match for the given range at the given index.
  * @param substitutions
  *   The substitutions associated with the variable for the given range at the given index to use for potential printing.
+ * @param reassignments
+ *   The reassignments associated with the variable for the given range at the given index to use for potential printing.
  * @param index
  *   The index used to identify the desired range in variable, content, and ranges.
  * @param content_only
@@ -35,7 +37,7 @@ extern "C" {
  *   Set to FALSE to print the entire variable when printing substituted text.
  */
 #ifndef _di_iki_read_substitutions_print_
-  extern void iki_read_substitutions_print(iki_read_data_t * const data, const f_iki_data_t iki_data, const f_string_ranges_t ranges, const iki_read_substitution_t replacement, const iki_read_substitution_t wraps, const iki_read_substitutions_t substitutions, const f_array_length_t index, const bool content_only) F_attribute_visibility_internal_d;
+  extern void iki_read_substitutions_print(iki_read_data_t * const data, const f_iki_data_t iki_data, const f_string_ranges_t ranges, const iki_read_substitution_t replacement, const iki_read_substitution_t wraps, const iki_read_substitutions_t substitutions, const iki_read_substitutions_t reassignments, const f_array_length_t index, const bool content_only) F_attribute_visibility_internal_d;
 #endif // _di_iki_read_substitutions_print_
 
 #ifdef __cplusplus
index 79b2b32d0710aee4d0da9554f7cbfb2e0e455c3f..229cde7faa304232e47fac00af87c45ba9e86236 100644 (file)
@@ -123,10 +123,12 @@ extern "C" {
 
     iki_read_substitution_t replacements[iki_data->variable.used];
     iki_read_substitution_t wraps[iki_data->variable.used];
+    iki_read_substitutions_t reassignments[iki_data->variable.used];
     iki_read_substitutions_t substitutionss[iki_data->variable.used];
 
     memset(replacements, 0, sizeof(iki_read_substitution_t) * iki_data->variable.used);
     memset(wraps, 0, sizeof(iki_read_substitution_t) * iki_data->variable.used);
+    memset(reassignments, 0, sizeof(iki_read_substitutions_t) * iki_data->variable.used);
     memset(substitutionss, 0, sizeof(iki_read_substitutions_t) * iki_data->variable.used);
 
     if (data->mode == iki_read_mode_literal_e || data->mode == iki_read_mode_content_e) {
@@ -146,12 +148,22 @@ extern "C" {
         return status;
       }
 
-      status = iki_read_substitutions_identify(data, &iki_data->vocabulary, substitutionss);
+      status = iki_read_substitutions_identify(data, &data->main->parameters.array[iki_read_parameter_reassign_e], &iki_data->vocabulary, reassignments);
+
+      if (F_status_is_error_not(status)) {
+        status = iki_read_substitutions_identify(data, &data->main->parameters.array[iki_read_parameter_substitute_e], &iki_data->vocabulary, substitutionss);
+      }
 
       if (F_status_is_error(status)) {
         fll_error_print(data->main->error, F_status_set_fine(status), "iki_read_substitutions_identify", F_true);
 
-        for (f_array_length_t i = 0; i < iki_data->variable.used; ++i) {
+        f_array_length_t i = 0;
+
+        for (; i < iki_data->variable.used; ++i) {
+          macro_iki_read_substitutions_t_delete_simple(reassignments[i]);
+        } // for
+
+        for (i = 0; i < iki_data->variable.used; ++i) {
           macro_iki_read_substitutions_t_delete_simple(substitutionss[i]);
         } // for
 
@@ -178,11 +190,18 @@ extern "C" {
         if (F_status_is_error(status)) {
           fll_error_print(data->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) {
+          f_array_length_t i = 0;
+
+          for (; i < iki_data->variable.used; ++i) {
+            macro_iki_read_substitutions_t_delete_simple(reassignments[i]);
+          } // for
+
+          for (i = 0; i < iki_data->variable.used; ++i) {
             macro_iki_read_substitutions_t_delete_simple(substitutionss[i]);
           } // for
 
           f_string_dynamic_resize(0, &name);
+
           return status;
         }
 
@@ -201,8 +220,8 @@ extern "C" {
               if (matches++ != data->at) continue;
             }
 
-            if (replacements[j].replace.used || wraps[j].replace.used || wraps[j].with.used || substitutionss[j].used) {
-              iki_read_substitutions_print(data, *iki_data, *ranges, replacements[j], wraps[j], substitutionss[j], j, content_only);
+            if (replacements[j].replace.used || wraps[j].replace.used || wraps[j].with.used || substitutionss[j].used || reassignments[j].used) {
+              iki_read_substitutions_print(data, *iki_data, *ranges, replacements[j], wraps[j], substitutionss[j], reassignments[j], j, content_only);
             }
             else {
               f_print_dynamic_partial(data->buffer, ranges->array[j], data->main->output.to.stream);
@@ -229,8 +248,8 @@ extern "C" {
         if (data->at < ranges->used) {
           flockfile(data->main->output.to.stream);
 
-          if (replacements[data->at].replace.used || wraps[data->at].replace.used || wraps[data->at].with.used || substitutionss[data->at].used) {
-            iki_read_substitutions_print(data, *iki_data, *ranges, replacements[data->at], wraps[data->at], substitutionss[data->at], data->at, content_only);
+          if (replacements[data->at].replace.used || wraps[data->at].replace.used || wraps[data->at].with.used || substitutionss[data->at].used || reassignments[data->at].used) {
+            iki_read_substitutions_print(data, *iki_data, *ranges, replacements[data->at], wraps[data->at], substitutionss[data->at], reassignments[data->at], data->at, content_only);
           }
           else {
             f_print_dynamic_partial(data->buffer, ranges->array[data->at], data->main->output.to.stream);
@@ -251,8 +270,8 @@ extern "C" {
 
         for (f_array_length_t i = 0; i < ranges->used; ++i) {
 
-          if (replacements[i].replace.used || wraps[i].replace.used || wraps[i].with.used || substitutionss[i].used) {
-            iki_read_substitutions_print(data, *iki_data, *ranges, replacements[i], wraps[i], substitutionss[i], i, content_only);
+          if (replacements[i].replace.used || wraps[i].replace.used || wraps[i].with.used || substitutionss[i].used || reassignments[i].used) {
+            iki_read_substitutions_print(data, *iki_data, *ranges, replacements[i], wraps[i], substitutionss[i], reassignments[i], i, content_only);
           }
           else {
             f_print_dynamic_partial(data->buffer, ranges->array[i], data->main->output.to.stream);
@@ -270,7 +289,13 @@ extern "C" {
       status = F_data_not;
     }
 
-    for (f_array_length_t i = 0; i < iki_data->variable.used; ++i) {
+    f_array_length_t i = 0;
+
+    for (; i < iki_data->variable.used; ++i) {
+      macro_iki_read_substitutions_t_delete_simple(reassignments[i]);
+    } // for
+
+    for (i = 0; i < iki_data->variable.used; ++i) {
       macro_iki_read_substitutions_t_delete_simple(substitutionss[i]);
     } // for
 
@@ -310,10 +335,12 @@ extern "C" {
 
     iki_read_substitution_t replacements[iki_data->variable.used];
     iki_read_substitution_t wraps[iki_data->variable.used];
+    iki_read_substitutions_t reassignments[iki_data->variable.used];
     iki_read_substitutions_t substitutionss[iki_data->variable.used];
 
     memset(replacements, 0, sizeof(iki_read_substitution_t) * iki_data->variable.used);
     memset(wraps, 0, sizeof(iki_read_substitution_t) * iki_data->variable.used);
+    memset(reassignments, 0, sizeof(iki_read_substitutions_t) * iki_data->variable.used);
     memset(substitutionss, 0, sizeof(iki_read_substitutions_t) * iki_data->variable.used);
 
     if (data->mode == iki_read_mode_literal_e || data->mode == iki_read_mode_content_e) {
@@ -333,12 +360,22 @@ extern "C" {
         return status;
       }
 
-      status = iki_read_substitutions_identify(data, &iki_data->vocabulary, substitutionss);
+      status = iki_read_substitutions_identify(data, &data->main->parameters.array[iki_read_parameter_reassign_e], &iki_data->vocabulary, reassignments);
+
+      if (F_status_is_error_not(status)) {
+        status = iki_read_substitutions_identify(data, &data->main->parameters.array[iki_read_parameter_substitute_e], &iki_data->vocabulary, substitutionss);
+      }
 
       if (F_status_is_error(status)) {
         fll_error_print(data->main->error, F_status_set_fine(status), "iki_read_substitutions_identify", F_true);
 
-        for (f_array_length_t i = 0; i < iki_data->variable.used; ++i) {
+        f_array_length_t i = 0;
+
+        for (; i < iki_data->variable.used; ++i) {
+          macro_iki_read_substitutions_t_delete_simple(reassignments[i]);
+        } // for
+
+        for (i = 0; i < iki_data->variable.used; ++i) {
           macro_iki_read_substitutions_t_delete_simple(substitutionss[i]);
         } // for
 
@@ -390,6 +427,10 @@ extern "C" {
       } // for
 
       if (F_status_is_error(status)) {
+        for (; i < iki_data->variable.used; ++i) {
+          macro_iki_read_substitutions_t_delete_simple(reassignments[i]);
+        } // for
+
         for (i = 0; i < iki_data->variable.used; ++i) {
           macro_iki_read_substitutions_t_delete_simple(substitutionss[i]);
         } // for
@@ -435,21 +476,22 @@ extern "C" {
 
             if (status == F_equal_to) {
               name_missed = F_false;
+
               break;
             }
           } // for
 
           if (name_missed) {
-            if (replacements[j].replace.used || wraps[j].replace.used || wraps[j].with.used || substitutionss[j].used) {
-              iki_read_substitutions_print(data, *iki_data, iki_data->variable, replacements[j], wraps[j], substitutionss[j], j, F_false);
+            if (replacements[j].replace.used || wraps[j].replace.used || wraps[j].with.used || substitutionss[j].used || reassignments[j].used) {
+              iki_read_substitutions_print(data, *iki_data, iki_data->variable, replacements[j], wraps[j], substitutionss[j], reassignments[j], j, F_false);
             }
             else {
               f_print_dynamic_partial(data->buffer, iki_data->variable.array[j], data->main->output.to.stream);
             }
           }
           else {
-            if (replacements[j].replace.used || wraps[j].replace.used || wraps[j].with.used || substitutionss[j].used) {
-              iki_read_substitutions_print(data, *iki_data, *ranges, replacements[j], wraps[j], substitutionss[j], j, content_only);
+            if (replacements[j].replace.used || wraps[j].replace.used || wraps[j].with.used || substitutionss[j].used || reassignments[j].used) {
+              iki_read_substitutions_print(data, *iki_data, *ranges, replacements[j], wraps[j], substitutionss[j], reassignments[j], j, content_only);
             }
             else {
               f_print_dynamic_partial(data->buffer, ranges->array[j], data->main->output.to.stream);
@@ -457,8 +499,8 @@ extern "C" {
           }
         }
         else {
-          if (replacements[j].replace.used || wraps[j].replace.used || wraps[j].with.used || substitutionss[j].used) {
-            iki_read_substitutions_print(data, *iki_data, *ranges, replacements[j], wraps[j], substitutionss[j], j, content_only);
+          if (replacements[j].replace.used || wraps[j].replace.used || wraps[j].with.used || substitutionss[j].used || reassignments[j].used) {
+            iki_read_substitutions_print(data, *iki_data, *ranges, replacements[j], wraps[j], substitutionss[j], reassignments[j], j, content_only);
           }
           else {
             f_print_dynamic_partial(data->buffer, ranges->array[j], data->main->output.to.stream);
@@ -477,7 +519,13 @@ extern "C" {
       funlockfile(data->main->output.to.stream);
     }
 
-    for (f_array_length_t i = 0; i < iki_data->variable.used; ++i) {
+    f_array_length_t i = 0;
+
+    for (; i < iki_data->variable.used; ++i) {
+      macro_iki_read_substitutions_t_delete_simple(reassignments[i]);
+    } // for
+
+    for (i = 0; i < iki_data->variable.used; ++i) {
       macro_iki_read_substitutions_t_delete_simple(substitutionss[i]);
     } // for
 
@@ -629,11 +677,9 @@ extern "C" {
 #endif // _di_iki_read_replacements_identify_
 
 #ifndef _di_iki_read_substitutions_identify_
-  f_status_t iki_read_substitutions_identify(iki_read_data_t * const data, f_iki_vocabulary_t *vocabulary, iki_read_substitutions_t *substitutionss) {
+  f_status_t iki_read_substitutions_identify(iki_read_data_t * const data, f_console_parameter_t * const parameter, f_iki_vocabulary_t *vocabulary, iki_read_substitutions_t *substitutionss) {
 
-    if (data->main->parameters.array[iki_read_parameter_substitute_e].result != f_console_result_additional_e) {
-      return F_none;
-    }
+    if (parameter->result != f_console_result_additional_e) return F_none;
 
     f_status_t status = F_none;
 
@@ -643,8 +689,6 @@ extern "C" {
     f_array_length_t index = 0;
     f_array_length_t index2 = 0;
 
-    f_console_parameter_t *parameter = &data->main->parameters.array[iki_read_parameter_substitute_e];
-
     for (; i < parameter->values.used; i += 3) {
 
       index = parameter->values.array[i];
index 9172aae6a98eb05e6c6fee908bbb73a00db009ee..a92b99a329891855566920c087ce070e2ecd8e98 100644 (file)
@@ -146,6 +146,8 @@ extern "C" {
  *
  * @param data
  *   The program data.
+ * @param parameter
+ *   The parameter data for the parameter being processed.
  * @param vocabulary
  *   The ranges representing a vocabulary.
  * @param substitutionss
@@ -157,7 +159,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_data_t * const data, 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_data_t * const data, f_console_parameter_t * const parameter, f_iki_vocabulary_t *vocabulary, iki_read_substitutions_t *substitutionss) F_attribute_visibility_internal_d;
 #endif // _di_iki_read_substitutions_identify_
 
 /**