Added support for "make check" and the "format" c_fix

From-SVN: r33843
This commit is contained in:
Bruce Korb 2000-05-11 13:41:12 +00:00 committed by Bruce Korb
parent e54d500c8d
commit 35dfe41582
9 changed files with 287 additions and 455 deletions

View File

@ -1,3 +1,19 @@
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
Thu May 11 11:57:02 MET DST 2000 Jan Hubicka <jh@suse.cz>
* toplev.c (rest_of_compilation): Remove dead code after

View File

@ -35,13 +35,15 @@ subdir = fixinc
# End of variables for you to override.
default : gen
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
#
INCLUDES = -I. -I.. -I$(srcdir) -I$(srcdir)/.. \
-I$(srcdir)/../config -I$(srcdir)/../../include
# Always use -I$(srcdir)/config when compiling.
.c.o:
@ -60,86 +62,64 @@ INCLUDES = -I. -I.. -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../config -I$(srcdir)
## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
LIBERTY = ../../libiberty/libiberty.a
LIBOBJ = gnu-regex.o fixlib.o $(LIBERTY)
FIOBJ = fixincl.o server.o procopen.o $(LIBOBJ)
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
BIN_TARGET = fixincl fixfixes fixtests
TARGETS = $(BIN_TARGET)
TARGETS = fixincl
all : $(TARGETS)
gen : fixincl.x
$(FIOBJ): $(HDR)
fixincl: $(OBJ) $(LIBERTY)
$(CC) $(FIXINC_DEFS) -o $@ $(OBJ) $(LIBERTY)
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
$(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
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' 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
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".
# Build the executable and copy up into gcc dir.
# We still copy the script because we still have alternative scripts.
#
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
install-bin : fixincl
./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
@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
autogen4 -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

View File

@ -14,8 +14,9 @@ TARGET_MACHINE='*'
DESTDIR=`pwd`/res
SRCDIR=`pwd`/inc
FIND_BASE='.'
VERBOSE=1
export TARGET_MACHINE DESTDIR SRCDIR FIND_BASE
export TARGET_MACHINE DESTDIR SRCDIR FIND_BASE VERBOSE
mkdir ${DESTDIR} ${SRCDIR}
@ -39,7 +40,6 @@ cat >> inc/[=
#ifndef [=hackname _up=]_CHECK
#define [=hackname _up=]_CHECK
[=test_text "\t" _prefix=]
#endif /* [=hackname _up=]_CHECK */
_HACK_EOF_
@ -50,11 +50,21 @@ _HACK_EOF_
=]
cd inc
find . -type f | ../../fixincl
find . -type f | sed 's;\./;;' | sort > ../LIST
../../fixincl < ../LIST
cd ..
diff -cr inc res | \
sed -e 's;^\(\*\*\* inc/[^ ]*\) .*$;\1;' \
-e 's;^\(--- res/[^ ]*\) .*$;\1;' > NEWDIFF
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,7 +73,7 @@ _FOR fix =][=
_IF test_text _exist =]
fgrep [=hackname _up=]_CHECK NEWDIFF > /dev/null 2>&1 || \
echo "[=_eval hackname _get "#%32s test failed. See inc/"
echo "[=_eval hackname _get "#%32s test failed. See testdir/inc/"
_printf =][=
_IF files _exist =][=
files[0] =][=

View File

@ -72,8 +72,7 @@ typedef struct {
} fix_entry_t;
#define FIXUP_TABLE \
_FT_( "no_double_slash", double_slash_fix ) \
_FT_( "else_endif_label", else_endif_label_fix ) \
_FT_( "format", format_fix ) \
_FT_( "IO_use", IO_use_fix ) \
_FT_( "CTRL_use", CTRL_use_fix) \
_FT_( "IO_defn", IO_defn_fix ) \
@ -82,9 +81,10 @@ typedef struct {
#define FIX_PROC_HEAD( fix ) \
static void fix ( filname, text ) \
static void fix ( filname, text, p_fixd ) \
const char* filname; \
char* text;
char* text; \
tFixDesc* p_fixd;
/*
@ -130,233 +130,101 @@ print_quote( q, text )
}
FIX_PROC_HEAD( double_slash_fix )
FIX_PROC_HEAD( format_fix )
{
/* Now look for the comment markers in the text */
for (;;)
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 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;
char* apz[10];
int i;
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;
/*
* Write the text up to the match
*/
fwrite( text, rm[0].rm_so, 1, stdout );
default:
fputc (ch, 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;
}
break;
case NUL:
goto fix_done;
case '"':
case '\'':
text = print_quote (ch, text );
break;
default:
fputc (ch, stdout );
}
} fix_done:;
/*
* 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] );
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;
/*
* Free our submatch strings
*/
for (i=0; i<10; i++) {
if (apz[i] == (char*)NULL)
break;
free( (void*)apz[i] );
}
/*
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;
text += rm[0].rm_eo;
}
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;
/*
* Dump out the rest of the file
*/
fputs (text, stdout);
}
/* Scan the input file for all occurrences of text like this:
@ -370,7 +238,7 @@ FIX_PROC_HEAD( else_endif_label_fix )
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
static void
fix_char_macro_uses (text, str)
const char *text;
const char *str;
@ -448,7 +316,7 @@ fix_char_macro_uses (text, str)
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
static void
fix_char_macro_defines (text, str)
const char *text;
const char *str;
@ -660,15 +528,16 @@ FIX_PROC_HEAD( machine_name_fix )
*/
void
apply_fix( fixname, filname )
const char* fixname;
const char* filname;
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,30 +556,5 @@ apply_fix( fixname, filname )
}
buf = load_file_data (stdin);
(*pfe->fix_proc)( filname, buf );
(*pfe->fix_proc)( filname, buf, p_fixd );
}
#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

View File

@ -38,61 +38,6 @@ Boston, MA 02111-1307, USA. */
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;
@ -145,14 +90,12 @@ void do_version ();
char *load_file _P_((const char *));
void process _P_((char *, const char *));
void run_compiles ();
void initialize ();
void initialize _P_((int argc,char** argv));
void process ();
/* External Source Code */
#include "fixincl.x"
#include "fixtests.c"
#include "fixfixes.c"
/* * * * * * * * * * * * * * * * * * *
*
@ -165,28 +108,7 @@ main (argc, 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 ();
initialize ( argc, argv );
have_tty = isatty (fileno (stderr));
@ -264,8 +186,8 @@ do_version ()
/* 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.
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,12 +198,35 @@ do_version ()
/* * * * * * * * * * * * */
void
initialize ()
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,7 +313,9 @@ initialize ()
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,7 +385,6 @@ run_compiles ()
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));
@ -455,7 +401,12 @@ run_compiles ()
memset ( (void*)&incl_quote_re, '\0', sizeof (regex_t) );
compile_re (incl_quote_pat, &incl_quote_re, 1,
"quoted include", "run_compiles");
"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,20 +495,21 @@ run_compiles ()
{
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);
}
#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);
}
compile_re (p_test->pz_test_text, p_test->p_test_regex, 0,
"select test", p_fixd->fix_name);
}
p_test++;
}
}
@ -890,10 +842,8 @@ internal_fix (read_fd, p_fixd)
*/
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);
apply_fix (p_fixd, pz_curr_file);
exit (0);
}

View File

@ -95,7 +95,7 @@ esac
# Original directory.
ORIGDIR=`${PWDCMD}`
FIXINCL=${ORIGDIR}/fixincl
FIXINCL=${ORIGDIR}/fixinc/fixincl
export FIXINCL
# Make LIB absolute only if needed to avoid problems with the amd.

View File

@ -158,7 +158,13 @@ const char* apz[=hackname _cap=]Patch[] = {[=
_ELIF shell _exist =] "sh", "-c",
[=shell _krstr=],[=
_ELIF c_fix _exist =]"[=c_fix=]",[=
_ELIF c_fix _exist =]
[=
c_fix _krstr=],[=
_FOR c_fix_arg =]
[=c_fix_arg _krstr=],[=
/c_fix_arg =][=
_ELIF replace _len =]
[=replace _krstr=],[=
@ -184,7 +190,7 @@ tFixDesc fixDescList[ FIX_COUNT ] = {[=
_FOR fix ",\n" =]
{ z[=hackname _cap=]Name, z[=hackname _cap=]List,
apz[=hackname _cap=]Machs, (regex_t*)NULL,
apz[=hackname _cap=]Machs,
[=hackname _up=]_TEST_CT, [=
_IF not_machine _exist =]FD_MACH_IFNOT[=
_ELSE =]FD_MACH_ONLY[=

View File

@ -93,6 +93,61 @@ typedef int apply_fix_p_t; /* Apply Fix Predicate Type */
#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,6 +155,10 @@ char * load_file_data _P_(( FILE* fp ));
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 ));

View File

@ -73,7 +73,7 @@ static apply_fix_p_t test ( fname, text ) \
* a backslash. Especially a backslash followed by octal digits.
* We are not doing a correctness syntax check here.
*/
tSCC*
static tSCC*
skip_quote( q, text )
char q;
char* text;
@ -351,36 +351,3 @@ run_test( tname, fname, text )
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