Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/ed Conditionalize printfs instead of using conditional e...
details: https://anonhg.NetBSD.org/src/rev/921674fcd8be
branches: trunk
changeset: 765292:921674fcd8be
user: joerg <joerg%NetBSD.org@localhost>
date: Mon May 23 23:13:10 2011 +0000
description:
Conditionalize printfs instead of using conditional empty format
strings.
diffstat:
bin/ed/io.c | 10 ++++++----
bin/ed/main.c | 43 +++++++++++++++++++++++++------------------
2 files changed, 31 insertions(+), 22 deletions(-)
diffs (117 lines):
diff -r 27cbfb818787 -r 921674fcd8be bin/ed/io.c
--- a/bin/ed/io.c Mon May 23 23:06:41 2011 +0000
+++ b/bin/ed/io.c Mon May 23 23:13:10 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: io.c,v 1.8 2005/06/26 19:10:49 christos Exp $ */
+/* $NetBSD: io.c,v 1.9 2011/05/23 23:13:10 joerg Exp $ */
/* io.c: This file contains the i/o routines for the ed line editor */
/*-
@@ -32,7 +32,7 @@
#if 0
static char *rcsid = "@(#)io.c,v 1.1 1994/02/01 00:34:41 alm Exp";
#else
-__RCSID("$NetBSD: io.c,v 1.8 2005/06/26 19:10:49 christos Exp $");
+__RCSID("$NetBSD: io.c,v 1.9 2011/05/23 23:13:10 joerg Exp $");
#endif
#endif /* not lint */
@@ -59,7 +59,8 @@
sprintf(errmsg, "cannot close input file");
return ERR;
}
- fprintf(stderr, !scripted ? "%lu\n" : "", size);
+ if (!scripted)
+ fprintf(stderr, "%lu\n", size);
return current_addr - n;
}
@@ -165,7 +166,8 @@
sprintf(errmsg, "cannot close output file");
return ERR;
}
- fprintf(stderr, !scripted ? "%lu\n" : "", size);
+ if (!scripted)
+ fprintf(stderr, "%lu\n", size);
return n ? m - n + 1 : 0;
}
diff -r 27cbfb818787 -r 921674fcd8be bin/ed/main.c
--- a/bin/ed/main.c Mon May 23 23:06:41 2011 +0000
+++ b/bin/ed/main.c Mon May 23 23:13:10 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.22 2009/06/10 04:16:53 ginsbach Exp $ */
+/* $NetBSD: main.c,v 1.23 2011/05/23 23:13:10 joerg Exp $ */
/* main.c: This file contains the main control and user-interface routines
for the ed line editor. */
@@ -39,7 +39,7 @@
#if 0
static char *rcsid = "@(#)main.c,v 1.1 1994/02/01 00:34:42 alm Exp";
#else
-__RCSID("$NetBSD: main.c,v 1.22 2009/06/10 04:16:53 ginsbach Exp $");
+__RCSID("$NetBSD: main.c,v 1.23 2011/05/23 23:13:10 joerg Exp $");
#endif
#endif /* not lint */
@@ -200,9 +200,11 @@
fputs("?\n", stderr);
sprintf(errmsg, "warning: file modified");
if (!isatty(0)) {
- fprintf(stderr, garrulous ?
- "script, line %d: %s\n" :
- "", lineno, errmsg);
+ if (garrulous) {
+ fprintf(stderr,
+ "script, line %d: %s\n",
+ lineno, errmsg);
+ }
quit(2);
}
clearerr(stdin);
@@ -233,27 +235,32 @@
fputs("?\n", stderr); /* give warning */
sprintf(errmsg, "warning: file modified");
if (!isatty(0)) {
- fprintf(stderr, garrulous ?
- "script, line %d: %s\n" :
- "", lineno, errmsg);
+ if (garrulous) {
+ fprintf(stderr,
+ "script, line %d: %s\n",
+ lineno, errmsg);
+ }
quit(2);
}
break;
case FATAL:
- if (!isatty(0))
- fprintf(stderr, garrulous ?
- "script, line %d: %s\n" : "",
- lineno, errmsg);
- else
- fprintf(stderr, garrulous ? "%s\n" : "",
- errmsg);
+ if (garrulous) {
+ if (!isatty(0)) {
+ fprintf(stderr,
+ "script, line %d: %s\n",
+ lineno, errmsg);
+ } else {
+ fprintf(stderr, "%s\n", errmsg);
+ }
+ }
quit(3);
default:
fputs("?\n", stderr);
if (!isatty(0)) {
- fprintf(stderr, garrulous ?
- "script, line %d: %s\n" : "",
- lineno, errmsg);
+ if (garrulous) {
+ fprintf(stderr, "script, line %d: %s\n",
+ lineno, errmsg);
+ }
quit(2);
}
break;
Home |
Main Index |
Thread Index |
Old Index