summary refs log tree commit diff
path: root/core.e
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-05-28 21:07:55 -0700
committerIrene Knapp <ireneista@irenes.space>2026-05-28 21:07:55 -0700
commit0f3c90d8c67c7150feed36a1e620a6aa68f987a7 (patch)
treebc80e407fd8508afdd78f99e8dae5e958a454622 /core.e
parentfb57c4ae52e9836f52e4fc5d4999824ebdd2c57c (diff)
moved pack-raw-string into core.e
Force-Push: yes
Change-Id: I0940c0c21580e810716a5f61b95fd520c464ab9e
Diffstat (limited to 'core.e')
-rw-r--r--core.e14
1 files changed, 14 insertions, 0 deletions
diff --git a/core.e b/core.e
index 62e2301..e49c2f9 100644
--- a/core.e
+++ b/core.e
@@ -1197,6 +1197,20 @@ here !
   ~ (output point, source, destination, length)
   memcopy ;
 
+~   This also works on C-style strings, relying on the null terminator, but
+~ the packed data does not include it.
+~
+~ (output point, string pointer -- output point)
+: pack-raw-string
+  dup stringlen dup
+  ~ (output point, source, length, length)
+  4 roll dup 4 unroll
+
+  ~ (source, destination, length, length, output point)
+  + 4 unroll
+  ~ (output point, source, destination, length)
+  memcopy ;
+
 ~ (output point, alignment byte count -- output point)
 : packalign
   { 2dup /% drop { drop exit } unless