Each of the argument files is processed in the order listed.
authorSteven Wallace <swallace@ece.uci.edu>
Sun, 16 Jan 1994 00:30:32 +0000 (00:30 +0000)
committerSteven Wallace <swallace@ece.uci.edu>
Sun, 16 Jan 1994 00:30:32 +0000 (00:30 +0000)
If there are no files listed, or if a filename is '-', the standard
input is processed.  Before, only stadard input (with no filenames listed)
OR files could be processed, limiting flexibility.
Two lines in main.c were added and the man page was updated.

usr.bin/m4/m4.1
usr.bin/m4/main.c

index ccd2dfc..ee1ab7f 100644 (file)
@@ -1,5 +1,5 @@
 .\"
 .\"
-.\"    @(#) $Id$
+.\"    @(#) $Id: m4.1,v 1.3 1993/12/21 02:27:40 alm Exp $
 .\"
 .Dd January 26, 1993
 .Dt m4 1
 .\"
 .Dd January 26, 1993
 .Dt m4 1
 .Fl D Ns Ar name Ns Op Ar =value
 .Oc
 .Op Fl U Ns Ar name
 .Fl D Ns Ar name Ns Op Ar =value
 .Oc
 .Op Fl U Ns Ar name
+.Op Ar filename 
+\|.\|.\|.
 .Sh DESCRIPTION
 The
 .Nm m4
 utility is a macro processor that can be used as a front end to any
 language (e.g., C, ratfor, fortran, lex, and yacc).
 .Sh DESCRIPTION
 The
 .Nm m4
 utility is a macro processor that can be used as a front end to any
 language (e.g., C, ratfor, fortran, lex, and yacc).
-.Nm m4
-reads from the standard input and writes
-the processed text to the standard output.
+Each of the argument files is processed in order.
+If there are no files, or if a filename is \`-\', the standard input is read.
+The processed text is sent to the standard output.
 .Pp
 Macro calls have the form name(argument1[, argument2, ...,] argumentN).
 .Pp
 .Pp
 Macro calls have the form name(argument1[, argument2, ...,] argumentN).
 .Pp
index c4dc133..d243387 100644 (file)
@@ -863,7 +863,10 @@ int main(argc, argv)
        } else                          /* file names in commandline */
        for (; optind < argc; optind++) {
            char *name = argv[optind];  /* next file name            */
        } else                          /* file names in commandline */
        for (; optind < argc; optind++) {
            char *name = argv[optind];  /* next file name            */
-           infile[0] = fopen(name, "r");
+           if(name[1] == 0 && name[0] == '-')
+               infile[0] = stdin;
+           else
+               infile[0] = fopen(name, "r");
            if (!infile[0]) cantread(name);
            sp = -1;                    /* stack pointer initialized */
            fp = 0;                     /* frame pointer initialized */
            if (!infile[0]) cantread(name);
            sp = -1;                    /* stack pointer initialized */
            fp = 0;                     /* frame pointer initialized */