From ccb998581d8ba1e2f8f9c56768d57e32c51777c5 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 3 Jul 2021 16:06:17 -0700 Subject: suffix functions: ignore trailing slashes. Another requirements tweak to short-suffix and long-suffix: ignore one or more trailing slashes, instead of just one. This harmonizes with base-name, which does same, that requirement being copies from the POSIX basename utility. * stream.c (short_suffix, long_suffix): If sl points to a trailing slash which is the start of a suffix that consists of nothing but trailing slashes, then we pretend it isn't there. * tests/018/path.tl: Adjusted two existing test cases, and added more. * txr.1: Documented. --- tests/018/path.tl | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'tests/018') diff --git a/tests/018/path.tl b/tests/018/path.tl index 96298dfd..937d2d6e 100644 --- a/tests/018/path.tl +++ b/tests/018/path.tl @@ -49,7 +49,12 @@ (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//") nil) + (short-suffix ".a/b/c.b//") ".b" + (short-suffix ".a/b/c.b///") ".b" + (short-suffix ".a/b/c.") "." + (short-suffix ".a/b/c./") "." + (short-suffix ".a/b/c.//") "." + (short-suffix ".a/b/c.///") ".") (mtest (long-suffix "/") nil @@ -67,7 +72,16 @@ (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//") nil) + (long-suffix "a.b/c.d.e//") ".d.e" + (long-suffix "a.b/c.d.e///") ".d.e" + (long-suffix "a.b/c.d.") ".d." + (long-suffix "a.b/c.d./") ".d." + (long-suffix "a.b/c.d.//") ".d." + (long-suffix "a.b/c.d.///") ".d." + (long-suffix "a.b/c.") "." + (long-suffix "a.b/c./") "." + (long-suffix "a.b/c.//") "." + (long-suffix "a.b/c.///") ".") (mtest (base-name "") "" -- cgit v1.2.3