#include <stdio.h>
#include <unistd.h> /* for getopt(), isatty() */
#include <string.h> /* for memset(), strcpy() */
-#include <term.h> /* for setupterm() */
#include <stdlib.h> /* for getenv() */
#include <limits.h> /* for INT_MAX */
#include <signal.h> /* for signal() */
#include <errno.h>
#include <getopt.h>
+#if defined(HAVE_NCURSESW_TERM_H)
+# include <ncursesw/term.h>
+#elif defined(HAVE_NCURSES_TERM_H)
+# include <ncurses/term.h>
+#elif defined(HAVE_TERM_H)
+# include <term.h>
+#endif
+
#include "nls.h"
#include "xalloc.h"
#include "widechar.h"
static int upln;
static int iflag;
-static void __attribute__((__noreturn__))
-usage(FILE *out)
+static void __attribute__((__noreturn__)) usage(void)
{
+ FILE *out = stdout;
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s [options] [<file> ...]\n"), program_invocation_short_name);
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);
- fputs(USAGE_HELP, out);
- fputs(USAGE_VERSION, out);
+ printf(USAGE_HELP_OPTIONS(30));
- fprintf(out, USAGE_MAN_TAIL("ul(1)"));
+ printf(USAGE_MAN_TAIL("ul(1)"));
- exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}
int main(int argc, char **argv)
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
signal(SIGINT, sig_handler);
signal(SIGTERM, sig_handler);
case 'i':
iflag = 1;
break;
+
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
- usage(stdout);
+ usage();
default:
errtryhelp(EXIT_FAILURE);
}
default:
warnx(_("trouble reading terminfo"));
- /* fall through to ... */
+ /* fallthrough */
case 0:
if (tflag)
}
obuf[col].c_char = '_';
obuf[col].c_width = 1;
- /* fall through */
+ /* fallthrough */
case ' ':
setcol(col + 1);
continue;
static void overstrike(void)
{
register int i;
- register wchar_t *lbuf = xmalloc((maxcol + 1) * sizeof(wchar_t));
+ register wchar_t *lbuf = xcalloc(maxcol + 1, sizeof(wchar_t));
register wchar_t *cp = lbuf;
int hadbold=0;
static void iattr(void)
{
register int i;
- register wchar_t *lbuf = xmalloc((maxcol + 1) * sizeof(wchar_t));
+ register wchar_t *lbuf = xcalloc(maxcol + 1, sizeof(wchar_t));
register wchar_t *cp = lbuf;
for (i = 0; i < maxcol; i++)