Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/csh Fix



details:   https://anonhg.NetBSD.org/src/rev/c36639da3206
branches:  trunk
changeset: 955477:c36639da3206
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Sep 30 17:51:10 2020 +0000

description:
Fix
% set x='a/b c/d.e'
% echo $x:q:h

diffstat:

 bin/csh/lex.c |  38 ++++++++++++++++++--------------------
 1 files changed, 18 insertions(+), 20 deletions(-)

diffs (63 lines):

diff -r 5efbff3e54bf -r c36639da3206 bin/csh/lex.c
--- a/bin/csh/lex.c     Wed Sep 30 17:14:11 2020 +0000
+++ b/bin/csh/lex.c     Wed Sep 30 17:51:10 2020 +0000
@@ -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 @@
        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')
+       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;
-       else
-           xp = Strsave(wp + 1);
        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;
     }



Home | Main Index | Thread Index | Old Index