Commit 40ea76de by Zack Weinberg Committed by Zack Weinberg

cpperror.c: Remove #ifdef EMACS block.

	* cpperror.c: Remove #ifdef EMACS block.
	* cppmain.c: Likewise.
	* cpphash.c: Remove #if 0 blocks.
	* cppinit.c: Remove #if 0 blocks, and the -lint option.
	* cpplib.c: Remove #if 0 blocks and code referencing
	pcp_inside_if or for_lint.  Remove duplicate error message.
	Fix error messages for #else after #else or #elif.  Reformat.
	Remove archaic TODO list.
	* cpplib.h: Remove pcp_inside_if and for_lint flags.

From-SVN: r31817
parent fd81d24f
2000-02-05 Zack Weinberg <zack@wolery.cumb.org> 2000-02-05 Zack Weinberg <zack@wolery.cumb.org>
* cpperror.c: Remove #ifdef EMACS block.
* cppmain.c: Likewise.
* cpphash.c: Remove #if 0 blocks.
* cppinit.c: Remove #if 0 blocks, and the -lint option.
* cpplib.c: Remove #if 0 blocks and code referencing
pcp_inside_if or for_lint. Remove duplicate error message.
Fix error messages for #else after #else or #elif. Reformat.
Remove archaic TODO list.
* cpplib.h: Remove pcp_inside_if and for_lint flags.
2000-02-05 Zack Weinberg <zack@wolery.cumb.org>
* i386/osf1elf.h: Add missing backslash to multiline string. * i386/osf1elf.h: Add missing backslash to multiline string.
2000-02-05 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 2000-02-05 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
......
/* Default error handlers for CPP Library. /* Default error handlers for CPP Library.
Copyright (C) 1986, 87, 89, 92-95, 98, 99, 2000 Free Software Foundation, Inc. Copyright (C) 1986, 87, 89, 92-95, 98, 99, 2000
Free Software Foundation, Inc.
Written by Per Bothner, 1994. Written by Per Bothner, 1994.
Based on CCCP program by Paul Rubin, June 1986 Based on CCCP program by Paul Rubin, June 1986
Adapted to ANSI C, Richard Stallman, Jan 1987 Adapted to ANSI C, Richard Stallman, Jan 1987
...@@ -22,13 +23,8 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -22,13 +23,8 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
You are forbidden to forbid anyone else to use, share and improve You are forbidden to forbid anyone else to use, share and improve
what you give them. Help stamp out software-hoarding! */ what you give them. Help stamp out software-hoarding! */
#ifndef EMACS
#include "config.h" #include "config.h"
#include "system.h" #include "system.h"
#else
#include <stdio.h>
#endif /* not EMACS */
#include "cpplib.h" #include "cpplib.h"
#include "intl.h" #include "intl.h"
......
/* Part of CPP library. (Macro handling.) /* Part of CPP library. (Macro handling.)
Copyright (C) 1986, 87, 89, 92-96, 98, 99, 2000 Free Software Foundation, Inc. Copyright (C) 1986, 87, 89, 92-96, 98, 99, 2000
Free Software Foundation, Inc.
Written by Per Bothner, 1994. Written by Per Bothner, 1994.
Based on CCCP program by Paul Rubin, June 1986 Based on CCCP program by Paul Rubin, June 1986
Adapted to ANSI C, Richard Stallman, Jan 1987 Adapted to ANSI C, Richard Stallman, Jan 1987
...@@ -440,11 +441,6 @@ collect_expansion (pfile, buf, limit, nargs, arglist) ...@@ -440,11 +441,6 @@ collect_expansion (pfile, buf, limit, nargs, arglist)
p += 1; p += 1;
while (p < limit && !(p[-2] == '*' && p[-1] == '/')) while (p < limit && !(p[-2] == '*' && p[-1] == '/'))
p++; p++;
#if 0
/* Mark this as a concatenation-point,
as if it had been ##. */
concat = p;
#endif
} }
break; break;
} }
...@@ -1003,19 +999,9 @@ macroexpand (pfile, hp) ...@@ -1003,19 +999,9 @@ macroexpand (pfile, hp)
int xbuf_len; int xbuf_len;
struct argdata *args = 0; struct argdata *args = 0;
long old_written = CPP_WRITTEN (pfile); long old_written = CPP_WRITTEN (pfile);
#if 0
int start_line = instack[indepth].lineno;
#endif
int rest_args, rest_zero = 0; int rest_args, rest_zero = 0;
register int i; register int i;
#if 0
/* This macro is being used inside a #if, which means it must be */
/* recorded as a precondition. */
if (pcp_inside_if && pcp_outfile && defn->predefined)
dump_single_macro (hp, pcp_outfile);
#endif
cpp_buf_line_and_col (cpp_file_buffer (pfile), &start_line, &start_column); cpp_buf_line_and_col (cpp_file_buffer (pfile), &start_line, &start_column);
/* Check for and handle special symbols. */ /* Check for and handle special symbols. */
......
/* CPP Library. /* CPP Library.
Copyright (C) 1986, 87, 89, 92-98, 1999, 2000 Free Software Foundation, Inc. Copyright (C) 1986, 87, 89, 92-99, 2000 Free Software Foundation, Inc.
Contributed by Per Bothner, 1994-95. Contributed by Per Bothner, 1994-95.
Based on CCCP program by Paul Rubin, June 1986 Based on CCCP program by Paul Rubin, June 1986
Adapted to ANSI C, Richard Stallman, Jan 1987 Adapted to ANSI C, Richard Stallman, Jan 1987
...@@ -200,7 +200,8 @@ static void append_include_chain PARAMS ((cpp_reader *, ...@@ -200,7 +200,8 @@ static void append_include_chain PARAMS ((cpp_reader *,
static char *base_name PARAMS ((const char *)); static char *base_name PARAMS ((const char *));
static void dump_special_to_buffer PARAMS ((cpp_reader *, const char *)); static void dump_special_to_buffer PARAMS ((cpp_reader *, const char *));
static void initialize_dependency_output PARAMS ((cpp_reader *)); static void initialize_dependency_output PARAMS ((cpp_reader *));
static void new_pending_define PARAMS ((struct cpp_options *, const char *)); static void new_pending_define PARAMS ((struct cpp_options *,
const char *));
/* Last argument to append_include_chain: chain to use */ /* Last argument to append_include_chain: chain to use */
enum { QUOTE = 0, BRACKET, SYSTEM, AFTER }; enum { QUOTE = 0, BRACKET, SYSTEM, AFTER };
...@@ -418,9 +419,6 @@ cpp_reader_init (pfile) ...@@ -418,9 +419,6 @@ cpp_reader_init (pfile)
cpp_reader *pfile; cpp_reader *pfile;
{ {
bzero ((char *) pfile, sizeof (cpp_reader)); bzero ((char *) pfile, sizeof (cpp_reader));
#if 0
pfile->get_token = cpp_get_token;
#endif
pfile->token_buffer_size = 200; pfile->token_buffer_size = 200;
pfile->token_buffer = (U_CHAR *) xmalloc (pfile->token_buffer_size); pfile->token_buffer = (U_CHAR *) xmalloc (pfile->token_buffer_size);
...@@ -1283,17 +1281,6 @@ cpp_handle_option (pfile, argc, argv) ...@@ -1283,17 +1281,6 @@ cpp_handle_option (pfile, argc, argv)
CPP_PEDANTIC (pfile) = 1; CPP_PEDANTIC (pfile) = 1;
opts->pedantic_errors = 1; opts->pedantic_errors = 1;
} }
#if 0
else if (!strcmp (argv[i], "-pcp")) {
char *pcp_fname = argv[++i];
pcp_outfile = ((pcp_fname[0] != '-' || pcp_fname[1] != '\0')
? fopen (pcp_fname, "w")
: fdopen (dup (fileno (stdout)), "w"));
if (pcp_outfile == 0)
cpp_pfatal_with_name (pfile, pcp_fname);
no_precomp = 1;
}
#endif
break; break;
case 't': case 't':
...@@ -1332,8 +1319,6 @@ cpp_handle_option (pfile, argc, argv) ...@@ -1332,8 +1319,6 @@ cpp_handle_option (pfile, argc, argv)
opts->lang_asm = 1; opts->lang_asm = 1;
if (! strcmp (argv[i], "-lang-fortran")) if (! strcmp (argv[i], "-lang-fortran"))
opts->lang_fortran = 1, opts->cplusplus_comments = 0; opts->lang_fortran = 1, opts->cplusplus_comments = 0;
if (! strcmp (argv[i], "-lint"))
opts->for_lint = 1;
if (! strcmp (argv[i], "-lang-chill")) if (! strcmp (argv[i], "-lang-chill"))
opts->objc = 0, opts->cplusplus = 0, opts->chill = 1, opts->objc = 0, opts->cplusplus = 0, opts->chill = 1,
opts->traditional = 1; opts->traditional = 1;
...@@ -1633,10 +1618,6 @@ cpp_handle_option (pfile, argc, argv) ...@@ -1633,10 +1618,6 @@ cpp_handle_option (pfile, argc, argv)
else if (!strcmp (argv[i], "-nostdinc++")) else if (!strcmp (argv[i], "-nostdinc++"))
/* -nostdinc++ causes no default C++-specific include directories. */ /* -nostdinc++ causes no default C++-specific include directories. */
opts->no_standard_cplusplus_includes = 1; opts->no_standard_cplusplus_includes = 1;
#if 0
else if (!strcmp (argv[i], "-noprecomp"))
no_precomp = 1;
#endif
break; break;
case 'r': case 'r':
......
...@@ -1796,35 +1796,35 @@ do_elif (pfile, keyword) ...@@ -1796,35 +1796,35 @@ do_elif (pfile, keyword)
cpp_reader *pfile; cpp_reader *pfile;
const struct directive *keyword ATTRIBUTE_UNUSED; const struct directive *keyword ATTRIBUTE_UNUSED;
{ {
if (pfile->if_stack == CPP_BUFFER (pfile)->if_stack) { if (pfile->if_stack == CPP_BUFFER (pfile)->if_stack)
cpp_error (pfile, "`#elif' not within a conditional"); {
return 0; cpp_error (pfile, "`#elif' not within a conditional");
} else { return 0;
if (pfile->if_stack->type != T_IF && pfile->if_stack->type != T_ELIF) { }
cpp_error (pfile, "`#elif' after `#else'"); else
#if 0 {
fprintf (stderr, " (matches line %d", pfile->if_stack->lineno); if (pfile->if_stack->type != T_IF && pfile->if_stack->type != T_ELIF)
#endif {
if (pfile->if_stack->fname != NULL && CPP_BUFFER (pfile)->fname != NULL cpp_error (pfile, "`#elif' after `#else'");
&& strcmp (pfile->if_stack->fname, cpp_error_with_line (pfile, pfile->if_stack->lineno, -1,
CPP_BUFFER (pfile)->nominal_fname) != 0) "the conditional began here");
fprintf (stderr, ", file %s", pfile->if_stack->fname); }
fprintf (stderr, ")\n"); pfile->if_stack->type = T_ELIF;
} }
pfile->if_stack->type = T_ELIF;
}
if (pfile->if_stack->if_succeeded) if (pfile->if_stack->if_succeeded)
skip_if_group (pfile); skip_if_group (pfile);
else { else
HOST_WIDEST_INT value = eval_if_expression (pfile); {
if (value == 0) HOST_WIDEST_INT value = eval_if_expression (pfile);
skip_if_group (pfile); if (value == 0)
else { skip_if_group (pfile);
++pfile->if_stack->if_succeeded; /* continue processing input */ else
output_line_command (pfile, same_file); {
++pfile->if_stack->if_succeeded; /* continue processing input */
output_line_command (pfile, same_file);
}
} }
}
return 0; return 0;
} }
...@@ -1840,9 +1840,7 @@ eval_if_expression (pfile) ...@@ -1840,9 +1840,7 @@ eval_if_expression (pfile)
HOST_WIDEST_INT value; HOST_WIDEST_INT value;
long old_written = CPP_WRITTEN (pfile); long old_written = CPP_WRITTEN (pfile);
pfile->pcp_inside_if = 1;
value = cpp_parse_expr (pfile); value = cpp_parse_expr (pfile);
pfile->pcp_inside_if = 0;
CPP_SET_WRITTEN (pfile, old_written); /* Pop */ CPP_SET_WRITTEN (pfile, old_written); /* Pop */
...@@ -1918,20 +1916,6 @@ do_xifdef (pfile, keyword) ...@@ -1918,20 +1916,6 @@ do_xifdef (pfile, keyword)
} }
skip_rest_of_line (pfile); skip_rest_of_line (pfile);
#if 0
if (pcp_outfile) {
/* Output a precondition for this macro. */
if (hp && hp->value.defn->predefined)
fprintf (pcp_outfile, "#define %s\n", hp->name);
else {
U_CHAR *cp = buf;
fprintf (pcp_outfile, "#undef ");
while (is_idchar(*cp)) /* Ick! */
fputc (*cp++, pcp_outfile);
putc ('\n', pcp_outfile);
}
#endif
conditional_skip (pfile, skip, T_IF, control_macro); conditional_skip (pfile, skip, T_IF, control_macro);
return 0; return 0;
} }
...@@ -2010,9 +1994,6 @@ consider_directive_while_skipping (pfile, stack) ...@@ -2010,9 +1994,6 @@ consider_directive_while_skipping (pfile, stack)
validate_else (pfile, "#else"); validate_else (pfile, "#else");
/* fall through */ /* fall through */
case T_ELIF: case T_ELIF:
if (pfile->if_stack->type == T_ELSE)
cpp_error (pfile, "`%s' after `#else'", kt->name);
if (pfile->if_stack == stack) if (pfile->if_stack == stack)
return 1; return 1;
else else
...@@ -2136,35 +2117,36 @@ do_else (pfile, keyword) ...@@ -2136,35 +2117,36 @@ do_else (pfile, keyword)
cpp_reader *pfile; cpp_reader *pfile;
const struct directive *keyword ATTRIBUTE_UNUSED; const struct directive *keyword ATTRIBUTE_UNUSED;
{ {
cpp_buffer *ip = CPP_BUFFER (pfile);
validate_else (pfile, "#else"); validate_else (pfile, "#else");
skip_rest_of_line (pfile); skip_rest_of_line (pfile);
if (pfile->if_stack == CPP_BUFFER (pfile)->if_stack) { if (pfile->if_stack == CPP_BUFFER (pfile)->if_stack)
cpp_error (pfile, "`#else' not within a conditional"); {
return 0; cpp_error (pfile, "`#else' not within a conditional");
} else { return 0;
/* #ifndef can't have its special treatment for containing the whole file }
if it has a #else clause. */ else
pfile->if_stack->control_macro = 0; {
/* #ifndef can't have its special treatment for containing the whole file
if (pfile->if_stack->type != T_IF && pfile->if_stack->type != T_ELIF) { if it has a #else clause. */
cpp_error (pfile, "`#else' after `#else'"); pfile->if_stack->control_macro = 0;
fprintf (stderr, " (matches line %d", pfile->if_stack->lineno);
if (strcmp (pfile->if_stack->fname, ip->nominal_fname) != 0) if (pfile->if_stack->type != T_IF && pfile->if_stack->type != T_ELIF)
fprintf (stderr, ", file %s", pfile->if_stack->fname); {
fprintf (stderr, ")\n"); cpp_error (pfile, "`#else' after `#else'");
} cpp_error_with_line (pfile, pfile->if_stack->lineno, -1,
pfile->if_stack->type = T_ELSE; "the conditional began here");
} }
pfile->if_stack->type = T_ELSE;
}
if (pfile->if_stack->if_succeeded) if (pfile->if_stack->if_succeeded)
skip_if_group (pfile); skip_if_group (pfile);
else { else
++pfile->if_stack->if_succeeded; /* continue processing input */ {
output_line_command (pfile, same_file); ++pfile->if_stack->if_succeeded; /* continue processing input */
} output_line_command (pfile, same_file);
}
return 0; return 0;
} }
...@@ -2347,51 +2329,7 @@ cpp_get_token (pfile) ...@@ -2347,51 +2329,7 @@ cpp_get_token (pfile)
CPP_PUTC (pfile, c); CPP_PUTC (pfile, c);
return CPP_HSPACE; return CPP_HSPACE;
} }
#if 0
if (opts->for_lint) {
U_CHAR *argbp;
int cmdlen, arglen;
char *lintcmd = get_lintcmd (ibp, limit, &argbp, &arglen, &cmdlen);
if (lintcmd != NULL) {
/* I believe it is always safe to emit this newline: */
obp[-1] = '\n';
bcopy ("#pragma lint ", (char *) obp, 13);
obp += 13;
bcopy (lintcmd, (char *) obp, cmdlen);
obp += cmdlen;
if (arglen != 0) {
*(obp++) = ' ';
bcopy (argbp, (char *) obp, arglen);
obp += arglen;
}
/* OK, now bring us back to the state we were in before we entered
this branch. We need #line because the newline for the pragma
could mess things up. */
output_line_command (pfile, same_file);
*(obp++) = ' '; /* just in case, if comments are copied thru */
*(obp++) = '/';
}
}
#endif
case '#': case '#':
#if 0
/* If this is expanding a macro definition, don't recognize
preprocessor directives. */
if (ip->macro != 0)
goto randomchar;
/* If this is expand_into_temp_buffer, recognize them
only after an actual newline at this level,
not at the beginning of the input level. */
if (ip->fname == 0 && beg_of_line == ip->buf)
goto randomchar;
if (ident_length)
goto specialchar;
#endif
if (!pfile->only_seen_white) if (!pfile->only_seen_white)
goto randomchar; goto randomchar;
/* -traditional directives are recognized only with the # in /* -traditional directives are recognized only with the # in
...@@ -3555,15 +3493,3 @@ cpp_perror_with_name (pfile, name) ...@@ -3555,15 +3493,3 @@ cpp_perror_with_name (pfile, name)
{ {
cpp_message (pfile, 1, "%s: %s: %s", progname, name, my_strerror (errno)); cpp_message (pfile, 1, "%s: %s: %s", progname, name, my_strerror (errno));
} }
/* TODO:
* No pre-compiled header file support.
*
* Possibly different enum token codes for each C/C++ token.
*
* Find and cleanup remaining uses of static variables,
*
* Support -dM flag (dump_all_macros).
*
* Support for_lint flag.
*/
...@@ -200,11 +200,6 @@ struct cpp_reader ...@@ -200,11 +200,6 @@ struct cpp_reader
struct if_stack *if_stack; struct if_stack *if_stack;
/* Nonzero means we are inside an IF during a -pcp run. In this mode
macro expansion is done, and preconditions are output for all macro
uses requiring them. */
char pcp_inside_if;
/* Nonzero means we have printed (while error reporting) a list of /* Nonzero means we have printed (while error reporting) a list of
containing files that matches the current status. */ containing files that matches the current status. */
char input_stack_listing_current; char input_stack_listing_current;
...@@ -369,10 +364,6 @@ struct cpp_options { ...@@ -369,10 +364,6 @@ struct cpp_options {
char lang_fortran; char lang_fortran;
/* Nonzero means turn NOTREACHED into #pragma NOTREACHED etc */
char for_lint;
/* Nonzero means handle CHILL comment syntax /* Nonzero means handle CHILL comment syntax
and output CHILL string delimiter for __DATE___ etc. */ and output CHILL string delimiter for __DATE___ etc. */
......
/* CPP main program, using CPP Library. /* CPP main program, using CPP Library.
Copyright (C) 1995, 1997, 1998, 1999 Free Software Foundation, Inc. Copyright (C) 1995, 1997-1999, 2000 Free Software Foundation, Inc.
Written by Per Bothner, 1994-95. Written by Per Bothner, 1994-95.
This program is free software; you can redistribute it and/or modify it This program is free software; you can redistribute it and/or modify it
...@@ -20,15 +20,8 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -20,15 +20,8 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
You are forbidden to forbid anyone else to use, share and improve You are forbidden to forbid anyone else to use, share and improve
what you give them. Help stamp out software-hoarding! */ what you give them. Help stamp out software-hoarding! */
#ifndef EMACS
#include "config.h" #include "config.h"
#include "system.h" #include "system.h"
#else
#include <stdio.h>
extern char *getenv ();
#endif /* not EMACS */
#include "cpplib.h" #include "cpplib.h"
#include "intl.h" #include "intl.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment