summaryrefslogtreecommitdiffstats
path: root/glob.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2020-05-24 22:05:09 -0700
committerKaz Kylheku <kaz@kylheku.com>2020-05-24 22:05:09 -0700
commit5c7a7732e8938b5d127b677f0d42d3a774103112 (patch)
treeb5d1aeac179df52e717a1fac483637ec601b1116 /glob.h
parent19e36297b54f684becbebe54637c5a0c9bd18cd7 (diff)
downloadtxr-5c7a7732e8938b5d127b677f0d42d3a774103112.tar.gz
txr-5c7a7732e8938b5d127b677f0d42d3a774103112.tar.bz2
txr-5c7a7732e8938b5d127b677f0d42d3a774103112.zip
lib: combine cat_str and vscat implementations.
The vscat function is white-box copy of cat_str, with just the iteration over the inputs done differently, and without the support for separators that are characters instead of strings (which was added to cat_str after vscat was forked. In this patch, the common logic underlying both functions is factored out into a small ad-hoc "struct cat_str" object which maintains the state and provides the operations to measure the pieces of the string, allocate the space, copy the pieces together and produce the resulting object. The motivation here isn't just to reduce duplication. I would like a more efficient function for catenating strings which takes a "struct args *", not requiring a list to be consed up. * lib.c (struct cat_str): New struct type. (cat_str_init, cat_str_measure, cat_str_alloc, cat_str_append, cat_str_get): New static functions. (cat_str, vscat): Considerably shorten by using the above functions.
Diffstat (limited to 'glob.h')
0 files changed, 0 insertions, 0 deletions