summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-05-30 09:08:50 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-05-30 09:08:50 -0700
commit1f54ad5cc1d384d0818a6bf6cec20a95ecc5a5ae (patch)
treeaab51e24a075aed919f5ed3ad4d8232130768730 /lib.c
parentc5134a9ddba4fd14703d506b0cccd51d823e013e (diff)
downloadtxr-1f54ad5cc1d384d0818a6bf6cec20a95ecc5a5ae.tar.gz
txr-1f54ad5cc1d384d0818a6bf6cec20a95ecc5a5ae.tar.bz2
txr-1f54ad5cc1d384d0818a6bf6cec20a95ecc5a5ae.zip
Replace trivial format(nil, ...) with simpler ops.
* gencadr.txr (cadr_register): Use scat2 to glue two strings. * cadr.c: Regenerated. * lib.c (scat2, scat3): New functions. * lib.h (scat2, scat3): Declared. * liblib.c (place_instantiate, ver_instantiate, ifa_instantiate, txr_case_instantiate, with_resources_instantiate, path_test_instantiate, struct_instantiate, with_stream_instantiate, hash_instantiate, except_instantiate, type_instantiate, yield_instantiate, sock_instantiate, termios_instantiate, awk_instantiate, build_instantiate, trace_instantiate, getopts_instantiate, package_instantiate, getput_instantiate, tagbody_instantiate, pmac_instantiate, error_instantiate, keyparams_instantiate, ffi_instantiate, doloop_instantiate, stream_wrap_instantiate, asm_instantiate, compiler_instantiate, debugger_instantiate, op_instantiate, save_exe_instantiate, defset_instantiate, copy_file_instantiate): Use scat2 to glue two strings instead of format. * parser.c (find_matching_syms, hist_save, repl): Replace trivial uses of format with scat2 or scat3. * sysif.c (ensure_dir): Likewise. * txr.c (get_self_path, substitute_basename, sysroot, sysroot_init, parse_once_noerr, read_compiled_file_noerr, read_eval_stream_noerr): Likewise. * unwind.c (uw_unwind_to_exit_point): Likewise.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index ef3d511c..1b9fefa9 100644
--- a/lib.c
+++ b/lib.c
@@ -4223,6 +4223,41 @@ val scat(val sep, ...)
return ret;
}
+val scat2(val s1, val s2)
+{
+ struct cat_str cs;
+
+ cat_str_init(&cs, nil, NULL);
+
+ cat_str_measure(&cs, s1, 1);
+ cat_str_measure(&cs, s2, 0);
+
+ cat_str_alloc(&cs);
+
+ cat_str_append(&cs, s1, 1);
+ cat_str_append(&cs, s2, 0);
+
+ return cat_str_get(&cs);
+}
+
+val scat3(val s1, val sep, val s2)
+{
+ struct cat_str cs;
+ wchar_t onech[] = wini(" ");
+
+ cat_str_init(&cs, sep, onech);
+
+ cat_str_measure(&cs, s1, 1);
+ cat_str_measure(&cs, s2, 0);
+
+ cat_str_alloc(&cs);
+
+ cat_str_append(&cs, s1, 1);
+ cat_str_append(&cs, s2, 0);
+
+ return cat_str_get(&cs);
+}
+
val fmt_join(struct args *args)
{
cnum index;