From: Ben Gras Date: Wed, 24 Aug 2005 07:20:04 +0000 (+0000) Subject: Let m4 accept a command-line argument (input file) X-Git-Tag: v3.1.0~299 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/Bv9ARM.ch10.html?a=commitdiff_plain;h=f13d86f6e50ea78f16f58fbfdd6dfad382c6abf7;p=minix.git Let m4 accept a command-line argument (input file) This unbreaks some configure scripts (reported by David Given) --- diff --git a/commands/m4/main.c b/commands/m4/main.c index d54b4aac3..91034406c 100755 --- a/commands/m4/main.c +++ b/commands/m4/main.c @@ -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 */