1999-10-12 16:44:18 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
Test to see if a particular fix should be applied to a header file.
|
|
|
|
|
2009-04-09 17:00:19 +02:00
|
|
|
Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2009
|
2003-05-23 22:48:48 +02:00
|
|
|
Free Software Foundation, Inc.
|
1999-10-12 16:44:18 +02:00
|
|
|
|
|
|
|
= = = = = = = = = = = = = = = = = = = = = = = = =
|
|
|
|
|
|
|
|
NOTE TO DEVELOPERS
|
|
|
|
|
2000-05-11 21:30:47 +02:00
|
|
|
The routines you write here must work closely with fixincl.c.
|
1999-10-12 16:44:18 +02:00
|
|
|
|
|
|
|
Here are the rules:
|
|
|
|
|
|
|
|
1. Every test procedure name must be suffixed with "_fix".
|
|
|
|
These routines will be referenced from inclhack.def, sans the suffix.
|
|
|
|
|
|
|
|
2. Use the "FIX_PROC_HEAD()" macro _with_ the "_fix" suffix
|
|
|
|
(I cannot use the ## magic from ANSI C) for defining your entry point.
|
|
|
|
|
2000-05-14 21:29:02 +02:00
|
|
|
3. Put your test name into the FIXUP_TABLE.
|
1999-10-12 16:44:18 +02:00
|
|
|
|
|
|
|
4. Do not read anything from stdin. It is closed.
|
|
|
|
|
|
|
|
5. Write to stderr only in the event of a reportable error
|
2000-05-30 22:24:44 +02:00
|
|
|
In such an event, call "exit (EXIT_FAILURE)".
|
1999-10-12 16:44:18 +02:00
|
|
|
|
2000-05-11 21:30:47 +02:00
|
|
|
6. You have access to the fixDescList entry for the fix in question.
|
2000-05-14 21:29:02 +02:00
|
|
|
This may be useful, for example, if there are interesting strings
|
|
|
|
or pre-compiled regular expressions stored there.
|
1999-10-12 16:44:18 +02:00
|
|
|
|
|
|
|
= = = = = = = = = = = = = = = = = = = = = = = = =
|
|
|
|
|
2003-05-23 22:48:48 +02:00
|
|
|
This file is part of GCC.
|
1999-10-12 16:44:18 +02:00
|
|
|
|
2003-05-23 22:48:48 +02:00
|
|
|
GCC is free software; you can redistribute it and/or modify
|
1999-10-12 16:44:18 +02:00
|
|
|
it under the terms of the GNU General Public License as published by
|
2009-04-09 17:00:19 +02:00
|
|
|
the Free Software Foundation; either version 3, or (at your option)
|
1999-10-12 16:44:18 +02:00
|
|
|
any later version.
|
|
|
|
|
2003-05-23 22:48:48 +02:00
|
|
|
GCC is distributed in the hope that it will be useful,
|
1999-10-12 16:44:18 +02:00
|
|
|
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
|
2009-04-09 17:00:19 +02:00
|
|
|
along with GCC; see the file COPYING3. If not see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
1999-10-12 16:44:18 +02:00
|
|
|
|
|
|
|
#include "fixlib.h"
|
2000-07-13 16:47:55 +02:00
|
|
|
#define GTYPE_SE_CT 1
|
1999-10-12 16:44:18 +02:00
|
|
|
|
2000-12-02 20:46:32 +01:00
|
|
|
#ifdef SEPARATE_FIX_PROC
|
2000-08-04 16:16:57 +02:00
|
|
|
#include "fixincl.x"
|
|
|
|
#endif
|
|
|
|
|
2000-05-30 22:24:44 +02:00
|
|
|
tSCC zNeedsArg[] = "fixincl error: `%s' needs %s argument (c_fix_arg[%d])\n";
|
|
|
|
|
2003-08-02 01:07:04 +02:00
|
|
|
typedef void t_fix_proc (const char *, const char *, tFixDesc *) ;
|
1999-10-12 16:44:18 +02:00
|
|
|
typedef struct {
|
|
|
|
const char* fix_name;
|
2000-09-12 16:28:55 +02:00
|
|
|
t_fix_proc* fix_proc;
|
1999-10-12 16:44:18 +02:00
|
|
|
} fix_entry_t;
|
|
|
|
|
|
|
|
#define FIXUP_TABLE \
|
2000-05-12 17:55:45 +02:00
|
|
|
_FT_( "char_macro_def", char_macro_def_fix ) \
|
2000-05-14 21:29:02 +02:00
|
|
|
_FT_( "char_macro_use", char_macro_use_fix ) \
|
|
|
|
_FT_( "format", format_fix ) \
|
|
|
|
_FT_( "machine_name", machine_name_fix ) \
|
2000-07-13 16:47:55 +02:00
|
|
|
_FT_( "wrap", wrap_fix ) \
|
|
|
|
_FT_( "gnu_type", gnu_type_fix )
|
1999-10-12 16:44:18 +02:00
|
|
|
|
|
|
|
|
2003-08-02 01:07:04 +02:00
|
|
|
#define FIX_PROC_HEAD( fix ) \
|
|
|
|
static void fix (const char* filname ATTRIBUTE_UNUSED , \
|
|
|
|
const char* text ATTRIBUTE_UNUSED , \
|
|
|
|
tFixDesc* p_fixd ATTRIBUTE_UNUSED )
|
1999-10-12 16:44:18 +02:00
|
|
|
|
2000-09-12 16:28:55 +02:00
|
|
|
#ifdef NEED_PRINT_QUOTE
|
1999-10-12 16:44:18 +02:00
|
|
|
/*
|
|
|
|
* Skip over a quoted string. Single quote strings may
|
|
|
|
* contain multiple characters if the first character is
|
|
|
|
* a backslash. Especially a backslash followed by octal digits.
|
|
|
|
* We are not doing a correctness syntax check here.
|
|
|
|
*/
|
|
|
|
static char*
|
2003-08-02 01:07:04 +02:00
|
|
|
print_quote(char q, char* text )
|
1999-10-12 16:44:18 +02:00
|
|
|
{
|
|
|
|
fputc( q, stdout );
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
char ch = *(text++);
|
|
|
|
fputc( ch, stdout );
|
|
|
|
|
|
|
|
switch (ch)
|
|
|
|
{
|
|
|
|
case '\\':
|
|
|
|
if (*text == NUL)
|
|
|
|
goto quote_done;
|
|
|
|
|
|
|
|
fputc( *(text++), stdout );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '"':
|
|
|
|
case '\'':
|
|
|
|
if (ch != q)
|
|
|
|
break;
|
|
|
|
/*FALLTHROUGH*/
|
|
|
|
|
|
|
|
case '\n':
|
|
|
|
case NUL:
|
|
|
|
goto quote_done;
|
|
|
|
}
|
|
|
|
} quote_done:;
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
2000-09-12 16:28:55 +02:00
|
|
|
#endif /* NEED_PRINT_QUOTE */
|
1999-10-12 16:44:18 +02:00
|
|
|
|
2000-05-16 16:23:47 +02:00
|
|
|
|
2000-07-13 16:47:55 +02:00
|
|
|
/*
|
|
|
|
* Emit the GNU standard type wrapped up in such a way that
|
|
|
|
* this thing can be encountered countless times during a compile
|
|
|
|
* and not cause even a warning.
|
|
|
|
*/
|
|
|
|
static const char*
|
2003-08-02 01:07:04 +02:00
|
|
|
emit_gnu_type (const char* text, regmatch_t* rm )
|
2000-07-13 16:47:55 +02:00
|
|
|
{
|
2000-07-27 15:29:21 +02:00
|
|
|
char z_TYPE[ 64 ];
|
|
|
|
char z_type[ 64 ];
|
2000-07-13 16:47:55 +02:00
|
|
|
|
|
|
|
fwrite (text, rm[0].rm_so, 1, stdout);
|
|
|
|
|
2000-07-27 15:29:21 +02:00
|
|
|
{
|
|
|
|
const char* ps = text + rm[1].rm_so;
|
|
|
|
const char* pe = text + rm[1].rm_eo;
|
|
|
|
char* pd = z_type;
|
|
|
|
char* pD = z_TYPE;
|
2000-07-13 16:47:55 +02:00
|
|
|
|
2000-07-27 15:29:21 +02:00
|
|
|
while (ps < pe)
|
safe-ctype.h: New file.
include:
* safe-ctype.h: New file.
libiberty:
* safe-ctype.c: New file.
* Makefile.in (CFILES): Add safe-ctype.c.
(REQUIRED_OFILES): Add safe-ctype.o.
* argv.c: Define ISBLANK and use it, not isspace.
* basename.c, cplus-dem.c, fnmatch.c, pexecute.c, strtod.c,
strtol.c, strtoul.c: Include safe-ctype.h, not ctype.h. Use
uppercase ctype macros. Don't test ISUPPER(c)/ISLOWER(c)
before calling TOLOWER(c)/TOUPPER(c).
gcc:
* Makefile.in (HOST_RTL): Add safe-ctype.o.
(safe-ctype.o): New rule.
* system.h: Include safe-ctype.h, not ctype.h. No need to
wrap ctype macros.
* cpphash.h: Zap IStable and related macros. Define is_* in
terms of safe-ctype.h macros.
* cppinit.c: Delete the IStable and all related code.
* tradcpp.c: Delete is_idchar, is_idstart, is_hor_space, and
is_space arrays. Delete initialize_char_syntax. Change all
references to the above arrays to use macros instead.
* tradcpp.h: Define is_idchar, is_idstart, is_space, and
is_nvspace in terms of safe_ctype.h's macros.
* tradcif.y: is_idchar, is_idstart are macros not arrays.
* config/i370/i370.c, config/winnt/dirent.c,
config/winnt/fixinc-nt.c, config/winnt/ld.c:
Use uppercase ctype macros. If we included ctype.h,
include safe-ctype.h instead.
* fixinc/fixfixes.c: Use uppercase ctype macros. Don't test
ISLOWER(c) before calling TOUPPER(c).
* fixinc/fixincl.c (extract_quoted_files): Simplify out some gunk.
* fixinc/gnu-regex.c: Include safe-ctype.h, not ctype.h. No need to
wrap ctype macros. Don't test ISUPPER(x) before calling TOLOWER(x).
gcc/ch:
* lex.c: Don't bother checking whether ISUPPER(c) before
calling TOLOWER(c). Don't bother checking whether isascii(c)
before testing ISSPACE(c); ISSPACE(c) includes '\n'.
gcc/f:
* Make-lang.in: Link f/fini with safe-ctype.o.
* bad.c: Don't test ISUPPER(c) || ISLOWER(c) before calling TOUPPER(c).
* com.c: Use TOUPPER, not ffesrc_toupper.
* fini.c: Don't test ISALPHA(c) before calling TOUPPER(c)/TOLOWER(c).
* intrin.c: Don't test IN_CTYPE_DOMAIN(c).
* src.c: Delete ffesrc_toupper_ and ffesrc_tolower_ and their
initializing code; use TOUPPER and TOLOWER instead of
ffesrc_toupper and ffesrc_tolower.
* src.h: Don't declare ffesrc_toupper_ or ffesrc_tolower_.
Don't define ffesrc_toupper or ffesrc_tolower.
gcc/java:
* jvgenmain.c: Use ISPRINT not isascii.
From-SVN: r38124
2000-12-08 04:00:26 +01:00
|
|
|
*(pD++) = TOUPPER( *(pd++) = *(ps++) );
|
2000-07-27 15:29:21 +02:00
|
|
|
|
|
|
|
*pD = *pd = NUL;
|
|
|
|
}
|
2000-07-13 16:47:55 +02:00
|
|
|
|
|
|
|
/*
|
2000-07-27 15:29:21 +02:00
|
|
|
* Now print out the reformed typedef,
|
|
|
|
* with a C++ guard for WCHAR
|
2000-07-13 16:47:55 +02:00
|
|
|
*/
|
2000-07-20 15:29:29 +02:00
|
|
|
{
|
|
|
|
tSCC z_fmt[] = "\
|
2000-07-16 19:17:46 +02:00
|
|
|
#if !defined(_GCC_%s_T)%s\n\
|
2000-07-27 15:29:21 +02:00
|
|
|
#define _GCC_%s_T\n\
|
|
|
|
typedef __%s_TYPE__ %s_t;\n\
|
|
|
|
#endif\n";
|
2000-07-20 15:29:29 +02:00
|
|
|
|
c-common.c (c_tree_code_name): Const-ification.
* c-common.c (c_tree_code_name): Const-ification.
* c-decl.c (c_decode_option): Likewise.
* c-typeck.c (warn_for_assignment): Likewise.
* collect2.c (libexts, is_ctor_dtor, main, ignore_library):
Likewise.
* cppinit.c (output_deps): Likewise.
* dependence.c (dependence_string, direction_string): Likewise.
* dwarf2out.c (output_ranges): Likewise.
* fixinc/fixfixes.c (emit_gnu_type): Likewise.
* fixinc/gnu-regex.c (re_error_msgid): Likewise.
* gcc.c (standard_exec_prefix, standard_exec_prefix_1,
standard_startfile_prefix, standard_startfile_prefix_1,
standard_startfile_prefix_2, tooldir_base_prefix,
standard_bindir_prefix, find_a_file): Likewise.
* genattrtab.c (make_length_attrs): Likewise.
* gencheck.c (tree_codes): Likewise.
* genemit.c (gen_split): Likewise.
* genrecog.c (special_mode_pred_table): Likewise.
* graph.c (graph_ext): Likewise.
* protoize (default_include): Likewise.
* reload.c (reload_when_needed_name): Likewise.
* sched-vis.c (visualize_stall_cycles): Likewise.
* tlink.c (recompile_files): Likewise.
* toplev.c (decode_g_option): Likewise.
* tradcpp.c (output_deps): Likewise.
* varasm.c (decode_reg_name): Likewise.
* arm.c (arm_condition_codes, strings_fpa, thumb_condition_code):
Const-ification.
* arm.md: Likewise.
* avr.c (avr_regnames, encode_section_info): Likewise.
* c4x.c (float_reg_names): Likewise.
* darwin.h (ASM_GLOBALIZE_LABEL): Likewise.
* elfos.h (const_section): Likewise.
* i386.c (ix86_comp_type_attributes): Likewise.
* i386/win32.h (STRIP_NAME_ENCODING): Likewise.
* ia64/aix.h (UNIQUE_SECTION): Likewise.
* ia64.c (type_names): Likewise.
* m68hc11.c (reg_class_names): Likewise.
* m88k.c (m_options): Likewise.
* mips.c (mips_output_conditional_branch, mips_unique_section):
Likewise.
* rs6000/sysv4.h (ASM_DECLARE_FUNCTION_NAME): Likewise.
* sparc.c (sparc_flat_function_prologue, sparc_flat_function_epilogue,
ultra_code_names): Likewise.
* sparc.h (OVERRIDE_OPTIONS): Likewise.
From-SVN: r45567
2001-09-12 19:18:03 +02:00
|
|
|
const char *const pz_guard = (strcmp (z_type, "wchar") == 0)
|
2000-07-27 15:29:21 +02:00
|
|
|
? " && ! defined(__cplusplus)" : "";
|
2000-07-20 15:29:29 +02:00
|
|
|
|
2000-07-27 15:29:21 +02:00
|
|
|
printf (z_fmt, z_TYPE, pz_guard, z_TYPE, z_TYPE, z_type);
|
2000-07-20 15:29:29 +02:00
|
|
|
}
|
2000-07-13 16:47:55 +02:00
|
|
|
|
2000-07-27 15:29:21 +02:00
|
|
|
return text += rm[0].rm_eo;
|
2000-07-13 16:47:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-05-16 16:23:47 +02:00
|
|
|
/*
|
|
|
|
* Copy the `format' string to std out, replacing `%n' expressions
|
|
|
|
* with the matched text from a regular expression evaluation.
|
|
|
|
* Doubled '%' characters will be replaced with a single copy.
|
|
|
|
* '%' characters in other contexts and all other characters are
|
|
|
|
* copied out verbatim.
|
|
|
|
*/
|
2000-05-12 17:51:55 +02:00
|
|
|
static void
|
2003-08-02 01:07:04 +02:00
|
|
|
format_write (tCC* format, tCC* text, regmatch_t av[] )
|
2000-05-12 17:51:55 +02:00
|
|
|
{
|
2000-05-16 16:23:47 +02:00
|
|
|
int c;
|
2000-05-12 18:35:21 +02:00
|
|
|
|
2000-05-16 16:23:47 +02:00
|
|
|
while ((c = (unsigned)*(format++)) != NUL) {
|
2000-05-12 18:35:21 +02:00
|
|
|
|
2000-05-16 16:23:47 +02:00
|
|
|
if (c != '%')
|
|
|
|
{
|
|
|
|
putchar(c);
|
|
|
|
continue;
|
|
|
|
}
|
2000-05-12 18:35:21 +02:00
|
|
|
|
2000-05-16 16:23:47 +02:00
|
|
|
c = (unsigned)*(format++);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* IF the character following a '%' is not a digit,
|
|
|
|
* THEN we will always emit a '%' and we may or may
|
|
|
|
* not emit the following character. We will end on
|
|
|
|
* a NUL and we will emit only one of a pair of '%'.
|
|
|
|
*/
|
2000-12-02 20:01:16 +01:00
|
|
|
if (! ISDIGIT ( c ))
|
2000-05-16 16:23:47 +02:00
|
|
|
{
|
|
|
|
putchar( '%' );
|
|
|
|
switch (c) {
|
|
|
|
case NUL:
|
|
|
|
return;
|
|
|
|
case '%':
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
putchar(c);
|
2000-05-12 18:35:21 +02:00
|
|
|
}
|
2000-05-16 16:23:47 +02:00
|
|
|
}
|
2000-05-12 18:35:21 +02:00
|
|
|
|
2000-05-16 16:23:47 +02:00
|
|
|
/*
|
|
|
|
* Emit the matched subexpression numbered 'c'.
|
|
|
|
* IF, of course, there was such a match...
|
|
|
|
*/
|
|
|
|
else {
|
|
|
|
regmatch_t* pRM = av + (c - (unsigned)'0');
|
|
|
|
size_t len;
|
2000-05-12 18:35:21 +02:00
|
|
|
|
2000-05-16 16:23:47 +02:00
|
|
|
if (pRM->rm_so < 0)
|
|
|
|
continue;
|
2000-05-12 18:35:21 +02:00
|
|
|
|
2000-05-16 16:23:47 +02:00
|
|
|
len = pRM->rm_eo - pRM->rm_so;
|
|
|
|
if (len > 0)
|
|
|
|
fwrite(text + pRM->rm_so, len, 1, stdout);
|
2000-05-12 17:51:55 +02:00
|
|
|
}
|
2000-05-16 16:23:47 +02:00
|
|
|
}
|
2000-05-12 17:51:55 +02:00
|
|
|
}
|
1999-10-12 16:44:18 +02:00
|
|
|
|
2000-05-12 18:35:21 +02:00
|
|
|
|
2000-05-16 16:23:47 +02:00
|
|
|
/*
|
|
|
|
* Search for multiple copies of a regular expression. Each block
|
|
|
|
* of matched text is replaced with the format string, as described
|
|
|
|
* above in `format_write'.
|
|
|
|
*/
|
2000-05-11 15:41:12 +02:00
|
|
|
FIX_PROC_HEAD( format_fix )
|
1999-10-12 16:44:18 +02:00
|
|
|
{
|
2000-05-16 16:23:47 +02:00
|
|
|
tCC* pz_pat = p_fixd->patch_args[2];
|
|
|
|
tCC* pz_fmt = p_fixd->patch_args[1];
|
|
|
|
regex_t re;
|
|
|
|
regmatch_t rm[10];
|
2000-12-13 21:07:46 +01:00
|
|
|
IGNORE_ARG(filname);
|
2000-05-16 16:23:47 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We must have a format
|
|
|
|
*/
|
|
|
|
if (pz_fmt == (tCC*)NULL)
|
|
|
|
{
|
2000-05-30 22:24:44 +02:00
|
|
|
fprintf( stderr, zNeedsArg, p_fixd->fix_name, "replacement format", 0 );
|
|
|
|
exit (EXIT_BROKEN);
|
2000-05-11 15:41:12 +02:00
|
|
|
}
|
1999-10-22 15:23:43 +02:00
|
|
|
|
2000-05-16 16:23:47 +02:00
|
|
|
/*
|
|
|
|
* IF we don't have a search text, then go find the first
|
|
|
|
* regular expression among the tests.
|
|
|
|
*/
|
|
|
|
if (pz_pat == (tCC*)NULL)
|
|
|
|
{
|
|
|
|
tTestDesc* pTD = p_fixd->p_test_desc;
|
|
|
|
int ct = p_fixd->test_ct;
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
if (ct-- <= 0)
|
|
|
|
{
|
2000-05-30 22:24:44 +02:00
|
|
|
fprintf( stderr, zNeedsArg, p_fixd->fix_name, "search text", 1 );
|
|
|
|
exit (EXIT_BROKEN);
|
2000-05-11 15:41:12 +02:00
|
|
|
}
|
1999-10-22 15:23:43 +02:00
|
|
|
|
2000-05-16 16:23:47 +02:00
|
|
|
if (pTD->type == TT_EGREP)
|
|
|
|
{
|
|
|
|
pz_pat = pTD->pz_test_text;
|
|
|
|
break;
|
1999-10-22 15:23:43 +02:00
|
|
|
}
|
|
|
|
|
2000-05-16 16:23:47 +02:00
|
|
|
pTD++;
|
1999-10-22 15:23:43 +02:00
|
|
|
}
|
2000-05-11 15:41:12 +02:00
|
|
|
}
|
1999-10-22 15:23:43 +02:00
|
|
|
|
2000-05-16 16:23:47 +02:00
|
|
|
/*
|
|
|
|
* Replace every copy of the text we find
|
|
|
|
*/
|
|
|
|
compile_re (pz_pat, &re, 1, "format search-text", "format_fix" );
|
2003-07-08 22:42:19 +02:00
|
|
|
while (xregexec (&re, text, 10, rm, 0) == 0)
|
2000-05-11 15:41:12 +02:00
|
|
|
{
|
2000-05-16 16:23:47 +02:00
|
|
|
fwrite( text, rm[0].rm_so, 1, stdout );
|
|
|
|
format_write( pz_fmt, text, rm );
|
|
|
|
text += rm[0].rm_eo;
|
2000-05-11 15:41:12 +02:00
|
|
|
}
|
1999-10-22 15:23:43 +02:00
|
|
|
|
2000-05-16 16:23:47 +02:00
|
|
|
/*
|
|
|
|
* Dump out the rest of the file
|
|
|
|
*/
|
|
|
|
fputs (text, stdout);
|
1999-10-22 15:23:43 +02:00
|
|
|
}
|
|
|
|
|
2000-05-14 21:29:02 +02:00
|
|
|
|
Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/fixfixes.c (IO_use, CTRL_use, IO_defn, CTRL_defn): New fixes.
(fix_char_macro_defines, fix_char_macro_uses): New functions.
* fixinc/fixlib.c (is_cxx_header): Do the text scan with a regexp.
Recognize Emacs mode markers also.
* fixinc/fixtests.c (else_endif_label): Fix bug in recognition of
C++ comments in C++ headers. Call is_cxx_header only if
necessary.
* fixinc/inclhack.def (avoid_bool): Add select for the problem and
bypass for ncurses.
(bsd43_io_macros, io_def_quotes, ioctl_fix_ctrl): Replace with...
(io_def_quotes, io_use_quotes, ctrl_def_quotes, ctrl_use_quotes):
... these, which use the new C fixes.
(math_exception): Escape literal '+' in bypass expression.
* fixinc/fixincl.x, fixinc/fixincl.sh, fixinc/inclhack.sh:
Regenerate.
From-SVN: r31512
2000-01-19 22:41:04 +01:00
|
|
|
/* Scan the input file for all occurrences of text like this:
|
|
|
|
|
|
|
|
#define TIOCCONS _IO(T, 12)
|
|
|
|
|
|
|
|
and change them to read like this:
|
|
|
|
|
|
|
|
#define TIOCCONS _IO('T', 12)
|
|
|
|
|
|
|
|
which is the required syntax per the C standard. (The definition of
|
|
|
|
_IO also has to be tweaked - see below.) 'IO' is actually whatever you
|
2000-05-16 16:23:47 +02:00
|
|
|
provide as the `c_fix_arg' argument. */
|
2000-05-12 17:51:55 +02:00
|
|
|
|
|
|
|
FIX_PROC_HEAD( char_macro_use_fix )
|
Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/fixfixes.c (IO_use, CTRL_use, IO_defn, CTRL_defn): New fixes.
(fix_char_macro_defines, fix_char_macro_uses): New functions.
* fixinc/fixlib.c (is_cxx_header): Do the text scan with a regexp.
Recognize Emacs mode markers also.
* fixinc/fixtests.c (else_endif_label): Fix bug in recognition of
C++ comments in C++ headers. Call is_cxx_header only if
necessary.
* fixinc/inclhack.def (avoid_bool): Add select for the problem and
bypass for ncurses.
(bsd43_io_macros, io_def_quotes, ioctl_fix_ctrl): Replace with...
(io_def_quotes, io_use_quotes, ctrl_def_quotes, ctrl_use_quotes):
... these, which use the new C fixes.
(math_exception): Escape literal '+' in bypass expression.
* fixinc/fixincl.x, fixinc/fixincl.sh, fixinc/inclhack.sh:
Regenerate.
From-SVN: r31512
2000-01-19 22:41:04 +01:00
|
|
|
{
|
|
|
|
/* This regexp looks for a traditional-syntax #define (# in column 1)
|
|
|
|
of an object-like macro. */
|
2000-05-30 22:24:44 +02:00
|
|
|
static const char pat[] =
|
|
|
|
"^#[ \t]*define[ \t]+[_A-Za-z][_A-Za-z0-9]*[ \t]+";
|
Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/fixfixes.c (IO_use, CTRL_use, IO_defn, CTRL_defn): New fixes.
(fix_char_macro_defines, fix_char_macro_uses): New functions.
* fixinc/fixlib.c (is_cxx_header): Do the text scan with a regexp.
Recognize Emacs mode markers also.
* fixinc/fixtests.c (else_endif_label): Fix bug in recognition of
C++ comments in C++ headers. Call is_cxx_header only if
necessary.
* fixinc/inclhack.def (avoid_bool): Add select for the problem and
bypass for ncurses.
(bsd43_io_macros, io_def_quotes, ioctl_fix_ctrl): Replace with...
(io_def_quotes, io_use_quotes, ctrl_def_quotes, ctrl_use_quotes):
... these, which use the new C fixes.
(math_exception): Escape literal '+' in bypass expression.
* fixinc/fixincl.x, fixinc/fixincl.sh, fixinc/inclhack.sh:
Regenerate.
From-SVN: r31512
2000-01-19 22:41:04 +01:00
|
|
|
static regex_t re;
|
|
|
|
|
2000-05-30 22:24:44 +02:00
|
|
|
const char* str = p_fixd->patch_args[1];
|
|
|
|
regmatch_t rm[1];
|
|
|
|
const char *p, *limit;
|
|
|
|
size_t len;
|
2000-12-13 21:07:46 +01:00
|
|
|
IGNORE_ARG(filname);
|
2000-05-12 17:51:55 +02:00
|
|
|
|
2000-05-30 22:24:44 +02:00
|
|
|
if (str == NULL)
|
Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/fixfixes.c (IO_use, CTRL_use, IO_defn, CTRL_defn): New fixes.
(fix_char_macro_defines, fix_char_macro_uses): New functions.
* fixinc/fixlib.c (is_cxx_header): Do the text scan with a regexp.
Recognize Emacs mode markers also.
* fixinc/fixtests.c (else_endif_label): Fix bug in recognition of
C++ comments in C++ headers. Call is_cxx_header only if
necessary.
* fixinc/inclhack.def (avoid_bool): Add select for the problem and
bypass for ncurses.
(bsd43_io_macros, io_def_quotes, ioctl_fix_ctrl): Replace with...
(io_def_quotes, io_use_quotes, ctrl_def_quotes, ctrl_use_quotes):
... these, which use the new C fixes.
(math_exception): Escape literal '+' in bypass expression.
* fixinc/fixincl.x, fixinc/fixincl.sh, fixinc/inclhack.sh:
Regenerate.
From-SVN: r31512
2000-01-19 22:41:04 +01:00
|
|
|
{
|
2000-05-30 22:24:44 +02:00
|
|
|
fprintf (stderr, zNeedsArg, p_fixd->fix_name, "ioctl type", 0);
|
|
|
|
exit (EXIT_BROKEN);
|
2000-05-16 16:23:47 +02:00
|
|
|
}
|
Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/fixfixes.c (IO_use, CTRL_use, IO_defn, CTRL_defn): New fixes.
(fix_char_macro_defines, fix_char_macro_uses): New functions.
* fixinc/fixlib.c (is_cxx_header): Do the text scan with a regexp.
Recognize Emacs mode markers also.
* fixinc/fixtests.c (else_endif_label): Fix bug in recognition of
C++ comments in C++ headers. Call is_cxx_header only if
necessary.
* fixinc/inclhack.def (avoid_bool): Add select for the problem and
bypass for ncurses.
(bsd43_io_macros, io_def_quotes, ioctl_fix_ctrl): Replace with...
(io_def_quotes, io_use_quotes, ctrl_def_quotes, ctrl_use_quotes):
... these, which use the new C fixes.
(math_exception): Escape literal '+' in bypass expression.
* fixinc/fixincl.x, fixinc/fixincl.sh, fixinc/inclhack.sh:
Regenerate.
From-SVN: r31512
2000-01-19 22:41:04 +01:00
|
|
|
|
2000-05-30 22:24:44 +02:00
|
|
|
len = strlen (str);
|
|
|
|
compile_re (pat, &re, 1, "macro pattern", "char_macro_use_fix");
|
2000-05-16 16:23:47 +02:00
|
|
|
|
2000-05-30 22:24:44 +02:00
|
|
|
for (p = text;
|
2003-07-08 22:42:19 +02:00
|
|
|
xregexec (&re, p, 1, rm, 0) == 0;
|
2000-05-30 22:24:44 +02:00
|
|
|
p = limit + 1)
|
2000-05-16 16:23:47 +02:00
|
|
|
{
|
2000-05-30 22:24:44 +02:00
|
|
|
/* p + rm[0].rm_eo is the first character of the macro replacement.
|
|
|
|
Find the end of the macro replacement, and the STR we were
|
|
|
|
sent to look for within the replacement. */
|
|
|
|
p += rm[0].rm_eo;
|
|
|
|
limit = p - 1;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
limit = strchr (limit + 1, '\n');
|
|
|
|
if (!limit)
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
while (limit[-1] == '\\');
|
2000-05-16 16:23:47 +02:00
|
|
|
|
2000-05-30 22:24:44 +02:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (*p == str[0] && !strncmp (p+1, str+1, len-1))
|
|
|
|
goto found;
|
|
|
|
}
|
|
|
|
while (++p < limit - len);
|
|
|
|
/* Hit end of line. */
|
|
|
|
continue;
|
|
|
|
|
|
|
|
found:
|
|
|
|
/* Found STR on this line. If the macro needs fixing,
|
|
|
|
the next few chars will be whitespace or uppercase,
|
|
|
|
then an open paren, then a single letter. */
|
2000-12-02 20:01:16 +01:00
|
|
|
while ((ISSPACE (*p) || ISUPPER (*p)) && p < limit) p++;
|
2000-05-30 22:24:44 +02:00
|
|
|
if (*p++ != '(')
|
|
|
|
continue;
|
2000-12-02 20:01:16 +01:00
|
|
|
if (!ISALPHA (*p))
|
2000-05-30 22:24:44 +02:00
|
|
|
continue;
|
c-format.c (maybe_read_dollar_number): Use safe-ctype macros and/or fold extra calls into fewer ones.
* c-format.c (maybe_read_dollar_number): Use safe-ctype macros
and/or fold extra calls into fewer ones.
* collect2.c (dump_file): Likewise.
* cppexp.c (parse_number): Likewise.
* cpplex.c (_cpp_lex_direct): Likewise.
* final.c (output_asm_insn, asm_fprintf): Likewise.
* fix-header.c (inf_scan_ident, main): Likewise.
* fixinc/fixfixes.c (char_macro_use_fix, char_macro_def_fix):
Likewise.
* fold-const.c (real_hex_to_f): Likewise.
* gen-protos.c (parse_fn_proto): Likewise.
* genattrtab.c (check_attr_test, check_attr_value): Likewise.
* genrecog.c (change_state, write_action): Likewise.
* gensupport.c (shift_output_template): Likewise.
* local-alloc.c (requires_inout): Likewise.
* mips-tfile.c (IS_ASM_IDENT): Likewise.
* protoize.c (is_id_char, main): Likewise.
* real.c (asctoeg): Likewise.
* recog.c (asm_operand_ok): Likewise.
* reload.c (find_reloads): Likewise.
* scan.c (scan_identget_token): Likewise.
* sched-vis.c (print_value): Likewise.
* stringpool.c (ggc_alloc_string): Likewise.
* toplev.c (read_integral_parameter, decode_g_option): Likewise.
* tradcif.y (parse_number, yylex, parse_escape): Likewise.
* tradcpp.c (rescan): Likewise.
* tree.c (clean_symbol_name): Likewise.
* varasm.c (decode_reg_name): Likewise.
* alpha.h (ASM_OUTPUT_ASCII): Likewise.
* darwin.c (name_needs_quotes, func_name_maybe_scoped): Likewise.
* dsp16xx.h (ASM_OUTPUT_ASCII): Likewise.
* m88k.c (output_ascii): Likewise.
* m88k.h (OVERRIDE_OPTIONS): Likewise.
* mcore.h (REG_CLASS_FROM_LETTER): Likewise.
* ns32k/encore.h (ASM_OUTPUT_ASCII): Likewise.
* sh.h (REG_CLASS_FROM_LETTER): Likewise.
cp:
* xref.c (GNU_xref_member): Use safe-ctype macros and/or fold
extra calls into fewer ones.
f:
* bad.c (ffebad_finish): Use safe-ctype macros and/or fold extra
calls into fewer ones.
* implic.c (ffeimplic_lookup_): Likewise.
* intdoc.c (dumpimp): Likewise.
* intrin.c (ffeintrin_init_0): Likewise.
* lex.c (ffelex_backslash_, ffelex_cfebackslash_, ffelex_hash_):
Likewise.
* lex.h (ffelex_is_firstnamechar): Likewise.
* target.c (ffetarget_integerhex): Likewise.
java:
* gjavah.c (jni_print_char, decode_signature_piece): Use
safe-ctype macros and/or fold extra calls into fewer ones.
* lex.c (java_read_unicode, java_lex): Likewise.
* lex.h (JAVA_START_CHAR_P, JAVA_PART_CHAR_P, JAVA_ASCII_DIGIT,
JAVA_ASCII_HEXDIGIT, JAVA_ASCII_LETTER): Likewise.
* mangle_name.c (append_unicode_mangled_name,
unicode_mangling_length): Likewise.
From-SVN: r46397
2001-10-21 23:32:15 +02:00
|
|
|
if (ISIDNUM (p[1]))
|
2000-05-30 22:24:44 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Splat all preceding text into the output buffer,
|
|
|
|
quote the character at p, then proceed. */
|
|
|
|
fwrite (text, 1, p - text, stdout);
|
|
|
|
putchar ('\'');
|
|
|
|
putchar (*p);
|
|
|
|
putchar ('\'');
|
|
|
|
text = p + 1;
|
|
|
|
}
|
|
|
|
done:
|
Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/fixfixes.c (IO_use, CTRL_use, IO_defn, CTRL_defn): New fixes.
(fix_char_macro_defines, fix_char_macro_uses): New functions.
* fixinc/fixlib.c (is_cxx_header): Do the text scan with a regexp.
Recognize Emacs mode markers also.
* fixinc/fixtests.c (else_endif_label): Fix bug in recognition of
C++ comments in C++ headers. Call is_cxx_header only if
necessary.
* fixinc/inclhack.def (avoid_bool): Add select for the problem and
bypass for ncurses.
(bsd43_io_macros, io_def_quotes, ioctl_fix_ctrl): Replace with...
(io_def_quotes, io_use_quotes, ctrl_def_quotes, ctrl_use_quotes):
... these, which use the new C fixes.
(math_exception): Escape literal '+' in bypass expression.
* fixinc/fixincl.x, fixinc/fixincl.sh, fixinc/inclhack.sh:
Regenerate.
From-SVN: r31512
2000-01-19 22:41:04 +01:00
|
|
|
fputs (text, stdout);
|
|
|
|
}
|
|
|
|
|
2000-05-16 16:23:47 +02:00
|
|
|
|
Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/fixfixes.c (IO_use, CTRL_use, IO_defn, CTRL_defn): New fixes.
(fix_char_macro_defines, fix_char_macro_uses): New functions.
* fixinc/fixlib.c (is_cxx_header): Do the text scan with a regexp.
Recognize Emacs mode markers also.
* fixinc/fixtests.c (else_endif_label): Fix bug in recognition of
C++ comments in C++ headers. Call is_cxx_header only if
necessary.
* fixinc/inclhack.def (avoid_bool): Add select for the problem and
bypass for ncurses.
(bsd43_io_macros, io_def_quotes, ioctl_fix_ctrl): Replace with...
(io_def_quotes, io_use_quotes, ctrl_def_quotes, ctrl_use_quotes):
... these, which use the new C fixes.
(math_exception): Escape literal '+' in bypass expression.
* fixinc/fixincl.x, fixinc/fixincl.sh, fixinc/inclhack.sh:
Regenerate.
From-SVN: r31512
2000-01-19 22:41:04 +01:00
|
|
|
/* Scan the input file for all occurrences of text like this:
|
|
|
|
|
2000-05-17 16:56:13 +02:00
|
|
|
#define xxxIOxx(x, y) (....'x'<<16....)
|
Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/fixfixes.c (IO_use, CTRL_use, IO_defn, CTRL_defn): New fixes.
(fix_char_macro_defines, fix_char_macro_uses): New functions.
* fixinc/fixlib.c (is_cxx_header): Do the text scan with a regexp.
Recognize Emacs mode markers also.
* fixinc/fixtests.c (else_endif_label): Fix bug in recognition of
C++ comments in C++ headers. Call is_cxx_header only if
necessary.
* fixinc/inclhack.def (avoid_bool): Add select for the problem and
bypass for ncurses.
(bsd43_io_macros, io_def_quotes, ioctl_fix_ctrl): Replace with...
(io_def_quotes, io_use_quotes, ctrl_def_quotes, ctrl_use_quotes):
... these, which use the new C fixes.
(math_exception): Escape literal '+' in bypass expression.
* fixinc/fixincl.x, fixinc/fixincl.sh, fixinc/inclhack.sh:
Regenerate.
From-SVN: r31512
2000-01-19 22:41:04 +01:00
|
|
|
|
|
|
|
and change them to read like this:
|
|
|
|
|
2000-05-17 16:56:13 +02:00
|
|
|
#define xxxIOxx(x, y) (....x<<16....)
|
Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/fixfixes.c (IO_use, CTRL_use, IO_defn, CTRL_defn): New fixes.
(fix_char_macro_defines, fix_char_macro_uses): New functions.
* fixinc/fixlib.c (is_cxx_header): Do the text scan with a regexp.
Recognize Emacs mode markers also.
* fixinc/fixtests.c (else_endif_label): Fix bug in recognition of
C++ comments in C++ headers. Call is_cxx_header only if
necessary.
* fixinc/inclhack.def (avoid_bool): Add select for the problem and
bypass for ncurses.
(bsd43_io_macros, io_def_quotes, ioctl_fix_ctrl): Replace with...
(io_def_quotes, io_use_quotes, ctrl_def_quotes, ctrl_use_quotes):
... these, which use the new C fixes.
(math_exception): Escape literal '+' in bypass expression.
* fixinc/fixincl.x, fixinc/fixincl.sh, fixinc/inclhack.sh:
Regenerate.
From-SVN: r31512
2000-01-19 22:41:04 +01:00
|
|
|
|
|
|
|
which is the required syntax per the C standard. (The uses of _IO
|
2000-05-16 16:23:47 +02:00
|
|
|
also has to be tweaked - see above.) 'IO' is actually whatever
|
|
|
|
you provide as the `c_fix_arg' argument. */
|
2000-05-12 17:51:55 +02:00
|
|
|
FIX_PROC_HEAD( char_macro_def_fix )
|
Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/fixfixes.c (IO_use, CTRL_use, IO_defn, CTRL_defn): New fixes.
(fix_char_macro_defines, fix_char_macro_uses): New functions.
* fixinc/fixlib.c (is_cxx_header): Do the text scan with a regexp.
Recognize Emacs mode markers also.
* fixinc/fixtests.c (else_endif_label): Fix bug in recognition of
C++ comments in C++ headers. Call is_cxx_header only if
necessary.
* fixinc/inclhack.def (avoid_bool): Add select for the problem and
bypass for ncurses.
(bsd43_io_macros, io_def_quotes, ioctl_fix_ctrl): Replace with...
(io_def_quotes, io_use_quotes, ctrl_def_quotes, ctrl_use_quotes):
... these, which use the new C fixes.
(math_exception): Escape literal '+' in bypass expression.
* fixinc/fixincl.x, fixinc/fixincl.sh, fixinc/inclhack.sh:
Regenerate.
From-SVN: r31512
2000-01-19 22:41:04 +01:00
|
|
|
{
|
2000-05-30 22:24:44 +02:00
|
|
|
/* This regexp looks for any traditional-syntax #define (# in column 1). */
|
|
|
|
static const char pat[] =
|
|
|
|
"^#[ \t]*define[ \t]+";
|
Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/fixfixes.c (IO_use, CTRL_use, IO_defn, CTRL_defn): New fixes.
(fix_char_macro_defines, fix_char_macro_uses): New functions.
* fixinc/fixlib.c (is_cxx_header): Do the text scan with a regexp.
Recognize Emacs mode markers also.
* fixinc/fixtests.c (else_endif_label): Fix bug in recognition of
C++ comments in C++ headers. Call is_cxx_header only if
necessary.
* fixinc/inclhack.def (avoid_bool): Add select for the problem and
bypass for ncurses.
(bsd43_io_macros, io_def_quotes, ioctl_fix_ctrl): Replace with...
(io_def_quotes, io_use_quotes, ctrl_def_quotes, ctrl_use_quotes):
... these, which use the new C fixes.
(math_exception): Escape literal '+' in bypass expression.
* fixinc/fixincl.x, fixinc/fixincl.sh, fixinc/inclhack.sh:
Regenerate.
From-SVN: r31512
2000-01-19 22:41:04 +01:00
|
|
|
static regex_t re;
|
|
|
|
|
2000-05-30 22:24:44 +02:00
|
|
|
const char* str = p_fixd->patch_args[1];
|
|
|
|
regmatch_t rm[1];
|
|
|
|
const char *p, *limit;
|
|
|
|
char arg;
|
|
|
|
size_t len;
|
2000-12-13 21:07:46 +01:00
|
|
|
IGNORE_ARG(filname);
|
2000-05-12 17:51:55 +02:00
|
|
|
|
2000-05-30 22:24:44 +02:00
|
|
|
if (str == NULL)
|
2000-05-16 16:23:47 +02:00
|
|
|
{
|
2000-05-30 22:24:44 +02:00
|
|
|
fprintf (stderr, zNeedsArg, p_fixd->fix_name, "ioctl type", 0);
|
|
|
|
exit (EXIT_BROKEN);
|
2000-05-16 16:23:47 +02:00
|
|
|
}
|
|
|
|
|
2000-05-30 22:24:44 +02:00
|
|
|
len = strlen (str);
|
|
|
|
compile_re (pat, &re, 1, "macro pattern", "fix_char_macro_defines");
|
Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/fixfixes.c (IO_use, CTRL_use, IO_defn, CTRL_defn): New fixes.
(fix_char_macro_defines, fix_char_macro_uses): New functions.
* fixinc/fixlib.c (is_cxx_header): Do the text scan with a regexp.
Recognize Emacs mode markers also.
* fixinc/fixtests.c (else_endif_label): Fix bug in recognition of
C++ comments in C++ headers. Call is_cxx_header only if
necessary.
* fixinc/inclhack.def (avoid_bool): Add select for the problem and
bypass for ncurses.
(bsd43_io_macros, io_def_quotes, ioctl_fix_ctrl): Replace with...
(io_def_quotes, io_use_quotes, ctrl_def_quotes, ctrl_use_quotes):
... these, which use the new C fixes.
(math_exception): Escape literal '+' in bypass expression.
* fixinc/fixincl.x, fixinc/fixincl.sh, fixinc/inclhack.sh:
Regenerate.
From-SVN: r31512
2000-01-19 22:41:04 +01:00
|
|
|
|
2000-05-30 22:24:44 +02:00
|
|
|
for (p = text;
|
2003-07-08 22:42:19 +02:00
|
|
|
xregexec (&re, p, 1, rm, 0) == 0;
|
2000-05-30 22:24:44 +02:00
|
|
|
p = limit + 1)
|
Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/fixfixes.c (IO_use, CTRL_use, IO_defn, CTRL_defn): New fixes.
(fix_char_macro_defines, fix_char_macro_uses): New functions.
* fixinc/fixlib.c (is_cxx_header): Do the text scan with a regexp.
Recognize Emacs mode markers also.
* fixinc/fixtests.c (else_endif_label): Fix bug in recognition of
C++ comments in C++ headers. Call is_cxx_header only if
necessary.
* fixinc/inclhack.def (avoid_bool): Add select for the problem and
bypass for ncurses.
(bsd43_io_macros, io_def_quotes, ioctl_fix_ctrl): Replace with...
(io_def_quotes, io_use_quotes, ctrl_def_quotes, ctrl_use_quotes):
... these, which use the new C fixes.
(math_exception): Escape literal '+' in bypass expression.
* fixinc/fixincl.x, fixinc/fixincl.sh, fixinc/inclhack.sh:
Regenerate.
From-SVN: r31512
2000-01-19 22:41:04 +01:00
|
|
|
{
|
2000-05-30 22:24:44 +02:00
|
|
|
/* p + rm[0].rm_eo is the first character of the macro name.
|
|
|
|
Find the end of the macro replacement, and the STR we were
|
|
|
|
sent to look for within the name. */
|
|
|
|
p += rm[0].rm_eo;
|
|
|
|
limit = p - 1;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
limit = strchr (limit + 1, '\n');
|
|
|
|
if (!limit)
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
while (limit[-1] == '\\');
|
2000-05-16 16:23:47 +02:00
|
|
|
|
2000-05-30 22:24:44 +02:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (*p == str[0] && !strncmp (p+1, str+1, len-1))
|
|
|
|
goto found;
|
|
|
|
p++;
|
|
|
|
}
|
c-format.c (maybe_read_dollar_number): Use safe-ctype macros and/or fold extra calls into fewer ones.
* c-format.c (maybe_read_dollar_number): Use safe-ctype macros
and/or fold extra calls into fewer ones.
* collect2.c (dump_file): Likewise.
* cppexp.c (parse_number): Likewise.
* cpplex.c (_cpp_lex_direct): Likewise.
* final.c (output_asm_insn, asm_fprintf): Likewise.
* fix-header.c (inf_scan_ident, main): Likewise.
* fixinc/fixfixes.c (char_macro_use_fix, char_macro_def_fix):
Likewise.
* fold-const.c (real_hex_to_f): Likewise.
* gen-protos.c (parse_fn_proto): Likewise.
* genattrtab.c (check_attr_test, check_attr_value): Likewise.
* genrecog.c (change_state, write_action): Likewise.
* gensupport.c (shift_output_template): Likewise.
* local-alloc.c (requires_inout): Likewise.
* mips-tfile.c (IS_ASM_IDENT): Likewise.
* protoize.c (is_id_char, main): Likewise.
* real.c (asctoeg): Likewise.
* recog.c (asm_operand_ok): Likewise.
* reload.c (find_reloads): Likewise.
* scan.c (scan_identget_token): Likewise.
* sched-vis.c (print_value): Likewise.
* stringpool.c (ggc_alloc_string): Likewise.
* toplev.c (read_integral_parameter, decode_g_option): Likewise.
* tradcif.y (parse_number, yylex, parse_escape): Likewise.
* tradcpp.c (rescan): Likewise.
* tree.c (clean_symbol_name): Likewise.
* varasm.c (decode_reg_name): Likewise.
* alpha.h (ASM_OUTPUT_ASCII): Likewise.
* darwin.c (name_needs_quotes, func_name_maybe_scoped): Likewise.
* dsp16xx.h (ASM_OUTPUT_ASCII): Likewise.
* m88k.c (output_ascii): Likewise.
* m88k.h (OVERRIDE_OPTIONS): Likewise.
* mcore.h (REG_CLASS_FROM_LETTER): Likewise.
* ns32k/encore.h (ASM_OUTPUT_ASCII): Likewise.
* sh.h (REG_CLASS_FROM_LETTER): Likewise.
cp:
* xref.c (GNU_xref_member): Use safe-ctype macros and/or fold
extra calls into fewer ones.
f:
* bad.c (ffebad_finish): Use safe-ctype macros and/or fold extra
calls into fewer ones.
* implic.c (ffeimplic_lookup_): Likewise.
* intdoc.c (dumpimp): Likewise.
* intrin.c (ffeintrin_init_0): Likewise.
* lex.c (ffelex_backslash_, ffelex_cfebackslash_, ffelex_hash_):
Likewise.
* lex.h (ffelex_is_firstnamechar): Likewise.
* target.c (ffetarget_integerhex): Likewise.
java:
* gjavah.c (jni_print_char, decode_signature_piece): Use
safe-ctype macros and/or fold extra calls into fewer ones.
* lex.c (java_read_unicode, java_lex): Likewise.
* lex.h (JAVA_START_CHAR_P, JAVA_PART_CHAR_P, JAVA_ASCII_DIGIT,
JAVA_ASCII_HEXDIGIT, JAVA_ASCII_LETTER): Likewise.
* mangle_name.c (append_unicode_mangled_name,
unicode_mangling_length): Likewise.
From-SVN: r46397
2001-10-21 23:32:15 +02:00
|
|
|
while (ISIDNUM (*p));
|
2000-05-30 22:24:44 +02:00
|
|
|
/* Hit end of macro name without finding the string. */
|
|
|
|
continue;
|
|
|
|
|
|
|
|
found:
|
|
|
|
/* Found STR in this macro name. If the macro needs fixing,
|
|
|
|
there may be a few uppercase letters, then there will be an
|
|
|
|
open paren with _no_ intervening whitespace, and then a
|
|
|
|
single letter. */
|
2000-12-02 20:01:16 +01:00
|
|
|
while (ISUPPER (*p) && p < limit) p++;
|
2000-05-30 22:24:44 +02:00
|
|
|
if (*p++ != '(')
|
|
|
|
continue;
|
2000-12-02 20:01:16 +01:00
|
|
|
if (!ISALPHA (*p))
|
2000-05-30 22:24:44 +02:00
|
|
|
continue;
|
c-format.c (maybe_read_dollar_number): Use safe-ctype macros and/or fold extra calls into fewer ones.
* c-format.c (maybe_read_dollar_number): Use safe-ctype macros
and/or fold extra calls into fewer ones.
* collect2.c (dump_file): Likewise.
* cppexp.c (parse_number): Likewise.
* cpplex.c (_cpp_lex_direct): Likewise.
* final.c (output_asm_insn, asm_fprintf): Likewise.
* fix-header.c (inf_scan_ident, main): Likewise.
* fixinc/fixfixes.c (char_macro_use_fix, char_macro_def_fix):
Likewise.
* fold-const.c (real_hex_to_f): Likewise.
* gen-protos.c (parse_fn_proto): Likewise.
* genattrtab.c (check_attr_test, check_attr_value): Likewise.
* genrecog.c (change_state, write_action): Likewise.
* gensupport.c (shift_output_template): Likewise.
* local-alloc.c (requires_inout): Likewise.
* mips-tfile.c (IS_ASM_IDENT): Likewise.
* protoize.c (is_id_char, main): Likewise.
* real.c (asctoeg): Likewise.
* recog.c (asm_operand_ok): Likewise.
* reload.c (find_reloads): Likewise.
* scan.c (scan_identget_token): Likewise.
* sched-vis.c (print_value): Likewise.
* stringpool.c (ggc_alloc_string): Likewise.
* toplev.c (read_integral_parameter, decode_g_option): Likewise.
* tradcif.y (parse_number, yylex, parse_escape): Likewise.
* tradcpp.c (rescan): Likewise.
* tree.c (clean_symbol_name): Likewise.
* varasm.c (decode_reg_name): Likewise.
* alpha.h (ASM_OUTPUT_ASCII): Likewise.
* darwin.c (name_needs_quotes, func_name_maybe_scoped): Likewise.
* dsp16xx.h (ASM_OUTPUT_ASCII): Likewise.
* m88k.c (output_ascii): Likewise.
* m88k.h (OVERRIDE_OPTIONS): Likewise.
* mcore.h (REG_CLASS_FROM_LETTER): Likewise.
* ns32k/encore.h (ASM_OUTPUT_ASCII): Likewise.
* sh.h (REG_CLASS_FROM_LETTER): Likewise.
cp:
* xref.c (GNU_xref_member): Use safe-ctype macros and/or fold
extra calls into fewer ones.
f:
* bad.c (ffebad_finish): Use safe-ctype macros and/or fold extra
calls into fewer ones.
* implic.c (ffeimplic_lookup_): Likewise.
* intdoc.c (dumpimp): Likewise.
* intrin.c (ffeintrin_init_0): Likewise.
* lex.c (ffelex_backslash_, ffelex_cfebackslash_, ffelex_hash_):
Likewise.
* lex.h (ffelex_is_firstnamechar): Likewise.
* target.c (ffetarget_integerhex): Likewise.
java:
* gjavah.c (jni_print_char, decode_signature_piece): Use
safe-ctype macros and/or fold extra calls into fewer ones.
* lex.c (java_read_unicode, java_lex): Likewise.
* lex.h (JAVA_START_CHAR_P, JAVA_PART_CHAR_P, JAVA_ASCII_DIGIT,
JAVA_ASCII_HEXDIGIT, JAVA_ASCII_LETTER): Likewise.
* mangle_name.c (append_unicode_mangled_name,
unicode_mangling_length): Likewise.
From-SVN: r46397
2001-10-21 23:32:15 +02:00
|
|
|
if (ISIDNUM (p[1]))
|
2000-05-30 22:24:44 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
/* The character at P is the one to look for in the following
|
|
|
|
text. */
|
|
|
|
arg = *p;
|
|
|
|
p += 2;
|
|
|
|
|
|
|
|
while (p < limit)
|
|
|
|
{
|
|
|
|
if (p[-1] == '\'' && p[0] == arg && p[1] == '\'')
|
|
|
|
{
|
|
|
|
/* Remove the quotes from this use of ARG. */
|
|
|
|
p--;
|
|
|
|
fwrite (text, 1, p - text, stdout);
|
|
|
|
putchar (arg);
|
|
|
|
p += 3;
|
|
|
|
text = p;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
p++;
|
|
|
|
}
|
Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/fixfixes.c (IO_use, CTRL_use, IO_defn, CTRL_defn): New fixes.
(fix_char_macro_defines, fix_char_macro_uses): New functions.
* fixinc/fixlib.c (is_cxx_header): Do the text scan with a regexp.
Recognize Emacs mode markers also.
* fixinc/fixtests.c (else_endif_label): Fix bug in recognition of
C++ comments in C++ headers. Call is_cxx_header only if
necessary.
* fixinc/inclhack.def (avoid_bool): Add select for the problem and
bypass for ncurses.
(bsd43_io_macros, io_def_quotes, ioctl_fix_ctrl): Replace with...
(io_def_quotes, io_use_quotes, ctrl_def_quotes, ctrl_use_quotes):
... these, which use the new C fixes.
(math_exception): Escape literal '+' in bypass expression.
* fixinc/fixincl.x, fixinc/fixincl.sh, fixinc/inclhack.sh:
Regenerate.
From-SVN: r31512
2000-01-19 22:41:04 +01:00
|
|
|
}
|
2000-05-30 22:24:44 +02:00
|
|
|
done:
|
Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/Makefile.in: Correct dependencies of fixincl and fixincl.o.
* fixinc/fixfixes.c (IO_use, CTRL_use, IO_defn, CTRL_defn): New fixes.
(fix_char_macro_defines, fix_char_macro_uses): New functions.
* fixinc/fixlib.c (is_cxx_header): Do the text scan with a regexp.
Recognize Emacs mode markers also.
* fixinc/fixtests.c (else_endif_label): Fix bug in recognition of
C++ comments in C++ headers. Call is_cxx_header only if
necessary.
* fixinc/inclhack.def (avoid_bool): Add select for the problem and
bypass for ncurses.
(bsd43_io_macros, io_def_quotes, ioctl_fix_ctrl): Replace with...
(io_def_quotes, io_use_quotes, ctrl_def_quotes, ctrl_use_quotes):
... these, which use the new C fixes.
(math_exception): Escape literal '+' in bypass expression.
* fixinc/fixincl.x, fixinc/fixincl.sh, fixinc/inclhack.sh:
Regenerate.
From-SVN: r31512
2000-01-19 22:41:04 +01:00
|
|
|
fputs (text, stdout);
|
|
|
|
}
|
|
|
|
|
2000-01-20 19:25:12 +01:00
|
|
|
/* Fix for machine name #ifdefs that are not in the namespace reserved
|
|
|
|
by the C standard. They won't be defined if compiling with -ansi,
|
|
|
|
and the headers will break. We go to some trouble to only change
|
|
|
|
#ifdefs where the macro is defined by GCC in non-ansi mode; this
|
|
|
|
minimizes the number of headers touched. */
|
|
|
|
|
|
|
|
#define SCRATCHSZ 64 /* hopefully long enough */
|
|
|
|
|
|
|
|
FIX_PROC_HEAD( machine_name_fix )
|
|
|
|
{
|
|
|
|
regmatch_t match[2];
|
2000-05-12 17:51:55 +02:00
|
|
|
const char *line, *base, *limit, *p, *q;
|
2000-01-20 19:25:12 +01:00
|
|
|
regex_t *label_re, *name_re;
|
|
|
|
char scratch[SCRATCHSZ];
|
|
|
|
size_t len;
|
2000-12-13 21:07:46 +01:00
|
|
|
IGNORE_ARG(filname);
|
|
|
|
IGNORE_ARG(p_fixd);
|
2000-01-20 19:25:12 +01:00
|
|
|
|
2004-08-30 15:32:57 +02:00
|
|
|
if (!mn_get_regexps (&label_re, &name_re, "machine_name_fix"))
|
|
|
|
{
|
|
|
|
fputs( "The target machine has no needed machine name fixes\n", stderr );
|
|
|
|
goto done;
|
|
|
|
}
|
2000-02-02 00:51:38 +01:00
|
|
|
|
2000-01-20 19:25:12 +01:00
|
|
|
scratch[0] = '_';
|
|
|
|
scratch[1] = '_';
|
|
|
|
|
|
|
|
for (base = text;
|
2003-07-08 22:42:19 +02:00
|
|
|
xregexec (label_re, base, 2, match, 0) == 0;
|
2000-01-20 19:25:12 +01:00
|
|
|
base = limit)
|
|
|
|
{
|
|
|
|
base += match[0].rm_eo;
|
|
|
|
/* We're looking at an #if or #ifdef. Scan forward for the
|
2000-05-16 16:23:47 +02:00
|
|
|
next non-escaped newline. */
|
2000-01-20 19:25:12 +01:00
|
|
|
line = limit = base;
|
|
|
|
do
|
2000-05-16 16:23:47 +02:00
|
|
|
{
|
|
|
|
limit++;
|
|
|
|
limit = strchr (limit, '\n');
|
|
|
|
if (!limit)
|
|
|
|
goto done;
|
|
|
|
}
|
2000-01-20 19:25:12 +01:00
|
|
|
while (limit[-1] == '\\');
|
|
|
|
|
|
|
|
/* If the 'name_pat' matches in between base and limit, we have
|
2000-05-16 16:23:47 +02:00
|
|
|
a bogon. It is not worth the hassle of excluding comments
|
|
|
|
because comments on #if/#ifdef lines are rare, and strings on
|
|
|
|
such lines are illegal.
|
2000-01-20 19:25:12 +01:00
|
|
|
|
2000-05-16 16:23:47 +02:00
|
|
|
REG_NOTBOL means 'base' is not at the beginning of a line, which
|
|
|
|
shouldn't matter since the name_re has no ^ anchor, but let's
|
|
|
|
be accurate anyway. */
|
2000-01-20 19:25:12 +01:00
|
|
|
|
|
|
|
for (;;)
|
2000-05-16 16:23:47 +02:00
|
|
|
{
|
|
|
|
again:
|
|
|
|
if (base == limit)
|
|
|
|
break;
|
|
|
|
|
2003-07-08 22:42:19 +02:00
|
|
|
if (xregexec (name_re, base, 1, match, REG_NOTBOL))
|
2000-05-16 16:23:47 +02:00
|
|
|
goto done; /* No remaining match in this file */
|
|
|
|
|
|
|
|
/* Match; is it on the line? */
|
|
|
|
if (match[0].rm_eo > limit - base)
|
|
|
|
break;
|
|
|
|
|
|
|
|
p = base + match[0].rm_so;
|
|
|
|
base += match[0].rm_eo;
|
|
|
|
|
|
|
|
/* One more test: if on the same line we have the same string
|
|
|
|
with the appropriate underscores, then leave it alone.
|
|
|
|
We want exactly two leading and trailing underscores. */
|
|
|
|
if (*p == '_')
|
|
|
|
{
|
|
|
|
len = base - p - ((*base == '_') ? 2 : 1);
|
|
|
|
q = p + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
len = base - p - ((*base == '_') ? 1 : 0);
|
|
|
|
q = p;
|
|
|
|
}
|
|
|
|
if (len + 4 > SCRATCHSZ)
|
|
|
|
abort ();
|
|
|
|
memcpy (&scratch[2], q, len);
|
|
|
|
len += 2;
|
|
|
|
scratch[len++] = '_';
|
|
|
|
scratch[len++] = '_';
|
|
|
|
|
|
|
|
for (q = line; q <= limit - len; q++)
|
|
|
|
if (*q == '_' && !strncmp (q, scratch, len))
|
|
|
|
goto again;
|
|
|
|
|
|
|
|
fwrite (text, 1, p - text, stdout);
|
|
|
|
fwrite (scratch, 1, len, stdout);
|
|
|
|
|
|
|
|
text = base;
|
|
|
|
}
|
2000-01-20 19:25:12 +01:00
|
|
|
}
|
|
|
|
done:
|
|
|
|
fputs (text, stdout);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-05-14 21:29:02 +02:00
|
|
|
FIX_PROC_HEAD( wrap_fix )
|
|
|
|
{
|
2000-12-02 20:46:32 +01:00
|
|
|
tSCC z_no_wrap_pat[] = "^#if.*__need_";
|
2000-12-13 21:07:46 +01:00
|
|
|
static regex_t no_wrapping_re; /* assume zeroed data */
|
2000-12-02 20:46:32 +01:00
|
|
|
|
2003-01-04 22:17:01 +01:00
|
|
|
tCC* pz_name = NULL;
|
2000-05-14 21:29:02 +02:00
|
|
|
|
2000-12-02 20:46:32 +01:00
|
|
|
if (no_wrapping_re.allocated == 0)
|
|
|
|
compile_re( z_no_wrap_pat, &no_wrapping_re, 0, "no-wrap pattern",
|
|
|
|
"wrap-fix" );
|
|
|
|
|
|
|
|
/*
|
|
|
|
* IF we do *not* match the no-wrap re, then we have a double negative.
|
|
|
|
* A double negative means YES.
|
|
|
|
*/
|
2003-07-08 22:42:19 +02:00
|
|
|
if (xregexec( &no_wrapping_re, text, 0, NULL, 0 ) != 0)
|
2000-12-02 20:46:32 +01:00
|
|
|
{
|
2003-01-04 22:17:01 +01:00
|
|
|
/*
|
|
|
|
* A single file can get wrapped more than once by different fixes.
|
|
|
|
* A single fix can wrap multiple files. Therefore, guard with
|
|
|
|
* *both* the fix name and the file name.
|
|
|
|
*/
|
|
|
|
size_t ln = strlen( filname ) + strlen( p_fixd->fix_name ) + 14;
|
2005-05-15 20:28:36 +02:00
|
|
|
char* pz = XNEWVEC (char, ln);
|
2003-01-04 22:17:01 +01:00
|
|
|
pz_name = pz;
|
|
|
|
sprintf( pz, "FIXINC_WRAP_%s-%s", filname, p_fixd->fix_name );
|
|
|
|
|
|
|
|
for (pz += 12; 1; pz++) {
|
|
|
|
char ch = *pz;
|
|
|
|
|
|
|
|
if (ch == NUL)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (! ISALNUM( ch )) {
|
|
|
|
*pz = '_';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*pz = TOUPPER( ch );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf( "#ifndef %s\n", pz_name );
|
|
|
|
printf( "#define %s 1\n\n", pz_name );
|
2000-12-02 20:46:32 +01:00
|
|
|
}
|
2000-05-14 21:29:02 +02:00
|
|
|
|
|
|
|
if (p_fixd->patch_args[1] == (tCC*)NULL)
|
|
|
|
fputs( text, stdout );
|
|
|
|
|
|
|
|
else {
|
|
|
|
fputs( p_fixd->patch_args[1], stdout );
|
|
|
|
fputs( text, stdout );
|
|
|
|
if (p_fixd->patch_args[2] != (tCC*)NULL)
|
|
|
|
fputs( p_fixd->patch_args[2], stdout );
|
|
|
|
}
|
|
|
|
|
2003-01-04 22:17:01 +01:00
|
|
|
if (pz_name != NULL) {
|
|
|
|
printf( "\n#endif /* %s */\n", pz_name );
|
2000-05-14 21:29:02 +02:00
|
|
|
free( (void*)pz_name );
|
2003-01-04 22:17:01 +01:00
|
|
|
}
|
2000-05-14 21:29:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-13 16:47:55 +02:00
|
|
|
/*
|
|
|
|
* Search for multiple copies of a regular expression. Each block
|
|
|
|
* of matched text is replaced with the format string, as described
|
|
|
|
* above in `format_write'.
|
|
|
|
*/
|
|
|
|
FIX_PROC_HEAD( gnu_type_fix )
|
|
|
|
{
|
|
|
|
const char* pz_pat;
|
|
|
|
regex_t re;
|
|
|
|
regmatch_t rm[GTYPE_SE_CT+1];
|
2000-12-13 21:07:46 +01:00
|
|
|
IGNORE_ARG(filname);
|
2000-07-13 16:47:55 +02:00
|
|
|
|
|
|
|
{
|
|
|
|
tTestDesc* pTD = p_fixd->p_test_desc;
|
|
|
|
int ct = p_fixd->test_ct;
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
if (ct-- <= 0)
|
|
|
|
{
|
|
|
|
fprintf (stderr, zNeedsArg, p_fixd->fix_name, "search text", 1);
|
|
|
|
exit (EXIT_BROKEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pTD->type == TT_EGREP)
|
|
|
|
{
|
|
|
|
pz_pat = pTD->pz_test_text;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pTD++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
compile_re (pz_pat, &re, 1, "gnu type typedef", "gnu_type_fix");
|
|
|
|
|
2003-07-08 22:42:19 +02:00
|
|
|
while (xregexec (&re, text, GTYPE_SE_CT+1, rm, 0) == 0)
|
2000-07-13 16:47:55 +02:00
|
|
|
{
|
|
|
|
text = emit_gnu_type (text, rm);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Dump out the rest of the file
|
|
|
|
*/
|
|
|
|
fputs (text, stdout);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-12 16:44:18 +02:00
|
|
|
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
|
|
|
|
|
|
|
|
test for fix selector
|
|
|
|
|
|
|
|
THIS IS THE ONLY EXPORTED ROUTINE
|
|
|
|
|
|
|
|
*/
|
|
|
|
void
|
2003-08-02 01:07:04 +02:00
|
|
|
apply_fix( tFixDesc* p_fixd, tCC* filname )
|
1999-10-12 16:44:18 +02:00
|
|
|
{
|
1999-11-01 19:14:50 +01:00
|
|
|
#define _FT_(n,p) { n, p },
|
1999-10-12 16:44:18 +02:00
|
|
|
static fix_entry_t fix_table[] = { FIXUP_TABLE { NULL, NULL }};
|
1999-11-01 19:14:50 +01:00
|
|
|
#undef _FT_
|
optabs.c (init_optabs): Initialize fixtab...
* optabs.c (init_optabs): Initialize fixtab, fixtrunctab, floattab,
and extendtab within their proper array boundaries.
* emit-rtl.c (init_emit_once): Pass `const_tiny_rtx' with bounds
for the entire array.
* config/arm/arm.c (arm_override_options): Use ARRAY_SIZE.
* config/alpha/alpha.c (alpha_lookup_xfloating_lib_func): Likewise.
* config/avr/avr.c (order_regs_for_local_alloc): Likewise.
* config/fr30/fr30.c (fr30_print_operand): Likewise.
* config/i386/dgux.c (output_options): Likewise.
* config/i386/dgux.h (ASM_FILE_START): Likewise.
* config/m88k/m88k.c (output_options): Likewise.
* config/m88k/m88k.h (ASM_FILE_START): Likewise.
* config/mcore/mcore.c (mcore_output_inline_const_forced,
layout_mcore_frame, handle_structs_in_regs): Likewise.
* config/mips/mips.c (output_block_move): Likewise.
* config/rs6000/rs6000.c (rs6000_override_options,
rs6000_file_start): Likewise.
* config/sparc/sparc.c (sparc_add_gc_roots): Likewise.
* fixinc/fixfixes.c (FIX_TABLE_CT): Likewise.
* fixinc/fixtests.c (TEST_TABLE_CT): Likewise.
* builtins.c (expand_builtin_setjmp): Likewise.
* expr.c (safe_from_p): Likewise.
* flow.c (life_analysis): Likewise.
* fold-const.c (size_int_type_wide): Likewise.
* gcc.c (translate_options, init_spec, set_spec, main): Likewise.
* genattrtab.c (make_length_attrs): Likewise.
* genopinit.c (gen_insn): Likewise.
* genrecog.c (NUM_KNOWN_PREDS, NUM_SPECIAL_MODE_PREDS): Likewise.
* global.c (global_alloc): Likewise.
* local-alloc.c (find_free_reg): Likewise.
* mips-tdump.c (print_symbol): Likewise.
* mips-tfile.c (parse_def, parse_input): Likewise.
* reload1.c (NUM_ELIMINABLE_REGS): Likewise.
* stmt.c (expand_nl_goto_receiver): Likewise.
* stor-layout.c (set_sizetype): Likewise.
* varasm.c (decode_reg_name): Likewise.
* toplev.c (decode_f_option, decode_W_option,
set_target_switch, print_switch_values): Likewise.
(NUM_ELEM): Remove macro.
(display_help, main): s/NUM_ELEM/ARRAY_SIZE/
From-SVN: r35949
2000-08-24 22:31:35 +02:00
|
|
|
#define FIX_TABLE_CT (ARRAY_SIZE (fix_table)-1)
|
1999-10-12 16:44:18 +02:00
|
|
|
|
2000-05-11 15:41:12 +02:00
|
|
|
tCC* fixname = p_fixd->patch_args[0];
|
1999-10-12 16:44:18 +02:00
|
|
|
char* buf;
|
|
|
|
int ct = FIX_TABLE_CT;
|
|
|
|
fix_entry_t* pfe = fix_table;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
if (strcmp (pfe->fix_name, fixname) == 0)
|
|
|
|
break;
|
|
|
|
if (--ct <= 0)
|
1999-10-22 15:23:43 +02:00
|
|
|
{
|
2000-05-30 22:24:44 +02:00
|
|
|
fprintf (stderr, "fixincl error: the `%s' fix is unknown\n",
|
1999-10-22 15:23:43 +02:00
|
|
|
fixname );
|
2000-05-30 22:24:44 +02:00
|
|
|
exit (EXIT_BROKEN);
|
1999-10-22 15:23:43 +02:00
|
|
|
}
|
|
|
|
pfe++;
|
1999-10-12 16:44:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
buf = load_file_data (stdin);
|
2000-05-11 15:41:12 +02:00
|
|
|
(*pfe->fix_proc)( filname, buf, p_fixd );
|
1999-10-12 16:44:18 +02:00
|
|
|
}
|
2000-08-04 16:16:57 +02:00
|
|
|
|
2000-12-02 20:46:32 +01:00
|
|
|
#ifdef SEPARATE_FIX_PROC
|
2000-08-04 16:16:57 +02:00
|
|
|
tSCC z_usage[] =
|
|
|
|
"USAGE: applyfix <fix-name> <file-to-fix> <file-source> <file-destination>\n";
|
|
|
|
tSCC z_reopen[] =
|
|
|
|
"FS error %d (%s) reopening %s as std%s\n";
|
|
|
|
|
|
|
|
int
|
2003-08-02 01:07:04 +02:00
|
|
|
main( int argc, char** argv )
|
2000-08-04 16:16:57 +02:00
|
|
|
{
|
|
|
|
tFixDesc* pFix;
|
|
|
|
char* pz_tmptmp;
|
2020-09-11 13:58:59 +02:00
|
|
|
#ifdef _PC_NAME_MAX
|
2000-08-04 16:16:57 +02:00
|
|
|
char* pz_tmp_base;
|
|
|
|
char* pz_tmp_dot;
|
2020-09-11 13:58:59 +02:00
|
|
|
#endif
|
2000-08-04 16:16:57 +02:00
|
|
|
|
|
|
|
if (argc != 5)
|
|
|
|
{
|
|
|
|
usage_failure:
|
2000-12-02 20:46:32 +01:00
|
|
|
fputs (z_usage, stderr);
|
2000-08-04 16:16:57 +02:00
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2004-10-15 09:58:38 +02:00
|
|
|
initialize_opts ();
|
|
|
|
|
2000-08-04 16:16:57 +02:00
|
|
|
{
|
|
|
|
char* pz = argv[1];
|
|
|
|
long idx;
|
|
|
|
|
2000-12-02 20:01:16 +01:00
|
|
|
if (! ISDIGIT ( *pz ))
|
2000-08-04 16:16:57 +02:00
|
|
|
goto usage_failure;
|
|
|
|
|
2000-12-02 20:46:32 +01:00
|
|
|
idx = strtol (pz, &pz, 10);
|
2000-08-04 16:16:57 +02:00
|
|
|
if ((*pz != NUL) || ((unsigned)idx >= FIX_COUNT))
|
|
|
|
goto usage_failure;
|
|
|
|
pFix = fixDescList + idx;
|
|
|
|
}
|
|
|
|
|
2000-12-02 20:46:32 +01:00
|
|
|
if (freopen (argv[3], "r", stdin) != stdin)
|
2000-08-04 16:16:57 +02:00
|
|
|
{
|
2000-12-02 20:46:32 +01:00
|
|
|
fprintf (stderr, z_reopen, errno, strerror( errno ), argv[3], "in");
|
2000-08-04 16:16:57 +02:00
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2005-05-15 20:28:36 +02:00
|
|
|
pz_tmptmp = XNEWVEC (char, strlen (argv[4]) + 5);
|
2000-08-04 16:16:57 +02:00
|
|
|
strcpy( pz_tmptmp, argv[4] );
|
|
|
|
|
2020-09-11 13:58:59 +02:00
|
|
|
#ifdef _PC_NAME_MAX
|
2000-08-04 16:16:57 +02:00
|
|
|
/* Don't lose because "12345678" and "12345678X" map to the same
|
|
|
|
file under DOS restricted 8+3 file namespace. Note that DOS
|
|
|
|
doesn't allow more than one dot in the trunk of a file name. */
|
|
|
|
pz_tmp_base = basename( pz_tmptmp );
|
|
|
|
pz_tmp_dot = strchr( pz_tmp_base, '.' );
|
|
|
|
if (pathconf( pz_tmptmp, _PC_NAME_MAX ) <= 12 /* is this DOS or Windows9X? */
|
|
|
|
&& pz_tmp_dot != (char*)NULL)
|
2000-12-02 20:46:32 +01:00
|
|
|
strcpy (pz_tmp_dot+1, "X"); /* nuke the original extension */
|
2000-08-04 16:16:57 +02:00
|
|
|
else
|
2004-10-27 22:13:57 +02:00
|
|
|
#endif /* _PC_NAME_MAX */
|
2000-12-02 20:46:32 +01:00
|
|
|
strcat (pz_tmptmp, ".X");
|
|
|
|
if (freopen (pz_tmptmp, "w", stdout) != stdout)
|
2000-08-04 16:16:57 +02:00
|
|
|
{
|
2000-12-02 20:46:32 +01:00
|
|
|
fprintf (stderr, z_reopen, errno, strerror( errno ), pz_tmptmp, "out");
|
2000-08-04 16:16:57 +02:00
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2016-09-30 18:36:18 +02:00
|
|
|
/* Second parameter of apply_fix is file name */
|
|
|
|
apply_fix (pFix, argv[2]);
|
2000-12-02 20:46:32 +01:00
|
|
|
fclose (stdout);
|
|
|
|
fclose (stdin);
|
|
|
|
unlink (argv[4]);
|
|
|
|
if (rename (pz_tmptmp, argv[4]) != 0)
|
2000-08-04 16:16:57 +02:00
|
|
|
{
|
2000-12-02 20:46:32 +01:00
|
|
|
fprintf (stderr, "error %d (%s) renaming %s to %s\n", errno,
|
|
|
|
strerror( errno ), pz_tmptmp, argv[4]);
|
2000-08-04 16:16:57 +02:00
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
#endif
|