#include "cpphash.h"
#include "intl.h"
-#define SKIP_WHITE_SPACE(p) do { while (is_hor_space[*p]) p++; } while (0)
-#define SKIP_ALL_WHITE_SPACE(p) do { while (is_space[*p]) p++; } while (0)
+#define SKIP_WHITE_SPACE(p) do { while (is_hspace(*p)) p++; } while (0)
#define PEEKN(N) (CPP_BUFFER (pfile)->rlimit - CPP_BUFFER (pfile)->cur >= (N) ? CPP_BUFFER (pfile)->cur[N] : EOF)
#define FORWARD(N) CPP_FORWARD (CPP_BUFFER (pfile), (N))
static void parse_name PARAMS ((cpp_reader *, int));
static void parse_string PARAMS ((cpp_reader *, int));
static int parse_assertion PARAMS ((cpp_reader *));
+static const char *if_directive_name PARAMS ((cpp_reader *,
+ struct if_stack *));
/* External declarations. */
c = GETC();
if (c == EOF)
return;
- else if (is_hor_space[c])
+ else if (is_hspace(c))
{
if ((c == '\f' || c == '\v') && CPP_PEDANTIC (pfile))
cpp_pedwarn (pfile, "%s in preprocessing directive",
cpp_skip_hspace (pfile);
c = PEEKC ();
+ /* # followed by a number is equivalent to #line. Do not recognize
+ this form in assembly language source files. Complain about this
+ form if we're being pedantic, but not if this is regurgitated
+ input (preprocessed or fed back in by the C++ frontend). */
if (c >= '0' && c <= '9')
{
- /* Handle # followed by a line number. Complain about using that
- form if we're being pedantic, but not if this is regurgitated
- input (preprocessed or fed back in by the C++ frontend). */
+ if (CPP_OPTIONS (pfile)->lang_asm)
+ {
+ skip_rest_of_line (pfile);
+ return 1;
+ }
+
if (CPP_PEDANTIC (pfile)
&& ! CPP_PREPROCESSED (pfile)
&& ! CPP_BUFFER (pfile)->manual_pop)
return 1;
}
+ /* If we are rescanning preprocessed input, don't obey any directives
+ other than # nnn. */
+ if (CPP_PREPROCESSED (pfile))
+ return 0;
+
/* Now find the directive name. */
CPP_PUTC (pfile, '#');
parse_name (pfile, GETC());
CPP_PUTS_Q (pfile, buf, len);
}
-/* Check a purported macro name SYMNAME, and yield its length.
- ASSERTION is nonzero if this is really for an assertion name. */
+/* Check a purported macro name SYMNAME, and yield its length. */
int
-check_macro_name (pfile, symname, assertion)
+check_macro_name (pfile, symname)
cpp_reader *pfile;
const U_CHAR *symname;
- int assertion;
{
const U_CHAR *p;
int sym_length;
- for (p = symname; is_idchar[*p]; p++)
+ for (p = symname; is_idchar(*p); p++)
;
sym_length = p - symname;
if (sym_length == 0
|| (sym_length == 1 && *symname == 'L' && (*p == '\'' || *p == '"')))
- cpp_error (pfile,
- assertion ? "invalid assertion name" : "invalid macro name");
- else if (!is_idstart[*symname]
+ cpp_error (pfile, "invalid macro name");
+ else if (!is_idstart(*symname)
|| (! strncmp (symname, "defined", 7) && sym_length == 7)) {
U_CHAR *msg; /* what pain... */
msg = (U_CHAR *) alloca (sym_length + 1);
bcopy (symname, msg, sym_length);
msg[sym_length] = 0;
- cpp_error (pfile,
- (assertion
- ? "invalid assertion name `%s'"
- : "invalid macro name `%s'"),
- msg);
+ cpp_error (pfile, "invalid macro name `%s'", msg);
}
return sym_length;
}
if (strcmp (fname, ip->nominal_fname))
{
- char *newname, *oldname;
+ const char *newname, *oldname;
if (!strcmp (fname, ip->fname))
newname = ip->fname;
else if (ip->last_nominal_fname
&& ip->last_nominal_fname != oldname
&& ip->last_nominal_fname != newname
&& ip->last_nominal_fname != ip->fname)
- free (ip->last_nominal_fname);
+ free ((void *) ip->last_nominal_fname);
if (newname == ip->fname)
ip->last_nominal_fname = NULL;
cpp_skip_hspace (pfile);
c = GETC();
- if (! is_idstart[c])
+ if (! is_idstart(c))
{
cpp_error (pfile, "token after #undef is not an identifier");
skip_rest_of_line (pfile);
CPP_SET_WRITTEN (pfile, here);
- sym_length = check_macro_name (pfile, buf, 0);
+ sym_length = check_macro_name (pfile, buf);
while ((hp = cpp_lookup (pfile, name, sym_length, -1)) != NULL)
{
{
U_CHAR *end = syms;
- while (is_idchar[*end])
+ while (is_idchar(*end))
end++;
- if (!is_hor_space[*end] && *end != '\0')
+ if (!is_hspace(*end) && *end != '\0')
{
cpp_error (pfile, "invalid #pragma poison directive");
return 1;
else {
U_CHAR *cp = buf;
fprintf (pcp_outfile, "#undef ");
- while (is_idchar[*cp]) /* Ick! */
+ while (is_idchar(*cp)) /* Ick! */
fputc (*cp++, pcp_outfile);
putc ('\n', pcp_outfile);
}
if (!pfile->only_seen_white)
goto randomchar;
+ /* -traditional directives are recognized only with the # in
+ column 1.
+ XXX Layering violation. */
+ if (CPP_TRADITIONAL (pfile)
+ && CPP_BUFFER (pfile)->cur - CPP_BUFFER (pfile)->line_base != 1)
+ goto randomchar;
if (handle_directive (pfile))
return CPP_DIRECTIVE;
pfile->only_seen_white = 0;
c = PEEKC ();
if (c == EOF)
break;
- if (!is_idchar[c] && c != '.'
+ if (!is_idchar(c) && c != '.'
&& ((c2 != 'e' && c2 != 'E'
&& ((c2 != 'p' && c2 != 'P') || CPP_C89 (pfile)))
|| (c != '+' && c != '-')))
c = GETC();
if (c == EOF)
goto chill_number_eof;
- if (!is_idchar[c])
+ if (!is_idchar(c))
break;
CPP_PUTC (pfile, c);
}
{
CPP_PUTC (pfile, c);
c = PEEKC ();
- if (c == EOF || !is_hor_space[c])
+ if (c == EOF || !is_hspace(c))
break;
FORWARD(1);
}
{
for (;;)
{
- if (! is_idchar[c])
+ if (! is_idchar(c))
{
FORWARD (-1);
break;
case '\n':
CPP_BUMP_LINE (pfile);
pfile->lineno++;
+
+ /* In Fortran and assembly language, silently terminate
+ strings of either variety at end of line. This is a
+ kludge around not knowing where comments are in these
+ languages. */
+ if (CPP_OPTIONS (pfile)->lang_fortran
+ || CPP_OPTIONS (pfile)->lang_asm)
+ return;
/* Character constants may not extend over multiple lines.
- In ANSI, neither may strings. We accept multiline strings
- as an extension. */
+ In Standard C, neither may strings. We accept multiline
+ strings as an extension. */
if (c == '\'')
{
cpp_error_with_line (pfile, start_line, start_column,
return;
}
if (CPP_PEDANTIC (pfile) && pfile->multiline_string_line == 0)
- {
- cpp_pedwarn_with_line (pfile, start_line, start_column,
- "string constant runs past end of line");
- }
+ cpp_pedwarn_with_line (pfile, start_line, start_column,
+ "string constant runs past end of line");
if (pfile->multiline_string_line == 0)
pfile->multiline_string_line = start_line;
break;
int c, dropwhite;
cpp_skip_hspace (pfile);
c = PEEKC();
- if (! is_idstart[c])
+ if (! is_idstart(c))
{
cpp_error (pfile, "assertion predicate is not an identifier");
return 0;
c = PEEKC();
if (c != '(')
{
- if (is_hor_space[c] || c == '\r')
+ if (is_hspace(c) || c == '\r')
cpp_skip_hspace (pfile);
c = PEEKC();
}
dropwhite = 1;
while ((c = GETC()) != ')')
{
- if (is_hor_space[c])
+ if (is_space(c))
{
if (! dropwhite)
{