mirror of
https://github.com/Orc/discount.git
synced 2026-09-25 04:10:00 +03:00
Tweaks to argument handling
This commit is contained in:
+16
-9
@@ -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 )
|
||||
|
||||
Reference in New Issue
Block a user