summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-07-10 08:44:16 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-07-10 08:44:16 -0700
commit91d1a70c1d64c67bbaa5dc94dabf7461ad97bb8d (patch)
tree08f93715512867f64d942fcecaddece9e2d7b141 /txr.1
parent44fc04addc852cd4d0bbfa53a44b69679aaa29c2 (diff)
downloadtxr-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.159
1 files changed, 59 insertions, 0 deletions
diff --git a/txr.1 b/txr.1
index 8fc4a3f5..026df54d 100644
--- a/txr.1
+++ b/txr.1
@@ -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 }*])