Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/unifdef - Fix bug where -o outfile fails when outfil...



details:   https://anonhg.NetBSD.org/src/rev/b4da67eea908
branches:  trunk
changeset: 750990:b4da67eea908
user:      ginsbach <ginsbach%NetBSD.org@localhost>
date:      Wed Jan 20 19:02:42 2010 +0000

description:
- Fix bug where -o outfile fails when outfile does not exist.  Pointed
  out by Tony Finch.

diffstat:

 usr.bin/unifdef/unifdef.c |  16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diffs (38 lines):

diff -r 61ef203495ba -r b4da67eea908 usr.bin/unifdef/unifdef.c
--- a/usr.bin/unifdef/unifdef.c Wed Jan 20 19:00:47 2010 +0000
+++ b/usr.bin/unifdef/unifdef.c Wed Jan 20 19:02:42 2010 +0000
@@ -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;
 



Home | Main Index | Thread Index | Old Index