From: Kevin Day Date: Sun, 23 Oct 2022 04:03:11 +0000 (-0500) Subject: Bugfix: The iki_read is should apply the "--wrap" when using "--substitute". X-Git-Tag: 0.6.1~6 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=bbc7591a040baeca7d19d1d6b644b80ad2e70d01;p=fll Bugfix: The iki_read is should apply the "--wrap" when using "--substitute". Given some iki text such as: This is some random:"iki" random:"text". Run the command: # echo 'This is some random:"iki" random:"text".' | iki_read -W random "___" "______" -L -s random text PIZZA -r random tomato The result that I get is: random:"___tomato______" random:"PIZZA" I think the following is better: random:"___tomato______" random:"___PIZZA______" This makes more sense to me rather than having substitute not include wrap. This is a behavioral change that I thought and perhaps still think can be considered a bug. This "bug" is by design as per the documentation but in retrospect I think this is a mistake in the design and should be considered a bug. --- diff --git a/level_3/iki_read/c/iki_read.c b/level_3/iki_read/c/iki_read.c index 3da7f43..e6d5c83 100644 --- a/level_3/iki_read/c/iki_read.c +++ b/level_3/iki_read/c/iki_read.c @@ -88,9 +88,6 @@ extern "C" { 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); - fl_print_format(" The %[%r%r%]", file.stream, context.set.notable, f_console_symbol_long_enable_s, iki_read_long_wrap_s, context.set.notable); - fl_print_format(" option is ignored when the %[%r%r%] option is matching the same variable.%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 default behavior is to only display content portion of the IKI variable.%r%r", file.stream, f_string_eol_s, f_string_eol_s); funlockfile(file.stream); diff --git a/level_3/iki_read/c/private-print.c b/level_3/iki_read/c/private-print.c index 1848ff6..ecb8432 100644 --- a/level_3/iki_read/c/private-print.c +++ b/level_3/iki_read/c/private-print.c @@ -30,8 +30,18 @@ extern "C" { 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); + } + 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; range.stop = iki_data.variable.array[index].stop;