]> Kevux Git Server - fll/commitdiff
Feature: Byte Dump should print the first and last range.
authorKevin Day <Kevin@kevux.org>
Mon, 26 Oct 2026 01:33:00 +0000 (20:33 -0500)
committerKevin Day <Kevin@kevux.org>
Mon, 26 Oct 2026 01:33:00 +0000 (20:33 -0500)
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.

build/stand_alone/byte_dump.config.h
level_3/byte_dump/c/main/common/define.h
level_3/byte_dump/c/main/print/data.c

index 476ebb6..f656e8b 100644 (file)
 #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_
index 0a3c1d3..ad9e6cf 100644 (file)
@@ -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
index bf6cf99..235b580 100644 (file)
@@ -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);