commit a3fecebfb76696fd643791ec7c76f17ed0e0cb33
parent 3c2c47d941166d74b596ce55bc76109c5a67e1e4
Author: vx-clutch <[email protected]>
Date: Fri, 5 Sep 2025 18:40:20 -0400
breakup string into literals
Diffstat:
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/tools/tostr b/tools/tostr
@@ -1,10 +1,10 @@
#!/bin/sh
awk '
-BEGIN {
- printf "\""
-}
{
+ # Start a new string literal
+ printf "\""
+
for (i = 1; i <= length($0); i++) {
c = substr($0, i, 1)
if (c == "\\") {
@@ -31,10 +31,9 @@ BEGIN {
printf "%s", c
}
}
- printf "\\n"
-}
-END {
- printf "\"\n"
+
+ # Always end each literal with \n inside, close quote, then newline
+ printf "\\n\"\n"
}
function ord(str, l, r) {
l = sprintf("%c", 255)