From 13009f3cdaf596887a6ba2c746a46027e0b6e4a0 Mon Sep 17 00:00:00 2001 From: Vincent Labrecque Date: Mon, 13 Oct 2003 02:29:30 +0000 Subject: remember the new filename on ^X^W ok deraadt --- usr.bin/mg/file.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'usr.bin') 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 */ -- cgit v1.2.3