summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorVincent Labrecque <vincent@cvs.openbsd.org>2003-10-13 02:29:30 +0000
committerVincent Labrecque <vincent@cvs.openbsd.org>2003-10-13 02:29:30 +0000
commit13009f3cdaf596887a6ba2c746a46027e0b6e4a0 (patch)
treeb5736dfdc1333748b1baf1be9fc9f2105d4d9a53 /usr.bin
parent287d378e39129aaed7b38b1bb1c7226b6805794b (diff)
remember the new filename on ^X^W
ok deraadt
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mg/file.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/usr.bin/mg/file.c b/usr.bin/mg/file.c
index 7ee11cd1dbf..52cce2d07d1 100644
--- a/usr.bin/mg/file.c
+++ b/usr.bin/mg/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.25 2003/08/16 00:24:51 deraadt Exp $ */
+/* $OpenBSD: file.c,v 1.26 2003/10/13 02:29:29 vincent Exp $ */
/*
* File commands.
@@ -373,7 +373,7 @@ filewrite(int f, int n)
{
int s;
char fname[NFILEN];
- char *adjfname;
+ char *adjfname, *p;
if ((s = eread("Write file: ", fname, NFILEN,
EFNEW | EFCR | EFFILE)) != TRUE)
@@ -385,6 +385,14 @@ filewrite(int f, int n)
bzero(&curbp->b_fi, sizeof(curbp->b_fi));
if ((s = writeout(curbp, adjfname)) == TRUE) {
(void)strlcpy(curbp->b_fname, adjfname, sizeof curbp->b_fname);
+ p = strrchr(curbp->b_fname, '/');
+ if (p)
+ p++;
+ else
+ p = curbp->b_fname;
+ if (curbp->b_bname)
+ free((char *)curbp->b_bname);
+ curbp->b_bname = strdup(p);
#ifndef NO_BACKUP
curbp->b_flag &= ~(BFBAK | BFCHG);
#else /* !NO_BACKUP */