Commit 87ad679b by Bruce Korb Committed by Bruce Korb

C++ file type checking

From-SVN: r31125
parent ec6bfc9b
1999-12-29 Bruce Korb <autogen@linuxbox.com>
* fixinc/fixincl.c(wait_for_pid): sometimes a WSTOPSIG of zero is OK
* fixinc/fixincl.tpl(<hack>TEST_CT): Just do the existence test once
(<hack>_RE_CT): not needed
* fixinc/fixlib.c(is_cxx_header): moved from fixtests.c
rewritten to scan the file text once only
"template<..." test added
* fixinc/fixlib.h(apply_fix_p_t): moved from fixtests.c
(is_cxx_header): declaration added
* fixinc/fixtests.c(is_cxx_header): removed
(apply_fix_p_t): removed
(double_slash_test): is_cxx_header is only called once now
* fixinc/hackshell.tpl: indexing the fixes is now done under DEBUG
* fixinc/inclhack.def(FIXINC_DEBUG): added for testing DEBUG state
within the templates.
The borken spelling of "broken" was fixed.
* fixinc/inclhack.tpl: The $VERBOSE level is used on various messages
The default level depends on FIXINC_DEBUG.
1999-12-29 Kaveh R. Ghazi <ghazi@caip.rutgers.edu> 1999-12-29 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* crtstuff.c: If !inhibit_libc, include stdlib.h/unistd.h. * crtstuff.c: If !inhibit_libc, include stdlib.h/unistd.h.
......
...@@ -433,16 +433,17 @@ wait_for_pid(child) ...@@ -433,16 +433,17 @@ wait_for_pid(child)
{ {
if (! WIFEXITED( status )) if (! WIFEXITED( status ))
{ {
if (NOT_SILENT) if (WSTOPSIG( status ) == 0)
fprintf (stderr, "child process %d is hung on signal %d\n", break;
child, WSTOPSIG( status ));
fprintf (stderr, "child process %d is hung on signal %d\n",
child, WSTOPSIG( status ));
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
if (WEXITSTATUS( status ) != 0) if (WEXITSTATUS( status ) != 0)
{ {
if (NOT_SILENT) fprintf (stderr, "child process %d exited with status %d\n",
fprintf (stderr, "child process %d exited with status %d\n", child, WEXITSTATUS( status ));
child, WEXITSTATUS( status ));
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
break; /* normal child completion */ break; /* normal child completion */
......
...@@ -34,8 +34,9 @@ ...@@ -34,8 +34,9 @@
# Directory in which to store the results. # Directory in which to store the results.
# Fail if no arg to specify a directory for the output. # Fail if no arg to specify a directory for the output.
if [ "x$1" = "x" ] if [ "x$1" = "x" ]
then echo fixincludes: no output directory specified then
exit 1 echo fixincludes: no output directory specified
exit 1
fi fi
LIB=${1} LIB=${1}
...@@ -54,6 +55,17 @@ else ...@@ -54,6 +55,17 @@ else
} }
fi fi
if test -z "$VERBOSE"
then
VERBOSE=2
export VERBOSE
else
case "$VERBOSE" in
[0-9] ) : ;;
* ) VERBOSE=3 ;;
esac
fi
# Define what target system we're fixing. # Define what target system we're fixing.
# #
if test -r ./Makefile; then if test -r ./Makefile; then
...@@ -96,7 +108,8 @@ case $LIB in ...@@ -96,7 +108,8 @@ case $LIB in
;; ;;
esac esac
echo Fixing headers into ${LIB} for ${target_canonical} target if test $VERBOSE -gt 0
then echo Fixing headers into ${LIB} for ${target_canonical} target ; fi
# Determine whether this system has symbolic links. # Determine whether this system has symbolic links.
if ln -s X $LIB/ShouldNotExist 2>/dev/null; then if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
...@@ -131,7 +144,8 @@ INPUT=`${PWDCMD}` ...@@ -131,7 +144,8 @@ INPUT=`${PWDCMD}`
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
echo Finding directories and links to directories if test $VERBOSE -gt 1
then echo Finding directories and links to directories ; fi
# Find all directories and all symlinks that point to directories. # Find all directories and all symlinks that point to directories.
# Put the list in $all_dirs. # Put the list in $all_dirs.
...@@ -150,7 +164,8 @@ do ...@@ -150,7 +164,8 @@ do
newdirs= newdirs=
for d in $dirs for d in $dirs
do do
echo " Searching $INPUT/$d" if test $VERBOSE -gt 1
then echo " Searching $INPUT/$d" ; fi
# Find all directories under $d, relative to $d, excluding $d itself. # Find all directories under $d, relative to $d, excluding $d itself.
# (The /. is needed after $d in case $d is a symlink.) # (The /. is needed after $d in case $d is a symlink.)
...@@ -186,8 +201,10 @@ done ...@@ -186,8 +201,10 @@ done
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
dirs= dirs=
echo "All directories (including links to directories):" if test $VERBOSE -gt 2
echo $all_dirs then echo "All directories (including links to directories):"
echo $all_dirs
fi
for file in $all_dirs; do for file in $all_dirs; do
rm -rf $LIB/$file rm -rf $LIB/$file
...@@ -205,7 +222,8 @@ mkdir $LIB/root ...@@ -205,7 +222,8 @@ mkdir $LIB/root
treetops=". ${LIB}" treetops=". ${LIB}"
if $LINKS; then if $LINKS; then
echo 'Making symbolic directory links' if test $VERBOSE -gt 1
then echo 'Making symbolic directory links' ; fi
cwd=`${PWDCMD}` cwd=`${PWDCMD}`
for sym_link in $search_dirs; do for sym_link in $search_dirs; do
...@@ -235,7 +253,8 @@ if $LINKS; then ...@@ -235,7 +253,8 @@ if $LINKS; then
# If a link points to ., make a similar link to . # If a link points to ., make a similar link to .
# #
if [ ${full_dest_dir} = ${cinput} ]; then if [ ${full_dest_dir} = ${cinput} ]; then
echo ${sym_link} '->' . ': Making self link' if test $VERBOSE -gt 2
then echo ${sym_link} '->' . ': Making self link' ; fi
rm -fr ${LIB}/${sym_link} > /dev/null 2>&1 rm -fr ${LIB}/${sym_link} > /dev/null 2>&1
ln -s . ${LIB}/${sym_link} > /dev/null 2>&1 ln -s . ${LIB}/${sym_link} > /dev/null 2>&1
...@@ -248,7 +267,8 @@ if $LINKS; then ...@@ -248,7 +267,8 @@ if $LINKS; then
# DOTS is the relative path from ${LIB}/${sym_link} back to ${LIB}. # DOTS is the relative path from ${LIB}/${sym_link} back to ${LIB}.
dots=`echo "${sym_link}" | dots=`echo "${sym_link}" |
sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'` sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
echo ${sym_link} '->' $dots$y ': Making local link' if test $VERBOSE -gt 2
then echo ${sym_link} '->' $dots$y ': Making local link' ; fi
rm -fr ${LIB}/${sym_link} > /dev/null 2>&1 rm -fr ${LIB}/${sym_link} > /dev/null 2>&1
ln -s $dots$y ${LIB}/${sym_link} > /dev/null 2>&1 ln -s $dots$y ${LIB}/${sym_link} > /dev/null 2>&1
...@@ -258,7 +278,9 @@ if $LINKS; then ...@@ -258,7 +278,9 @@ if $LINKS; then
# and process $target into ${INPUT}/root$target # and process $target into ${INPUT}/root$target
# treat this directory as if it actually contained the files. # treat this directory as if it actually contained the files.
# #
echo ${sym_link} '->' root${full_dest_dir} ': Making rooted link' if test $VERBOSE -gt 2
then echo ${sym_link} '->' root${full_dest_dir} ': Making rooted link'
fi
if [ -d $LIB/root${full_dest_dir} ] if [ -d $LIB/root${full_dest_dir} ]
then true then true
else else
...@@ -282,7 +304,8 @@ if $LINKS; then ...@@ -282,7 +304,8 @@ if $LINKS; then
${sym_link}/*) ${sym_link}/*)
dupdir=${LIB}/root${full_dest_dir}/`echo $file2 | dupdir=${LIB}/root${full_dest_dir}/`echo $file2 |
sed -n "s|^${sym_link}/||p"` sed -n "s|^${sym_link}/||p"`
echo "Duplicating ${sym_link}'s ${dupdir}" if test $VERBOSE -gt 2
then echo "Duplicating ${sym_link}'s ${dupdir}" ; fi
if [ -d ${dupdir} ] if [ -d ${dupdir} ]
then true then true
else else
...@@ -337,7 +360,8 @@ while [ $# != 0 ]; do ...@@ -337,7 +360,8 @@ while [ $# != 0 ]; do
then continue ; fi then continue ; fi
touch ${DESTDIR}/DONE touch ${DESTDIR}/DONE
echo Fixing directory ${SRCDIR} into ${DESTDIR} if test $VERBOSE -gt 1
then echo Fixing directory ${SRCDIR} into ${DESTDIR} ; fi
# Check files which are symlinks as well as those which are files. # Check files which are symlinks as well as those which are files.
# #
...@@ -371,7 +395,8 @@ while [ $# != 0 ]; do ...@@ -371,7 +395,8 @@ while [ $# != 0 ]; do
cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2" >&2 cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2" >&2
chmod +w $3 2>/dev/null chmod +w $3 2>/dev/null
chmod a+r $3 2>/dev/null chmod a+r $3 2>/dev/null
echo Copied $2 if test $VERBOSE -gt 2
then echo Copied $2 ; fi
for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 | for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 |
sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'` sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`
do do
...@@ -387,17 +412,22 @@ while [ $# != 0 ]; do ...@@ -387,17 +412,22 @@ while [ $# != 0 ]; do
shift shift
done done
echo 'Cleaning up DONE files.' if test $VERBOSE -gt 2
then echo 'Cleaning up DONE files.' ; fi
cd $LIB cd $LIB
find . -name DONE -exec rm -f '{}' ';' find . -name DONE -exec rm -f '{}' ';'
echo 'Removing unneeded directories:' if test $VERBOSE -gt 1
then echo 'Cleaning up unneeded directories:' ; fi
cd $LIB cd $LIB
all_dirs=`find . -type d \! -name '.' -print | sort -r` all_dirs=`find . -type d \! -name '.' -print | sort -r`
for file in $all_dirs; do for file in $all_dirs; do
rmdir $LIB/$file > /dev/null 2>&1 rmdir $LIB/$file > /dev/null 2>&1
done done
if test $VERBOSE -gt 0
then echo fixincludes is done ; fi
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# End of for INPUT directories # End of for INPUT directories
......
...@@ -125,24 +125,18 @@ tSCC z[=hackname _cap=]FTst[=_eval _index=][] = "[=c_test=]";[= ...@@ -125,24 +125,18 @@ tSCC z[=hackname _cap=]FTst[=_eval _index=][] = "[=c_test=]";[=
#define [=hackname _up =]_TEST_CT [= #define [=hackname _up =]_TEST_CT [=
_IF exesel _exist =][= _IF exesel _exist =][=
_eval exesel _count _eval exesel _count
bypass _count + bypass _count +
test _count + test _count +
c_test _count + =][= c_test _count +
"ct=%d ; re_ct=`expr $ct + $re_ct` ; echo $ct"
_printf _shell =][=
_ELSE =][= _ELSE =][=
_eval select _count _eval select _count
bypass _count + bypass _count +
test _count + test _count +
c_test _count + =][= c_test _count +
_ENDIF =] "ct=%d ; re_ct=`expr $ct + $re_ct` ; echo $ct"
#define [=hackname _up =]_RE_CT [= _printf _shell =][=
_IF exesel _exist =][=
_eval exesel _count bypass _count
"#2$ct=`expr %d + %d` ; re_ct=`expr $ct + $re_ct` ; echo $ct"
_printf _shell =][=
_ELSE =][=
_eval select _count bypass _count
"#2$ct=`expr %d + %d` ; re_ct=`expr $ct + $re_ct` ; echo $ct"
_printf _shell =][=
_ENDIF =] _ENDIF =]
tTestDesc a[=hackname _cap=]Tests[] = {[= tTestDesc a[=hackname _cap=]Tests[] = {[=
...@@ -173,7 +167,6 @@ tTestDesc a[=hackname _cap=]Tests[] = {[= ...@@ -173,7 +167,6 @@ tTestDesc a[=hackname _cap=]Tests[] = {[=
_ENDIF =] };[= _ENDIF =] };[=
_ELSE =] _ELSE =]
#define [=hackname _up=]_TEST_CT 0 #define [=hackname _up=]_TEST_CT 0
#define [=hackname _up=]_RE_CT 0
#define a[=hackname _cap=]Tests (tTestDesc*)NULL[= #define a[=hackname _cap=]Tests (tTestDesc*)NULL[=
_ENDIF =] _ENDIF =]
......
...@@ -57,3 +57,74 @@ load_file_data (fp) ...@@ -57,3 +57,74 @@ load_file_data (fp)
return pz_data; return pz_data;
} }
t_bool
is_cxx_header (fname, text)
tCC *fname;
tCC *text;
{
/* First, check to see if the file is in a C++ directory */
for (;;)
{
switch (*(fname++))
{
case 'C': /* check for "CC/" */
if ((fname[0] == 'C') && (fname[1] == '/'))
return BOOL_TRUE;
break;
case 'x': /* check for "xx/" */
if ((fname[0] == 'x') && (fname[1] == '/'))
return BOOL_TRUE;
break;
case '+': /* check for "++" */
if (fname[0] == '+')
return BOOL_TRUE;
break;
case NUL:
goto not_cxx_name;
}
} not_cxx_name:;
/* Or it might contain the phrase 'extern "C++"' */
for (;;)
{
tSCC zExtern[] = "extern";
tSCC zExtCxx[] = "\"C++\"";
tSCC zTemplate[] = "template";
switch (*(text++))
{
case 'e':
/* Check for "extern \"C++\"" */
if (strncmp (text, zExtern+1, sizeof( zExtern )-2) != 0)
break;
text += sizeof( zExtern )-2;
if (! isspace( *(text++)) )
break;
while (isspace( *text )) text++;
if (strncmp (text, zExtCxx, sizeof (zExtCxx) -1) == 0)
return BOOL_TRUE;
break;
case 't':
/* Check for "template<" */
if (strncmp (text, zTemplate+1, sizeof( zTemplate )-2) != 0)
break;
text += sizeof( zTemplate )-2;
while (isspace( *text )) text++;
if (*text == '<')
return BOOL_TRUE;
break;
case NUL:
goto text_done;
break;
}
} text_done:;
return BOOL_FALSE;
}
...@@ -84,6 +84,11 @@ typedef enum ...@@ -84,6 +84,11 @@ typedef enum
} t_bool; } t_bool;
#endif #endif
typedef int apply_fix_p_t; /* Apply Fix Predicate Type */
#define APPLY_FIX 0
#define SKIP_FIX 1
#define _P_(p) () #define _P_(p) ()
#endif #endif
...@@ -91,5 +96,6 @@ typedef enum ...@@ -91,5 +96,6 @@ typedef enum
* Exported procedures * Exported procedures
*/ */
char * load_file_data _P_(( FILE* fp )); char * load_file_data _P_(( FILE* fp ));
t_bool is_cxx_header _P_(( tCC* filename, tCC* filetext ));
#endif /* FIXINCLUDES_FIXLIB_H */ #endif /* FIXINCLUDES_FIXLIB_H */
...@@ -48,16 +48,11 @@ Boston, MA 02111-1307, USA. */ ...@@ -48,16 +48,11 @@ Boston, MA 02111-1307, USA. */
#include "fixlib.h" #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) #define SHOULD_APPLY(afp) ((afp) == APPLY_FIX)
apply_fix_p_t run_test(); apply_fix_p_t run_test();
typedef struct { typedef struct {
const char* test_name; tCC* test_name;
apply_fix_p_t (*test_proc)(); apply_fix_p_t (*test_proc)();
} test_entry_t; } test_entry_t;
...@@ -68,8 +63,8 @@ typedef struct { ...@@ -68,8 +63,8 @@ typedef struct {
#define TEST_FOR_FIX_PROC_HEAD( test ) \ #define TEST_FOR_FIX_PROC_HEAD( test ) \
static apply_fix_p_t test ( fname, text ) \ static apply_fix_p_t test ( fname, text ) \
const char* fname; \ tCC* fname; \
const char* text; tCC* text;
/* /*
* Skip over a quoted string. Single quote strings may * Skip over a quoted string. Single quote strings may
...@@ -77,7 +72,7 @@ static apply_fix_p_t test ( fname, text ) \ ...@@ -77,7 +72,7 @@ static apply_fix_p_t test ( fname, text ) \
* a backslash. Especially a backslash followed by octal digits. * a backslash. Especially a backslash followed by octal digits.
* We are not doing a correctness syntax check here. * We are not doing a correctness syntax check here.
*/ */
static const char* tSCC*
skip_quote( q, text ) skip_quote( q, text )
char q; char q;
char* text; char* text;
...@@ -106,29 +101,10 @@ skip_quote( q, text ) ...@@ -106,29 +101,10 @@ skip_quote( q, text )
return text; return text;
} }
static apply_fix_p_t
is_cxx_header (fname, text)
const char *fname;
const char *text;
{
/* 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;
/* Or it might contain the phrase 'extern "C++"' */
if (strstr( text, "extern \"C++\"" ) != NULL)
return SKIP_FIX;
return APPLY_FIX;
}
TEST_FOR_FIX_PROC_HEAD( double_slash_test ) TEST_FOR_FIX_PROC_HEAD( double_slash_test )
{ {
if (is_cxx_header (fname, text) == SKIP_FIX) if (is_cxx_header (fname, text))
return SKIP_FIX; return SKIP_FIX;
/* Now look for the comment markers in the text */ /* Now look for the comment markers in the text */
...@@ -173,13 +149,13 @@ TEST_FOR_FIX_PROC_HEAD( double_slash_test ) ...@@ -173,13 +149,13 @@ TEST_FOR_FIX_PROC_HEAD( double_slash_test )
TEST_FOR_FIX_PROC_HEAD( else_endif_label_test ) TEST_FOR_FIX_PROC_HEAD( else_endif_label_test )
{ {
static int compiled = 0; static int compiled = 0;
static const char label_pat[] = "^[ \t]*#[ \t]*(else|endif)"; tSCC label_pat[] = "^[ \t]*#[ \t]*(else|endif)";
static regex_t label_re; static regex_t label_re;
char ch; char ch;
const char* pz_next = (char*)NULL; tCC* pz_next = (char*)NULL;
regmatch_t match[2]; regmatch_t match[2];
const char *all_text = text; t_bool file_is_cxx = is_cxx_header( fname, text );
/* /*
This routine may be run many times within a single execution. This routine may be run many times within a single execution.
...@@ -271,25 +247,33 @@ TEST_FOR_FIX_PROC_HEAD( else_endif_label_test ) ...@@ -271,25 +247,33 @@ TEST_FOR_FIX_PROC_HEAD( else_endif_label_test )
case '/': case '/':
/* /*
Skip comments. Otherwise, we have a bogon */ Skip comments. Otherwise, we have a bogon */
if (*pz_next == '*') switch (*pz_next)
{ {
case '/':
/* IF we found a "//" in a C header, THEN fix it. */
if (! file_is_cxx)
return APPLY_FIX;
/* C++ header. Skip to newline and continue. */
pz_next = strchr( pz_next+1, '\n' );
if (pz_next == (char*)NULL)
return SKIP_FIX;
pz_next++;
break;
case '*':
/* A comment for either C++ or C. Skip over it. */
pz_next = strstr( pz_next+1, "*/" ); pz_next = strstr( pz_next+1, "*/" );
if (pz_next == (char*)NULL) if (pz_next == (char*)NULL)
return SKIP_FIX; return SKIP_FIX;
pz_next += 2; pz_next += 2;
break; break;
default:
/* a '/' followed by other junk. */
return APPLY_FIX;
} }
else if (*pz_next == '/' break; /* a C or C++ comment */
&& is_cxx_header( fname, all_text ) == SKIP_FIX)
{
pz_next = strchr( pz_next+1, '\n' );
if (pz_next == (char*)NULL)
return SKIP_FIX;
pz_next++;
break;
}
/* FALLTHROUGH */
default: default:
/* /*
...@@ -311,9 +295,9 @@ TEST_FOR_FIX_PROC_HEAD( else_endif_label_test ) ...@@ -311,9 +295,9 @@ TEST_FOR_FIX_PROC_HEAD( else_endif_label_test )
*/ */
apply_fix_p_t apply_fix_p_t
run_test( tname, fname, text ) run_test( tname, fname, text )
const char* tname; tCC* tname;
const char* fname; tCC* fname;
const char* text; tCC* text;
{ {
#define _FT_(n,p) { n, p }, #define _FT_(n,p) { n, p },
static test_entry_t test_table[] = { FIX_TEST_TABLE { NULL, NULL }}; static test_entry_t test_table[] = { FIX_TEST_TABLE { NULL, NULL }};
...@@ -353,7 +337,6 @@ main( argc, argv ) ...@@ -353,7 +337,6 @@ main( argc, argv )
char* fname = *++argv; char* fname = *++argv;
char* tname = *++argv; char* tname = *++argv;
char* buf; char* buf;
size_t buf_size = 0;
if (argc != 3) if (argc != 3)
return run_test( "No test name provided", NULL, NULL, 0 ); return run_test( "No test name provided", NULL, NULL, 0 );
......
...@@ -24,7 +24,9 @@ ...@@ -24,7 +24,9 @@
_FOR fix "\n\n" =] _FOR fix "\n\n" =]
# #
# Fix [=_eval _index 1 + #%3d _printf=]: [=hackname _Cap=] # Fix [=
_IF FIXINC_DEBUG _exist =][=_eval _index 1 + #%3d _printf=]: [=
_ENDIF =][=hackname _Cap=]
#[= #[=
_IF files _exist=] _IF files _exist=]
case "${file}" in [=_FOR files " | \\\n\t"=]./[=files=][=/files=] )[= case "${file}" in [=_FOR files " | \\\n\t"=]./[=files=][=/files=] )[=
...@@ -117,12 +119,12 @@ _FOR fix "\n\n" =] ...@@ -117,12 +119,12 @@ _FOR fix "\n\n" =]
_ELIF replace _exist =][= _ELIF replace _exist =][=
_IF replace _len 0 > =] _IF replace _len 0 > =]
echo "[=hackname _down=] replacing file ${file}" >&2 echo "[=hackname =] replacing file ${file}" >&2
cat > ${DESTFILE} << '_EOF_' cat > ${DESTFILE} << '_EOF_'
[=replace=] [=replace=]
_EOF_[= _EOF_[=
_ELSE =] _ELSE =]
echo "[=hackname _down=] bypassing file ${file}"[= echo "[=hackname =] bypassing file ${file}"[=
_ENDIF =] _ENDIF =]
continue continue
[= [=
......
...@@ -8,12 +8,17 @@ autogen definitions inclhack; ...@@ -8,12 +8,17 @@ autogen definitions inclhack;
Define all the fixes we know about for repairing damaged headers. Define all the fixes we know about for repairing damaged headers.
Please see the README before adding or changing entries in this file. Please see the README before adding or changing entries in this file.
Now, first: DO NOT DO BROKEN FIXES (empty replacement fixes) */ Set up a debug test so we can make the templates emit special
code while debugging these fixes: */
#ifdef DEBUG
FIXINC_DEBUG = yes;
#endif
/* DO NOT DO BROKEN FIXES (empty replacement fixes) */
/* /*
* Purge some HP-UX 11 files that are only borken after they are "fixed". * Purge some HP-UX 11 files that are only broken after they are "fixed".
*/ */
fix = { fix = {
hackname = AAA_ki_iface; hackname = AAA_ki_iface;
...@@ -24,7 +29,7 @@ fix = { ...@@ -24,7 +29,7 @@ fix = {
/* /*
* Purge some HP-UX 11 files that are only borken after they are "fixed". * Purge some HP-UX 11 files that are only broken after they are "fixed".
*/ */
fix = { fix = {
hackname = AAA_ki; hackname = AAA_ki;
...@@ -35,7 +40,7 @@ fix = { ...@@ -35,7 +40,7 @@ fix = {
/* /*
* Purge some HP-UX 11 files that are only borken after they are "fixed". * Purge some HP-UX 11 files that are only broken after they are "fixed".
*/ */
fix = { fix = {
hackname = AAA_ki_calls; hackname = AAA_ki_calls;
...@@ -46,7 +51,7 @@ fix = { ...@@ -46,7 +51,7 @@ fix = {
/* /*
* Purge some HP-UX 11 files that are only borken after they are "fixed". * Purge some HP-UX 11 files that are only broken after they are "fixed".
*/ */
fix = { fix = {
hackname = AAA_ki_defs; hackname = AAA_ki_defs;
...@@ -71,7 +76,7 @@ fix = { ...@@ -71,7 +76,7 @@ fix = {
/* /*
* Purge some HP-UX 11 files that are only borken after they are "fixed". * Purge some HP-UX 11 files that are only broken after they are "fixed".
*/ */
fix = { fix = {
hackname = AAA_time; hackname = AAA_time;
......
[= autogen template -*- Mode: ksh -*- [= autogen template -*- Mode: sh -*-
sh sh
# #
# #
...@@ -25,8 +25,9 @@ sh ...@@ -25,8 +25,9 @@ sh
# Directory in which to store the results. # Directory in which to store the results.
# Fail if no arg to specify a directory for the output. # Fail if no arg to specify a directory for the output.
if [ "x$1" = "x" ] if [ "x$1" = "x" ]
then echo fixincludes: no output directory specified then
exit 1 echo fixincludes: no output directory specified
exit 1
fi fi
LIB=${1} LIB=${1}
...@@ -48,6 +49,18 @@ fi ...@@ -48,6 +49,18 @@ fi
FIXTESTS=$PWD/fixinc/fixtests FIXTESTS=$PWD/fixinc/fixtests
FIXFIXES=$PWD/fixinc/fixfixes FIXFIXES=$PWD/fixinc/fixfixes
[=_ENDIF=] [=_ENDIF=]
if test -z "$VERBOSE"
then
VERBOSE=[=
_IF FIXINC_DEBUG _exist =]3[=_ELSE=]2[=_ENDIF=]
export VERBOSE
else
case "$VERBOSE" in
[0-9] ) : ;;
* ) VERBOSE=3 ;;
esac
fi
# Define what target system we're fixing. # Define what target system we're fixing.
# #
if test -r ./Makefile; then if test -r ./Makefile; then
...@@ -92,7 +105,8 @@ case $LIB in ...@@ -92,7 +105,8 @@ case $LIB in
;; ;;
esac esac
echo Fixing headers into ${LIB} for ${target_canonical} target if test $VERBOSE -gt 0
then echo Fixing headers into ${LIB} for ${target_canonical} target ; fi
# Determine whether this system has symbolic links. # Determine whether this system has symbolic links.
if ln -s X $LIB/ShouldNotExist 2>/dev/null; then if ln -s X $LIB/ShouldNotExist 2>/dev/null; then
...@@ -127,7 +141,8 @@ INPUT=`${PWDCMD}` ...@@ -127,7 +141,8 @@ INPUT=`${PWDCMD}`
# #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
echo Finding directories and links to directories if test $VERBOSE -gt 1
then echo Finding directories and links to directories ; fi
# Find all directories and all symlinks that point to directories. # Find all directories and all symlinks that point to directories.
# Put the list in $all_dirs. # Put the list in $all_dirs.
...@@ -146,7 +161,8 @@ do ...@@ -146,7 +161,8 @@ do
newdirs= newdirs=
for d in $dirs for d in $dirs
do do
echo " Searching $INPUT/$d" if test $VERBOSE -gt 1
then echo " Searching $INPUT/$d" ; fi
# Find all directories under $d, relative to $d, excluding $d itself. # Find all directories under $d, relative to $d, excluding $d itself.
# (The /. is needed after $d in case $d is a symlink.) # (The /. is needed after $d in case $d is a symlink.)
...@@ -182,8 +198,10 @@ done ...@@ -182,8 +198,10 @@ done
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
dirs= dirs=
echo "All directories (including links to directories):" if test $VERBOSE -gt 2
echo $all_dirs then echo "All directories (including links to directories):"
echo $all_dirs
fi
for file in $all_dirs; do for file in $all_dirs; do
rm -rf $LIB/$file rm -rf $LIB/$file
...@@ -201,7 +219,8 @@ mkdir $LIB/root ...@@ -201,7 +219,8 @@ mkdir $LIB/root
treetops=". ${LIB}" treetops=". ${LIB}"
if $LINKS; then if $LINKS; then
echo 'Making symbolic directory links' if test $VERBOSE -gt 1
then echo 'Making symbolic directory links' ; fi
cwd=`${PWDCMD}` cwd=`${PWDCMD}`
for sym_link in $search_dirs; do for sym_link in $search_dirs; do
...@@ -231,7 +250,8 @@ if $LINKS; then ...@@ -231,7 +250,8 @@ if $LINKS; then
# If a link points to ., make a similar link to . # If a link points to ., make a similar link to .
# #
if [ ${full_dest_dir} = ${cinput} ]; then if [ ${full_dest_dir} = ${cinput} ]; then
echo ${sym_link} '->' . ': Making self link' if test $VERBOSE -gt 2
then echo ${sym_link} '->' . ': Making self link' ; fi
rm -fr ${LIB}/${sym_link} > /dev/null 2>&1 rm -fr ${LIB}/${sym_link} > /dev/null 2>&1
ln -s . ${LIB}/${sym_link} > /dev/null 2>&1 ln -s . ${LIB}/${sym_link} > /dev/null 2>&1
...@@ -244,7 +264,8 @@ if $LINKS; then ...@@ -244,7 +264,8 @@ if $LINKS; then
# DOTS is the relative path from ${LIB}/${sym_link} back to ${LIB}. # DOTS is the relative path from ${LIB}/${sym_link} back to ${LIB}.
dots=`echo "${sym_link}" | dots=`echo "${sym_link}" |
sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'` sed -e 's@^./@@' -e 's@/./@/@g' -e 's@[^/][^/]*@..@g' -e 's@..$@@'`
echo ${sym_link} '->' $dots$y ': Making local link' if test $VERBOSE -gt 2
then echo ${sym_link} '->' $dots$y ': Making local link' ; fi
rm -fr ${LIB}/${sym_link} > /dev/null 2>&1 rm -fr ${LIB}/${sym_link} > /dev/null 2>&1
ln -s $dots$y ${LIB}/${sym_link} > /dev/null 2>&1 ln -s $dots$y ${LIB}/${sym_link} > /dev/null 2>&1
...@@ -254,7 +275,9 @@ if $LINKS; then ...@@ -254,7 +275,9 @@ if $LINKS; then
# and process $target into ${INPUT}/root$target # and process $target into ${INPUT}/root$target
# treat this directory as if it actually contained the files. # treat this directory as if it actually contained the files.
# #
echo ${sym_link} '->' root${full_dest_dir} ': Making rooted link' if test $VERBOSE -gt 2
then echo ${sym_link} '->' root${full_dest_dir} ': Making rooted link'
fi
if [ -d $LIB/root${full_dest_dir} ] if [ -d $LIB/root${full_dest_dir} ]
then true then true
else else
...@@ -278,7 +301,8 @@ if $LINKS; then ...@@ -278,7 +301,8 @@ if $LINKS; then
${sym_link}/*) ${sym_link}/*)
dupdir=${LIB}/root${full_dest_dir}/`echo $file2 | dupdir=${LIB}/root${full_dest_dir}/`echo $file2 |
sed -n "s|^${sym_link}/||p"` sed -n "s|^${sym_link}/||p"`
echo "Duplicating ${sym_link}'s ${dupdir}" if test $VERBOSE -gt 2
then echo "Duplicating ${sym_link}'s ${dupdir}" ; fi
if [ -d ${dupdir} ] if [ -d ${dupdir} ]
then true then true
else else
...@@ -333,7 +357,8 @@ while [ $# != 0 ]; do ...@@ -333,7 +357,8 @@ while [ $# != 0 ]; do
then continue ; fi then continue ; fi
touch ${DESTDIR}/DONE touch ${DESTDIR}/DONE
echo Fixing directory ${SRCDIR} into ${DESTDIR} if test $VERBOSE -gt 1
then echo Fixing directory ${SRCDIR} into ${DESTDIR} ; fi
# Check files which are symlinks as well as those which are files. # Check files which are symlinks as well as those which are files.
# #
...@@ -384,7 +409,8 @@ while [ $# != 0 ]; do ...@@ -384,7 +409,8 @@ while [ $# != 0 ]; do
cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2" >&2 cp $2 $3 >/dev/null 2>&1 || echo "Can't copy $2" >&2
chmod +w $3 2>/dev/null chmod +w $3 2>/dev/null
chmod a+r $3 2>/dev/null chmod a+r $3 2>/dev/null
echo Copied $2 if test $VERBOSE -gt 2
then echo Copied $2 ; fi
for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 | for include in `egrep '^[ ]*#[ ]*include[ ]*"[^/]' $3 |
sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'` sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`
do do
...@@ -400,17 +426,22 @@ while [ $# != 0 ]; do ...@@ -400,17 +426,22 @@ while [ $# != 0 ]; do
shift shift
done done
echo 'Cleaning up DONE files.' if test $VERBOSE -gt 2
then echo 'Cleaning up DONE files.' ; fi
cd $LIB cd $LIB
find . -name DONE -exec rm -f '{}' ';' find . -name DONE -exec rm -f '{}' ';'
echo 'Removing unneeded directories:' if test $VERBOSE -gt 1
then echo 'Cleaning up unneeded directories:' ; fi
cd $LIB cd $LIB
all_dirs=`find . -type d \! -name '.' -print | sort -r` all_dirs=`find . -type d \! -name '.' -print | sort -r`
for file in $all_dirs; do for file in $all_dirs; do
rmdir $LIB/$file > /dev/null 2>&1 rmdir $LIB/$file > /dev/null 2>&1
done done
if test $VERBOSE -gt 0
then echo fixincludes is done ; fi
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# End of for INPUT directories # End of for INPUT directories
......
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