Merge from no_bogosity

From-SVN: r29918
This commit is contained in:
Bruce Korb 1999-10-12 14:44:18 +00:00 committed by Bruce Korb
parent 9e15ef0520
commit 5abc1f741e
13 changed files with 3077 additions and 2299 deletions

View File

@ -1,3 +1,7 @@
Tue Oct 12 07:38:41 1999 Bruce Korb <autogen@linuxbox.com>
* fixincl/*: Merged "no_bogosity" branch
Mon Oct 11 20:18:41 1999 Jim Wilson <wilson@cygnus.com>
* genoutput.c: Include toplev.h.

View File

@ -22,7 +22,7 @@
# Its purpose is to build the any-platforms fixinc.sh script.
CFLAGS = -g
FIXINC_DEFS = @fixinc_defs@
FIXINC_DEFS = $(CFLAGS) $(CPPFLAGS) @fixinc_defs@ $(INCLUDES)
CC = @CC@
SHELL = /bin/sh
@ -45,7 +45,7 @@ INCLUDES = -I. -I.. -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../config -I$(srcdir)
# Always use -I$(srcdir)/config when compiling.
.c.o:
$(CC) -c $(CFLAGS) $(FIXINC_DEFS) $(CPPFLAGS) $(INCLUDES) $<
$(CC) -c $(FIXINC_DEFS) $<
# The only suffixes we want for implicit rules are .c and .o.
.SUFFIXES:
@ -59,28 +59,37 @@ INCLUDES = -I. -I.. -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../config -I$(srcdir)
##
## # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
OBJ = fixincl.o server.o gnu-regex.o procopen.o
HDR = server.h gnu-regex.h
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
SH_TARGET = inclhack.sh fixincl.sh
BIN_TARGET = fixincl
AG_TEXT = $(SH_TARGET) fixincl.x \
inclhack.def inclhack.tpl hackshell.tpl fixincl.tpl
BIN_TARGET = fixincl fixfixes fixtests
TARGETS = $(SH_TARGET) $(BIN_TARGET)
all : $(TARGETS)
sh : $(SH_TARGET)
gen : $(SH_TARGET) fixincl.x
$(OBJ): $(HDR)
$(FIOBJ): $(HDR)
fixincl: $(OBJ)
@echo $(CC) -o $@ $(OBJ) $(LIBERTY) $(LIB) ; \
if $(CC) -o $@ $(OBJ) $(LIBERTY) $(LIB) ; then : ; else \
fixincl: $(FIOBJ)
@echo $(CC) -o $@ $(FIOBJ) $(LIBERTY) $(LIB) ; \
if $(CC) -o $@ $(FIOBJ) $(LIBERTY) $(LIB) ; 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)
gnu-regex.o: gnu-regex.c
-$(CC) $(CFLAGS) $(FIXINC_DEFS) $(INCLUDES) -DREGEX_MALLOC \
-c $(srcdir)/gnu-regex.c

243
gcc/fixinc/fixfixes.c Normal file
View File

@ -0,0 +1,243 @@
/*
Test to see if a particular fix should be applied to a header file.
Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
= = = = = = = = = = = = = = = = = = = = = = = = =
NOTE TO DEVELOPERS
The routines you write here must work closely with both the fixincl.c
and the test_need.c program.
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.
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. If "MAIN" is _not_ defined, then 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.
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!!
tFixDesc* pMyDesc = fixDescList + MY_FIX_NAME_FIXIDX;
tTestDesc* pTestList = pMyDesc->p_test_desc;
regexec (pTestList->p_test_regex, ...)
If MAIN _is_ defined, then you will have to compile it on
your own.
= = = = = = = = = = = = = = = = = = = = = = = = =
This file is part of GNU CC.
GNU CC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU CC is distributed in the hope that it will be useful,
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
along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include "fixlib.h"
typedef struct {
const char* fix_name;
void (*fix_proc)();
} fix_entry_t;
#define FIXUP_TABLE \
_FT_( "no_double_slash", double_slash_fix )
#define FIX_PROC_HEAD( fix ) \
static void fix ( filname, text ) \
const char* filname; \
char* text;
/*
* 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*
print_quote( q, text )
char q;
char* text;
{
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;
}
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);;
}
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
test for fix selector
THIS IS THE ONLY EXPORTED ROUTINE
*/
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;
for (;;)
{
if (strcmp (pfe->fix_name, fixname) == 0)
break;
if (--ct <= 0)
{
fprintf (stderr, "fixincludes error: the `%s' fix is unknown\n",
fixname );
exit (3);
}
}
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

File diff suppressed because it is too large Load Diff

View File

@ -15,12 +15,13 @@ x =]
=] The Free Software Foundation, Inc.
*
[=_eval inclhack "# * " _gpl=]
*[=_EVAL "re_ct=0" _shell=][=
*[=_EVAL "re_ct=0\nmax_mach=0" _shell=][=
_FOR fix =]
*
* Description [=_eval _index 1 + "#%3d -" _printf=] [=hackname _Cap=] fix
* Description of [=hackname _Cap=] fix
*/
#define [=hackname _up #_FIXIDX + #%-32s _printf=] [=_eval _index=]
tSCC z[=hackname _cap=]Name[] =
[=hackname _cap _krstr=];
/*
@ -40,11 +41,18 @@ tSCC z[=hackname _cap=]List[] =
_IF mach _exist=]
tSCC* apz[=hackname _cap=]Machs[] = {[=
_EVAL "this_mach=0" _shell =][=
_FOR mach =]
[=mach _krstr=],[=
_EVAL mach _len "this_mach=`expr $this_mach + %d + 5`"
_printf _shell =][=
/mach=]
(const char*)NULL };[=
_EVAL "if [ $this_mach -gt $max_mach ] ; then max_mach=$this_mach ; fi"
_shell =][=
_ELSE =]
#define apz[=hackname _cap=]Machs (const char**)NULL[=
_ENDIF "files _exist" =][=
@ -94,24 +102,37 @@ tSCC z[=hackname _cap=]Test[=_eval _index=][] =
/test =][=
_ENDIF =][=
_IF c_test _exist=]
/*
* perform the C function call test
*/[=
_FOR c_test =]
tSCC z[=hackname _cap=]FTst[=_eval _index=][] = "[=c_test=]";[=
/c_test =][=
_ENDIF =][=
# Build the array of test descriptions for this fix: =][=
_IF exesel _exist
select _exist |
bypass _exist |
test _exist |
_IF exesel _exist
select _exist |
bypass _exist |
test _exist |
c_test _exist |
=]
#define [=hackname _up =]_TEST_CT [=
_IF exesel _exist =][=
_eval exesel _count
bypass _count +
test _count + =][=
test _count +
c_test _count + =][=
_ELSE =][=
_eval select _count
bypass _count +
test _count + =][=
test _count +
c_test _count + =][=
_ENDIF =]
#define [=hackname _up =]_RE_CT [=
_IF exesel _exist =][=
@ -126,11 +147,15 @@ tSCC z[=hackname _cap=]Test[=_eval _index=][] =
tTestDesc a[=hackname _cap=]Tests[] = {[=
_FOR test =]
{ TT_TEST, z[=hackname _cap=]Test[=_eval _index=], 0 /* unused */ },[=
{ TT_TEST, z[=hackname _cap=]Test[=_eval _index=], 0 /* unused */ },[=
/test =][=
_FOR c_test =]
{ TT_FUNCTION, z[=hackname _cap=]FTst[=_eval _index=], 0 /* unused */ },[=
/c_test =][=
_FOR bypass =]
{ TT_NEGREP, z[=hackname _cap=]Bypass[=_eval _index=], (regex_t*)NULL },[=
{ TT_NEGREP, z[=hackname _cap=]Bypass[=_eval _index=], (regex_t*)NULL },[=
/bypass =][=
# IF there is an exesel, then use that (those) selection
@ -138,12 +163,12 @@ tTestDesc a[=hackname _cap=]Tests[] = {[=
=][=
_IF exesel _exist =][=
_FOR exesel =]
{ TT_EGREP, z[=hackname _cap=]Select[=_eval _index=], (regex_t*)NULL },[=
{ TT_EGREP, z[=hackname _cap=]Select[=_eval _index=], (regex_t*)NULL },[=
/exesel =][=
_ELSE =][=
_FOR select =]
{ TT_EGREP, z[=hackname _cap=]Select[=_eval _index=], (regex_t*)NULL },[=
{ TT_EGREP, z[=hackname _cap=]Select[=_eval _index=], (regex_t*)NULL },[=
/select =][=
_ENDIF =] };[=
_ELSE =]
@ -156,11 +181,20 @@ tTestDesc a[=hackname _cap=]Tests[] = {[=
* Fix Command Arguments for [=hackname _cap=]
*/
const char* apz[=hackname _cap=]Patch[] = {[=
_IF sed _exist =] "sed"[=_FOR sed=],
"-e", [=sed _krstr=][=/sed=][=
_IF sed _exist =] "sed"[=
_FOR sed=],
"-e", [=sed _krstr=][=
/sed=],[=
_ELIF shell _exist =] "sh", "-c",
[=shell _krstr=][=
_ENDIF=],
[=shell _krstr=],[=
_ELIF c_fix _exist =]"[=c_fix=]",[=
_ELIF replace _len =]
[=replace _krstr=],[=
_ENDIF=]
(char*)NULL };
/* * * * * * * * * * * * * * * * * * * * * * * * * *[=
@ -168,8 +202,16 @@ const char* apz[=hackname _cap=]Patch[] = {[=
*
* List of all fixes
*/
#define REGEX_COUNT [=_eval "echo $re_ct" _shell =]
#define FIX_COUNT [=_eval fix _count =]
[=_EVAL '
echo "#define REGEX_COUNT $re_ct"
echo "#define MACH_LIST_SIZE_LIMIT `expr $max_mach + 128`" ' _shell =][=
# as of this writing, 49 bytes are needed by the case statement format.
We also must allow for the size of the target machine machine name.
This allows for a 79 byte machine name. Better be enough.
=]
#define FIX_COUNT [=_eval fix _count =]
tFixDesc fixDescList[ FIX_COUNT ] = {[=
@ -180,7 +222,9 @@ _FOR fix ",\n" =]
_IF not_machine _exist =]FD_MACH_IFNOT[=
_ELSE =]FD_MACH_ONLY[=
_ENDIF =][=
_IF shell _exist =] | FD_SHELL_SCRIPT[=
_IF shell _exist =] | FD_SHELL_SCRIPT[=
_ELIF c_fix _exist =] | FD_SUBROUTINE[=
_ELIF replace _exist =] | FD_REPLACEMENT[=
_ENDIF =],
a[=hackname _cap=]Tests, apz[=hackname _cap=]Patch }[=

File diff suppressed because it is too large Load Diff

56
gcc/fixinc/fixlib.c Normal file
View File

@ -0,0 +1,56 @@
#include "fixlib.h"
/* * * * * * * * * * * * *
load_file_data loads all the contents of a file into malloc-ed memory.
Its argument is the file pointer of the file to read in; the returned
result is the NUL terminated contents of the file. The file
is presumed to be an ASCII text file containing no NULs. */
char *
load_file_data (fp)
FILE* fp;
{
char *pz_data = (char*)NULL;
int space_left = -1; /* allow for terminating NUL */
size_t space_used = 0;
do
{
size_t size_read;
if (space_left < 1024)
{
space_left += 4096;
pz_data = realloc ((void*)pz_data, space_left + space_used + 1 );
}
size_read = fread (pz_data + space_used, 1, space_left, fp);
if (size_read == 0)
{
if (feof (fp))
break;
if (ferror (fp))
{
int err = errno;
if (err != EISDIR)
fprintf (stderr, "error %d (%s) reading input\n", err,
strerror (err));
free ((void *) pz_data);
fclose (fp);
return (char *) NULL;
}
}
space_left -= size_read;
space_used += size_read;
} while (! feof (fp));
pz_data = realloc ((void*)pz_data, space_used+1 );
pz_data[ space_used ] = NUL;
fclose (fp);
return pz_data;
}

92
gcc/fixinc/fixlib.h Normal file
View File

@ -0,0 +1,92 @@
/* Install modified versions of certain ANSI-incompatible system header
files which are fixed to work correctly with ANSI C and placed in a
directory that GNU C will search.
Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
This file is part of GNU CC.
GNU CC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU CC is distributed in the hope that it will be useful,
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
along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifndef FIXINCLUDES_FIXLIB_H
#define FIXINCLUDES_FIXLIB_H
#include "auto-host.h"
#include "gansidecl.h"
#include "system.h"
#include "gnu-regex.h"
#ifndef STDIN_FILENO
# define STDIN_FILENO 0
#endif
#ifndef STDOUT_FILENO
# define STDOUT_FILENO 1
#endif
typedef int t_success;
#define FAILURE (-1)
#define SUCCESS 0
#define PROBLEM 1
#define SUCCEEDED(p) ((p) == SUCCESS)
#define SUCCESSFUL(p) SUCCEEDED (p)
#define FAILED(p) ((p) < SUCCESS)
#define HADGLITCH(p) ((p) > SUCCESS)
#define tSCC static const char
#define tCC const char
#define tSC static char
/* If this particular system's header files define the macro `MAXPATHLEN',
we happily take advantage of it; otherwise we use a value which ought
to be large enough. */
#ifndef MAXPATHLEN
# define MAXPATHLEN 4096
#endif
#ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
#endif
#ifndef EXIT_FAILURE
# define EXIT_FAILURE 1
#endif
#define NUL '\0'
#ifndef NOPROCESS
#define NOPROCESS ((pid_t) -1)
#define NULLPROCESS ((pid_t)0)
#define EXIT_PANIC 99
typedef enum
{
BOOL_FALSE, BOOL_TRUE
} t_bool;
#define _P_(p) ()
#endif
/*
* Exported procedures
*/
char * load_file_data _P_(( FILE* fp ));
#endif /* FIXINCLUDES_FIXLIB_H */

220
gcc/fixinc/fixtests.c Normal file
View File

@ -0,0 +1,220 @@
/*
Test to see if a particular fix should be applied to a header file.
Copyright (C) 1997, 1998, 1999 Free Software Foundation, Inc.
= = = = = = = = = = = = = = = = = = = = = = = = =
NOTE TO DEVELOPERS
The routines you write here must work closely with both the fixincl.c
and the test_need.c program.
Here are the rules:
1. Every test procedure name must be suffixed with "_test".
These routines will be referenced from inclhack.def, sans the suffix.
2. Use the "TEST_FOR_FIX_PROC_HEAD()" macro _with_ the "_test" suffix
(I cannot use the ## magic from ANSI C) for defining your entry point.
3. Put your test name into the FIX_TEST_TABLE
4. Do not write anything to stdout. It may be closed.
5. Write to stderr only in the event of a reportable error
In such an event, call "exit(1)".
= = = = = = = = = = = = = = = = = = = = = = = = =
This file is part of GNU CC.
GNU CC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU CC is distributed in the hope that it will be useful,
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
along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include "fixlib.h"
typedef int apply_fix_p_t; /* Apply Fix Predicate Type */
#define APPLY_FIX 0
#define SKIP_FIX 1
#define SHOULD_APPLY(afp) ((afp) == APPLY_FIX)
apply_fix_p_t run_test();
typedef struct {
const char* test_name;
apply_fix_p_t (*test_proc)();
} test_entry_t;
#define FIX_TEST_TABLE \
_FT_( "double_slash", double_slash_test )
#define TEST_FOR_FIX_PROC_HEAD( test ) \
static apply_fix_p_t test ( fname, text ) \
const char* fname; \
const char* text;
/*
* 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 const char*
skip_quote( q, text )
char q;
char* text;
{
for (;;)
{
char ch = *(text++);
switch (ch)
{
case '\\':
text++; /* skip over whatever character follows */
break;
case '"':
case '\'':
if (ch != q)
break;
/*FALLTHROUGH*/
case '\n':
case NUL:
goto skip_done;
}
} skip_done:;
return text;
}
TEST_FOR_FIX_PROC_HEAD( double_slash_test )
{
/* First, check to see if the file is in a C++ directory */
if (strstr( fname, "CC/" ) != NULL)
return SKIP_FIX;
if (strstr( fname, "xx/" ) != NULL)
return SKIP_FIX;
if (strstr( fname, "++/" ) != NULL)
return SKIP_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.
The fix must be applied
*/
return APPLY_FIX;
case '*':
/* We found a C-style comment. Skip forward to the end */
text = strstr( text+1, "*/" );
if (text == (char*)NULL)
goto test_done;
text += 2;
}
break;
case NUL:
goto test_done;
case '"':
case '\'':
text = skip_quote( ch, text );
}
} test_done:;
return SKIP_FIX;
}
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
test for fix selector
THIS IS THE ONLY EXPORTED ROUTINE
*/
apply_fix_p_t
run_test( tname, fname, text )
const char* tname;
const char* fname;
const char* text;
{
#define _FT_(n,p) { n, p },
static test_entry_t test_table[] = { FIX_TEST_TABLE { NULL, NULL }};
#undef _FT_
#define TEST_TABLE_CT ((sizeof(test_table)/sizeof(test_table[0]))-1)
int ct = TEST_TABLE_CT;
test_entry_t* pte = test_table;
do
{
if (strcmp( pte->test_name, tname ) == 0)
return (*pte->test_proc)( fname, text );
} while (--ct > 0);
fprintf( stderr, "fixincludes error: the `%s' fix test is unknown\n",
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;
size_t buf_size = 0;
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

View File

@ -43,70 +43,54 @@ _FOR fix "\n\n" =]
_ENDIF=][=
# There are three conditional tests: select, bypass and test.
# There are four conditional tests: select, bypass and test c_test.
They may appear as often as desired. They must all pass for
the fix to be applied. "select" and "bypass" are egrep expressions
that must each appear (or not appear) in the target file.
"test" is an arbitrary test program expression that must yield
true or false. It is enclosed in parenthesis to avoid
precedence problems. The output looks like this:
if ( test -n "`egrep 'find-expr' ${file}`" -a
-z "`egrep 'not-find' ${file}`" -a
'(' <some-test-expression> ')'
) > /dev/null 2>&1 ; then
# =][=
true or false. =][=
_IF select _exist =]
if ( test [=
_FOR select " -a \\\n "
=]-n [=select _shrstr "#`egrep %s ${file}`"
_printf _shstr =][=
/select=][=
/select=]
) > /dev/null 2>&1 ; then[=
_ENDIF =][=
_IF bypass _exist =][=
_IF bypass _exist =]
if ( test [=
_FOR bypass=] -a \
-z [=bypass _shrstr "#`egrep %s ${file}`"
_printf _shstr =][=
/bypass=][=
_ENDIF=][=
_IF test _exist=][=
_FOR test=] -a \
'(' [=test=] ')'[=
/test=][=
_ENDIF=]
/bypass=]
) > /dev/null 2>&1 ; then[=
_ENDIF =][=
_ELIF test _exist =]
_IF test _exist =]
if ( test [=
_FOR test " -a \\\n "
=]'(' [=test=] ')'[=
/test=][=
_IF bypass _exist=][=
_FOR bypass=] -a \
-z [=bypass _shrstr "#`egrep %s ${file}`"
_printf _shstr=][=
/bypass=][=
_ENDIF=]
/test=]
) > /dev/null 2>&1 ; then[=
_ENDIF=][=
_IF c_test _exist =]
if [=
_FOR c_test " && \\\n "
=]${FIXTESTS} ${file} [=c_test=][=
/c_test=]
then[=
_ELIF bypass _exist =]
if ( test [=_FOR bypass " -a \\\n "
=]-z [=bypass _shrstr "#`egrep %s ${file}`"
_printf _shstr=][=/bypass=]
) > /dev/null 2>&1 ; then[=
_ENDIF=]
_ENDIF=][=
_IF replace _exist ! =]
fixlist="${fixlist}
[=hackname=]"
if [ ! -r ${DESTFILE} ]
then infile=${file}
else infile=${DESTFILE} ; fi [=
_ENDIF =][=
_IF sed _exist=][=
_IF shell _exist =][=
@ -129,20 +113,50 @@ _FOR fix "\n\n" =]
if test ! -f ${DESTDIR}/fixinc.tmp
then continue ; fi [=
_ELIF c_fix _exist =]
${FIXFIXES} ${file} [=c_fix=] < $infile > ${DESTDIR}/fixinc.tmp[=
_ELIF replace _exist =][=
_IF replace _len 0 > =]
echo "[=hackname _down=] replacing file ${file}" >&2
cat > ${DESTFILE} << '_EOF_'
[=replace=]
_EOF_[=
_ELSE =]
echo "[=hackname _down=] bypassing file ${file}"[=
_ENDIF =]
continue
[=
_ELSE=][=
_ERROR hackname _get "ERROR: %s has no fixup" _printf=][=
_ENDIF=]
_ENDIF=][=
_IF replace _exist ! =]
rm -f ${DESTFILE}
mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}[=
_ENDIF =][=
# Close off any opened "if" or "case" statements in reverse order
# =][=
_IF select _exist test _exist | bypass _exist | =]
fi # end of selection 'if'[=
_IF c_test _exist =]
fi # end of c_test 'if'[=
_ENDIF =][=
_IF test _exist =]
fi # end of test expression 'if'[=
_ENDIF =][=
_IF bypass _exist =]
fi # end of bypass 'if'[=
_ENDIF =][=
_IF select _exist =]
fi # end of select 'if'[=
_ENDIF =][=
_IF mach _exist=]

View File

@ -45,7 +45,7 @@ The rules for making fixes:
that the backslash is processed before '\\', '\'' and '#'
characters (using C character syntax).
4. There are currently two methods of fixing a file:
4. There are currently four methods of fixing a file:
1. a series of sed expressions. Each will be an individual
"-e" argument to a single invocation of sed.
@ -54,16 +54,182 @@ The rules for making fixes:
of stdin in order to avoid pipe stalls. They may choose to
discard the input.
A C language subroutine method is planned for both tests and fixes
in the near term. Awk ought to be possible too, but there may
be portability issues that I am not familiar with.
3. A C language subroutine method for both tests and fixes.
5. If the fix is to remove the file (i.e. the fixing process broke
the file), then you must use a shell script that deletes all
copies of the output file and does not write _anything_ to stdout.
See the "zzz_*" fixes at the end of this file.
4. Replacement text. If the replacement is empty, then
no fix is applied. Otherwise, the replacement text is written
to the output file and no further fixes are applied.
Replacement text "fixes" must be first in this file!!
Now, first: DO NOT DO BROKEN FIXES (empty replacement fixes) */
/*
* Purge some HP-UX 11 files that are only borken after they are "fixed".
*/
fix = {
hackname = AAA_ki_iface;
files = sys/ki_iface.h;
select = 'These definitions are for HP Internal developers';
replace; /* empty replacement -> no fixing the file */
};
/*
* Purge some HP-UX 11 files that are only borken after they are "fixed".
*/
fix = {
hackname = AAA_ki;
files = sys/ki.h;
select = '11.00 HP-UX LP64';
replace; /* empty replacement -> no fixing the file */
};
/*
* Purge some HP-UX 11 files that are only borken after they are "fixed".
*/
fix = {
hackname = AAA_ki_calls;
files = sys/ki_calls.h;
select = 'kthread_create_caller_t';
replace; /* empty replacement -> no fixing the file */
};
/*
* Purge some HP-UX 11 files that are only borken after they are "fixed".
*/
fix = {
hackname = AAA_ki_defs;
files = sys/ki_defs.h;
select = 'Kernel Instrumentation Definitions';
replace; /* empty replacement -> no fixing the file */
};
/*
* This file on SunOS 4 has a very large macro. When the sed loop
* tries pull it in, it overflows the pattern space size of the SunOS
* sed (GNU sed does not have this problem). Since the file does not
* require fixing, we remove it from the fixed directory.
*/
fix = {
hackname = AAA_bad_fixes;
files = sundev/ipi_error.h;
/* shouldn't there be a select expression here??? */
replace; /* empty replacement -> no fixing the file */
};
/*
* Purge some HP-UX 11 files that are only borken after they are "fixed".
*/
fix = {
hackname = AAA_time;
files = sys/time.h;
select = '11.0 and later representation of ki time';
replace; /* empty replacement -> no fixing the file */
};
/* And now, the real fixes, replacement text fixes first: */
/*
* Completely replace &lt;_int_varargs.h&gt; with a file that includes gcc's
* stdarg.h or varargs.h files as appropriate on DG/UX
*/
fix = {
hackname = AAB_dgux_int_varargs;
files = _int_varargs.h;
replace = "#ifndef __INT_VARARGS_H
\#define __INT_VARARGS_H
/************************************************************************/
/* _INT_VARARGS.H - Define the common stuff for varargs/stdarg/stdio. */
/************************************************************************/
/*
** This file is a DG internal header. Never include this
** file directly.
*/
\#ifndef ___int_features_h
\#include &lt;sys/_int_features.h&gt;
\#endif
\#if !(defined(_VA_LIST) || defined(_VA_LIST_))
\#define _VA_LIST
\#define _VA_LIST_
\#ifdef __LINT__
\#ifdef __STDC__
typedef void * va_list;
\#else
typedef char * va_list;
\#endif
\#else
\#if _M88K_ANY
\#if defined(__DCC__)
typedef struct {
int next_arg;
int *mem_ptr;
int *reg_ptr;
} va_list;
\#else /* ! defined(__DCC__) */
typedef struct {
int __va_arg; /* argument number */
int *__va_stk; /* start of args passed on stack */
int *__va_reg; /* start of args passed in regs */
} va_list;
\#endif /* ! defined(__DCC__) */
\#elif _IX86_ANY
\#if defined(__GNUC__) || defined(__STDC__)
typedef void * va_list;
\#else
typedef char * va_list;
\#endif
\#endif /* _IX86_ANY */
\#endif /* __LINT__ */
\#endif /* !(defined(_VA_LIST) || defined(_VA_LIST_)) */
\#endif /* #ifndef __INT_VARARGS_H */\n";
};
/*
* Completely replace <sys/varargs.h> with a file that includes gcc's
* stdarg.h or varargs.h files as appropriate.
*/
#ifdef SVR4
fix = {
hackname = AAB_svr4_no_varargs;
files = sys/varargs.h;
replace = "/* This file was generated by fixincludes. */\n"
"#ifndef _SYS_VARARGS_H\n"
"#define _SYS_VARARGS_H\n\n"
"#ifdef __STDC__\n"
"#include <stdarg.h>\n"
"#else\n"
"#include <varargs.h>\n"
"#endif\n\n"
"#endif /* _SYS_VARARGS_H */\n";
};
#endif
Let the fixes begin: */
/*
* sys/wait.h on AIX 3.2.5 puts the declaration of wait3 before the definition
@ -321,80 +487,6 @@ fix = {
};
/*
* Completely replace &lt;_int_varargs.h&gt; with a file that includes gcc's
* stdarg.h or varargs.h files as appropriate on DG/UX
*/
fix = {
hackname = dgux_int_varargs;
files = _int_varargs.h;
shell = "cat > /dev/null\ncat << '_EOF_'
\#ifndef __INT_VARARGS_H
\#define __INT_VARARGS_H
/************************************************************************/
/* _INT_VARARGS.H - Define the common stuff for varargs/stdarg/stdio. */
/************************************************************************/
/*
** This file is a DG internal header. Never include this
** file directly.
*/
\#ifndef ___int_features_h
\#include &lt;sys/_int_features.h&gt;
\#endif
\#if !(defined(_VA_LIST) || defined(_VA_LIST_))
\#define _VA_LIST
\#define _VA_LIST_
\#ifdef __LINT__
\#ifdef __STDC__
typedef void * va_list;
\#else
typedef char * va_list;
\#endif
\#else
\#if _M88K_ANY
\#if defined(__DCC__)
typedef struct {
int next_arg;
int *mem_ptr;
int *reg_ptr;
} va_list;
\#else /* ! defined(__DCC__) */
typedef struct {
int __va_arg; /* argument number */
int *__va_stk; /* start of args passed on stack */
int *__va_reg; /* start of args passed in regs */
} va_list;
\#endif /* ! defined(__DCC__) */
\#elif _IX86_ANY
\#if defined(__GNUC__) || defined(__STDC__)
typedef void * va_list;
\#else
typedef char * va_list;
\#endif
\#endif /* _IX86_ANY */
\#endif /* __LINT__ */
\#endif /* !(defined(_VA_LIST) || defined(_VA_LIST_)) */
\#endif /* #ifndef __INT_VARARGS_H */
_EOF_\n";
};
/*
* Remove the double-slash comments
* They *must* be removed so it will not create nested comments!!
@ -435,11 +527,17 @@ fix = {
* and do not appear to be within a single-line C-style comment
* and are not the end of a quoted string.
*/
#ifdef NO_C_TESTS
test = ' -z "`echo ${file} | egrep \'(CC|cxx|\+\+)/\'`"';
select = '(^|[^:])//[^"*]';
sed = 's,^//.*$,,';
sed = 's,\(/\*.*\)//\(.*\*/\),\1/ /\2,g';
sed = 's,\([^:]\)//[^"].*$,\1,';
sed = 's,[^:]//[^"].*$,,';
#else
c_test = "double_slash";
c_fix = "no_double_slash";
#endif
};
@ -1451,7 +1549,7 @@ fix = {
sed -e 's@ va_list @ __gnuc_va_list @' \\
-e 's@ va_list)@ __gnuc_va_list)@' \\
-e 's@ _BSD_VA_LIST_))@ __gnuc_va_list))@' \\
-e 's@ _BSD_VA_LIST_));@ __gnuc_va_list));@' \\
-e 's@ _VA_LIST_));@ __gnuc_va_list));@' \\
-e 's@ va_list@ __va_list__@' \\
-e 's@\\*va_list@*__va_list__@' \\
@ -1867,31 +1965,6 @@ fix = {
};
#endif
/*
* Completely replace <sys/varargs.h> with a file that includes gcc's
* stdarg.h or varargs.h files as appropriate.
*/
#ifdef SVR4
fix = {
hackname = svr4_no_varargs;
files = sys/varargs.h;
shell = "cat > /dev/null\n"
"cat << _EOF_\n"
"/* This file was generated by fixincludes. */\n"
"#ifndef _SYS_VARARGS_H\n"
"#define _SYS_VARARGS_H\n\n"
"#ifdef __STDC__\n"
"#include <stdarg.h>\n"
"#else\n"
"#include <varargs.h>\n"
"#endif\n\n"
"#endif /* _SYS_VARARGS_H */\n"
"_EOF_";
};
#endif
/*
* Fix broken decl of profil present on some svr4 systems.
*/
@ -2443,99 +2516,4 @@ fix = {
"#endif /* !defined __STDC__ */,";
};
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* UNDO BROKEN FIXES
*
* We sure do hope that broken fixes and needed fixes are never
* applied to the same file!! :-}
*/
/*
* Purge some HP-UX 11 files that are only borken after they are "fixed".
*/
fix = {
hackname = zzz_ki_iface;
files = sys/ki_iface.h;
select = 'These definitions are for HP Internal developers';
shell =
"echo \"Removing incorrect fix to <$file>\" >&2\n"
"rm -f ${DESTFILE} ${DESTDIR}/fixinc.tmp\n"
"cat > /dev/null";
};
/*
* Purge some HP-UX 11 files that are only borken after they are "fixed".
*/
fix = {
hackname = zzz_ki;
files = sys/ki.h;
select = '11.00 HP-UX LP64';
shell =
"echo \"Removing incorrect fix to <$file>\" >&2\n"
"rm -f ${DESTFILE} ${DESTDIR}/fixinc.tmp\n"
"cat > /dev/null";
};
/*
* Purge some HP-UX 11 files that are only borken after they are "fixed".
*/
fix = {
hackname = zzz_ki_calls;
files = sys/ki_calls.h;
select = 'kthread_create_caller_t';
shell =
"echo \"Removing incorrect fix to <$file>\" >&2\n"
"rm -f ${DESTFILE} ${DESTDIR}/fixinc.tmp\n"
"cat > /dev/null";
};
/*
* Purge some HP-UX 11 files that are only borken after they are "fixed".
*/
fix = {
hackname = zzz_ki_defs;
files = sys/ki_defs.h;
select = 'Kernel Instrumentation Definitions';
shell =
"echo \"Removing incorrect fix to <$file>\" >&2\n"
"rm -f ${DESTFILE} ${DESTDIR}/fixinc.tmp\n"
"cat > /dev/null";
};
/*
* This file on SunOS 4 has a very large macro. When the sed loop
* tries pull it in, it overflows the pattern space size of the SunOS
* sed (GNU sed does not have this problem). Since the file does not
* require fixing, we remove it from the fixed directory.
*/
fix = {
hackname = zzz_bad_fixes;
files = sundev/ipi_error.h;
/* shouldn't there be a select expression here??? */
shell =
"echo \"Removing incorrect fix to <$file>\" >&2\n"
"rm -f ${DESTFILE} ${DESTDIR}/fixinc.tmp\n"
"cat > /dev/null";
};
/*
* Purge some HP-UX 11 files that are only borken after they are "fixed".
*/
fix = {
hackname = zzz_time;
files = sys/time.h;
select = '11.0 and later representation of ki time';
shell =
"echo \"Removing incorrect fix to <$file>\" >&2\n"
"rm -f ${DESTFILE} ${DESTDIR}/fixinc.tmp\n"
"cat > /dev/null";
};
/*EOF*/

File diff suppressed because it is too large Load Diff

View File

@ -44,7 +44,10 @@ else
exit 1
}
fi
[=_IF PROGRAM _env ! =]
FIXTESTS=$PWD/fixinc/fixtests
FIXFIXES=$PWD/fixinc/fixfixes
[=_ENDIF=]
# Define what target system we're fixing.
#
if test -r ./Makefile; then