Let m4 accept a command-line argument (input file)

This unbreaks some configure scripts (reported by David Given)
This commit is contained in:
Ben Gras 2005-08-24 07:20:04 +00:00
parent 5cb414f4d5
commit f13d86f6e5

View file

@ -185,7 +185,7 @@ char *argv[];
#endif
initkwds();
while ((c = getopt(argc, argv, "tD:U:o:")) != EOF)
while ((c = getopt(argc, argv, "tD:U:o:")) != EOF) {
switch(c) {
case 'D': /* define something..*/
@ -204,8 +204,20 @@ char *argv[];
default:
usage();
}
}
argc -= optind;
argv += optind;
if(argc > 1) { usage(); }
infile[0] = stdin; /* default input (naturally) */
if(argc == 1) {
if(!(infile[0] = fopen(argv[0], "r"))) {
perror(argv[0]);
return 1;
}
}
active = stdout; /* default active output */
m4temp = mktemp(divnam); /* filename for diversions */