summaryrefslogtreecommitdiff
path: root/usr.bin/mg/main.c
diff options
context:
space:
mode:
authorJean-Francois Brousseau <jfb@cvs.openbsd.org>2005-03-09 16:20:49 +0000
committerJean-Francois Brousseau <jfb@cvs.openbsd.org>2005-03-09 16:20:49 +0000
commit34684c50a88034a63d96b0b8f54c590094fdca6f (patch)
treec381c1c4c09f76b66de332fdb0243d1df4bdff9c /usr.bin/mg/main.c
parent51e684432edb921bd1a5233896eb5be1c3cdcdbb (diff)
fix mg's behaviour with regards to files on which we do not have
write access. diff originally from vincent@ and forgotten for a while. ok rohee@, "toss it in, i'll bitch if it doesn't work" henning@
Diffstat (limited to 'usr.bin/mg/main.c')
-rw-r--r--usr.bin/mg/main.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/usr.bin/mg/main.c b/usr.bin/mg/main.c
index a8bf7264bbb..abbee6b6395 100644
--- a/usr.bin/mg/main.c
+++ b/usr.bin/mg/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.33 2004/07/19 12:14:08 vincent Exp $ */
+/* $OpenBSD: main.c,v 1.34 2005/03/09 16:20:48 jfb Exp $ */
/*
* Mainline.
@@ -31,7 +31,7 @@ main(int argc, char **argv)
{
char *cp, *init_fcn_name = NULL;
PF init_fcn = NULL;
- int o, i, nfiles;
+ int o, i, nfiles, status;
while ((o = getopt(argc, argv, "f:")) != -1)
switch (o) {
@@ -105,10 +105,13 @@ notnum:
}
curbp = findbuffer(cp);
(void)showbuffer(curbp, curwp, 0);
- (void)readin(cp);
- if (init_fcn_name)
- init_fcn(0, 1);
- nfiles++;
+ if ((status = readin(cp)) != TRUE) {
+ killbuffer(curbp);
+ } else {
+ if (init_fcn_name)
+ init_fcn(0, 1);
+ nfiles++;
+ }
}
}
}