From: Kevin Day Date: Mon, 26 Oct 2026 01:33:00 +0000 (-0500) Subject: Feature: Byte Dump should print the first and last range. X-Git-Url: https://www.git.kevux.org/?a=commitdiff_plain;h=e127ac813414a5000e632a06bd89932558e52f8f;p=fll Feature: Byte Dump should print the first and last range. Providing the `--first` and/or the `--last` parameters should then put the range in the title. The range is inclusive for the first character and exclusive for the last character. Therefore, the `[` character is used for a closed range for first and `)` character is used for an open range for the last. --- diff --git a/build/stand_alone/byte_dump.config.h b/build/stand_alone/byte_dump.config.h index 476ebb639..f656e8b65 100644 --- a/build/stand_alone/byte_dump.config.h +++ b/build/stand_alone/byte_dump.config.h @@ -965,7 +965,7 @@ #define _di_f_string_format_ull_single_s_ #define _di_f_string_format_un_double_s_ #define _di_f_string_format_un_s_ -#define _di_f_string_format_un_single_s_ +//#define _di_f_string_format_un_single_s_ #define _di_f_string_format_z_double_s_ #define _di_f_string_format_z_s_ #define _di_f_string_format_z_single_s_ diff --git a/level_3/byte_dump/c/main/common/define.h b/level_3/byte_dump/c/main/common/define.h index 0a3c1d387..ad9e6cfbb 100644 --- a/level_3/byte_dump/c/main/common/define.h +++ b/level_3/byte_dump/c/main/common/define.h @@ -42,6 +42,7 @@ extern "C" { * - first: The first position is specified. * - help: Print help. * - last: The last position is specified. + * - last_first: Either first position or last position is specified. * - placeholder: Placeholder is specified. * - pipe: Use the input pipe. * - text: Text is specified. @@ -57,6 +58,7 @@ extern "C" { #define byte_dump_main_flag_first_d 0x4 #define byte_dump_main_flag_help_d 0x8 #define byte_dump_main_flag_last_d 0x10 + #define byte_dump_main_flag_last_first_d 0x14 #define byte_dump_main_flag_pipe_d 0x20 #define byte_dump_main_flag_placeholder_d 0x40 #define byte_dump_main_flag_text_d 0x80 diff --git a/level_3/byte_dump/c/main/print/data.c b/level_3/byte_dump/c/main/print/data.c index bf6cf99e2..235b5807e 100644 --- a/level_3/byte_dump/c/main/print/data.c +++ b/level_3/byte_dump/c/main/print/data.c @@ -678,7 +678,33 @@ extern "C" { f_print_dynamic_raw(byte_dump_decimal_s, print->to); } - fl_print_format(")%]%r", print->to, print->set->title, f_string_eol_s); + if (main->setting.flag & byte_dump_main_flag_last_first_d) { + fl_print_format(") Range [%]", print->to, print->set->title); + + if (main->setting.flag & byte_dump_main_flag_first_d) { + fl_print_format(f_string_format_un_single_s.string, print->to, print->set->notable, main->setting.first, print->set->notable); + } + + fl_print_format("%[,%] ", print->to, print->set->title, print->set->title); + + // Last is stored as an offset from first, so add the two together. + if (main->setting.flag & byte_dump_main_flag_last_d) { + fl_print_format( + f_string_format_un_single_s.string, + print->to, + print->set->notable, + (main->setting.flag & byte_dump_main_flag_first_d) + ? main->setting.first + main->setting.last + : main->setting.last, + print->set->notable + ); + } + + fl_print_format("%[)%]%r", print->to, print->set->title, print->set->title, f_string_eol_s); + } + else { + fl_print_format(")%]%r", print->to, print->set->title, f_string_eol_s); + } f_file_stream_unlock(print->to);