summaryrefslogtreecommitdiffstats
path: root/text-utils/more.c
diff options
context:
space:
mode:
authorKarel Zak2015-08-05 13:09:12 +0200
committerKarel Zak2015-08-05 13:09:12 +0200
commit8f2a4650732ca3be5aec70b8e508cd975c2e1c15 (patch)
tree8b5d3fe58fb1b5d57f34e88db531027945ac2f79 /text-utils/more.c
parentlibfdisk: (gpt) fix label pointer usage [smatch scan] (diff)
downloadkernel-qcow2-util-linux-8f2a4650732ca3be5aec70b8e508cd975c2e1c15.tar.gz
kernel-qcow2-util-linux-8f2a4650732ca3be5aec70b8e508cd975c2e1c15.tar.xz
kernel-qcow2-util-linux-8f2a4650732ca3be5aec70b8e508cd975c2e1c15.zip
more: improve ugly macro
no comment, just F*CK YOU to the original author of this crap... Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'text-utils/more.c')
-rw-r--r--text-utils/more.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/text-utils/more.c b/text-utils/more.c
index 4602cba97..2ac74393f 100644
--- a/text-utils/more.c
+++ b/text-utils/more.c
@@ -1922,11 +1922,13 @@ int readch(void)
static char *BS = "\b";
static char *BSB = "\b \b";
static char *CARAT = "^";
-#define ERASEONECOLUMN \
- if (docrterase) \
- putserr(BSB); \
- else \
- putserr(BS);
+#define ERASEONECOLUMN(x) \
+ do { \
+ if (x) \
+ putserr(BSB); \
+ else \
+ putserr(BS); \
+ } while(0)
void ttyin(char buf[], register int nmax, char pchar)
{
@@ -1976,14 +1978,16 @@ void ttyin(char buf[], register int nmax, char pchar)
}
if (mblength == 1) {
- ERASEONECOLUMN} else {
+ ERASEONECOLUMN(docrterase);
+ } else {
int wc_width;
wc_width = wcwidth(wc);
wc_width =
(wc_width <
1) ? 1 : wc_width;
while (wc_width--) {
- ERASEONECOLUMN}
+ ERASEONECOLUMN(docrterase);
+ }
}
while (mblength--) {
@@ -1994,12 +1998,14 @@ void ttyin(char buf[], register int nmax, char pchar)
#endif /* HAVE_WIDECHAR */
{
--promptlen;
- ERASEONECOLUMN-- sp;
+ ERASEONECOLUMN(docrterase);
+ --sp;
}
if ((*sp < ' ' && *sp != '\n') || *sp == RUBOUT) {
--promptlen;
- ERASEONECOLUMN}
+ ERASEONECOLUMN(docrterase);
+ }
continue;
} else {
if (!eraseln)
@@ -2027,7 +2033,8 @@ void ttyin(char buf[], register int nmax, char pchar)
}
if (slash && ((cc_t) c == otty.c_cc[VKILL]
|| (cc_t) c == otty.c_cc[VERASE])) {
- ERASEONECOLUMN-- sp;
+ ERASEONECOLUMN(docrterase);
+ --sp;
}
if (c != '\\')
slash = 0;