mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-21 15:40:55 +08:00
cppfiles.c: Update comments.
* 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. From-SVN: r39938
This commit is contained in:
parent
75beacf885
commit
373e217703
@ -1,3 +1,17 @@
|
||||
2001-02-21 Neil Booth <neil@daikokuya.demon.co.uk>
|
||||
|
||||
* 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.
|
||||
|
||||
2001-02-20 Will Cohen <wcohen@redhat.com>
|
||||
|
||||
* config/pa/quadlib.c (_U_Qfcnvfxt_quad_to_usgl): New function.
|
||||
|
13
gcc/c-lex.c
13
gcc/c-lex.c
@ -53,8 +53,8 @@ Boston, MA 02111-1307, USA. */
|
||||
#define GET_ENVIRONMENT(ENV_VALUE,ENV_NAME) ((ENV_VALUE) = getenv (ENV_NAME))
|
||||
#endif
|
||||
|
||||
/* The original file name, before changing "-" to "stdin". */
|
||||
static const char *orig_filename;
|
||||
/* The input filename as understood by CPP, where "" represents stdin. */
|
||||
static const char *cpp_filename;
|
||||
|
||||
/* We may keep statistics about how long which files took to compile. */
|
||||
static int header_time, body_time;
|
||||
@ -102,8 +102,6 @@ init_c_lex (filename)
|
||||
struct cpp_callbacks *cb;
|
||||
struct c_fileinfo *toplevel;
|
||||
|
||||
orig_filename = filename;
|
||||
|
||||
/* Set up filename timing. Must happen before cpp_start_read. */
|
||||
file_info_tree = splay_tree_new ((splay_tree_compare_fn)strcmp,
|
||||
0,
|
||||
@ -136,8 +134,11 @@ init_c_lex (filename)
|
||||
cb->undef = cb_undef;
|
||||
}
|
||||
|
||||
|
||||
if (filename == 0 || !strcmp (filename, "-"))
|
||||
filename = "stdin";
|
||||
filename = "stdin", cpp_filename = "";
|
||||
else
|
||||
cpp_filename = filename;
|
||||
|
||||
/* Start it at 0. */
|
||||
lineno = 0;
|
||||
@ -151,7 +152,7 @@ init_c_lex (filename)
|
||||
int
|
||||
yyparse()
|
||||
{
|
||||
if (! cpp_start_read (parse_in, orig_filename))
|
||||
if (! cpp_start_read (parse_in, cpp_filename))
|
||||
return 1; /* cpplib has emitted an error. */
|
||||
|
||||
return yyparse_1();
|
||||
|
@ -174,7 +174,8 @@ _cpp_fake_include (pfile, fname)
|
||||
create one with a non-NULL value (regardless of success in opening
|
||||
the file). If the file doesn't exist or is inaccessible, this
|
||||
entry is flagged so we don't attempt to open it again in the
|
||||
future. If the file isn't open, open it.
|
||||
future. If the file isn't open, open it. The empty string is
|
||||
interpreted as stdin.
|
||||
|
||||
Returns an include_file structure with an open file descriptor on
|
||||
success, or NULL on failure. */
|
||||
@ -755,18 +756,13 @@ _cpp_compare_file_date (pfile, f)
|
||||
|
||||
|
||||
/* Push an input buffer and load it up with the contents of FNAME.
|
||||
If FNAME is "" or NULL, read standard input. */
|
||||
If FNAME is "", read standard input. */
|
||||
int
|
||||
_cpp_read_file (pfile, fname)
|
||||
cpp_reader *pfile;
|
||||
const char *fname;
|
||||
{
|
||||
struct include_file *f;
|
||||
|
||||
if (fname == NULL)
|
||||
fname = "";
|
||||
|
||||
f = open_file (pfile, fname);
|
||||
struct include_file *f = open_file (pfile, fname);
|
||||
|
||||
if (f == NULL)
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -271,9 +271,6 @@ printer_init (pfile)
|
||||
print.lineno = 0;
|
||||
print.printed = 0;
|
||||
|
||||
if (options->out_fname == NULL)
|
||||
options->out_fname = "";
|
||||
|
||||
if (options->out_fname[0] == '\0')
|
||||
print.outf = stdout;
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user