summaryrefslogtreecommitdiffstats
path: root/lib.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2024-05-27 20:20:14 -0700
committerKaz Kylheku <kaz@kylheku.com>2024-05-27 20:20:14 -0700
commit1e78321bcd7838565fb6ea6ecf330db7d2422547 (patch)
tree2c0c75c5022003f0de0f8d6f20bfa70bc76d9266 /lib.h
parent89eb0e18c6af1dc2150e34af19e81b1ad3b52f81 (diff)
downloadtxr-1e78321bcd7838565fb6ea6ecf330db7d2422547.tar.gz
txr-1e78321bcd7838565fb6ea6ecf330db7d2422547.tar.bz2
txr-1e78321bcd7838565fb6ea6ecf330db7d2422547.zip
quasiliterals: buffers in hex, separation for strings and buffers.
In this commit, output variables in the TXR Pattern language and in TXR Lisp quasiliterals now support separator strings for values that are strings and buffers. Values which are buffers appear differently: they are rendered as a sequence of lower case hex digit pairs. When a string-valued variable specifies a separator, the separator appears between characters of the string value. Previously, the separator was ignored. When a buffer-valued variable specifies a separator. the separator appears between pairs of digits, not between digits. For instance if ethaddr is a variable holding #b'08:00:27:79:c7:f5', then the quasiliteral `@ethaddr` produces "08002779c7f" whereas `@{ethaddr ":"}` produces "08:00:27:79:c7:f5". * buf.[ch] (buf_str_sep): New function. * lib.[ch] (fmt_str_sep): New function. * eval.c (fmt_cat): If the argument is a string, and a separator is present, replace the value with the result of calling fmt_str_sep. If the argument is a buffer, and a separator is present, use buf_str_sep to convert to a string, otherwise use tostringp. * txr.1: Section on Output Variables updated. * tests/012/readprint.tl: New tests.
Diffstat (limited to 'lib.h')
-rw-r--r--lib.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib.h b/lib.h
index dfa23c6e..07c37b9f 100644
--- a/lib.h
+++ b/lib.h
@@ -1103,6 +1103,7 @@ val scat2(val s1, val s2);
val scat3(val s1, val sep, val s2);
val join_with(val sep, varg args);
val fmt_join(varg args);
+val fmt_str_sep(val sep, val str, val self);
val split_str(val str, val sep);
val split_str_keep(val str, val sep, val keep_sep_opt, val count_opt);
val spl(val sep, val arg1, val arg2);