Skip to content

Commit

Permalink
implement "wrap" c_fix
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@33892 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
korbb committed May 14, 2000
1 parent e2820a7 commit e665080
Show file tree
Hide file tree
Showing 7 changed files with 264 additions and 109 deletions.
11 changes: 11 additions & 0 deletions gcc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
2000-05-14 Bruce Korb <bkorb@gnu.org>

* fixinc/fixfixes.c(wrap_fix): new fix - inserts text before
and/or after current text of file
* fixinc/fixlib.c(must_malloc):
* fixinc/fixlib.h(must_malloc): + reformatting
* fixinc/inclhack.def: replace the "1i" and "$a" sed commands
with usages of ``c_fix = wrap;''
* fixinc/fixincl.x: regen
* fixinc/check.diff: regen

Sun May 14 17:58:59 2000 Hans-Peter Nilsson <hp@axis.com>

* mklibgcc.in (building libgcc1) [Xlibgcc1.a]: Do not use unset
Expand Down
93 changes: 84 additions & 9 deletions gcc/fixinc/check.diff
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,30 @@
--- res/assert.h
***************
*** 1,3 ****
--- 1,7 ----
--- 1,13 ----
+ #ifndef FIXINC_BROKEN_ASSERT_STDLIB_CHECK
+ #define FIXINC_BROKEN_ASSERT_STDLIB_CHECK 1
+
+ #ifdef __cplusplus
+ #include <stdlib.h>
+ #endif /* BROKEN_ASSERT_STDLIB_CHECK fix stamp */
+ #endif
+ #ifndef FIXINC_BROKEN_ASSERT_STDIO_CHECK
+ #define FIXINC_BROKEN_ASSERT_STDIO_CHECK 1
+
+ #include <stdio.h>


#ifndef BROKEN_ASSERT_STDIO_CHECK
***************
*** 8,10 ****
--- 18,24 ----
#ifndef BROKEN_ASSERT_STDLIB_CHECK
extern void exit ( int );
#endif /* BROKEN_ASSERT_STDLIB_CHECK */
+
+ #endif /* FIXINC_BROKEN_ASSERT_STDIO_CHECK */
+
+ #endif /* FIXINC_BROKEN_ASSERT_STDLIB_CHECK */
*** inc/c_asm.h
--- res/c_asm.h
***************
Expand Down Expand Up @@ -140,10 +156,28 @@
#ifndef BAD_STRUCT_TERM_CHECK
! struct term;
#endif /* BAD_STRUCT_TERM_CHECK */
*** inc/libgen.h
--- res/libgen.h
***************
*** 2,7 ****

#ifndef BAD_LVAL_CHECK
#pragma extern_prefix "_FOO"
! #define something(x,y,z) _FOOsomething(x,y,z)
#define mumble _FOOmumble
#endif /* BAD_LVAL_CHECK */
--- 2,7 ----

#ifndef BAD_LVAL_CHECK
#pragma extern_prefix "_FOO"
! #define something _FOOsomething
#define mumble _FOOmumble
#endif /* BAD_LVAL_CHECK */
*** inc/math.h
--- res/math.h
***************
*** 2,9 ****
*** 1,10 ****


#ifndef BROKEN_CABS_CHECK
#ifdef __STDC__
Expand All @@ -152,7 +186,33 @@
- extern double cabs();
#endif
#endif /* BROKEN_CABS_CHECK */
--- 2,7 ----

--- 1,14 ----
+ #ifndef FIXINC_MATH_EXCEPTION_CHECK
+ #define FIXINC_MATH_EXCEPTION_CHECK 1
+
+ #ifdef __cplusplus
+ #define exception __math_exception
+ #endif


#ifndef BROKEN_CABS_CHECK
#ifdef __STDC__
#else
#endif
#endif /* BROKEN_CABS_CHECK */

***************
*** 12,14 ****
--- 16,23 ----
#ifndef MATH_EXCEPTION_CHECK
typedef struct exception t_math_exception;
#endif /* MATH_EXCEPTION_CHECK */
+ #ifdef __cplusplus
+ #undef exception
+ #endif
+
+ #endif /* FIXINC_MATH_EXCEPTION_CHECK */
*** inc/stdio.h
--- res/stdio.h
***************
Expand All @@ -169,7 +229,10 @@
int foo;
#endif
#endif /* ISC_OMITS_WITH_STDC_CHECK */
--- 1,14 ----
--- 1,17 ----
+ #ifndef FIXINC_STDIO_STDARG_H_CHECK
+ #define FIXINC_STDIO_STDARG_H_CHECK 1
+
+ #define __need___va_list
+ #include <stdarg.h>

Expand All @@ -184,6 +247,14 @@
int foo;
#endif
#endif /* ISC_OMITS_WITH_STDC_CHECK */
***************
*** 15,17 ****
--- 20,24 ----
#ifndef STDIO_STDARG_H_CHECK

#endif /* STDIO_STDARG_H_CHECK */
+
+ #endif /* FIXINC_STDIO_STDARG_H_CHECK */
*** inc/stdlib.h
--- res/stdlib.h
***************
Expand Down Expand Up @@ -275,19 +346,23 @@
--- res/sys/mman.h
***************
*** 1,5 ****
--- 1,12 ----
--- 1,16 ----
+ #ifndef FIXINC_CXX_UNREADY_CHECK
+ #define FIXINC_CXX_UNREADY_CHECK 1
+
+ #ifdef __cplusplus
+ extern "C" {
+ #endif /* CXX_UNREADY_CHECK */
+
+ #endif


#ifndef CXX_UNREADY_CHECK
extern void* malloc( size_t );
#endif /* CXX_UNREADY_CHECK */
+ #ifdef __cplusplus
+ }
+ #endif /* CXX_UNREADY_CHECK */
+ #endif
+
+ #endif /* FIXINC_CXX_UNREADY_CHECK */
*** inc/sys/param.h
--- res/sys/param.h
***************
Expand Down
78 changes: 65 additions & 13 deletions gcc/fixinc/fixfixes.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,24 @@ Here are the rules:
2. Use the "FIX_PROC_HEAD()" macro _with_ the "_fix" suffix
(I cannot use the ## magic from ANSI C) for defining your entry point.
3. Put your test name into the FIXUP_TABLE
3. Put your test name into the FIXUP_TABLE.
4. Do not read anything from stdin. It is closed.
5. Write to stderr only in the event of a reportable error
In such an event, call "exit(1)".
6. You have access to the fixDescList entry for the fix in question.
This may be useful, for example, if there are pre-compiled
selection expressions stored there.
This may be useful, for example, if there are interesting strings
or pre-compiled regular expressions stored there.
For example, you may do this if you know that the first
test contains a useful regex. This is okay because, remember,
this code perforce works closely with the inclhack.def fixes!!
It is also possible to access fix descriptions by using the
index of a known fix, "my_fix_name" for example:
tFixDesc* pMyDesc = fixDescList + MY_FIX_NAME_FIXIDX;
tTestDesc* pTestList = pMyDesc->p_test_desc;
tFixDesc* p_desc = fixDescList + MY_FIX_NAME_FIXIDX;
tTestDesc* p_tlist = p_desc->p_test_desc;
regexec (pTestList->p_test_regex, ...)
regexec (p_tlist->p_test_regex, ...)
= = = = = = = = = = = = = = = = = = = = = = = = =
Expand Down Expand Up @@ -66,10 +65,11 @@ typedef struct {
} fix_entry_t;

#define FIXUP_TABLE \
_FT_( "format", format_fix ) \
_FT_( "char_macro_use", char_macro_use_fix ) \
_FT_( "char_macro_def", char_macro_def_fix ) \
_FT_( "machine_name", machine_name_fix )
_FT_( "char_macro_use", char_macro_use_fix ) \
_FT_( "format", format_fix ) \
_FT_( "machine_name", machine_name_fix ) \
_FT_( "wrap", wrap_fix )


#define FIX_PROC_HEAD( fix ) \
Expand Down Expand Up @@ -234,6 +234,7 @@ FIX_PROC_HEAD( format_fix )
fputs (text, stdout);
}


/* Scan the input file for all occurrences of text like this:
#define TIOCCONS _IO(T, 12)
Expand Down Expand Up @@ -332,7 +333,7 @@ FIX_PROC_HEAD( char_macro_use_fix )
you provide in the STR argument. */
FIX_PROC_HEAD( char_macro_def_fix )
{
/* This regexp looks for any traditional-syntax #define (# in column 1). */
/* This regexp looks for any traditional-syntax #define (# in col 1). */
static const char pat[] =
"^#[ \t]*define[ \t]+";
static regex_t re;
Expand Down Expand Up @@ -518,6 +519,57 @@ FIX_PROC_HEAD( machine_name_fix )
}


FIX_PROC_HEAD( wrap_fix )
{
char z_fixname[ 64 ];
tCC* pz_src = p_fixd->fix_name;
tCC* pz_name = z_fixname;
char* pz_dst = z_fixname;
size_t len = 0;

for (;;) {
char ch = *(pz_src++);

if (islower(ch))
*(pz_dst++) = toupper( ch );

else if (isalnum( ch ))
*(pz_dst++) = ch;

else if (ch == NUL) {
*(pz_dst++) = ch;
break;
}
else
*(pz_dst++) = '_';

if (++len >= sizeof( z_fixname )) {
void* p = must_malloc( len + strlen( pz_src ) + 1 );
memcpy( p, (void*)z_fixname, len );
pz_name = (tCC*)p;
pz_dst = (char*)pz_name + len;
}
}

printf( "#ifndef FIXINC_%s_CHECK\n", pz_name );
printf( "#define FIXINC_%s_CHECK 1\n\n", pz_name );

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 );
}

printf( "\n#endif /* FIXINC_%s_CHECK */\n", pz_name );
if (pz_name != z_fixname)
free( (void*)pz_name );
}


/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
test for fix selector
Expand Down
Loading

0 comments on commit e665080

Please sign in to comment.