diff options
-rw-r--r-- | stream.c | 8 | ||||
-rw-r--r-- | tests/018/path.tl | 44 | ||||
-rw-r--r-- | txr.1 | 27 |
3 files changed, 40 insertions, 39 deletions
@@ -5043,9 +5043,9 @@ val short_suffix(val name, val alt_in) if (!dot || (sl && sl[1]) || dot == str || wcschr(psc, dot[-1])) { return default_null_arg(alt_in); } else { - wchar_t *suff = chk_strdup(dot + 1); + wchar_t *suff = chk_strdup(dot); if (sl) - suff[sl - (dot + 1)] = 0; + suff[sl - dot] = 0; return string_own(suff); } } @@ -5069,9 +5069,9 @@ val long_suffix(val name, val alt_in) if (!dot || dot == str) { return default_null_arg(alt_in); } else { - wchar_t *suff = chk_strdup(dot + 1); + wchar_t *suff = chk_strdup(dot); if (sl) - suff[sl - (dot + 1)] = 0; + suff[sl - dot] = 0; return string_own(suff); } } diff --git a/tests/018/path.tl b/tests/018/path.tl index a00b9465..bb45d000 100644 --- a/tests/018/path.tl +++ b/tests/018/path.tl @@ -8,13 +8,13 @@ (short-suffix "a") nil (short-suffix "a" 0) 0 (short-suffix ".") nil - (short-suffix "a.") "" - (short-suffix "a.b.") "" + (short-suffix "a.") "." + (short-suffix "a.b.") "." (short-suffix ".c") nil - (short-suffix "a.c") "c" - (short-suffix "a.b.c") "c" - (short-suffix "foo.txt.gz") "gz" - (short-suffix "txt.gz") "gz" + (short-suffix "a.c") ".c" + (short-suffix "a.b.c") ".c" + (short-suffix "foo.txt.gz") ".gz" + (short-suffix "txt.gz") ".gz" (short-suffix ".gz") nil) (mtest @@ -25,16 +25,16 @@ (long-suffix "a") nil (long-suffix "a" 0) 0 (long-suffix ".") nil - (long-suffix "a.") "" - (long-suffix "a.b.") "b." + (long-suffix "a.") "." + (long-suffix "a.b.") ".b." (long-suffix ".c") nil - (long-suffix "a.c") "c" - (long-suffix "a.b.c") "b.c" - (long-suffix "foo.txt.gz") "txt.gz" + (long-suffix "a.c") ".c" + (long-suffix "a.b.c") ".b.c" + (long-suffix "foo.txt.gz") ".txt.gz" (long-suffix ".gz") nil - (long-suffix ".txt.gz") "gz" - (long-suffix "/.txt.gz") "gz" - (long-suffix "a/.txt.gz") "gz") + (long-suffix ".txt.gz") ".gz" + (long-suffix "/.txt.gz") ".gz" + (long-suffix "a/.txt.gz") ".gz") (mtest (short-suffix "/") nil @@ -43,12 +43,12 @@ (short-suffix "a/.") nil (short-suffix ".a/") nil (short-suffix ".a/b") nil - (short-suffix ".a/c.b") "b" + (short-suffix ".a/c.b") ".b" (short-suffix ".a/b/") nil (short-suffix ".a/b/.b") nil (short-suffix ".a/b/.b/") nil - (short-suffix ".a/b/c.b") "b" - (short-suffix ".a/b/c.b/") "b" + (short-suffix ".a/b/c.b") ".b" + (short-suffix ".a/b/c.b/") ".b" (short-suffix ".a/b/c.b//") nil) (mtest @@ -61,10 +61,10 @@ (long-suffix ".a/b/") nil (long-suffix ".a/b/.b") nil (long-suffix ".a/b/.b/") nil - (long-suffix ".a/b/c.b") "b" - (long-suffix ".a/b/c.b/") "b" - (long-suffix "a.b/c.d.e") "d.e" - (long-suffix "a.b/c.d.e/") "d.e" + (long-suffix ".a/b/c.b") ".b" + (long-suffix ".a/b/c.b/") ".b" + (long-suffix "a.b/c.d.e") ".d.e" + (long-suffix "a.b/c.d.e/") ".d.e" (long-suffix "a.b/c.d.e/f") nil - (long-suffix "a.b/c.d.e/f.g.h") "g.h" + (long-suffix "a.b/c.d.e/f.g.h") ".g.h" (long-suffix "a.b/c.d.e//") nil) @@ -57204,10 +57204,11 @@ in more detail below. If a suffix delimiter is present, then the long or short suffix is the substring of .meta path -consisting of all the characters which follow the delimiting period, -exclusive of -.metn path 's -trailing path separator, if any. +which includes the delimiting period and all characters which follow, +except that if the last character of +.meta path +is a path separator character, that character is omitted from the +returned suffix. If multiple periods occur in the last component of the path, the delimiter for the long suffix is the leftmost period; @@ -57242,11 +57243,11 @@ extracted from this last component. (short-suffix ".abc") -> nil (short-suffix "/.abc") -> nil (short-suffix "abc" "") -> "" - (short-suffix "abc.") -> "" - (short-suffix "abc.tar") -> "tar" - (short-suffix "abc.tar.gz") -> "gz" - (short-suffix "abc.tar.gz/") -> "gz" - (short-suffix "x.y.z/abc.tar.gz/") -> "gz" + (short-suffix "abc.") -> "." + (short-suffix "abc.tar") -> ".tar" + (short-suffix "abc.tar.gz") -> ".gz" + (short-suffix "abc.tar.gz/") -> ".gz" + (short-suffix "x.y.z/abc.tar.gz/") -> ".gz" (short-suffix "x.y.z/abc.tar.gz//") -> nil (long-suffix "") -> nil @@ -57255,10 +57256,10 @@ extracted from this last component. (long-suffix ".abc") -> nil (long-suffix "/.abc") -> nil (long-suffix "abc.") -> "" - (long-suffix "abc.tar") -> "tar" - (long-suffix "abc.tar.gz") -> "tar.gz" - (long-suffix "abc.tar.gz/") -> "tar.gz" - (long-suffix "x.y.z/abc.tar.gz/") -> "tar.gz" + (long-suffix "abc.tar") -> ".tar" + (long-suffix "abc.tar.gz") -> ".tar.gz" + (long-suffix "abc.tar.gz/") -> ".tar.gz" + (long-suffix "x.y.z/abc.tar.gz/") -> ".tar.gz" .brev .coNP Function @ path-cat |