* modified by Kars de Jong <jongk@cs.utwente.nl>
* to use terminfo instead of termcap.
* 1999-02-22 Arkadiusz MiĆkiewicz <misiek@pld.ORG.PL>
- * added Native Language Support
+ * added Native Language Support
* 1999-09-19 Bruno Haible <haible@clisp.cons.org>
- * modified to work correctly in multi-byte locales
+ * modified to work correctly in multi-byte locales
*/
#include <stdio.h>
fputs(USAGE_OPTIONS, out);
fputs(_(" -t, -T, --terminal TERMINAL override the TERM environment variable\n"), out);
fputs(_(" -i, --indicated underlining is indicated via a separate line\n"), out);
- fputs(USAGE_SEPARATOR, out);
printf(USAGE_HELP_OPTIONS(30));
printf(USAGE_MAN_TAIL("ul(1)"));
tcs->enter_bold = tcs->enter_standout;
if (!tcs->enter_underline && tcs->enter_standout) {
- tcs->enter_underline = tcs->enter_standout;
- tcs->exit_underline = tcs->exit_standout;
+ tcs->enter_underline = tcs->enter_standout;
+ tcs->exit_underline = tcs->exit_standout;
}
if (!tcs->enter_dim && tcs->enter_standout)
- tcs->enter_dim = tcs->enter_standout;
+ tcs->enter_dim = tcs->enter_standout;
if (!tcs->enter_reverse && tcs->enter_standout)
- tcs->enter_reverse = tcs->enter_standout;
+ tcs->enter_reverse = tcs->enter_standout;
if (!tcs->exit_attributes && tcs->exit_standout)
- tcs->exit_attributes = tcs->exit_standout;
+ tcs->exit_attributes = tcs->exit_standout;
/*
* Note that we use REVERSE for the alternate character set,
ctl->must_use_uc = (tcs->under_char && !tcs->enter_underline);
if ((tigetflag("os") && tcs->enter_bold == NULL) ||
- (tigetflag("ul") && tcs->enter_underline == NULL && tcs->under_char == NULL))
+ (tigetflag("ul") && tcs->enter_underline == NULL
+ && tcs->under_char == NULL))
ctl->must_overstrike = 1;
}
if (!ctl->indicated_opt) {
if (ctl->current_mode != NORMAL_CHARSET && new_mode != NORMAL_CHARSET)
ul_setmode(ctl, tcs, NORMAL_CHARSET);
+
switch (new_mode) {
case NORMAL_CHARSET:
switch (ctl->current_mode) {
wchar_t *buf = xcalloc(ctl->max_column + 1, sizeof(wchar_t));
wchar_t *p = buf;
- for (i = 0; i < ctl->max_column; i++)
+ for (i = 0; i < ctl->max_column; i++) {
switch (ctl->buf[i].c_mode) {
case NORMAL_CHARSET: *p++ = ' '; break;
case ALTERNATIVE_CHARSET: *p++ = 'g'; break;
case BOLD: *p++ = '!'; break;
default: *p++ = 'X'; break;
}
+ }
+
for (*p = ' '; *p == ' '; p--)
*p = 0;
+
fputws(buf, stdout);
putwchar('\n');
free(buf);
int had_bold = 0;
/* Set up overstrike buffer */
- for (i = 0; i < ctl->max_column; i++)
+ for (i = 0; i < ctl->max_column; i++) {
switch (ctl->buf[i].c_mode) {
case NORMAL_CHARSET:
default:
had_bold = 1;
break;
}
+ }
+
putwchar('\r');
for (*p = ' '; *p == ' '; p--)
*p = 0;
fputws(buf, stdout);
+
if (had_bold) {
putwchar('\r');
for (p = buf; *p; p++)
termtype = getenv("TERM");
- while ((c = getopt_long(argc, argv, "it:T:Vh", longopts, NULL)) != -1)
+ while ((c = getopt_long(argc, argv, "it:T:Vh", longopts, NULL)) != -1) {
switch (c) {
case 't':
default:
errtryhelp(EXIT_FAILURE);
}
+ }
+
setupterm(termtype, STDOUT_FILENO, &ret);
switch (ret) {
-
case 1:
break;
-
default:
warnx(_("trouble reading terminfo"));
/* fallthrough */
-
case 0:
if (opt_terminal)
warnx(_("terminal `%s' is not known, defaulting to `dumb'"),
init_term_caps(&ctl, &tcs);
init_buffer(&ctl);
+
if (optind == argc)
filter(&ctl, &tcs, stdin);
- else
+ else {
for (; optind < argc; optind++) {
f = fopen(argv[optind], "r");
if (!f)
filter(&ctl, &tcs, f);
fclose(f);
}
+ }
+
free(ctl.buf);
del_curterm(cur_term);
return EXIT_SUCCESS;