Copyright (C) 1987, 1988, 1991, 1994, 1997, 1998, 1999, 2000, 2001
Free Software Foundation, Inc.
-This file is part of GNU CC.
+This file is part of GCC.
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING. If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
+along with GCC; see the file COPYING. If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA. */
#include "hconfig.h"
#include "system.h"
static char *read_string PARAMS ((struct obstack *, FILE *, int));
static char *read_quoted_string PARAMS ((struct obstack *, FILE *));
static char *read_braced_string PARAMS ((struct obstack *, FILE *));
+static void read_escape PARAMS ((struct obstack *, FILE *));
static unsigned def_hash PARAMS ((const void *));
static int def_name_eq_p PARAMS ((const void *, const void *));
static void read_constants PARAMS ((FILE *infile, char *tmp_char));
static void
fatal_with_file_and_line VPARAMS ((FILE *infile, const char *msg, ...))
{
-#ifndef ANSI_PROTOTYPES
- FILE *infile;
- const char *msg;
-#endif
- va_list ap;
char context[64];
size_t i;
int c;
- VA_START (ap, msg);
-
-#ifndef ANSI_PROTOTYPES
- infile = va_arg (ap, FILE *);
- msg = va_arg (ap, const char *);
-#endif
+ VA_OPEN (ap, msg);
+ VA_FIXEDARG (ap, FILE *, infile);
+ VA_FIXEDARG (ap, const char *, msg);
fprintf (stderr, "%s:%d: ", read_rtx_filename, read_rtx_lineno);
vfprintf (stderr, msg, ap);
fprintf (stderr, "%s:%d: following context is `%s'\n",
read_rtx_filename, read_rtx_lineno, context);
- va_end (ap);
+ VA_CLOSE (ap);
exit (1);
}
p = str;
while (1)
{
- if (c == ' ' || c == '\n' || c == '\t' || c == '\f')
+ if (c == ' ' || c == '\n' || c == '\t' || c == '\f' || c == '\r')
break;
if (c == ':' || c == ')' || c == ']' || c == '"' || c == '/'
|| c == '(' || c == '[')
}
}
+/* Subroutine of the string readers. Handles backslash escapes.
+ Caller has read the backslash, but not placed it into the obstack. */
+static void
+read_escape (ob, infile)
+ struct obstack *ob;
+ FILE *infile;
+{
+ int c = getc (infile);
+ switch (c)
+ {
+ /* Backslash-newline is replaced by nothing, as in C. */
+ case '\n':
+ read_rtx_lineno++;
+ return;
+
+ /* \" \' \\ are replaced by the second character. */
+ case '\\':
+ case '"':
+ case '\'':
+ break;
+
+ /* Standard C string escapes:
+ \a \b \f \n \r \t \v
+ \[0-7] \x
+ all are passed through to the output string unmolested.
+ In normal use these wind up in a string constant processed
+ by the C compiler, which will translate them appropriately.
+ We do not bother checking that \[0-7] are followed by up to
+ two octal digits, or that \x is followed by N hex digits.
+ \? \u \U are left out because they are not in traditional C. */
+ case 'a': case 'b': case 'f': case 'n': case 'r': case 't': case 'v':
+ case '0': case '1': case '2': case '3': case '4': case '5': case '6':
+ case '7': case 'x':
+ obstack_1grow (ob, '\\');
+ break;
+
+ /* \; makes stuff for a C string constant containing
+ newline and tab. */
+ case ';':
+ obstack_grow (ob, "\\n\\t", 4);
+ return;
+
+ /* pass anything else through, but issue a warning. */
+ default:
+ fprintf (stderr, "%s:%d: warning: unrecognized escape \\%c\n",
+ read_rtx_filename, read_rtx_lineno, c);
+ obstack_1grow (ob, '\\');
+ break;
+ }
+
+ obstack_1grow (ob, c);
+}
+
+
/* Read a double-quoted string onto the obstack. Caller has scanned
the leading quote. */
static char *
read_rtx_lineno++;
else if (c == '\\')
{
- c = getc (infile); /* Read the string */
- /* \; makes stuff for a C string constant containing
- newline and tab. */
- if (c == ';')
- {
- obstack_grow (ob, "\\n\\t", 4);
- continue;
- }
- else if (c == '\n')
- /* \-newline: delete the backslash and update our idea of
- the line number. */
- read_rtx_lineno++;
- else if (c == '\\' || c == '"')
- ; /* \", \\ are a literal quote and backslash. */
- else
- /* Backslash escapes we do not recognize are left unmolested.
- They may be handled by the C compiler (e.g. \n, \t) */
- {
- ungetc (c, infile); /* put it back */
- c = '\\';
- }
+ read_escape (ob, infile);
+ continue;
}
else if (c == '"')
break;
brace_depth--;
else if (c == '\\')
{
- c = getc (infile); /* Read the string */
- /* \; makes stuff for a C string constant containing
- newline and tab. */
- if (c == ';')
- {
- obstack_grow (ob, "\\n\\t", 4);
- continue;
- }
- else if (c == '\n')
- /* \-newline: delete the backslash and update our idea of
- the line number. */
- read_rtx_lineno++;
- else if (c == '\\')
- ; /* \\ is a literal backslash */
- else
- /* Backslash escapes we do not recognize are left unmolested.
- They may be handled by the C compiler (e.g. \n, \t) */
- {
- ungetc (c, infile); /* put it back */
- c = '\\';
- }
+ read_escape (ob, infile);
+ continue;
}
obstack_1grow (ob, c);
break;
}
+ case 'T':
case 's':
{
char *stringbuf;
DEFINE_INSN_AND_SPLIT, or DEFINE_PEEPHOLE automatically
gets a star inserted as its first character, if it is
written with a brace block instead of a string constant. */
- int star_if_braced =
- ((i == 3 && (GET_CODE (return_rtx) == DEFINE_INSN
- || GET_CODE (return_rtx) == DEFINE_INSN_AND_SPLIT))
- || (i == 2 && GET_CODE (return_rtx) == DEFINE_PEEPHOLE));
+ int star_if_braced = (format_ptr[-1] == 'T');
stringbuf = read_string (&rtl_obstack, infile, star_if_braced);
stringbuf = (char *) obstack_finish (&rtl_obstack);
}
- XSTR (return_rtx, i) = stringbuf;
+ if (star_if_braced)
+ XTMPL (return_rtx, i) = stringbuf;
+ else
+ XSTR (return_rtx, i) = stringbuf;
}
break;