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 an incorrect comparison (always true)



details:   https://anonhg.NetBSD.org/src/rev/f9db3ef3c9bd
branches:  trunk
changeset: 761202:f9db3ef3c9bd
user:      ginsbach <ginsbach%NetBSD.org@localhost>
date:      Thu Jan 20 15:24:24 2011 +0000

description:
- Fix an incorrect comparison (always true)
  This created an unnecessary temporary file when using the -o option
  to create a new file.

- Fix -o option bug reported by Tony Finch
  The output file was incorrectly called "[stdin]" when overwriting
  the the input file via standard in (unifdef -o file < file).

diffstat:

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

diffs (52 lines):

diff -r 9bb82109e6e4 -r f9db3ef3c9bd usr.bin/unifdef/unifdef.c
--- a/usr.bin/unifdef/unifdef.c Thu Jan 20 15:00:12 2011 +0000
+++ b/usr.bin/unifdef/unifdef.c Thu Jan 20 15:24:24 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: unifdef.c,v 1.18 2010/01/28 14:15:18 mbalmer Exp $     */
+/*     $NetBSD: unifdef.c,v 1.19 2011/01/20 15:24:24 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.18 2010/01/28 14:15:18 mbalmer Exp $");
+__IDSTRING(NetBSD, "$NetBSD: unifdef.c,v 1.19 2011/01/20 15:24:24 ginsbach Exp $");
 __IDSTRING(dotat, "$dotat: things/unifdef.c,v 1.161 2003/07/01 15:32:48 fanf2 Exp $");
 #endif
 #endif /* not lint */
@@ -347,7 +347,7 @@
                                err(2, "can't fstat %s", filename);
 
                        overwriting = (osb.st_dev == isb.st_dev &&
-                           osb.st_ino == osb.st_ino);
+                           osb.st_ino == isb.st_ino);
                }
                if (overwriting) {
                        int ofd;
@@ -506,12 +506,12 @@
        if (fclose(output)) {
                if (overwriting) {
                        unlink(tmpname);
-                       errx(2, "%s unchanged", filename);
+                       errx(2, "%s unchanged", ofilename);
                }
        }
-       if (overwriting && rename(tmpname, filename)) {
+       if (overwriting && rename(tmpname, ofilename)) {
                unlink(tmpname);
-               errx(2, "%s unchanged", filename);
+               errx(2, "%s unchanged", ofilename);
        }
        exit(exitstat);
 }
@@ -1034,7 +1034,7 @@
        fclose(output);
        if (overwriting) {
                unlink(tmpname);
-               errx(2, "%s unchanged", filename);
+               errx(2, "%s unchanged", ofilename);
        }
        errx(2, "output may be truncated");
 }



Home | Main Index | Thread Index | Old Index