From a5e69db365a98857ac2594590614a981d5f9ae74 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 9 Aug 2019 06:28:58 -0700 Subject: base-name: optionally remove suffix. The base-name function now takes a second argument which is optional, specifying a suffix to be removed. The behavior is similar to that of the second argument of the POSIX basename command. * stream.c (base_name): Second argument added. If present, the returned value is adjusted by trimming the suffix, unless that would cause an empty string to be returned. (stream_init): Update registration of base-name intrinsic. * stream.h (base_name): Declaration updated. * txr.1: New base-name parameter documented. --- txr.1 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'txr.1') diff --git a/txr.1 b/txr.1 index ae2f3563..c46a07a5 100644 --- a/txr.1 +++ b/txr.1 @@ -48234,7 +48234,7 @@ Examples of strings which are not pure relative paths: .coNP Functions @ dir-name and @ base-name .synb .mets (dir-name << path ) -.mets (base-name << path ) +.mets (base-name < path <> [ suffix ]) .syne .desc The @@ -48300,6 +48300,17 @@ The function returns the remaining part of the effective path, after the raw directory prefix. +If the +.meta suffix +argument is given to +.codn base-name , +then the returned base name is adjusted as follows. If the base +name ends in +.meta suffix +then a trimmed version of the base name is returned instead, with that suffix +removed. This adjustment isn't performed if it would result in an empty +string being returned. + .coNP Function @ path-cat .synb .mets (path-cat < dir-path << rel-path ) -- cgit v1.2.3