Module Name:    src
Committed By:   ginsbach
Date:           Thu Jan 20 15:24:24 UTC 2011

Modified Files:
        src/usr.bin/unifdef: unifdef.c

Log Message:
- 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).


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 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.18 src/usr.bin/unifdef/unifdef.c:1.19
--- src/usr.bin/unifdef/unifdef.c:1.18	Thu Jan 28 14:15:18 2010
+++ src/usr.bin/unifdef/unifdef.c	Thu Jan 20 15:24:24 2011
@@ -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");
 }

Reply via email to