summaryrefslogtreecommitdiffstats
path: root/stream.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-06-26 12:16:42 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-06-26 12:16:42 -0700
commit24c2898ff6d169b058d41ad68381d2036267ca0d (patch)
tree88ad198dcce80164ea18b7f849e77d1b7a1ca2a5 /stream.c
parentbf2e5199e8dbc4e6fd4fcac5dab1ea16f4ec5970 (diff)
downloadtxr-24c2898ff6d169b058d41ad68381d2036267ca0d.tar.gz
txr-24c2898ff6d169b058d41ad68381d2036267ca0d.tar.bz2
txr-24c2898ff6d169b058d41ad68381d2036267ca0d.zip
base-name: bug with empty string suffix.
* stream.c (base_name): We must check for a zero length suffix, otherwise sub(base, zero, neg(length(suff))) produces an empty string. * tests/018/path.tl: Test cases for base-name.
Diffstat (limited to 'stream.c')
-rw-r--r--stream.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/stream.c b/stream.c
index 9b329bfb..e4670e10 100644
--- a/stream.c
+++ b/stream.c
@@ -4990,7 +4990,7 @@ val base_name(val path, val suff)
val base = mkustring(num_fast(end - rsep));
init_str(base, rsep, self);
return if3(!null_or_missing_p(suff) && ends_with(suff, base, nil, nil) &&
- neql(length(suff), length(base)),
+ plusp(length(suff)) && neql(length(suff), length(base)),
sub(base, zero, neg(length(suff))),
base);
}