column: error messaging & exit codes
Human understandable error messages along with symbolic exit codes to comply with coding standard. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
80fa094c90
commit
bf90b8a6af
1 changed files with 12 additions and 8 deletions
|
@ -159,7 +159,7 @@ main(int argc, char **argv)
|
||||||
(void)fclose(fp);
|
(void)fclose(fp);
|
||||||
} else {
|
} else {
|
||||||
warn("%s", *argv);
|
warn("%s", *argv);
|
||||||
eval = 1;
|
eval = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!entries)
|
if (!entries)
|
||||||
|
@ -174,7 +174,7 @@ main(int argc, char **argv)
|
||||||
else
|
else
|
||||||
r_columnate();
|
r_columnate();
|
||||||
if (ferror(stdout) || fclose(stdout))
|
if (ferror(stdout) || fclose(stdout))
|
||||||
eval = 1;
|
eval = EXIT_FAILURE;
|
||||||
exit(eval);
|
exit(eval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,7 +280,7 @@ maketbl()
|
||||||
* sizeof(wchar_t *))) ||
|
* sizeof(wchar_t *))) ||
|
||||||
!(lens = realloc(lens, ((u_int)maxcols + DEFCOLS)
|
!(lens = realloc(lens, ((u_int)maxcols + DEFCOLS)
|
||||||
* sizeof(int))))
|
* sizeof(int))))
|
||||||
err(1, NULL);
|
err(EXIT_FAILURE, _("out of memory?"));
|
||||||
memset((char *)lens + maxcols * sizeof(int),
|
memset((char *)lens + maxcols * sizeof(int),
|
||||||
0, DEFCOLS * sizeof(int));
|
0, DEFCOLS * sizeof(int));
|
||||||
maxcols += DEFCOLS;
|
maxcols += DEFCOLS;
|
||||||
|
@ -313,7 +313,7 @@ input(fp)
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
{
|
{
|
||||||
static int maxentry;
|
static int maxentry;
|
||||||
int len;
|
int len, lineno = 1, reportedline = 0;
|
||||||
wchar_t *p, buf[MAXLINELEN];
|
wchar_t *p, buf[MAXLINELEN];
|
||||||
|
|
||||||
if (!list)
|
if (!list)
|
||||||
|
@ -323,10 +323,14 @@ input(fp)
|
||||||
if (!*p)
|
if (!*p)
|
||||||
continue;
|
continue;
|
||||||
if (!(p = wcschr(p, '\n')) && !feof(fp)) {
|
if (!(p = wcschr(p, '\n')) && !feof(fp)) {
|
||||||
warnx(_("line too long"));
|
if (reportedline < lineno) {
|
||||||
eval = 1;
|
warnx(_("line %d is too long, output will be truncated"), lineno);
|
||||||
|
reportedline = lineno;
|
||||||
|
}
|
||||||
|
eval = EXIT_FAILURE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
lineno++;
|
||||||
if (!feof(fp))
|
if (!feof(fp))
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
len = wcs_width(buf); /* len = p - buf; */
|
len = wcs_width(buf); /* len = p - buf; */
|
||||||
|
@ -336,7 +340,7 @@ input(fp)
|
||||||
maxentry += DEFNUM;
|
maxentry += DEFNUM;
|
||||||
if (!(list = realloc(list,
|
if (!(list = realloc(list,
|
||||||
(u_int)maxentry * sizeof(wchar_t *))))
|
(u_int)maxentry * sizeof(wchar_t *))))
|
||||||
err(1, NULL);
|
err(EXIT_FAILURE, _("out of memory?"));
|
||||||
}
|
}
|
||||||
list[entries++] = wcsdup(buf);
|
list[entries++] = wcsdup(buf);
|
||||||
}
|
}
|
||||||
|
@ -391,7 +395,7 @@ emalloc(size)
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
if (!(p = malloc(size)))
|
if (!(p = malloc(size)))
|
||||||
err(1, NULL);
|
err(EXIT_FAILURE, _("out of memory?"));
|
||||||
memset(p, 0, size);
|
memset(p, 0, size);
|
||||||
return (p);
|
return (p);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue