From e057cf7c280391a0148b6fb6e23947c0ba071ffb Mon Sep 17 00:00:00 2001 From: zack Date: Thu, 4 May 2000 04:38:01 +0000 Subject: [PATCH] gcc: * cpphash.h (U): New define, to correct type of string constants. (ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr): New wrapper routines, to do casts when passing unsigned strings to libc. * cppexp.c, cppfiles.c, cpphash.c, cppinit.c, cpplib.c: Use them. * cppfiles.c (_cpp_execute_include): Make filename an U_CHAR *. * cpphash.c (_cpp_quote_string): Make string an U_CHAR *. * cppinit.c (dump_special_to_buffer): Make macro name an U_CHAR *. * cpplex.c (parse_ifdef, parse_include, validate_else): Make second argument an U_CHAR *. * cppinit.c (builtin_array): Make name and value U_CHAR *, add length field, clean up initializer. (ISTABLE): Add __extension__ to designated- initializers version. * cpplex.c (CHARTAB): Likewise. * mbchar.c: Add dummy external declaration to the !MULTIBYTE_CHARS case so the file won't be empty. include: * symcat.h: Remove #endif label. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33657 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 23 +++++++++++++++- gcc/cppexp.c | 4 +-- gcc/cppfiles.c | 23 ++++++++-------- gcc/cpphash.c | 61 +++++++++++++++++++++++-------------------- gcc/cpphash.h | 46 +++++++++++++++++++++++++++++--- gcc/cppinit.c | 78 ++++++++++++++++++++++++++++++------------------------- gcc/cpplex.c | 6 ++--- gcc/cpplib.c | 70 +++++++++++++++++++++++++------------------------ gcc/mbchar.c | 2 ++ include/ChangeLog | 4 +++ include/symcat.h | 2 +- 11 files changed, 199 insertions(+), 120 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 622b76f..eb4ea28 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,25 @@ +2000-05-03 Zack Weinberg + + * cpphash.h (U): New define, to correct type of string constants. + (ustrcmp, ustrncmp, ustrlen, uxstrdup, ustrchr): New wrapper + routines, to do casts when passing unsigned strings to libc. + * cppexp.c, cppfiles.c, cpphash.c, cppinit.c, cpplib.c: Use them. + + * cppfiles.c (_cpp_execute_include): Make filename an U_CHAR *. + * cpphash.c (_cpp_quote_string): Make string an U_CHAR *. + * cppinit.c (dump_special_to_buffer): Make macro name an U_CHAR *. + * cpplex.c (parse_ifdef, parse_include, validate_else): Make + second argument an U_CHAR *. + + * cppinit.c (builtin_array): Make name and value U_CHAR *, add + length field, clean up initializer. + (ISTABLE): Add __extension__ to designated- + initializers version. + * cpplex.c (CHARTAB): Likewise. + + * mbchar.c: Add dummy external declaration to the !MULTIBYTE_CHARS + case so the file won't be empty. + Wed May 3 21:01:46 2000 Jason Eckhardt * bb-reorder.c (struct reorder_block_def): Member succ removed. @@ -175,7 +197,6 @@ Wed May 3 12:40:53 2000 Clinton Popetz * rtl.def (define_insn_and_split): New DEF_RTL_EXPR. * md.texi (Insn Splitting): Document define_insn_and_split. ->>>>>>> 1.6464 Tue May 2 00:20:30 2000 Jason Eckhardt * flow.c (verify_flow_info): Added two more sanity checks. The diff --git a/gcc/cppexp.c b/gcc/cppexp.c index dd7f431..00eaea7 100644 --- a/gcc/cppexp.c +++ b/gcc/cppexp.c @@ -313,7 +313,7 @@ parse_charconst (pfile, start, end) /* If char type is signed, sign-extend the constant. */ num_bits = num_chars * width; - if (cpp_defined (pfile, (const U_CHAR *)"__CHAR_UNSIGNED__", + if (cpp_defined (pfile, U"__CHAR_UNSIGNED__", sizeof ("__CHAR_UNSIGNED__")-1) || ((result >> (num_bits - 1)) & 1) == 0) op.value = result & ((unsigned HOST_WIDEST_INT) ~0 @@ -439,7 +439,7 @@ lex (pfile, skip_evaluation) return parse_charconst (pfile, tok_start, tok_end); case CPP_NAME: - if (!strncmp (tok_start, "defined", 7)) + if (!ustrncmp (tok_start, U"defined", 7)) return parse_defined (pfile); op.op = INT; diff --git a/gcc/cppfiles.c b/gcc/cppfiles.c index 5ec9d14..395976f 100644 --- a/gcc/cppfiles.c +++ b/gcc/cppfiles.c @@ -74,8 +74,8 @@ eq_IHASH (x, y) const void *x; const void *y; { - const U_CHAR *a = ((const IHASH *)x)->nshort; - const U_CHAR *b = ((const IHASH *)y)->nshort; + const char *a = ((const IHASH *)x)->nshort; + const char *b = ((const IHASH *)y)->nshort; return !strcmp (a, b); } @@ -132,7 +132,7 @@ redundant_include_p (pfile, ihash, ilist) return (i->control_macro && (i->control_macro[0] == '\0' || cpp_defined (pfile, i->control_macro, - strlen (i->control_macro)))) + ustrlen (i->control_macro)))) ? (IHASH *)-1 : i; return 0; @@ -147,7 +147,7 @@ cpp_included (pfile, fname) { IHASH dummy, *ptr; dummy.nshort = fname; - dummy.hash = _cpp_calc_hash (fname, strlen (fname)); + dummy.hash = _cpp_calc_hash ((const U_CHAR *)fname, strlen (fname)); ptr = htab_find_with_hash (pfile->all_include_files, (const void *)&dummy, dummy.hash); return (ptr != NULL); @@ -237,7 +237,7 @@ find_include_file (pfile, fname, search_start, ihash, before) char *name; dummy.nshort = fname; - dummy.hash = _cpp_calc_hash (fname, strlen (fname)); + dummy.hash = _cpp_calc_hash ((const U_CHAR *)fname, strlen (fname)); path = (fname[0] == '/') ? ABSOLUTE_PATH : search_start; slot = (IHASH **) htab_find_slot_with_hash (pfile->all_include_files, (const void *) &dummy, @@ -308,7 +308,7 @@ _cpp_fake_ihash (pfile, fname) IHASH dummy; dummy.nshort = fname; - dummy.hash = _cpp_calc_hash (fname, strlen (fname)); + dummy.hash = _cpp_calc_hash ((const U_CHAR *)fname, strlen (fname)); slot = (IHASH **) htab_find_slot_with_hash (pfile->all_include_files, (const void *) &dummy, dummy.hash, INSERT); @@ -515,14 +515,15 @@ remap_filename (pfile, name, loc) void -_cpp_execute_include (pfile, fname, len, no_reinclude, search_start) +_cpp_execute_include (pfile, f, len, no_reinclude, search_start) cpp_reader *pfile; - char *fname; + U_CHAR *f; unsigned int len; int no_reinclude; struct file_name_list *search_start; { IHASH *ihash; + char *fname = (char *)f; int fd; int angle_brackets = fname[0] == '<'; int before; @@ -615,7 +616,7 @@ _cpp_execute_include (pfile, fname, len, no_reinclude, search_start) /* Actually process the file. */ if (no_reinclude) - ihash->control_macro = (const U_CHAR *) ""; + ihash->control_macro = U""; if (read_include_file (pfile, fd, ihash)) { @@ -644,7 +645,7 @@ cpp_read_file (pfile, fname) if (*fname == 0) dummy.hash = 0; else - dummy.hash = _cpp_calc_hash (fname, strlen (fname)); + dummy.hash = _cpp_calc_hash ((const U_CHAR *)fname, strlen (fname)); slot = (IHASH **) htab_find_slot_with_hash (pfile->all_include_files, (const void *) &dummy, dummy.hash, INSERT); @@ -743,7 +744,7 @@ read_include_file (pfile, fd, ihash) if (length < 0) goto fail; if (length == 0) - ihash->control_macro = (const U_CHAR *) ""; /* never re-include */ + ihash->control_macro = U""; /* never re-include */ close (fd); fp->rlimit = fp->buf + length; diff --git a/gcc/cpphash.c b/gcc/cpphash.c index ca9b4e2..49bc1b5 100644 --- a/gcc/cpphash.c +++ b/gcc/cpphash.c @@ -225,7 +225,7 @@ eq_HASHNODE (x, y) const HASHNODE *b = (const HASHNODE *)y; return (a->length == b->length - && !strncmp (a->name, b->name, a->length)); + && !ustrncmp (a->name, b->name, a->length)); } /* Destroy a HASHNODE. */ @@ -377,7 +377,7 @@ warn_trad_stringify (pfile, p, len, argc, argv) break; for (i = 0; i < argc; i++) - if (!strncmp (p, argv[i].name, argv[i].len) + if (!ustrncmp (p, argv[i].name, argv[i].len) && ! is_idchar (p[argv[i].len])) { cpp_warning (pfile, @@ -416,7 +416,7 @@ trad_stringify (pfile, base, len, argc, argv, pat, endpat, last) break; for (i = 0; i < argc; i++) - if (!strncmp (p, argv[i].name, argv[i].len) + if (!ustrncmp (p, argv[i].name, argv[i].len) && ! is_idchar (p[argv[i].len])) { if (CPP_WTRADITIONAL (pfile)) @@ -618,11 +618,11 @@ collect_funlike_expansion (pfile, list, arglist, replacement) warn_trad_stringify (pfile, tok, len, argc, argv); goto norm; } - + case CPP_NAME: for (j = 0; j < argc; j++) if (argv[j].len == len - && !strncmp (tok, argv[j].name, argv[j].len)) + && !ustrncmp (tok, argv[j].name, argv[j].len)) goto addref; /* fall through */ @@ -683,12 +683,12 @@ static int duplicate_arg_p (args, new) U_CHAR *args, *new; { - size_t newlen = strlen (new) + 1; + size_t newlen = ustrlen (new) + 1; size_t oldlen; while (args < new) { - oldlen = strlen (args) + 1; + oldlen = ustrlen (args) + 1; if (!memcmp (args, new, MIN (oldlen, newlen))) return 1; args += oldlen; @@ -795,7 +795,7 @@ collect_params (pfile, list, arglist) } if (CPP_PEDANTIC (pfile) && CPP_OPTION (pfile, c99) && len == sizeof "__VA_ARGS__" - 1 - && !strcmp (p, "__VA_ARGS__")) + && !ustrcmp (p, U"__VA_ARGS__")) cpp_pedwarn (pfile, "C99 does not permit use of __VA_ARGS__ as a macro argument name"); argv[a].len = len; @@ -817,7 +817,7 @@ collect_params (pfile, list, arglist) argv[a].len = sizeof "__VA_ARGS__" - 1; argv[a].name = p; argv[a].rest_arg = 1; - strcpy (p, "__VA_ARGS__"); + strcpy ((char *)p, "__VA_ARGS__"); } else { @@ -868,8 +868,8 @@ _cpp_create_definition (pfile, list, hp) ntype = T_EMPTY; /* Empty definition of object-like macro. */ else if (list->tokens_used == 3 && TOK_TYPE (list, 1) == CPP_NAME && TOK_LEN (list, 0) == TOK_LEN (list, 1) - && !strncmp (TOK_NAME (list, 0), TOK_NAME (list, 1), - TOK_LEN (list, 0))) + && !ustrncmp (TOK_NAME (list, 0), TOK_NAME (list, 1), + TOK_LEN (list, 0))) ntype = T_IDENTITY; /* Object like macro defined to itself. */ /* The macro is function-like only if the next character, @@ -926,8 +926,8 @@ _cpp_create_definition (pfile, list, hp) case T_MACRO: ok = (ntype == hp->type && odefn->length == hp->value.odefn->length - && !strncmp (odefn->expansion, hp->value.odefn->expansion, - odefn->length)); + && !ustrncmp (odefn->expansion, hp->value.odefn->expansion, + odefn->length)); break; case T_FMACRO: ok = (ntype == hp->type @@ -1050,7 +1050,7 @@ static const char * const monthnames[] = void _cpp_quote_string (pfile, src) cpp_reader *pfile; - const char *src; + const U_CHAR *src; { U_CHAR c; @@ -1091,8 +1091,9 @@ special_symbol (pfile, hp) cpp_reader *pfile; HASHNODE *hp; { - const char *buf; + const U_CHAR *buf; cpp_buffer *ip; + size_t len; switch (hp->type) { @@ -1108,8 +1109,9 @@ special_symbol (pfile, hp) while (CPP_PREV_BUFFER (ip) != NULL) ip = CPP_PREV_BUFFER (ip); - buf = ip->nominal_fname; - CPP_RESERVE (pfile, 3 + 4 * strlen (buf)); + buf = (const U_CHAR *) ip->nominal_fname; + len = ustrlen (buf); + CPP_RESERVE (pfile, 3 + 4 * len); _cpp_quote_string (pfile, buf); return; @@ -1124,8 +1126,9 @@ special_symbol (pfile, hp) } CPP_RESERVE (pfile, 10); - sprintf (CPP_PWRITTEN (pfile), "%d", true_indepth); - CPP_ADJUST_WRITTEN (pfile, strlen (CPP_PWRITTEN (pfile))); + sprintf ((char *)CPP_PWRITTEN (pfile), "%d", true_indepth); + len = ustrlen (CPP_PWRITTEN (pfile)); + CPP_ADJUST_WRITTEN (pfile, len); return; } @@ -1144,7 +1147,8 @@ special_symbol (pfile, hp) if (!buf || *buf == '\0') return; - CPP_PUTS (pfile, buf, strlen (buf)); + len = ustrlen (buf); + CPP_PUTS (pfile, buf, len); return; case T_SPECLINE: @@ -1155,8 +1159,9 @@ special_symbol (pfile, hp) return; } CPP_RESERVE (pfile, 10); - sprintf (CPP_PWRITTEN (pfile), "%u", CPP_BUF_LINE (ip)); - CPP_ADJUST_WRITTEN (pfile, strlen (CPP_PWRITTEN (pfile))); + sprintf ((char *)CPP_PWRITTEN (pfile), "%u", CPP_BUF_LINE (ip)); + len = ustrlen (CPP_PWRITTEN (pfile)); + CPP_ADJUST_WRITTEN (pfile, len); return; case T_DATE: @@ -1231,7 +1236,7 @@ _cpp_macroexpand (pfile, hp) { const U_CHAR *cpval = hp->value.cpval; if (cpval && *cpval != '\0') - push_macro_expansion (pfile, cpval, strlen (cpval), hp); + push_macro_expansion (pfile, cpval, ustrlen (cpval), hp); return; } @@ -1782,7 +1787,7 @@ compare_defs (pfile, d1, d2) if (d1->nargs != d2->nargs) return 1; - if (strcmp (d1->expansion, d2->expansion)) + if (ustrcmp (d1->expansion, d2->expansion)) return 1; if (CPP_PEDANTIC (pfile) && d1->argnames && d2->argnames) @@ -1793,8 +1798,8 @@ compare_defs (pfile, d1, d2) int i = d1->nargs; while (i--) { - len = strlen (arg1) + 1; - if (strcmp (arg1, arg2)) + len = ustrlen (arg1) + 1; + if (ustrcmp (arg1, arg2)) return 1; arg1 += len; arg2 += len; @@ -1871,7 +1876,7 @@ dump_funlike_macro (pfile, defn) for (i = 0; i < defn->nargs; i++) { argv[i] = x; - argl[i] = strlen (x); + argl[i] = ustrlen (x); x += argl[i] + 1; } @@ -1881,7 +1886,7 @@ dump_funlike_macro (pfile, defn) { CPP_RESERVE (pfile, argl[i] + 2); if (!(i == defn->nargs-1 && defn->rest_args - && !strcmp (argv[i], "__VA_ARGS__"))) + && !ustrcmp (argv[i], U"__VA_ARGS__"))) CPP_PUTS_Q (pfile, argv[i], argl[i]); if (i < defn->nargs-1) CPP_PUTS_Q (pfile, ", ", 2); diff --git a/gcc/cpphash.h b/gcc/cpphash.h index 9512c7a..3c9ae38 100644 --- a/gcc/cpphash.h +++ b/gcc/cpphash.h @@ -23,6 +23,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define __GCC_CPPHASH__ typedef unsigned char U_CHAR; +#define U (const U_CHAR *) /* Intended use: U"string" */ /* The structure of a node in the hash table. The hash table has entries for all tokens defined by #define commands (type T_MACRO), @@ -60,7 +61,7 @@ struct hashnode char disabled; /* macro turned off for rescan? */ union { - const char *cpval; /* some predefined macros */ + const U_CHAR *cpval; /* some predefined macros */ const struct object_defn *odefn; /* #define foo bar */ const struct funct_defn *fdefn; /* #define foo(x) bar(x) */ struct hashnode *aschain; /* #assert */ @@ -217,14 +218,14 @@ extern void _cpp_free_definition PARAMS ((HASHNODE *)); extern int _cpp_create_definition PARAMS ((cpp_reader *, cpp_toklist *, HASHNODE *)); extern void _cpp_dump_definition PARAMS ((cpp_reader *, HASHNODE *)); -extern void _cpp_quote_string PARAMS ((cpp_reader *, const char *)); +extern void _cpp_quote_string PARAMS ((cpp_reader *, const U_CHAR *)); extern void _cpp_macroexpand PARAMS ((cpp_reader *, HASHNODE *)); extern void _cpp_init_macro_hash PARAMS ((cpp_reader *)); extern void _cpp_dump_macro_hash PARAMS ((cpp_reader *)); /* In cppfiles.c */ extern void _cpp_simplify_pathname PARAMS ((char *)); -extern void _cpp_execute_include PARAMS ((cpp_reader *, char *, +extern void _cpp_execute_include PARAMS ((cpp_reader *, U_CHAR *, unsigned int, int, struct file_name_list *)); extern void _cpp_init_include_hash PARAMS ((cpp_reader *)); @@ -254,6 +255,43 @@ extern void _cpp_scan_line PARAMS ((cpp_reader *, cpp_toklist *)); /* In cpplib.c */ extern int _cpp_handle_directive PARAMS ((cpp_reader *)); extern void _cpp_unwind_if_stack PARAMS ((cpp_reader *, cpp_buffer *)); -extern void _cpp_check_directive PARAMS((cpp_toklist *, cpp_token *)); +extern void _cpp_check_directive PARAMS ((cpp_toklist *, cpp_token *)); + +/* These are inline functions (if __GNUC__) instead of macros so we + can get type checking. */ +#if GCC_VERSION >= 2007 && defined __OPTIMIZE__ +extern inline int ustrcmp (const U_CHAR *, const U_CHAR *); +extern inline int ustrncmp (const U_CHAR *, const U_CHAR *, size_t); +extern inline size_t ustrlen (const U_CHAR *); +extern inline U_CHAR *uxstrdup (const U_CHAR *); +extern inline U_CHAR *ustrchr (const U_CHAR *, int); + +extern inline int +ustrcmp (const U_CHAR *s1, const U_CHAR *s2) +{ return strcmp ((const char *)s1, (const char *)s2); } + +extern inline int +ustrncmp (const U_CHAR *s1, const U_CHAR *s2, size_t n) +{ return strncmp ((const char *)s1, (const char *)s2, n); } + +extern inline size_t +ustrlen (const U_CHAR *s1) +{ return strlen ((const char *)s1); } + +extern inline U_CHAR * +uxstrdup (const U_CHAR *s1) +{ return (U_CHAR *) xstrdup ((const char *)s1); } + +extern inline U_CHAR * +ustrchr (const U_CHAR *s1, int c) +{ return (U_CHAR *) strchr ((const char *)s1, c); } + +#else +#define ustrcmp(s1_, s2_) strcmp((const char *)s1_, (const char *)s2_) +#define ustrncmp(s1_, s2_, n_) strncmp((const char *)s1_, (const char *)s2_, n_) +#define ustrlen(s1_) strlen((const char *)s1_) +#define uxstrdup(s1_) (U_CHAR *) xstrdup((const char *)s1_) +#define ustrchr(s1_, c_) (U_CHAR *) strchr((const char *)s1_, c_) +#endif #endif diff --git a/gcc/cppinit.c b/gcc/cppinit.c index 944dd59..3f47736 100644 --- a/gcc/cppinit.c +++ b/gcc/cppinit.c @@ -214,7 +214,8 @@ static void append_include_chain PARAMS ((cpp_reader *, char *, int, int)); static void merge_include_chains PARAMS ((cpp_reader *)); -static void dump_special_to_buffer PARAMS ((cpp_reader *, const char *)); +static void dump_special_to_buffer PARAMS ((cpp_reader *, const U_CHAR *, + size_t)); static void initialize_dependency_output PARAMS ((cpp_reader *)); static void initialize_standard_includes PARAMS ((cpp_reader *)); static void new_pending_directive PARAMS ((struct cpp_pending *, @@ -229,13 +230,13 @@ static int handle_option PARAMS ((cpp_reader *, int, char **)); /* Fourth argument to append_include_chain: chain to use */ enum { QUOTE = 0, BRACKET, SYSTEM, AFTER }; -/* If we have designated initializers (GCC >2.7, or C99) this table - can be initialized, constant data. Otherwise, it has to be filled - in at runtime. */ +/* If we have designated initializers (GCC >2.7) this table can be + initialized, constant data. Otherwise, it has to be filled in at + runtime. */ -#if (GCC_VERSION >= 2007) || (__STDC_VERSION__ >= 199901L) +#if (GCC_VERSION >= 2007) #define init_IStable() /* nothing */ -#define ISTABLE const unsigned char _cpp_IStable[256] = { +#define ISTABLE __extension__ const unsigned char _cpp_IStable[256] = { #define END }; #define s(p, v) [p] = v, #else @@ -514,17 +515,17 @@ merge_include_chains (pfile) to PFILE's token_buffer. */ static void -dump_special_to_buffer (pfile, macro_name) +dump_special_to_buffer (pfile, macro_name, macro_len) cpp_reader *pfile; - const char *macro_name; + const U_CHAR *macro_name; + size_t macro_len; { static const char define_directive[] = "#define "; - int macro_name_length = strlen (macro_name); - CPP_RESERVE (pfile, sizeof(define_directive) + macro_name_length); + CPP_RESERVE (pfile, sizeof(define_directive) + macro_len); CPP_PUTS_Q (pfile, define_directive, sizeof(define_directive)-1); - CPP_PUTS_Q (pfile, macro_name, macro_name_length); + CPP_PUTS_Q (pfile, macro_name, macro_len); CPP_PUTC_Q (pfile, ' '); - _cpp_expand_to_buffer (pfile, macro_name, macro_name_length); + _cpp_expand_to_buffer (pfile, macro_name, macro_len); CPP_PUTC (pfile, '\n'); } @@ -617,39 +618,46 @@ cpp_cleanup (pfile) struct builtin { - const char *name; - const char *value; + const U_CHAR *name; + const U_CHAR *value; unsigned short type; unsigned short flags; + unsigned int len; }; #define DUMP 0x01 #define VERS 0x02 #define ULP 0x04 +#define B(n, t) { U n, 0, t, 0, sizeof n - 1 } +#define C(n, v) { U n, U v, T_CONST, DUMP, sizeof n - 1 } +#define X(n, v, t, f) { U n, U v, t, DUMP|f, sizeof n - 1 } static const struct builtin builtin_array[] = { - { "__TIME__", 0, T_TIME, 0 }, - { "__DATE__", 0, T_DATE, 0 }, - { "__FILE__", 0, T_FILE, 0 }, - { "__BASE_FILE__", 0, T_BASE_FILE, 0 }, - { "__LINE__", 0, T_SPECLINE, 0 }, - { "__INCLUDE_LEVEL__", 0, T_INCLUDE_LEVEL, 0 }, - - { "__VERSION__", 0, T_XCONST, DUMP|VERS }, - { "__USER_LABEL_PREFIX__", 0, T_CONST, DUMP|ULP }, - { "__STDC__", "1", T_STDC, DUMP }, - { "__REGISTER_PREFIX__", REGISTER_PREFIX, T_CONST, DUMP }, - { "__HAVE_BUILTIN_SETJMP__", "1", T_CONST, DUMP }, + B("__TIME__", T_TIME), + B("__DATE__", T_DATE), + B("__FILE__", T_FILE), + B("__BASE_FILE__", T_BASE_FILE), + B("__LINE__", T_SPECLINE), + B("__INCLUDE_LEVEL__", T_INCLUDE_LEVEL), + + X("__VERSION__", 0, T_XCONST, VERS), + X("__USER_LABEL_PREFIX__", 0, T_CONST, ULP), + X("__STDC__", "1", T_STDC, 0), + C("__REGISTER_PREFIX__", REGISTER_PREFIX), + C("__HAVE_BUILTIN_SETJMP__", "1"), #ifndef NO_BUILTIN_SIZE_TYPE - { "__SIZE_TYPE__", SIZE_TYPE, T_CONST, DUMP }, + C("__SIZE_TYPE__", SIZE_TYPE), #endif #ifndef NO_BUILTIN_PTRDIFF_TYPE - { "__PTRDIFF_TYPE__", PTRDIFF_TYPE, T_CONST, DUMP }, + C("__PTRDIFF_TYPE__", PTRDIFF_TYPE), #endif #ifndef NO_BUILTIN_WCHAR_TYPE - { "__WCHAR_TYPE__", WCHAR_TYPE, T_CONST, DUMP }, + C("__WCHAR_TYPE__", WCHAR_TYPE), #endif }; +#undef B +#undef C +#undef X #define builtin_array_end \ builtin_array + sizeof(builtin_array)/sizeof(struct builtin) @@ -659,9 +667,8 @@ static void initialize_builtins (pfile) cpp_reader *pfile; { - int len; const struct builtin *b; - const char *val; + const U_CHAR *val; HASHNODE *hp; for(b = builtin_array; b < builtin_array_end; b++) { @@ -669,22 +676,21 @@ initialize_builtins (pfile) continue; if (b->flags & ULP) - val = user_label_prefix; + val = (const U_CHAR *) user_label_prefix; else if (b->flags & VERS) { - val = xmalloc (strlen (version_string) + 3); + val = (const U_CHAR *) xmalloc (strlen (version_string) + 3); sprintf ((char *)val, "\"%s\"", version_string); } else val = b->value; - len = strlen (b->name); - hp = _cpp_lookup (pfile, b->name, len); + hp = _cpp_lookup (pfile, b->name, b->len); hp->value.cpval = val; hp->type = b->type; if ((b->flags & DUMP) && CPP_OPTION (pfile, debug_output)) - dump_special_to_buffer (pfile, b->name); + dump_special_to_buffer (pfile, b->name, b->len); } } #undef DUMP diff --git a/gcc/cpplex.c b/gcc/cpplex.c index f011054..9e068a3 100644 --- a/gcc/cpplex.c +++ b/gcc/cpplex.c @@ -1720,13 +1720,13 @@ find_position (start, limit, linep) #define UCHAR_MAX 255 /* assume 8-bit bytes */ #endif -#if (GCC_VERSION >= 2007) || (__STDC_VERSION__ >= 199901L) +#if (GCC_VERSION >= 2007) #define init_chartab() /* nothing */ -#define CHARTAB static const unsigned char chartab[UCHAR_MAX + 1] = { +#define CHARTAB __extension__ static const U_CHAR chartab[UCHAR_MAX + 1] = { #define END }; #define s(p, v) [p] = v, #else -#define CHARTAB static unsigned char chartab[UCHAR_MAX + 1] = { 0 }; \ +#define CHARTAB static U_CHAR chartab[UCHAR_MAX + 1] = { 0 }; \ static void init_chartab PARAMS ((void)) { \ unsigned char *x = chartab; #define END } diff --git a/gcc/cpplib.c b/gcc/cpplib.c index baaeed6..ae5e2c0 100644 --- a/gcc/cpplib.c +++ b/gcc/cpplib.c @@ -32,7 +32,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ struct directive { directive_handler func; /* Function to handle directive. */ - const char *name; /* Name of directive. */ + const U_CHAR *name; /* Name of directive. */ unsigned short length; /* Length of name. */ unsigned short flags; /* Flags describing this directive. */ }; @@ -52,9 +52,9 @@ typedef struct if_stack IF_STACK; /* Forward declarations. */ -static void validate_else PARAMS ((cpp_reader *, const char *)); -static int parse_ifdef PARAMS ((cpp_reader *, const char *)); -static unsigned int parse_include PARAMS ((cpp_reader *, const char *)); +static void validate_else PARAMS ((cpp_reader *, const U_CHAR *)); +static int parse_ifdef PARAMS ((cpp_reader *, const U_CHAR *)); +static unsigned int parse_include PARAMS ((cpp_reader *, const U_CHAR *)); static int conditional_skip PARAMS ((cpp_reader *, int, int, U_CHAR *)); static int skip_if_group PARAMS ((cpp_reader *)); @@ -140,7 +140,8 @@ enum /* Don't invoke CONCAT2 with any whitespace or K&R cc will fail. */ #define D(name, t, flags) \ -{ CONCAT2(do_,name), STRINGX(name), sizeof STRINGX(name) - 1, flags }, +{ CONCAT2(do_,name), (const U_CHAR *) STRINGX(name), \ + sizeof STRINGX(name) - 1, flags }, static const struct directive dtable[] = { DIRECTIVE_TABLE @@ -155,7 +156,7 @@ _cpp_check_directive (list, token) cpp_toklist *list; cpp_token *token; { - const char *name = list->namebuf + token->val.name.offset; + const U_CHAR *name = list->namebuf + token->val.name.offset; size_t len = token->val.name.len; unsigned int i; @@ -163,7 +164,7 @@ _cpp_check_directive (list, token) list->dir_flags = 0; for (i = 0; i < N_DIRECTIVES; i++) - if (dtable[i].length == len && !strncmp (dtable[i].name, name, len)) + if (dtable[i].length == len && !ustrncmp (dtable[i].name, name, len)) { list->dir_handler = dtable[i].func; list->dir_flags = dtable[i].flags; @@ -237,7 +238,7 @@ _cpp_handle_directive (pfile) for (i = 0; i < N_DIRECTIVES; i++) { if (dtable[i].length == len - && !strncmp (dtable[i].name, ident, len)) + && !ustrncmp (dtable[i].name, ident, len)) goto real_directive; } /* Don't complain about invalid directives in assembly source, @@ -361,7 +362,7 @@ do_define (pfile) /* That NAME is not allowed to be "defined". (Not clear if the standard requires this.) */ - if (len == 7 && !strncmp (sym, "defined", 7)) + if (len == 7 && !ustrncmp (sym, U"defined", 7)) { cpp_error_with_line (pfile, list->line, TOK_COL (list, 0), "\"defined\" is not a legal macro name"); @@ -398,7 +399,7 @@ do_define (pfile) static unsigned int parse_include (pfile, name) cpp_reader *pfile; - const char *name; + const U_CHAR *name; { long old_written = CPP_WRITTEN (pfile); enum cpp_ttype token; @@ -457,12 +458,12 @@ do_include (pfile) cpp_reader *pfile; { unsigned int len; - char *token; + U_CHAR *token; len = parse_include (pfile, dtable[T_INCLUDE].name); if (len == 0) return 0; - token = alloca (len + 1); + token = (U_CHAR *) alloca (len + 1); memcpy (token, CPP_PWRITTEN (pfile), len); token[len] = '\0'; @@ -478,7 +479,7 @@ do_import (pfile) cpp_reader *pfile; { unsigned int len; - char *token; + U_CHAR *token; if (CPP_OPTION (pfile, warn_import) && !CPP_BUFFER (pfile)->system_header_p && !pfile->import_warning) @@ -491,7 +492,7 @@ do_import (pfile) len = parse_include (pfile, dtable[T_IMPORT].name); if (len == 0) return 0; - token = alloca (len + 1); + token = (U_CHAR *) alloca (len + 1); memcpy (token, CPP_PWRITTEN (pfile), len); token[len] = '\0'; @@ -507,13 +508,13 @@ do_include_next (pfile) cpp_reader *pfile; { unsigned int len; - char *token; + U_CHAR *token; struct file_name_list *search_start = 0; len = parse_include (pfile, dtable[T_INCLUDE_NEXT].name); if (len == 0) return 0; - token = alloca (len + 1); + token = (U_CHAR *) alloca (len + 1); memcpy (token, CPP_PWRITTEN (pfile), len); token[len] = '\0'; @@ -590,7 +591,8 @@ do_line (pfile) } CPP_PUTC (pfile, '\0'); /* not terminated for us */ - new_lineno = strtoul (pfile->token_buffer + old_written, &x, 10); + new_lineno = strtoul ((const char *) (pfile->token_buffer + old_written), + &x, 10); if (x[0] != '\0') { cpp_error (pfile, "token after `#line' is not an integer"); @@ -643,12 +645,12 @@ do_line (pfile) *end_name = '\0'; - if (strcmp (fname, ip->nominal_fname)) + if (strcmp ((const char *)fname, ip->nominal_fname)) { - if (!strcmp (fname, ip->ihash->name)) + if (!strcmp ((const char *)fname, ip->ihash->name)) ip->nominal_fname = ip->ihash->name; else - ip->nominal_fname = _cpp_fake_ihash (pfile, fname); + ip->nominal_fname = _cpp_fake_ihash (pfile, (const char *)fname); } } else if (token != CPP_VSPACE && token != CPP_EOF) @@ -888,7 +890,7 @@ do_pragma_once (pfile) if (CPP_PREV_BUFFER (ip) == NULL) cpp_warning (pfile, "`#pragma once' outside include file"); else - ip->ihash->control_macro = (const U_CHAR *) ""; /* never repeat */ + ip->ihash->control_macro = U""; /* never repeat */ return 1; } @@ -902,7 +904,7 @@ do_pragma_implementation (pfile) enum cpp_ttype token; long written = CPP_WRITTEN (pfile); U_CHAR *name; - U_CHAR *copy; + char *copy; size_t len; token = _cpp_get_directive_token (pfile); @@ -917,7 +919,7 @@ do_pragma_implementation (pfile) /* Trim the leading and trailing quote marks from the string. */ name = pfile->token_buffer + written + 1; len = CPP_PWRITTEN (pfile) - name; - copy = (U_CHAR *) alloca (len); + copy = alloca (len); memcpy (copy, name, len - 1); copy[len - 1] = '\0'; @@ -1026,7 +1028,7 @@ detect_if_not_defined (pfile) token = _cpp_get_directive_token (pfile); if (token != CPP_NAME) goto restore; - if (strncmp (pfile->token_buffer + token_offset, "defined", 7)) + if (ustrncmp (pfile->token_buffer + token_offset, U"defined", 7)) goto restore; /* ...then an optional '(' and the name, */ @@ -1122,7 +1124,7 @@ do_elif (pfile) static int parse_ifdef (pfile, name) cpp_reader *pfile; - const char *name; + const U_CHAR *name; { U_CHAR *ident; unsigned int len; @@ -1194,7 +1196,7 @@ do_ifndef (pfile) skip = parse_ifdef (pfile, dtable[T_IFNDEF].name); if (start_of_file && !skip) - control_macro = (U_CHAR *) xstrdup (CPP_PWRITTEN (pfile)); + control_macro = uxstrdup (CPP_PWRITTEN (pfile)); return conditional_skip (pfile, skip, T_IFNDEF, control_macro); } @@ -1256,7 +1258,7 @@ consider_directive_while_skipping (pfile, stack) for (i = 0; i < N_DIRECTIVES; i++) { if (dtable[i].length == len - && !strncmp (dtable[i].name, pfile->token_buffer + ident, len)) + && !ustrncmp (dtable[i].name, pfile->token_buffer + ident, len)) goto real_directive; } return 0; @@ -1446,7 +1448,7 @@ do_endif (pfile) static void validate_else (pfile, directive) cpp_reader *pfile; - const char *directive; + const U_CHAR *directive; { long old_written; if (! CPP_PEDANTIC (pfile)) @@ -1520,7 +1522,7 @@ do_assert (pfile) goto error; } - blen = (U_CHAR *) strchr (sym, '(') - sym; + blen = ustrchr (sym, '(') - sym; base = _cpp_lookup (pfile, sym, blen); if (base->type == T_VOID) { @@ -1581,7 +1583,7 @@ do_unassert (pfile) } else { - baselen = (U_CHAR *) strchr (sym, '(') - sym; + baselen = ustrchr (sym, '(') - sym; base = _cpp_lookup (pfile, sym, baselen); if (base->type == T_VOID) goto out; this = _cpp_lookup (pfile, sym, thislen); @@ -1644,7 +1646,7 @@ cpp_define (pfile, str) strcpy (&buf[count-4], " 1\n"); } - if (cpp_push_buffer (pfile, buf, count - 1) != NULL) + if (cpp_push_buffer (pfile, (U_CHAR *)buf, count - 1) != NULL) { do_define (pfile); cpp_pop_buffer (pfile); @@ -1663,7 +1665,7 @@ cpp_undef (pfile, macro) memcpy (buf, macro, len); buf[len] = '\n'; buf[len + 1] = '\0'; - if (cpp_push_buffer (pfile, buf, len + 1) != NULL) + if (cpp_push_buffer (pfile, (U_CHAR *)buf, len + 1) != NULL) { do_undef (pfile); cpp_pop_buffer (pfile); @@ -1676,7 +1678,7 @@ cpp_assert (pfile, str) cpp_reader *pfile; const char *str; { - if (cpp_push_buffer (pfile, str, strlen (str)) != NULL) + if (cpp_push_buffer (pfile, (const U_CHAR *)str, strlen (str)) != NULL) { do_assert (pfile); cpp_pop_buffer (pfile); @@ -1689,7 +1691,7 @@ cpp_unassert (pfile, str) cpp_reader *pfile; const char *str; { - if (cpp_push_buffer (pfile, str, strlen (str)) != NULL) + if (cpp_push_buffer (pfile, (const U_CHAR *)str, strlen (str)) != NULL) { do_unassert (pfile); cpp_pop_buffer (pfile); diff --git a/gcc/mbchar.c b/gcc/mbchar.c index 3978612..71cc99c 100644 --- a/gcc/mbchar.c +++ b/gcc/mbchar.c @@ -329,4 +329,6 @@ local_mb_cur_max () return 1; /* default */ #endif } +#else /* MULTIBYTE_CHARS */ +extern int dummy; /* silence 'ANSI C forbids an empty source file' warning */ #endif /* MULTIBYTE_CHARS */ diff --git a/include/ChangeLog b/include/ChangeLog index b905153..1329b0f 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,7 @@ +2000-05-03 Zack Weinberg + + * symcat.h: Remove #endif label. + 2000-04-28 Kenneth Block Jason Merrill diff --git a/include/symcat.h b/include/symcat.h index 41589d4..ed4c00e 100644 --- a/include/symcat.h +++ b/include/symcat.h @@ -46,4 +46,4 @@ to "foo". */ #define XSTRING(s) STRINGX(s) -#endif SYM_CAT_H +#endif -- 2.7.4