Tweaks to argument handling

This commit is contained in:
david parsons
2012-03-07 08:40:42 -08:00
parent a8810a6e5c
commit e645861ae2
+16 -9
View File
@@ -81,7 +81,7 @@ char **argv;
CREATE(footers);
pgm = basename(argv[0]);
while ( argc > 2 ) {
while ( argc ) {
if ( strcmp(argv[1], "-css") == 0 ) {
EXPAND(css) = argv[2];
argc -= 2;
@@ -97,14 +97,20 @@ char **argv;
argc -= 2;
argv += 2;
}
else
break;
}
if ( argc > 1 ) {
switch ( argc ) {
char *p, *dot;
case 1:
input = stdin;
output = stdout;
break;
case 2:
case 3:
dest = malloc(strlen(argv[argc-1]) + 6);
source = malloc(strlen(argv[1]) + 6);
dest = malloc(strlen(argv[1]) + 6);
if ( !(source && dest) )
fail("out of memory allocating name buffers");
@@ -128,10 +134,11 @@ char **argv;
if ( (output = fopen(dest, "w")) == 0 )
fail("can't write to %s", dest);
}
else {
input = stdin;
output = stdout;
break;
default:
fprintf(stderr, "usage: %s [opts] source [dest]\n", pgm);
exit(1);
}
if ( (mmiot = mkd_in(input, 0)) == 0 )