summary refs log tree commit diff
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-09-08 05:04:37 -0700
committerIrene Knapp <ireneista@irenes.space>2026-09-08 05:05:07 -0700
commit6f76a3a291d1a895e3e5cd36103fb4c4199825e1 (patch)
treecb334e7d1dfa308f8b96e92dca4f80cf6eeadf05
parent47bebc52ce2e9923be8ca4b7c144094f85d3c4b1 (diff)
the hex dump now prints trailing messages at the end of the data
Force-Push: yes
Change-Id: I71930b088c176ade6a0bf7aaecb46bdecb0636ad
-rw-r--r--hex.e9
-rw-r--r--transform.e16
2 files changed, 19 insertions, 6 deletions
diff --git a/hex.e b/hex.e
index c20d61a..fd283ca 100644
--- a/hex.e
+++ b/hex.e
@@ -254,6 +254,10 @@
 ~ Everything directly called by all-contents has this same interface.
 ~
 : all-contents
+  ~ :   This particular program is 'hex' itself. You of course already need to
+  ~ : have a binary copy of it to use this file, but you may find it helpful
+  ~ : to have this hex dump anyway, to aid in auditing your binary.
+  ~ : blank-line
   0x08000000 L!' origin
   elf-file-header
   elf-program-header-writable
@@ -271,7 +275,10 @@
   current-offset L!' buffer 0 pack64
   ~ : deindent
 
-  current-offset L!' total-size ;
+  current-offset L!' total-size
+  ~ : blank-line
+  ~ : This is the end of the hex dump.
+  ;
 
 ' all-contents entry-to-execution-token label-loop
 swap sys-write bye
diff --git a/transform.e b/transform.e
index 12c5483..7560752 100644
--- a/transform.e
+++ b/transform.e
@@ -3094,7 +3094,7 @@ allocate-transformation-state s" transformation-state" variable
 : hex-sys-write-replacement
   postprocess-metadata-entries
 
-  { over } {
+  { over 0 <= } {
     transformation-state transformation-state-output-metadata @
     hex-output-metadata-first-entry
     ~ (length remaining, current output address, metadata scan pointer)
@@ -3193,10 +3193,16 @@ allocate-transformation-state s" transformation-state" variable
     } while
     drop
 
-    is-fresh-line@ { indentation-depth@ dup indent advance-current-column } if
-    dup 8@ .hex8 space
-    3 advance-current-column
-    0 is-fresh-line!
+    over {
+      is-fresh-line@ {
+        indentation-depth@ dup indent advance-current-column
+      } if
+
+      dup 8@ .hex8 space
+
+      3 advance-current-column
+      0 is-fresh-line!
+    } if
 
     1+ swap 1- swap
   } while ;