usrbin_exec_PROGRAMS = col colcrt colrm column hexdump rev line tailf
+column_SOURCES = column.c $(top_srcdir)/lib/strutils.c
+
hexdump_SOURCES = hexdump.c conv.c display.c hexsyntax.c parse.c \
hexdump.h $(top_srcdir)/lib/strutils.c
#include "widechar.h"
#include "c.h"
#include "xalloc.h"
+#include "strutils.h"
#ifdef HAVE_WIDECHAR
#define wcs_width(s) wcswidth(s,wcslen(s))
int cols, *len;
} TBL;
-int termwidth = 80; /* default terminal width */
+long termwidth;
int entries; /* number of records */
int eval; /* exit value */
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &win) == -1 || !win.ws_col) {
if ((p = getenv("COLUMNS")) != NULL)
- termwidth = atoi(p);
+ termwidth = strtol_or_err(p,
+ _("terminal environment COLUMNS failed"));
} else
termwidth = win.ws_col;
PACKAGE_STRING);
return(EXIT_SUCCESS);
case 'c':
- termwidth = atoi(optarg);
+ termwidth = strtol_or_err(optarg,
+ _("bad columns width value"));
+ if (termwidth < 1)
+ errx(EXIT_FAILURE,
+ _("-%c positive integer expected as an argument"), ch);
break;
case 's':
separator = mbs_to_wcs(optarg);