diff options
author | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-02-21 07:29:56 +0000 |
---|---|---|
committer | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-02-21 07:29:56 +0000 |
commit | 7e555f5f60ed5adf91885c2c2b4f02687f131210 (patch) | |
tree | 63deedc494f43a8e08b2973548c30e790dcbbe8d /gcc/cppinit.c | |
parent | 3970e8910fe5cfbdfcdb502b5e2aa2a53a92fda4 (diff) | |
download | ppe42-gcc-7e555f5f60ed5adf91885c2c2b4f02687f131210.tar.gz ppe42-gcc-7e555f5f60ed5adf91885c2c2b4f02687f131210.zip |
* cppfiles.c: Update comments.
(_cpp_read_file): Don't check for NULL filenames any more.
* cppinit.c (cpp_start_read): Don't do canonicalization of
in_fname and out_fname. Use the passed file name exclusively.
(_cpp_handle_options): Don't treat "-" as a command line option,
but as a normal filename.
(_cpp_post_options): Canonicalize in_fname and out_fname.
* cppmain.c (printer_init): Don't check out_fname for NULL.
* c-lex.c (orig_filename): Rename cpp_filename for clarity.
(init_c_lex): Update, and use "" to represent stdin to CPP.
(yyparse): Update.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@39938 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cppinit.c')
-rw-r--r-- | gcc/cppinit.c | 55 |
1 files changed, 23 insertions, 32 deletions
diff --git a/gcc/cppinit.c b/gcc/cppinit.c index d885a764615..22ce18df1e3 100644 --- a/gcc/cppinit.c +++ b/gcc/cppinit.c @@ -882,9 +882,8 @@ do_includes (pfile, p, scan) } /* This is called after options have been processed. Setup for - processing input from the file named FNAME. (Use standard input if - FNAME == NULL.) Return 1 on success, 0 on failure. */ - + processing input from the file named FNAME, or stdin if it is the + empty string. Return 1 on success, 0 on failure. */ int cpp_start_read (pfile, fname) cpp_reader *pfile; @@ -912,19 +911,9 @@ cpp_start_read (pfile, fname) fprintf (stderr, _("End of search list.\n")); } - if (CPP_OPTION (pfile, in_fname) == NULL - || *CPP_OPTION (pfile, in_fname) == 0) - { - CPP_OPTION (pfile, in_fname) = fname; - if (CPP_OPTION (pfile, in_fname) == NULL) - CPP_OPTION (pfile, in_fname) = ""; - } - if (CPP_OPTION (pfile, out_fname) == NULL) - CPP_OPTION (pfile, out_fname) = ""; - if (CPP_OPTION (pfile, print_deps)) /* Set the default target (if there is none already). */ - deps_add_default_target (pfile->deps, CPP_OPTION (pfile, in_fname)); + deps_add_default_target (pfile->deps, fname); /* Open the main input file. This must be done early, so we have a buffer to stand on. */ @@ -1051,7 +1040,6 @@ new_pending_directive (pend, text, handler) /* This is the list of all command line options, with the leading "-" removed. It must be sorted in ASCII collating order. */ #define COMMAND_LINE_OPTIONS \ - DEF_OPT("", 0, OPT_stdin_stdout) \ DEF_OPT("$", 0, OPT_dollar) \ DEF_OPT("+", 0, OPT_plus) \ DEF_OPT("-help", 0, OPT__help) \ @@ -1224,15 +1212,16 @@ cpp_handle_option (pfile, argc, argv) int i = 0; struct cpp_pending *pend = CPP_OPTION (pfile, pending); - if (argv[i][0] != '-') + /* Interpret "-" or a non-option as a file name. */ + if (argv[i][0] != '-' || argv[i][1] == '\0') { - if (CPP_OPTION (pfile, out_fname) != NULL) - cpp_fatal (pfile, "Too many arguments. Type %s --help for usage info", - progname); - else if (CPP_OPTION (pfile, in_fname) != NULL) + if (CPP_OPTION (pfile, in_fname) == NULL) + CPP_OPTION (pfile, in_fname) = argv[i]; + else if (CPP_OPTION (pfile, out_fname) == NULL) CPP_OPTION (pfile, out_fname) = argv[i]; else - CPP_OPTION (pfile, in_fname) = argv[i]; + cpp_fatal (pfile, "Too many filenames. Type %s --help for usage info", + progname); } else { @@ -1415,21 +1404,13 @@ cpp_handle_option (pfile, argc, argv) CPP_OPTION (pfile, no_standard_cplusplus_includes) = 1; break; case OPT_o: - if (CPP_OPTION (pfile, out_fname) != NULL) + if (CPP_OPTION (pfile, out_fname) == NULL) + CPP_OPTION (pfile, out_fname) = arg; + else { cpp_fatal (pfile, "Output filename specified twice"); return argc; } - CPP_OPTION (pfile, out_fname) = arg; - if (!strcmp (CPP_OPTION (pfile, out_fname), "-")) - CPP_OPTION (pfile, out_fname) = ""; - break; - case OPT_stdin_stdout: - /* JF handle '-' as file name meaning stdin or stdout. */ - if (CPP_OPTION (pfile, in_fname) == NULL) - CPP_OPTION (pfile, in_fname) = ""; - else if (CPP_OPTION (pfile, out_fname) == NULL) - CPP_OPTION (pfile, out_fname) = ""; break; case OPT_d: /* Args to -d specify what parts of macros to dump. @@ -1693,6 +1674,16 @@ void cpp_post_options (pfile) cpp_reader *pfile; { + /* Canonicalize in_fname and out_fname. We guarantee they are not + NULL, and that the empty string represents stdin / stdout. */ + if (CPP_OPTION (pfile, in_fname) == NULL + || !strcmp (CPP_OPTION (pfile, in_fname), "-")) + CPP_OPTION (pfile, in_fname) = ""; + + if (CPP_OPTION (pfile, out_fname) == NULL + || !strcmp (CPP_OPTION (pfile, out_fname), "-")) + CPP_OPTION (pfile, out_fname) = ""; + /* -Wtraditional is not useful in C++ mode. */ if (CPP_OPTION (pfile, cplusplus)) CPP_OPTION (pfile, warn_traditional) = 0; |