summaryrefslogtreecommitdiff
path: root/usr.bin/mg
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/mg')
-rw-r--r--usr.bin/mg/file.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/usr.bin/mg/file.c b/usr.bin/mg/file.c
index 69dfd6d7159..a901f6e8d86 100644
--- a/usr.bin/mg/file.c
+++ b/usr.bin/mg/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.33 2005/04/21 19:16:21 beck Exp $ */
+/* $OpenBSD: file.c,v 1.34 2005/05/27 08:52:30 cloder Exp $ */
/*
* File commands.
@@ -39,9 +39,18 @@ int
filevisit(int f, int n)
{
BUFFER *bp;
- char fname[NFILEN], *bufp, *adjf;
+ char fname[NFILEN], *bufp, *adjf, *slash;
+
+ if (curbp->b_fname && curbp->b_fname[0] != '\0') {
+ strlcpy(fname, curbp->b_fname, sizeof(fname));
+ if ((slash = strrchr(fname, '/')) != NULL) {
+ *(slash + 1) = '\0';
+ }
+ }
+ else
+ fname[0] = '\0';
- bufp = eread("Find file: ", fname, NFILEN, EFNEW | EFCR | EFFILE);
+ bufp = eread("Find file: ", fname, NFILEN, EFNEW | EFCR | EFFILE | EFDEF);
if (bufp == NULL)
return (ABORT);
else if (bufp[0] == '\0')