Commit 35dfe415 by Bruce Korb Committed by Bruce Korb

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

From-SVN: r33843
parent e54d500c
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
......
......@@ -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: $(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 $@
fixincl: $(OBJ) $(LIBERTY)
$(CC) $(FIXINC_DEFS) -o $@ $(OBJ) $(LIBERTY)
## 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 $@
$(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
# 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
......@@ -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] =][=
......
......@@ -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);
}
......
......@@ -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.
......
......@@ -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[=
......
......@@ -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 ));
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment