diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-07-10 08:44:16 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-07-10 08:44:16 -0700 |
commit | 91d1a70c1d64c67bbaa5dc94dabf7461ad97bb8d (patch) | |
tree | 08f93715512867f64d942fcecaddece9e2d7b141 /txr.1 | |
parent | 44fc04addc852cd4d0bbfa53a44b69679aaa29c2 (diff) | |
download | txr-91d1a70c1d64c67bbaa5dc94dabf7461ad97bb8d.tar.gz txr-91d1a70c1d64c67bbaa5dc94dabf7461ad97bb8d.tar.bz2 txr-91d1a70c1d64c67bbaa5dc94dabf7461ad97bb8d.zip |
New functions: trim-short-suffix, trim-long-suffix.
* lib.c, lib.h (chk_substrdup): New function.
* stream.c, stream.h (trim_short_suffix, trim_long_suffix):
New functions.
(stream_init): trim-short-suffix and trim-long-suffix
intrinsics registered.
* tests/018/path.tl: New tests.
* txr.1: Documented.
* stdlib/doc-syms.tl: Updated.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 59 |
1 files changed, 59 insertions, 0 deletions
@@ -57577,6 +57577,65 @@ extracted from this last component. (long-suffix "x.y.z/abc.tar.gz/") -> ".tar.gz" .brev +.coNP Functions @ trim-long-suffix and @ trim-short-suffix +.synb +.mets (trim-long-suffix << path ) +.mets (trim-short-suffix << path ) +.syne +.desc +The +.code trim-long-suffix +and +.code trim-short-suffix +functions calculate the portion of +.meta path +.I "long suffix" +and +.I "short suffix" +of the string argument +.metn path , +and return a path with the suffix removed. + +Respectively, +.code trim-long-suffix +and +.code trim-short-suffix +calculate the suffix in exactly the same manner as +.code long-suffix +and +.codn short-suffix . + +If +.meta path +is found not to contain a suffix, then it is returned. + +If +.meta path +contains a suffix, then a new string is returned from which +the suffix is deleted. If the suffix is followed by one or more path separator +characters, these are preserved in the return value. + +.TP* Examples: + +.verb + (trim-short-suffix "") -> "" + (trim-short-suffix "a") -> "a" + (trim-short-suffix ".") -> "." + (trim-short-suffix ".a") -> ".a" + + (trim-short-suffix "a.") -> "a" + (trim-short-suffix "a.b") -> "a" + (trim-short-suffix "a.b.c") -> "a.b" + + (trim-short-suffix "a./") -> "a/" + (trim-short-suffix "a.b/") -> "a/" + (trim-short-suffix "a.b.c/") -> "a.b/" + + (trim-long-suffix "a.b.c") -> "a" + (trim-long-suffix "a.b.c/") -> "a/" + (trim-long-suffix "a.b.c///") -> "a///" +.brev + .coNP Function @ path-cat .synb .mets (path-cat >> [ dir-path <> { rel-path }*]) |