Module Name: src Committed By: christos Date: Wed Sep 30 17:51:10 UTC 2020
Modified Files: src/bin/csh: lex.c Log Message: Fix % set x='a/b c/d.e' % echo $x:q:h To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/bin/csh/lex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/bin/csh/lex.c diff -u src/bin/csh/lex.c:1.36 src/bin/csh/lex.c:1.37 --- src/bin/csh/lex.c:1.36 Sat Aug 8 20:34:21 2020 +++ src/bin/csh/lex.c Wed Sep 30 13:51:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lex.c,v 1.36 2020/08/09 00:34:21 dholland Exp $ */ +/* $NetBSD: lex.c,v 1.37 2020/09/30 17:51:10 christos Exp $ */ /*- * Copyright (c) 1980, 1991, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)lex.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: lex.c,v 1.36 2020/08/09 00:34:21 dholland Exp $"); +__RCSID("$NetBSD: lex.c,v 1.37 2020/09/30 17:51:10 christos Exp $"); #endif #endif /* not lint */ @@ -998,28 +998,26 @@ domod(Char *cp, int type) return (wp); case 'h': case 't': - if (!any(short2str(cp), '/')) - return (type == 't' ? Strsave(cp) : 0); - wp = Strend(cp); - while (*--wp != '/') - continue; - if (type == 'h') - xp = Strsave(cp), xp[wp - cp] = 0; - else + wp = Strrchr(cp, '/'); + if (wp == NULL) + return Strsave(type == 't' ? cp : STRNULL); + if (type == 't') xp = Strsave(wp + 1); + else + xp = Strsave(cp), xp[wp - cp] = 0; return (xp); + case 'e': case 'r': - wp = Strend(cp); - for (wp--; wp >= cp && *wp != '/'; wp--) - if (*wp == '.') { - if (type == 'e') - xp = Strsave(wp + 1); - else - xp = Strsave(cp), xp[wp - cp] = 0; - return (xp); - } - return (Strsave(type == 'e' ? STRNULL : cp)); + wp = Strrchr(cp, '.'); + if (wp == NULL) + return Strsave(type == 'r' ? cp : STRNULL); + if (type == 'e') + xp = Strsave(wp + 1); + else + xp = Strsave(cp), xp[wp - cp] = 0; + return (xp); + default: break; }