Properly initialise 'filename' so that random -l doesn't try to open NULL.

Const-qualify 'filename' to avoid a strdup() call due to -Wwrite-strings
silliness.
This commit is contained in:
Stefan Farfeleder 2004-10-03 15:34:15 +00:00
parent 363d31466e
commit 5618536d0b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=136090

View File

@ -70,10 +70,11 @@ main(int argc, char *argv[])
double denom;
int ch, fd, random_exit, randomize_lines, random_type, ret,
selected, unique_output, unbuffer_output;
char *ep, *filename;
char *ep;
const char *filename;
denom = 0;
filename = NULL;
filename = "/dev/fd/0";
random_type = RANDOM_TYPE_UNSET;
random_exit = randomize_lines = random_type = unbuffer_output = 0;
unique_output = 1;
@ -84,9 +85,7 @@ main(int argc, char *argv[])
break;
case 'f':
randomize_lines = 1;
if (!strcmp(optarg, "-"))
filename = strdup("/dev/fd/0");
else
if (strcmp(optarg, "-") != 0)
filename = optarg;
break;
case 'l':