summaryrefslogtreecommitdiffstats
path: root/text-utils/column.c
diff options
context:
space:
mode:
authorKarel Zak2011-05-26 10:23:50 +0200
committerKarel Zak2011-05-26 10:23:50 +0200
commita46e644e5c8d70015dc23b2af9c69c034bc7cb5a (patch)
treee4d10d081ecd650263385cc66990e188588a5ec8 /text-utils/column.c
parentMerge branch 'column' of git://github.com/kerolasa/lelux-utiliteetit into column (diff)
downloadkernel-qcow2-util-linux-a46e644e5c8d70015dc23b2af9c69c034bc7cb5a.tar.gz
kernel-qcow2-util-linux-a46e644e5c8d70015dc23b2af9c69c034bc7cb5a.tar.xz
kernel-qcow2-util-linux-a46e644e5c8d70015dc23b2af9c69c034bc7cb5a.zip
column: fix problems with uninitialized variables
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'text-utils/column.c')
-rw-r--r--text-utils/column.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/text-utils/column.c b/text-utils/column.c
index bb6147cf9..1e7a5779d 100644
--- a/text-utils/column.c
+++ b/text-utils/column.c
@@ -105,15 +105,13 @@ static void __attribute__((__noreturn__)) usage(int rc)
int main(int argc, char **argv)
{
struct winsize win;
- FILE *fp;
- int ch, tflag, xflag;
- char *p;
-
- long termwidth;
+ int ch, tflag = 0, xflag = 0;
+ long termwidth = 80;
int entries = 0; /* number of records */
unsigned int eval = 0; /* exit value */
- int maxlength; /* longest record */
+ int maxlength = 0; /* longest record */
wchar_t **list = NULL; /* array of pointers to records */
+
/* field separator for table option */
wchar_t default_separator[] = { '\t', ' ', 0 };
wchar_t *separator = default_separator;
@@ -134,13 +132,14 @@ int main(int argc, char **argv)
textdomain(PACKAGE);
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &win) == -1 || !win.ws_col) {
+ char *p;
+
if ((p = getenv("COLUMNS")) != NULL)
termwidth = strtol_or_err(p,
_("terminal environment COLUMNS failed"));
} else
termwidth = win.ws_col;
- tflag = xflag = 0;
while ((ch = getopt_long(argc, argv, "hVc:s:tx", longopts, NULL)) != -1)
switch(ch) {
case 'h':
@@ -176,6 +175,8 @@ int main(int argc, char **argv)
eval += input(stdin, &maxlength, &list, &entries);
else
for (; *argv; ++argv) {
+ FILE *fp;
+
if ((fp = fopen(*argv, "r")) != NULL) {
eval += input(fp, &maxlength, &list, &entries);
fclose(fp);
@@ -344,7 +345,7 @@ static int input(FILE *fp, int *maxlength, wchar_t ***list, int *entries)
static int maxentry = DEFNUM;
int len, lineno = 1, reportedline = 0, eval = 0;
wchar_t *p, buf[MAXLINELEN];
- wchar_t **local_list;
+ wchar_t **local_list = *list;
int local_entries = *entries;
if (!local_list)