]> Zhao Yanbai Git Server - minix.git/commitdiff
Let m4 accept a command-line argument (input file)
authorBen Gras <ben@minix3.org>
Wed, 24 Aug 2005 07:20:04 +0000 (07:20 +0000)
committerBen Gras <ben@minix3.org>
Wed, 24 Aug 2005 07:20:04 +0000 (07:20 +0000)
This unbreaks some configure scripts (reported by David Given)

commands/m4/main.c

index d54b4aac3ab84e202ac022e41d3b3705571adf4d..91034406ce7ab08f6b80355dcefd4fb8dd88eb28 100755 (executable)
@@ -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   */