This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
New fix method and a fixinc "make check"
- To: gcc at gcc dot gnu dot org
- Subject: New fix method and a fixinc "make check"
- From: Bruce Korb <bkorb at sco dot COM>
- Date: Wed, 10 May 2000 08:31:25 -0700
- CC: Bruce Korb <bkorb at gnu dot org>
- Organization: Santa Cruz Operations
- Reply-To: Bruce Korb <bkorb at gnu dot org>
The primary purpose of this patch is to install the functionality
of "format"ted C program fixes and some (more) of the infrastructure
needed to do a "make check".
The essence of the format fix is to use the text located with
the "search" clause as a string argument to a format string that
will be used to replace the located text. If the format text
does not contain "%s", then, obviously, it is a simple text
replacement. I will put details in the README when I am ready
to really turn it on.
The "make check" feature will make it possible to verify that
the fixincl program is making the intended changes on the
"test_text" strings that will gradually be added to the inclhack
definitions. Since this should only be useful to someone changing
these definitions, you will have to have autogen installed to
be able to run "make check" successfully. I will also need to
install a "check.diff" file before it will work. :)
I plan to install tomorrow.
2000-05-11 Bruce Korb <bkorb@gnu.org>
* fixinc/fixfixes.c(double_slash_fix): obsolete
(else_endif_label_fix): obsolete
(format_fix): new, unused as yet
(main): obsolete
* fixinc/fixlib.h: added fix description struct for use by format_fix
* fixinc/fixincl.c: removed the struct & test for SIGIOT befure using
* fixinc/Makefile.in: compile fixfixes.c and fixtests.c as separate
modules. Removed the vestiges of the script version.
Added support for "make check".
* fixinc/check.tpl: quiet the fixup output
* fixinc/fixtests.c(main): obsolete
* fixinc/fixincl.sh: don't bother copying fixincl to ..
* fixinc/fixincl.tpl: provide for arguments to c_fix routines
Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/Makefile.in,v
retrieving revision 1.20
diff -C3 -r1.20 Makefile.in
*** Makefile.in 2000/05/08 18:49:24 1.20
--- Makefile.in 2000/05/10 13:42:21
***************
*** 35,47 ****
# End of variables for you to override.
! default : gen
# Now figure out from those variables how to compile and link.
# Specify the directories to be searched for header files.
# Both . and srcdir are used, in that order.
! INCLUDES = -I. -I.. -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../config
-I$(srcdir)/../../include
# Always use -I$(srcdir)/config when compiling.
.c.o:
--- 35,49 ----
# End of variables for you to override.
! default : all
# Now figure out from those variables how to compile and link.
# Specify the directories to be searched for header files.
# Both . and srcdir are used, in that order.
! #
! INCLUDES = -I. -I.. -I$(srcdir) -I$(srcdir)/.. \
! -I$(srcdir)/../config -I$(srcdir)/../../include
# Always use -I$(srcdir)/config when compiling.
.c.o:
***************
*** 60,145 ****
## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
LIBERTY = ../../libiberty/libiberty.a
! LIBOBJ = gnu-regex.o fixlib.o $(LIBERTY)
! FIOBJ = fixincl.o server.o procopen.o $(LIBOBJ)
HDR = server.h gnu-regex.h fixlib.h machname.h
-
- BIN_TARGET = fixincl fixfixes fixtests
! TARGETS = $(BIN_TARGET)
all : $(TARGETS)
gen : fixincl.x
! $(FIOBJ): $(HDR)
! fixincl: $(FIOBJ)
! @echo $(CC) $(FIXINC_DEFS) -o $@ $(FIOBJ) ; \
! if $(CC) $(FIXINC_DEFS) -o $@ $(FIOBJ) ; then : ; else \
! rm -f $@ ; (echo "#! /bin/sh" ; echo exit 1 ) > $@ ; \
! chmod 777 $@ ; fi
!
! fixfixes: fixfixes.c $(LIBOBJ)
! $(CC) -o $@ $(FIXINC_DEFS) -DMAIN \
! $(srcdir)/fixfixes.c $(LIBOBJ) $(LIB)
!
! fixtests: fixtests.c $(LIBOBJ)
! $(CC) -o $@ $(FIXINC_DEFS) -DMAIN \
! $(srcdir)/fixtests.c $(LIBOBJ) $(LIB)
!
! fixincl.o : fixincl.x fixincl.c fixfixes.c fixtests.c
! server.o : server.c server.h
! procopen.o : procopen.c server.h
! fixlib.o: machname.h
! fixincl.x: fixincl.tpl inclhack.def
! cd $(srcdir) ; $(SHELL) ./genfixes $@
!
! ## inclhack.sh: inclhack.def inclhack.tpl hackshell.tpl
! ## cd $(srcdir) ; $(SHELL) ./genfixes $@
! ##
! ## # fixinc.sh, unlike the other two, has _no_ dependency on the .def file.
! ## fixincl.sh: inclhack.tpl
! ## cd $(srcdir) ; $(SHELL) ./genfixes $@
!
! # This invocation of genfixes is done from the build dir,
! # not the source dir (as above)
#
machname.h: ../specs
$(SHELL) $(srcdir)/genfixes $@
clean:
! rm -f *.o $(TARGETS) fixincl.x machname.h
! # Ensure all the targets are built. If the program "fixincl"
! # failed to compile, link or load, then we install the
! # "inclhack.sh" script. Otherwise, we install that program
! # plus the wrapper script, "fixincl.sh".
#
! install-bin: fixincl fixincl.sh
! @if [ -f ../fixincl ] ; then rm -f ../fixincl || \
! mv -f ../fixincl ../fixincl.$$ || exit 1 ; fi
! @if [ -f ../fixinc.sh ] ; then rm -f ../fixinc.sh || \
! mv -f ../fixinc.sh ../fixinc.sh.$$ || exit 1 ; fi
./fixincl -v
- cp fixincl ..
- cp $(srcdir)/fixincl.sh ../fixinc.sh
- chmod 755 ../fixinc.sh ../fixincl
-
- install-sh: fixfixes fixtests inclhack.sh
@if [ -f ../fixinc.sh ] ; then rm -f ../fixinc.sh || \
mv -f ../fixinc.sh ../fixinc.sh.$$ || exit 1 ; fi
! echo Could not install binary fixincludes. ; \
! echo Installing shell script instead.
! @if [ -f ./inclhack.sh ] ; \
! then echo cp ./inclhack.sh ../fixinc.sh ; \
! cp ./inclhack.sh ../fixinc.sh ; \
! else echo cp $(srcdir)/inclhack.sh ../fixinc.sh ; \
! cp $(srcdir)/inclhack.sh ../fixinc.sh ; fi
chmod 755 ../fixinc.sh
Makefile: Makefile.in ../config.status
cd .. \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= \
$(SHELL) ./config.status
--- 62,125 ----
## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
LIBERTY = ../../libiberty/libiberty.a
! OBJ = fixincl.o fixtests.o fixfixes.o server.o procopen.o \
! gnu-regex.o fixlib.o
HDR = server.h gnu-regex.h fixlib.h machname.h
! TARGETS = fixincl
all : $(TARGETS)
gen : fixincl.x
! fixincl: $(OBJ) $(LIBERTY)
! $(CC) $(FIXINC_DEFS) -o $@ $(OBJ) $(LIBERTY)
! $(OBJ) : $(HDR)
! fixincl.o : fixincl.x fixincl.c
! fixtests.o : fixtests.c
! fixfixes.o : fixfixes.c
! server.o : server.c
! procopen.o : procopen.c
! gnu-regex.o : gnu-regex.c
! fixlib.o : fixlib.c
! # 'machname.h' is built in the build directory.
! # 'fixincl.x' in the source dir.
#
machname.h: ../specs
$(SHELL) $(srcdir)/genfixes $@
+ fixincl.x: fixincl.tpl inclhack.def
+ cd $(srcdir) ; $(SHELL) ./genfixes $@
+
clean:
! rm -f *.o $(TARGETS) fixincl.x machname.h *~
! # Build the executable and copy up into gcc dir.
! # We still copy the script because we still have alternative scripts.
#
! install-bin : fixincl
./fixincl -v
@if [ -f ../fixinc.sh ] ; then rm -f ../fixinc.sh || \
mv -f ../fixinc.sh ../fixinc.sh.$$ || exit 1 ; fi
! @if [ -f ./fixincl.sh ] ; \
! then echo cp ./fixincl.sh ../fixinc.sh ; \
! cp ./fixincl.sh ../fixinc.sh ; \
! else echo cp $(srcdir)/fixincl.sh ../fixinc.sh ; \
! cp $(srcdir)/fixincl.sh ../fixinc.sh ; fi
chmod 755 ../fixinc.sh
Makefile: Makefile.in ../config.status
cd .. \
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= \
$(SHELL) ./config.status
+
+ check : fixincl
+ autogen -T $(srcdir)/check.tpl $(srcdir)/inclhack.def
+ $(SHELL) ./check.sh
+ @echo ; echo "diff of diffs:"
+ @if diff testdir/NEWDIFF $(srcdir)/check.diff ; \
+ then rm -rf ./testdir ./check.sh ; \
+ else echo ; echo "Results do not match expectations" ; echo ; \
+ exit 1 ; fi
Index: check.tpl
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/check.tpl,v
retrieving revision 1.1
diff -C3 -r1.1 check.tpl
*** check.tpl 2000/05/09 16:21:08 1.1
--- check.tpl 2000/05/10 13:42:21
***************
*** 14,21 ****
DESTDIR=`pwd`/res
SRCDIR=`pwd`/inc
FIND_BASE='.'
! export TARGET_MACHINE DESTDIR SRCDIR FIND_BASE
mkdir ${DESTDIR} ${SRCDIR}
--- 14,22 ----
DESTDIR=`pwd`/res
SRCDIR=`pwd`/inc
FIND_BASE='.'
+ VERBOSE=1
! export TARGET_MACHINE DESTDIR SRCDIR FIND_BASE VERBOSE
mkdir ${DESTDIR} ${SRCDIR}
***************
*** 39,45 ****
#ifndef [=hackname _up=]_CHECK
- #define [=hackname _up=]_CHECK
[=test_text "\t" _prefix=]
#endif /* [=hackname _up=]_CHECK */
_HACK_EOF_
--- 40,45 ----
***************
*** 50,60 ****
=]
cd inc
! find . -type f | ../../fixincl
cd ..
! diff -cr inc res | \
! sed -e 's;^\(\*\*\* inc/[^ ]*\) .*$;\1;' \
! -e 's;^\(--- res/[^ ]*\) .*$;\1;' > NEWDIFF
echo
echo Test output check:
[=
--- 50,70 ----
=]
cd inc
! find . -type f | sed 's;\./;;' | sort > ../LIST
! ../../fixincl < ../LIST
cd ..
!
! while read f
! do
! if [ ! -f res/$f ]
! then
! echo "Only in inc: inc/$f"
! else
! diff -c inc/$f res/$f | \
! sed -e '1,2s; .*;;'
! fi
! done > NEWDIFF < LIST
!
echo
echo Test output check:
[=
***************
*** 63,69 ****
_IF test_text _exist =]
fgrep [=hackname _up=]_CHECK NEWDIFF > /dev/null 2>&1 || \
! echo "[=_eval hackname _get "#%32s test failed. See inc/"
_printf =][=
_IF files _exist =][=
files[0] =][=
--- 73,79 ----
_IF test_text _exist =]
fgrep [=hackname _up=]_CHECK NEWDIFF > /dev/null 2>&1 || \
! echo "[=_eval hackname _get "#%32s test failed. See testdir/inc/"
_printf =][=
_IF files _exist =][=
files[0] =][=
Index: fixfixes.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixfixes.c,v
retrieving revision 1.13
diff -C3 -r1.13 fixfixes.c
*** fixfixes.c 2000/02/26 19:57:26 1.13
--- fixfixes.c 2000/05/10 13:42:21
***************
*** 72,79 ****
} fix_entry_t;
#define FIXUP_TABLE \
! _FT_( "no_double_slash", double_slash_fix ) \
! _FT_( "else_endif_label", else_endif_label_fix ) \
_FT_( "IO_use", IO_use_fix ) \
_FT_( "CTRL_use", CTRL_use_fix) \
_FT_( "IO_defn", IO_defn_fix ) \
--- 72,78 ----
} fix_entry_t;
#define FIXUP_TABLE \
! _FT_( "format", format_fix ) \
_FT_( "IO_use", IO_use_fix ) \
_FT_( "CTRL_use", CTRL_use_fix) \
_FT_( "IO_defn", IO_defn_fix ) \
***************
*** 82,90 ****
#define FIX_PROC_HEAD( fix ) \
! static void fix ( filname, text ) \
const char* filname; \
! char* text;
/*
--- 81,90 ----
#define FIX_PROC_HEAD( fix ) \
! static void fix ( filname, text, p_fixd ) \
const char* filname; \
! char* text; \
! tFixDesc* p_fixd;
/*
***************
*** 130,362 ****
}
! FIX_PROC_HEAD( double_slash_fix )
{
! /* Now look for the comment markers in the text */
! for (;;)
! {
! char ch = *(text++);
! switch (ch)
! {
! case '/':
! switch (*text) /* do not advance `text' here */
! {
! case '/':
! /*
! We found a "//" pair in open text.
! Delete text to New-Line
! */
! while ((*text != '\n') && (*text != '\0')) text++;
! break;
!
! case '*':
! {
! /* We found a C-style comment. Skip forward to the end */
! char* pz = strstr( (--text)+2, "*/" );
! if (pz == (char*)NULL)
! {
! fputs( text, stdout );
! goto fix_done;
! }
! pz += 2;
! fwrite (text, (pz - text), 1, stdout );
! text = pz;
! }
! break;
! default:
! fputc (ch, stdout );
}
- break;
-
- case NUL:
- goto fix_done;
-
- case '"':
- case '\'':
- text = print_quote (ch, text );
- break;
-
- default:
- fputc (ch, stdout );
- }
-
- } fix_done:;
-
- fclose (stdout);;
- }
!
! FIX_PROC_HEAD( else_endif_label_fix )
! {
! static const char label_pat[] = "^[ \t]*#[ \t]*(else|endif)";
! static regex_t label_re;
!
! char ch;
! char* pz_next = (char*)NULL;
! regmatch_t match[2];
!
! compile_re (label_pat, &label_re, 1,
! "label pattern", "else_endif_label_fix");
!
! for (;;) /* entire file */
! {
! /*
! See if we need to advance to the next candidate directive
! If the scanning pointer passes over the end of the directive,
! then the directive is inside a comment */
! if (pz_next < text)
! {
! if (regexec (&label_re, text, 2, match, 0) != 0)
! {
! fputs( text, stdout );
! break;
}
! pz_next = text + match[0].rm_eo;
}
!
! /*
! IF the scan pointer has not reached the directive end, ... */
! if (pz_next > text)
! {
! /*
! Advance the scanning pointer. If we are at the start
! of a quoted string or a comment, then skip the entire unit */
! ch = *text;
!
! switch (ch)
! {
! case '/':
! /*
! Skip comments */
! if (text[1] == '*')
! {
! char* pz = strstr( text+2, "*/" );
! if (pz == (char*)NULL)
! {
! fputs( text, stdout );
! return;
! }
! pz += 2;
! fwrite( text, 1, (pz - text), stdout );
! text = pz;
! continue;
! }
! putc( ch, stdout );
! text++;
! break;
!
! case '"':
! case '\'':
! text = print_quote( ch, text+1 );
! break;
!
! default:
! putc( ch, stdout );
! text++;
! } /* switch (ch) */
! continue;
! } /* if (still shy of directive end) */
!
! /*
! The scanning pointer (text) has reached the end of the current
! directive under test. Check for bogons here. */
! for (;;) /* bogon check */
! {
! char ch = *(text++);
! if (isspace (ch))
! {
! putc( ch, stdout );
! if (ch == '\n')
! {
! /*
! It is clean. No bogons on this directive */
! pz_next = (char*)NULL; /* force a new regex search */
! goto dont_fix_bogon;
! }
! continue;
! }
! switch (ch)
! {
! case NUL:
! return;
! case '\\':
! /*
! Skip escaped newlines. Otherwise, we have a bogon */
! if (*text != '\n') {
! text--;
! goto fix_the_bogon;
! }
!
! /*
! Emit the escaped newline and keep scanning for possible junk
*/
! putc( '\\', stdout );
! putc( '\n', stdout );
! text++;
! break;
!
! case '/':
! /*
! Skip comments. Otherwise, we have a bogon */
! if (*text == '*')
! {
! text--;
! pz_next = strstr( text+2, "*/" );
! if (pz_next == (char*)NULL)
! {
! putc( '\n', stdout );
! return;
! }
! pz_next += 2;
! fwrite( text, 1, (pz_next - text), stdout );
! text = pz_next;
! break;
! }
!
! /* FALLTHROUGH */
!
! default:
! /*
! GOTTA BE A BOGON */
! text--;
! goto fix_the_bogon;
! } /* switch (ch) */
! } /* for (bogon check loop) */
!
! fix_the_bogon:
! /*
! `text' points to the start of the bogus data */
! for (;;)
! {
! /*
! NOT an escaped newline. Find the end of line that
! is not preceeded by an escape character: */
! pz_next = strchr( text, '\n' );
! if (pz_next == (char*)NULL)
! {
! putc( '\n', stdout );
! return;
}
-
- if (pz_next[-1] != '\\')
{
! text = pz_next;
! pz_next = (char*)NULL; /* force a new regex search */
! break;
}
! /*
! The newline was escaped. We gotta keep going. */
! text = pz_next + 1;
}
! dont_fix_bogon:;
! } /* for (entire file) loop */
! return;
}
/* Scan the input file for all occurrences of text like this:
--- 130,230 ----
}
! FIX_PROC_HEAD( format_fix )
{
! tSCC zBad[] = "fixincl error: `%s' needs %s c_fix_arg\n";
! tCC* pz_pat = p_fixd->patch_args[2];
! tCC* pz_fmt = p_fixd->patch_args[1];
! const char *p;
! regex_t re;
! regmatch_t rm[10];
!
! /*
! * We must have a format
! */
! if (pz_fmt == (tCC*)NULL) {
! fprintf( stderr, zBad, p_fixd->fix_name, "replacement-format" );
! exit( 3 );
! }
! /*
! * 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) {
! fprintf( stderr, zBad, p_fixd->fix_name, "search-text" );
! exit( 3 );
}
! if (pTD->type == TT_EGREP) {
! pz_pat = pTD->pz_test_text;
! break;
}
! pTD++;
}
! }
! /*
! * Replace every copy of the text we find
! */
! compile_re (pz_pat, &re, 1, "format search-text", "format_fix" );
! while (regexec (&re, text, 10, rm, 0) == 0)
! {
! char* apz[10];
! int i;
! /*
! * Write the text up to the match
! */
! fwrite( text, rm[0].rm_so, 1, stdout );
!
! /*
! * Copy all the submatches into separate strings
! */
! for (i=0; i<10; i++) {
! if (rm[i].rm_so == -1) {
! apz[i] = (char*)NULL;
! break;
}
{
! int len = rm[i].rm_eo - rm[i].rm_so;
! apz[i] = (char*)malloc( len + 1 );
! memcpy( (void*)apz[i], text+rm[i].rm_so, len );
! apz[i][len] = NUL;
}
+ }
! /*
! * IF there are any submatches,
! * THEN only use the submatches in the formatting
! */
! if (apz[1] != (char*)NULL)
! printf( pz_fmt, apz[1], apz[2], apz[3], apz[4],
! apz[5], apz[6], apz[7], apz[8], apz[9] );
! else
! printf( pz_fmt, apz[0] );
!
! /*
! * Free our submatch strings
! */
! for (i=0; i<10; i++) {
! if (apz[i] == (char*)NULL)
! break;
! free( (void*)apz[i] );
}
! text += rm[0].rm_eo;
! }
! /*
! * Dump out the rest of the file
! */
! fputs (text, stdout);
}
/* Scan the input file for all occurrences of text like this:
***************
*** 370,376 ****
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
provide in the STR argument. */
! void
fix_char_macro_uses (text, str)
const char *text;
const char *str;
--- 238,244 ----
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
provide in the STR argument. */
! static void
fix_char_macro_uses (text, str)
const char *text;
const char *str;
***************
*** 448,454 ****
which is the required syntax per the C standard. (The uses of _IO
also have to be tweaked - see above.) 'IO' is actually whatever
you provide in the STR argument. */
! void
fix_char_macro_defines (text, str)
const char *text;
const char *str;
--- 316,322 ----
which is the required syntax per the C standard. (The uses of _IO
also have to be tweaked - see above.) 'IO' is actually whatever
you provide in the STR argument. */
! static void
fix_char_macro_defines (text, str)
const char *text;
const char *str;
***************
*** 660,674 ****
*/
void
! apply_fix( fixname, filname )
! const char* fixname;
! const char* filname;
{
#define _FT_(n,p) { n, p },
static fix_entry_t fix_table[] = { FIXUP_TABLE { NULL, NULL }};
#undef _FT_
#define FIX_TABLE_CT ((sizeof(fix_table)/sizeof(fix_table[0]))-1)
char* buf;
int ct = FIX_TABLE_CT;
fix_entry_t* pfe = fix_table;
--- 528,543 ----
*/
void
! apply_fix( p_fixd, filname )
! tFixDesc* p_fixd;
! tCC* filname;
{
#define _FT_(n,p) { n, p },
static fix_entry_t fix_table[] = { FIXUP_TABLE { NULL, NULL }};
#undef _FT_
#define FIX_TABLE_CT ((sizeof(fix_table)/sizeof(fix_table[0]))-1)
+ tCC* fixname = p_fixd->patch_args[0];
char* buf;
int ct = FIX_TABLE_CT;
fix_entry_t* pfe = fix_table;
***************
*** 687,716 ****
}
buf = load_file_data (stdin);
! (*pfe->fix_proc)( filname, buf );
! }
!
! #ifdef MAIN
!
! /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
!
! MAIN ROUTINE
!
! This file is both included in fixincl.c and compiled as a separate
! program for use by the inclhack.sh script.
!
! */
!
! int
! main( argc, argv )
! int argc;
! char** argv;
! {
! if (argc != 3)
! apply_fix ("No test name provided", NULL, NULL, 0 );
!
! apply_fix (argv[2], argv[1]);
! return 0;
}
-
- #endif
--- 556,560 ----
}
buf = load_file_data (stdin);
! (*pfe->fix_proc)( filname, buf, p_fixd );
}
Index: fixincl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixincl.c,v
retrieving revision 1.30
diff -C3 -r1.30 fixincl.c
*** fixincl.c 2000/05/04 14:54:59 1.30
--- fixincl.c 2000/05/10 13:42:21
***************
*** 38,98 ****
static const char program_id[] = "fixincl version 1.1";
- /* Test Descriptor
-
- Each fix may have associated tests that determine
- whether the fix needs to be applied or not.
- Each test has a type (from the te_test_type enumeration);
- associated test text; and, if the test is TT_EGREP or
- the negated form TT_NEGREP, a pointer to the compiled
- version of the text string.
-
- */
- typedef enum
- {
- TT_TEST, TT_EGREP, TT_NEGREP, TT_FUNCTION
- } te_test_type;
-
- typedef struct test_desc tTestDesc;
-
- struct test_desc
- {
- te_test_type type;
- const char *pz_test_text;
- regex_t *p_test_regex;
- };
-
- typedef struct patch_desc tPatchDesc;
-
- /* Fix Descriptor
-
- Everything you ever wanted to know about how to apply
- a particular fix (which files, how to qualify them,
- how to actually make the fix, etc...)
-
- NB: the FD_ defines are BIT FLAGS
-
- */
- #define FD_MACH_ONLY 0x0000
- #define FD_MACH_IFNOT 0x0001
- #define FD_SHELL_SCRIPT 0x0002
- #define FD_SUBROUTINE 0x0004
- #define FD_REPLACEMENT 0x0008
- #define FD_SKIP_TEST 0x8000
-
- typedef struct fix_desc tFixDesc;
- struct fix_desc
- {
- const char* fix_name; /* Name of the fix */
- const char* file_list; /* List of files it applies to */
- const char** papz_machs; /* List of machine/os-es it applies to */
- regex_t* unused;
- int test_ct;
- int fd_flags;
- tTestDesc* p_test_desc;
- const char** patch_args;
- };
-
/* Working environment strings. Essentially, invocation 'options'. */
char *pz_dest_dir = NULL;
char *pz_src_dir = NULL;
--- 38,43 ----
***************
*** 145,158 ****
char *load_file _P_((const char *));
void process _P_((char *, const char *));
void run_compiles ();
! void initialize ();
void process ();
/* External Source Code */
#include "fixincl.x"
- #include "fixtests.c"
- #include "fixfixes.c"
/* * * * * * * * * * * * * * * * * * *
*
--- 90,101 ----
char *load_file _P_((const char *));
void process _P_((char *, const char *));
void run_compiles ();
! void initialize _P_((int argc,char** argv));
void process ();
/* External Source Code */
#include "fixincl.x"
/* * * * * * * * * * * * * * * * * * *
*
***************
*** 164,192 ****
char **argv;
{
char *file_name_buf;
-
- switch (argc)
- {
- case 1:
- break;
-
- case 2:
- if (strcmp (argv[1], "-v") == 0)
- do_version ();
- if (freopen (argv[1], "r", stdin) == (FILE*)NULL)
- {
- fprintf (stderr, "Error %d (%s) reopening %s as stdin\n",
- errno, xstrerror (errno), argv[1] );
- exit (EXIT_FAILURE);
- }
- break;
-
- default:
- fputs ("fixincl ERROR: too many command line arguments\n", stderr);
- exit (EXIT_FAILURE);
- }
! initialize ();
have_tty = isatty (fileno (stderr));
--- 107,114 ----
char **argv;
{
char *file_name_buf;
! initialize ( argc, argv );
have_tty = isatty (fileno (stderr));
***************
*** 264,271 ****
/* The 'version' option is really used to test that:
1. The program loads correctly (no missing libraries)
! 2. we can correctly run our server shell process
! 3. that we can compile all the regular expressions.
*/
run_compiles ();
sprintf (zBuf, zFmt, program_id);
--- 186,193 ----
/* The 'version' option is really used to test that:
1. The program loads correctly (no missing libraries)
! 2. that we can compile all the regular expressions.
! 3. we can correctly run our server shell process
*/
run_compiles ();
sprintf (zBuf, zFmt, program_id);
***************
*** 276,287 ****
/* * * * * * * * * * * * */
void
! initialize ()
{
static const char var_not_found[] =
"fixincl ERROR: %s environment variable not defined\n\
\tTARGET_MACHINE, DESTDIR, SRCDIR and FIND_BASE are required\n";
{
static const char var[] = "TARGET_MACHINE";
pz_machine = getenv (var);
--- 198,232 ----
/* * * * * * * * * * * * */
void
! initialize ( argc, argv )
! int argc;
! char** argv;
{
static const char var_not_found[] =
"fixincl ERROR: %s environment variable not defined\n\
\tTARGET_MACHINE, DESTDIR, SRCDIR and FIND_BASE are required\n";
+ switch (argc)
+ {
+ case 1:
+ break;
+
+ case 2:
+ if (strcmp (argv[1], "-v") == 0)
+ do_version ();
+ if (freopen (argv[1], "r", stdin) == (FILE*)NULL)
+ {
+ fprintf (stderr, "Error %d (%s) reopening %s as stdin\n",
+ errno, xstrerror (errno), argv[1] );
+ exit (EXIT_FAILURE);
+ }
+ break;
+
+ default:
+ fputs ("fixincl ERROR: too many command line arguments\n", stderr);
+ exit (EXIT_FAILURE);
+ }
+
{
static const char var[] = "TARGET_MACHINE";
pz_machine = getenv (var);
***************
*** 368,374 ****
--- 313,321 ----
run_compiles ();
signal (SIGQUIT, SIG_IGN);
+ #ifdef SIGIOT
signal (SIGIOT, SIG_IGN);
+ #endif
signal (SIGPIPE, SIG_IGN);
signal (SIGALRM, SIG_IGN);
signal (SIGTERM, SIG_IGN);
***************
*** 438,444 ****
int fix_ct = FIX_COUNT;
tTestDesc *p_test;
int test_ct;
- int re_ct = REGEX_COUNT;
const char *pz_err;
regex_t *p_re = (regex_t *) malloc (REGEX_COUNT * sizeof (regex_t));
--- 385,390 ----
***************
*** 455,462 ****
memset ( (void*)&incl_quote_re, '\0', sizeof (regex_t) );
compile_re (incl_quote_pat, &incl_quote_re, 1,
! "quoted include", "run_compiles");
/* FOR every fixup, ... */
do
{
--- 401,413 ----
memset ( (void*)&incl_quote_re, '\0', sizeof (regex_t) );
compile_re (incl_quote_pat, &incl_quote_re, 1,
! "quoted include", "run_compiles");
!
! /* Allow machine name tests to be ignored (testing, mainly) */
+ if ((*pz_machine == '\0') || (*pz_machine == '*'))
+ pz_machine = (char*)NULL;
+
/* FOR every fixup, ... */
do
{
***************
*** 544,563 ****
{
case TT_EGREP:
case TT_NEGREP:
! /* You might consider putting the following under #ifdef.
! The number of re's used is computed by autogen.
! So, it is static and known at compile time. */
!
! if (--re_ct < 0)
! {
! fputs ("out of RE's\n", stderr);
! exit (EXIT_FAILURE);
! }
p_test->p_test_regex = p_re++;
! compile_re (p_test->pz_test_text, p_test->p_test_regex, 0,
! "select test", p_fixd->fix_name);
! }
p_test++;
}
}
--- 495,515 ----
{
case TT_EGREP:
case TT_NEGREP:
! #ifdef DEBUG
! {
! static int re_ct = REGEX_COUNT;
+ if (--re_ct < 0)
+ {
+ fputs ("out of RE's\n", stderr);
+ exit (EXIT_FAILURE);
+ }
+ }
+ #endif
p_test->p_test_regex = p_re++;
! compile_re (p_test->pz_test_text, p_test->p_test_regex, 0,
! "select test", p_fixd->fix_name);
! }
p_test++;
}
}
***************
*** 890,899 ****
*/
fcntl (fd[1], F_DUPFD, STDOUT_FILENO);
fcntl (read_fd, F_DUPFD, STDIN_FILENO);
- fdopen (STDIN_FILENO, "r");
- fdopen (STDOUT_FILENO, "w");
! apply_fix (p_fixd->patch_args[0], pz_curr_file);
exit (0);
}
--- 842,849 ----
*/
fcntl (fd[1], F_DUPFD, STDOUT_FILENO);
fcntl (read_fd, F_DUPFD, STDIN_FILENO);
! apply_fix (p_fixd, pz_curr_file);
exit (0);
}
Index: fixincl.sh
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixincl.sh,v
retrieving revision 1.30
diff -C3 -r1.30 fixincl.sh
*** fixincl.sh 2000/05/08 13:06:47 1.30
--- fixincl.sh 2000/05/10 13:42:21
***************
*** 95,101 ****
# Original directory.
ORIGDIR=`${PWDCMD}`
! FIXINCL=${ORIGDIR}/fixincl
export FIXINCL
# Make LIB absolute only if needed to avoid problems with the amd.
--- 95,101 ----
# Original directory.
ORIGDIR=`${PWDCMD}`
! FIXINCL=${ORIGDIR}/fixinc/fixincl
export FIXINCL
# Make LIB absolute only if needed to avoid problems with the amd.
Index: fixincl.tpl
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixincl.tpl,v
retrieving revision 1.11
diff -C3 -r1.11 fixincl.tpl
*** fixincl.tpl 2000/01/25 08:06:23 1.11
--- fixincl.tpl 2000/05/10 13:42:21
***************
*** 158,164 ****
_ELIF shell _exist =] "sh", "-c",
[=shell _krstr=],[=
! _ELIF c_fix _exist =]"[=c_fix=]",[=
_ELIF replace _len =]
[=replace _krstr=],[=
--- 158,170 ----
_ELIF shell _exist =] "sh", "-c",
[=shell _krstr=],[=
! _ELIF c_fix _exist =]
! [=
! c_fix _krstr=],[=
!
! _FOR c_fix_arg =]
! [=c_fix_arg _krstr=],[=
! /c_fix_arg =][=
_ELIF replace _len =]
[=replace _krstr=],[=
***************
*** 184,190 ****
_FOR fix ",\n" =]
{ z[=hackname _cap=]Name, z[=hackname _cap=]List,
! apz[=hackname _cap=]Machs, (regex_t*)NULL,
[=hackname _up=]_TEST_CT, [=
_IF not_machine _exist =]FD_MACH_IFNOT[=
_ELSE =]FD_MACH_ONLY[=
--- 190,196 ----
_FOR fix ",\n" =]
{ z[=hackname _cap=]Name, z[=hackname _cap=]List,
! apz[=hackname _cap=]Machs,
[=hackname _up=]_TEST_CT, [=
_IF not_machine _exist =]FD_MACH_IFNOT[=
_ELSE =]FD_MACH_ONLY[=
Index: fixlib.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixlib.h,v
retrieving revision 1.9
diff -C3 -r1.9 fixlib.h
*** fixlib.h 2000/02/26 19:57:26 1.9
--- fixlib.h 2000/05/10 13:42:21
***************
*** 93,98 ****
--- 93,153 ----
#define _P_(p) ()
#endif
+ /* Test Descriptor
+
+ Each fix may have associated tests that determine
+ whether the fix needs to be applied or not.
+ Each test has a type (from the te_test_type enumeration);
+ associated test text; and, if the test is TT_EGREP or
+ the negated form TT_NEGREP, a pointer to the compiled
+ version of the text string.
+
+ */
+ typedef enum
+ {
+ TT_TEST, TT_EGREP, TT_NEGREP, TT_FUNCTION
+ } te_test_type;
+
+ typedef struct test_desc tTestDesc;
+
+ struct test_desc
+ {
+ te_test_type type;
+ const char *pz_test_text;
+ regex_t *p_test_regex;
+ };
+
+ typedef struct patch_desc tPatchDesc;
+
+ /* Fix Descriptor
+
+ Everything you ever wanted to know about how to apply
+ a particular fix (which files, how to qualify them,
+ how to actually make the fix, etc...)
+
+ NB: the FD_ defines are BIT FLAGS
+
+ */
+ #define FD_MACH_ONLY 0x0000
+ #define FD_MACH_IFNOT 0x0001
+ #define FD_SHELL_SCRIPT 0x0002
+ #define FD_SUBROUTINE 0x0004
+ #define FD_REPLACEMENT 0x0008
+ #define FD_SKIP_TEST 0x8000
+
+ typedef struct fix_desc tFixDesc;
+ struct fix_desc
+ {
+ const char* fix_name; /* Name of the fix */
+ const char* file_list; /* List of files it applies to */
+ const char** papz_machs; /* List of machine/os-es it applies to */
+ int test_ct;
+ int fd_flags;
+ tTestDesc* p_test_desc;
+ const char** patch_args;
+ long unused;
+ };
+
/*
* Exported procedures
*/
***************
*** 100,105 ****
--- 155,164 ----
t_bool is_cxx_header _P_(( tCC* filename, tCC* filetext ));
void compile_re _P_(( tCC* pat, regex_t* re, int match,
tCC *e1, tCC *e2 ));
+
+ void apply_fix _P_(( tFixDesc* p_fixd, tCC* filname ));
+ apply_fix_p_t run_test _P_((tCC* t_name, tCC* f_name, tCC* text ));
+
#ifdef MN_NAME_PAT
void mn_get_regexps _P_(( regex_t** label_re, regex_t** name_re,
tCC *who ));
Index: fixtests.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixtests.c,v
retrieving revision 1.14
diff -C3 -r1.14 fixtests.c
*** fixtests.c 2000/02/26 19:57:26 1.14
--- fixtests.c 2000/05/10 13:42:22
***************
*** 73,79 ****
* a backslash. Especially a backslash followed by octal digits.
* We are not doing a correctness syntax check here.
*/
! tSCC*
skip_quote( q, text )
char q;
char* text;
--- 73,79 ----
* a backslash. Especially a backslash followed by octal digits.
* We are not doing a correctness syntax check here.
*/
! static tSCC*
skip_quote( q, text )
char q;
char* text;
***************
*** 351,386 ****
tname );
exit( 3 );
}
-
- /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
-
- MAIN ROUTINE
-
- This file is both included in fixincl.c and compiled as a separate
- program for use by the inclhack.sh script.
-
- */
-
- #ifdef MAIN
-
- int
- main( argc, argv )
- int argc;
- char** argv;
- {
- char* fname = *++argv;
- char* tname = *++argv;
- char* buf;
-
- if (argc != 3)
- return run_test( "No test name provided", NULL, NULL, 0 );
-
- fclose( stdin );
- fclose( stdout );
-
- buf = load_file_data (fopen (fname, "r"));
-
- return run_test( tname, fname, buf );
- }
-
- #endif
--- 351,353 ----