static int pass_unknown_seqs; /* whether to pass unknown control sequences */
static LINE *line_freelist;
-#define PUTC(ch) \
- if (putwchar(ch) == WEOF) \
- wrerr();
-
static void __attribute__((__noreturn__)) usage(void)
{
FILE *out = stdout;
exit(EXIT_SUCCESS);
}
-static void __attribute__((__noreturn__)) wrerr(void)
+static inline void col_putchar(wchar_t ch)
{
- errx(EXIT_FAILURE, _("write error"));
+ if (putwchar(ch) == WEOF)
+ errx(EXIT_FAILURE, _("write error"));
}
/*
}
nb /= 2;
for (i = nb; --i >= 0;)
- PUTC('\n');
+ col_putchar(NL);
if (half) {
- PUTC('\033');
- PUTC('9');
+ col_putchar(ESC);
+ col_putchar('9');
if (!nb)
- PUTC('\r');
+ col_putchar(CR);
}
nblank_lines = 0;
}
if (ntabs > 0) {
nspace = this_col & 7;
while (--ntabs >= 0)
- PUTC('\t');
+ col_putchar(TAB);
}
}
while (--nspace >= 0)
- PUTC(' ');
+ col_putchar(SPACE);
last_col = this_col;
}
if (c->c_set != last_set) {
switch (c->c_set) {
case CS_NORMAL:
- PUTC('\017');
+ col_putchar(SI);
break;
case CS_ALTERNATE:
- PUTC('\016');
+ col_putchar(SO);
}
last_set = c->c_set;
}
- PUTC(c->c_char);
+ col_putchar(c->c_char);
if ((c + 1) < endc) {
int i;
for (i=0; i < c->c_width; i++)
- PUTC('\b');
+ col_putchar(BS);
}
if (++c >= endc)
break;
/* make sure we leave things in a sane state */
if (last_set != CS_NORMAL)
- PUTC('\017');
+ col_putchar(SI);
/* flush out the last few blank lines */
nblank_lines = max_line - this_line;