Module Name: src
Committed By: ginsbach
Date: Wed Jan 20 19:02:42 UTC 2010
Modified Files:
src/usr.bin/unifdef: unifdef.c
Log Message:
- Fix bug where -o outfile fails when outfile does not exist. Pointed
out by Tony Finch.
To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/unifdef/unifdef.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/unifdef/unifdef.c
diff -u src/usr.bin/unifdef/unifdef.c:1.16 src/usr.bin/unifdef/unifdef.c:1.17
--- src/usr.bin/unifdef/unifdef.c:1.16 Sat Jan 16 21:26:59 2010
+++ src/usr.bin/unifdef/unifdef.c Wed Jan 20 19:02:42 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: unifdef.c,v 1.16 2010/01/16 21:26:59 christos Exp $ */
+/* $NetBSD: unifdef.c,v 1.17 2010/01/20 19:02:42 ginsbach Exp $ */
/*
* Copyright (c) 1985, 1993
@@ -77,7 +77,7 @@
#endif
#ifdef __IDSTRING
__IDSTRING(Berkeley, "@(#)unifdef.c 8.1 (Berkeley) 6/6/93");
-__IDSTRING(NetBSD, "$NetBSD: unifdef.c,v 1.16 2010/01/16 21:26:59 christos Exp $");
+__IDSTRING(NetBSD, "$NetBSD: unifdef.c,v 1.17 2010/01/20 19:02:42 ginsbach Exp $");
__IDSTRING(dotat, "$dotat: things/unifdef.c,v 1.161 2003/07/01 15:32:48 fanf2 Exp $");
#endif
#endif /* not lint */
@@ -342,13 +342,13 @@
if (ofilename == NULL) {
output = stdout;
} else {
- if (stat(ofilename, &osb) != 0)
- err(2, "can't stat %s", ofilename);
- if (fstat(fileno(input), &isb) != 0)
- err(2, "can't fstat %s", filename);
+ if (stat(ofilename, &osb) == 0) {
+ if (fstat(fileno(input), &isb) != 0)
+ err(2, "can't fstat %s", filename);
- overwriting = (osb.st_dev == isb.st_dev &&
- osb.st_ino == osb.st_ino);
+ overwriting = (osb.st_dev == isb.st_dev &&
+ osb.st_ino == osb.st_ino);
+ }
if (overwriting) {
int ofd;