/* C Compatible Compiler Preprocessor (CCCP)
- Copyright (C) 1986, 87, 89, 92-99, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1986, 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
+ 1998, 1999, 2000 Free Software Foundation, Inc.
Written by Paul Rubin, June 1986
Adapted to ANSI C, Richard Stallman, Jan 1987
#include "pcp.h"
#include "intl.h"
#include "prefix.h"
+#include "version.h"
#ifdef MULTIBYTE_CHARS
#include "mbchar.h"
/* External declarations. */
-extern char *version_string;
HOST_WIDEST_INT parse_escape PARAMS ((char **, HOST_WIDEST_INT));
HOST_WIDEST_INT parse_c_expression PARAMS ((char *, int));
\f
int c89;
-/* Nonzero for the 199x C Standard. */
+/* Nonzero for the 1999 C Standard. */
-int c9x;
+int c99;
/* Nonzero causes output not to be done,
but directives such as #define that have side effects
#define REST_EXTENSION_LENGTH (sizeof (rest_extension) - 1)
/* This is the implicit parameter name when using variable number of
- parameters for macros using the ISO C 9x extension. */
+ parameters for macros using the ISO C 99 extension. */
static char va_args_name[] = "__VA_ARGS__";
#define VA_ARGS_NAME_LENGTH (sizeof (va_args_name) - 1)
printf (" -lang-fortran Assume that the input sources are in Fortran\n");
printf (" -lang-chill Assume that the input sources are in Chill\n");
printf (" -std=<std name> Specify the conformance standard; one of:\n");
- printf (" gnu89, gnu9x, c89, c9x, iso9899:1990,\n");
- printf (" iso9899:199409, iso9899:199x\n");
+ printf (" gnu89, gnu99, c89, c99, iso9899:1990,\n");
+ printf (" iso9899:199409, iso9899:1999\n");
printf (" -+ Allow parsing of C++ style features\n");
printf (" -w Inhibit warning messages\n");
printf (" -Wtrigraphs Warn if trigraphs are encountered\n");
case 'l':
if (! strcmp (argv[i], "-lang-c"))
- cplusplus = 0, cplusplus_comments = 1, c89 = 0, c9x = 1, objc = 0;
+ cplusplus = 0, cplusplus_comments = 1, c89 = 0, c99 = 1, objc = 0;
else if (! strcmp (argv[i], "-lang-c89"))
{
- cplusplus = 0, cplusplus_comments = 0, c89 = 1, c9x = 0, objc = 0;
+ cplusplus = 0, cplusplus_comments = 0, c89 = 1, c99 = 0, objc = 0;
no_trigraphs = 0;
pend_defs[2*i] = "__STRICT_ANSI__";
}
else if (! strcmp (argv[i], "-lang-c++"))
- cplusplus = 1, cplusplus_comments = 1, c89 = 0, c9x = 0, objc = 0;
+ cplusplus = 1, cplusplus_comments = 1, c89 = 0, c99 = 0, objc = 0;
else if (! strcmp (argv[i], "-lang-objc"))
- cplusplus = 0, cplusplus_comments = 1, c89 = 0, c9x = 0, objc = 1;
+ cplusplus = 0, cplusplus_comments = 1, c89 = 0, c99 = 0, objc = 1;
else if (! strcmp (argv[i], "-lang-objc++"))
- cplusplus = 1, cplusplus_comments = 1, c89 = 0, c9x = 0, objc = 1;
+ cplusplus = 1, cplusplus_comments = 1, c89 = 0, c99 = 0, objc = 1;
else if (! strcmp (argv[i], "-lang-asm"))
lang_asm = 1;
else if (! strcmp (argv[i], "-lang-fortran"))
case 's':
if (!strcmp (argv[i], "-std=gnu89"))
{
- cplusplus = 0, cplusplus_comments = 0, c89 = 1, c9x = 0, objc = 0;
+ cplusplus = 0, cplusplus_comments = 0, c89 = 1, c99 = 0, objc = 0;
}
else if (!strcmp (argv[i], "-std=gnu9x")
|| !strcmp (argv[i], "-std=gnu99"))
{
- cplusplus = 0, cplusplus_comments = 1, c89 = 0, c9x = 1, objc = 0;
+ cplusplus = 0, cplusplus_comments = 1, c89 = 0, c99 = 1, objc = 0;
pend_defs[2*i+1] = "__STDC_VERSION__=199901L";
}
else if (!strcmp (argv[i], "-std=iso9899:1990")
|| !strcmp (argv[i], "-std=c89"))
{
- cplusplus = 0, cplusplus_comments = 0, c89 = 1, c9x = 0, objc = 0;
+ cplusplus = 0, cplusplus_comments = 0, c89 = 1, c99 = 0, objc = 0;
no_trigraphs = 0;
pend_defs[2*i] = "__STRICT_ANSI__";
}
else if (!strcmp (argv[i], "-std=iso9899:199409"))
{
- cplusplus = 0, cplusplus_comments = 0, c89 = 1, c9x = 0, objc = 0;
+ cplusplus = 0, cplusplus_comments = 0, c89 = 1, c99 = 0, objc = 0;
no_trigraphs = 0;
pend_defs[2*i] = "__STRICT_ANSI__";
pend_defs[2*i+1] = "__STDC_VERSION__=199409L";
|| !strcmp (argv[i], "-std=c9x")
|| !strcmp (argv[i], "-std=c99"))
{
- cplusplus = 0, cplusplus_comments = 1, c89 = 0, c9x = 1, objc = 0;
+ cplusplus = 0, cplusplus_comments = 1, c89 = 0, c99 = 1, objc = 0;
no_trigraphs = 0;
pend_defs[2*i] = "__STRICT_ANSI__";
pend_defs[2*i+1] = "__STDC_VERSION__=199901L";
struct file_name_list *dirtmp;
char *dir = argv[i][2] ? argv[i] + 2 : argv[++i];
- if (! ignore_srcdir && !strcmp (dir, "-")) {
+ if (! ignore_srcdir && dir && !strcmp (dir, "-")) {
ignore_srcdir = 1;
/* Don't use any preceding -I directories for #include <...>. */
first_bracket_include = 0;
fp->nominal_fname_len = strlen (in_fname);
fp->lineno = 0;
- /* In C++, wchar_t is a distinct basic type, and we can expect
- __wchar_t to be defined by cc1plus. */
- if (cplusplus)
- wchar_type = "__wchar_t";
-
/* Install __LINE__, etc. Must follow initialize_char_syntax
and option processing. */
initialize_builtins (fp, &outbuf);
case '\'':
case '\"':
{
- int backslash_newlines_p;
+ int backslash_newlines_p = 0;
register const U_CHAR *bp1
= skip_quoted_string (xp - 1, bp, ip->lineno,
break;
#endif
+#ifndef NO_BUILTIN_WCHAR_TYPE
case T_WCHAR_TYPE:
buf = wchar_type;
break;
+#endif
case T_USER_LABEL_PREFIX_TYPE:
buf = user_label_prefix;
if (!is_idstart[*bp])
{
- if (c9x && limit - bp > (long) REST_EXTENSION_LENGTH
+ if (c99 && limit - bp > (long) REST_EXTENSION_LENGTH
&& bcmp (rest_extension, bp, REST_EXTENSION_LENGTH) == 0)
{
- /* This is the ISO C 9x way to write macros with variable
+ /* This is the ISO C 99 way to write macros with variable
number of arguments. */
rest_args = 1;
temp->rest_args = 1;
}
if (bp == temp->name && rest_args == 1)
{
- /* This is the ISO C 9x style. */
+ /* This is the ISO C 99 style. */
temp->name = (U_CHAR *) va_args_name;
temp->length = VA_ARGS_NAME_LENGTH;
}
SKIP_WHITE_SPACE (bp);
/* A comma at this point can only be followed by an identifier. */
if (!is_idstart[*bp]
- && !(c9x && limit - bp > (long) REST_EXTENSION_LENGTH
+ && !(c99 && limit - bp > (long) REST_EXTENSION_LENGTH
&& bcmp (rest_extension, bp, REST_EXTENSION_LENGTH) == 0)) {
error ("badly punctuated parameter list in `#define'");
goto nope;
int stringified_length_bound;
U_CHAR *free1, *free2;
U_CHAR *free_ptr;
- char newlines;
+ int newlines;
char use_count;
};
* refer to them.
*/
for (i = 'a'; i <= 'z'; i++) {
- is_idchar[TOUPPER(i)] = 1;
- is_idchar[i] = 1;
- is_idstart[TOUPPER(i)] = 1;
- is_idstart[i] = 1;
+ /* SKIP EBCIDIC holes, char must be a valid low case char */
+ if (ISLOWER(i)) {
+ is_idchar[TOUPPER(i)] = 1;
+ is_idchar[i] = 1;
+ is_idstart[TOUPPER(i)] = 1;
+ is_idstart[i] = 1;
+ }
}
for (i = '0'; i <= '9'; i++)
is_idchar[i] = 1;
#ifndef NO_BUILTIN_PTRDIFF_TYPE
install ((const U_CHAR *) "__PTRDIFF_TYPE__ ", -1, T_PTRDIFF_TYPE, NULL_PTR, -1);
#endif
+#ifndef NO_BUILTIN_WCHAR_TYPE
install ((const U_CHAR *) "__WCHAR_TYPE__", -1, T_WCHAR_TYPE, NULL_PTR, -1);
+#endif
install ((const U_CHAR *) "__USER_LABEL_PREFIX__", -1, T_USER_LABEL_PREFIX_TYPE,
NULL_PTR, -1);
install ((const U_CHAR *) "__REGISTER_PREFIX__", -1, T_REGISTER_PREFIX_TYPE,
outp, dp);
#endif
+#ifndef NO_BUILTIN_WCHAR_TYPE
sprintf (directive, " __WCHAR_TYPE__ %s\n", wchar_type);
output_line_directive (inp, outp, 0, same_file);
pass_thru_directive (udirective, &udirective[strlen (directive)],
outp, dp);
+#endif
sprintf (directive, " __DATE__ \"%s %2d %4d\"\n",
monthnames[timebuf->tm_mon],