diff options
author | Kjell Wooding <kjell@cvs.openbsd.org> | 2005-10-18 04:07:07 +0000 |
---|---|---|
committer | Kjell Wooding <kjell@cvs.openbsd.org> | 2005-10-18 04:07:07 +0000 |
commit | ae37b774c781475c70cc42f6afee83c1c75001c6 (patch) | |
tree | 2fd5513d5eec4617a136e24ccd8e802ee40c9450 /usr.bin | |
parent | 75f81e9d54b98599a879b043bb636aa260c6b187 (diff) |
When attempting to open a filename, walk backwards through minibuffer:
a> if you run into the beginning of the string, use the whole thing
b> if you run into a // combo, use everything starting from the second /
c> if you run into a /~ combo, use everything starting from the ~
i.e. do like emacs.
From (and for) Jason Wright
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mg/fileio.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/usr.bin/mg/fileio.c b/usr.bin/mg/fileio.c index 3b53d0e7049..06838eb01d9 100644 --- a/usr.bin/mg/fileio.c +++ b/usr.bin/mg/fileio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fileio.c,v 1.57 2005/10/17 14:54:03 kjell Exp $ */ +/* $OpenBSD: fileio.c,v 1.58 2005/10/18 04:07:06 kjell Exp $ */ /* This file is in the public domain. */ @@ -260,11 +260,24 @@ char * adjustname(const char *fn) { static char fnb[MAXPATHLEN]; - const char *cp; + const char *cp, *ep = NULL; char user[LOGIN_NAME_MAX], path[MAXPATHLEN]; size_t ulen, plen; path[0] = '\0'; + + cp = fn + strlen(fn) - 1; + for (; cp >= fn; cp--) { + if (ep && (*cp == '/')) { + fn = ep; + break; + } + if (*cp == '/' || *cp == '~') + ep = cp; + else + ep = NULL; + } + /* first handle tilde expansion */ if (fn[0] == '~') { struct passwd *pw; |