Commit 7d9ccd90 by Bruce Korb

Reworked method for traversing sym-linked directory hierarchies

From-SVN: r26086
parent 5877286e
......@@ -139,6 +139,8 @@ struct fix_desc
char *pz_dest_dir = NULL;
char *pz_src_dir = NULL;
char *pz_machine = NULL;
char *pz_find_base = NULL;
int find_base_len = 0;
pid_t process_chain_head = (pid_t) -1;
......@@ -240,6 +242,17 @@ main (argc, argv)
}
}
{
static const char var[] = "FIND_BASE";
pz_find_base = getenv (var);
if (pz_find_base == (char *) NULL)
{
fprintf (stderr, var_not_found, var);
exit (EXIT_FAILURE);
}
find_base_len = strlen( pz_find_base );
}
/* Compile all the regular expressions now.
That way, it is done only once for the whole run.
*/
......@@ -298,10 +311,15 @@ main (argc, argv)
errno, strerror (errno));
exit (EXIT_FAILURE);
}
#ifdef DEBUG
#ifndef DEBUG
{
int status;
(void)wait (&status);
}
#else
fprintf (stderr, "Waiting for %d to complete %d files\n",
child, file_name_ct);
#endif
{
int status;
pid_t dead_kid = wait (&status);
......@@ -309,17 +327,18 @@ main (argc, argv)
if (dead_kid != child)
fprintf (stderr, "fixincl woke up from a strange child %d (not %d)\n",
dead_kid, child);
#ifdef DEBUG
else
fprintf (stderr, "child finished %d files %s\n", file_name_ct,
status ? strerror (status & 0xFF) : "ok");
#endif
}
#endif
}
#else
#error "NON-BOGUS LIMITS NOT SUPPORTED?!?!"
#endif
signal (SIGCLD, SIG_IGN);
#ifdef DEBUG
fprintf (stderr, "Child start -- processing %d files\n",
file_name_ct);
......@@ -411,8 +430,10 @@ load_file (pz_file_name)
if (ferror (fp))
{
fprintf (stderr, "error %d (%s) reading %s\n", errno,
strerror (errno), pz_file_name);
int err = errno;
if (err != EISDIR)
fprintf (stderr, "error %d (%s) reading %s\n", err,
strerror (err), pz_file_name);
free ((void *) pz_data);
fclose (fp);
return (char *) NULL;
......@@ -596,7 +617,16 @@ create_file (pz_file_name)
FILE *pf;
char fname[MAXPATHLEN];
sprintf (fname, "%s/%s", pz_dest_dir, pz_file_name);
#ifdef DEBUG
if (strncmp( pz_file_name, pz_find_base, find_base_len ) != 0)
{
fprintf (stderr, "Error: input file %s does not match %s/*\n",
pz_file_name, pz_find_base );
exit (1);
}
#endif
sprintf (fname, "%s/%s", pz_dest_dir, pz_file_name + find_base_len);
fd = open (fname, O_WRONLY | O_CREAT | O_TRUNC, S_IRALL);
......@@ -911,7 +941,7 @@ process (pz_data, pz_file_name)
}
}
fprintf (stderr, "Applying %-32s to %s\n",
fprintf (stderr, "Applying %-24s to %s\n",
p_fixd->fix_name, pz_file_name);
/* IF we do not have a read pointer,
......
......@@ -5,19 +5,15 @@
# fixincl program. It is the repetitive guts of the fixincludes logic.
#
=]
if $LINKS; then
files=`find . -name '*.h' \( -type f -o -type l \) -print`
else
files=`find . -name '*.h' -type f -print`
fi
echo Checking header files
for file in $files; do
if ( test ! -r $file -o \
-n "`fgrep 'This file is part of the GNU C Library' $file`" )
if ( test ! -r ${file} -o \
-n "`fgrep 'This file is part of the GNU C Library' ${file}`" )
then continue ; fi
fixlist=""
DESTFILE=${DESTDIR}/`echo ${file} | sed "s;${FIND_BASE}/;;" `
[=
#
# FOR every fix description,
......@@ -30,7 +26,7 @@ _FOR fix "\n\n" =]
# Fix [=_eval _index 1 + #%3d _printf=]: [=hackname _Cap=]
#[=
_IF files _exist=]
case "$file" in [=_FOR files " | \\\n\t"=]./[=files=][=/files=] )[=
case "${file}" in [=_FOR files " | \\\n\t"=]./[=files=][=/files=] )[=
_ENDIF=][=
_IF mach _exist=]
......@@ -52,8 +48,8 @@ _FOR fix "\n\n" =]
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
if ( test -n "`egrep 'find-expr' ${file}`" -a
-z "`egrep 'not-find' ${file}`" -a
'(' <some-test-expression> ')'
) > /dev/null 2>&1 ; then
......@@ -62,13 +58,13 @@ _FOR fix "\n\n" =]
_IF select _exist =]
if ( test [=
_FOR select " -a \\\n "
=]-n [=select _shrstr "#`egrep %s $file`"
=]-n [=select _shrstr "#`egrep %s ${file}`"
_printf _shstr =][=
/select=][=
_IF bypass _exist =][=
_FOR bypass=] -a \
-z [=bypass _shrstr "#`egrep %s $file`"
-z [=bypass _shrstr "#`egrep %s ${file}`"
_printf _shstr =][=
/bypass=][=
_ENDIF=][=
......@@ -89,7 +85,7 @@ _FOR fix "\n\n" =]
_IF bypass _exist=][=
_FOR bypass=] -a \
-z [=bypass _shrstr "#`egrep %s $file`"
-z [=bypass _shrstr "#`egrep %s ${file}`"
_printf _shstr=][=
/bypass=][=
_ENDIF=]
......@@ -98,16 +94,16 @@ _FOR fix "\n\n" =]
_ELIF bypass _exist =]
if ( test [=_FOR bypass " -a \\\n "
=]-z [=bypass _shrstr "#`egrep %s $file`"
=]-z [=bypass _shrstr "#`egrep %s ${file}`"
_printf _shstr=][=/bypass=]
) > /dev/null 2>&1 ; then[=
_ENDIF=]
fixlist="${fixlist}
[=hackname=]"
if [ ! -r ${DESTDIR}/$file ]
then infile=$file
else infile=${DESTDIR}/$file ; fi [=
if [ ! -r ${DESTFILE} ]
then infile=${file}
else infile=${DESTFILE} ; fi [=
_IF sed _exist=][=
_IF shell _exist =][=
......@@ -118,16 +114,16 @@ _FOR fix "\n\n" =]
sed [=
_FOR sed =]-e [=sed _shrstr=] \
[=
/sed=] < $infile > ${DESTDIR}/$file.[=
/sed=] < $infile > ${DESTFILE}.[=
_ELIF shell _exist =]
( [=shell=] ) < $infile > ${DESTDIR}/$file.
( [=shell=] ) < $infile > ${DESTDIR}/FIXINC.tmp
# Shell scripts have the potential of removing the output
# We interpret that to mean the file is not to be altered
#
if test ! -f ${DESTDIR}/$file.
if test ! -f ${DESTDIR}/fixinc.tmp
then continue ; fi [=
......@@ -135,8 +131,8 @@ _FOR fix "\n\n" =]
_ERROR hackname _get "ERROR: %s has no fixup" _printf=][=
_ENDIF=]
mv -f ${DESTDIR}/$file. ${DESTDIR}/$file[=
rm -f ${DESTFILE}
mv -f ${DESTDIR}/fixinc.tmp ${DESTFILE}[=
# Close off any opened "if" or "case" statements in reverse order
......@@ -165,21 +161,23 @@ _FOR fix "\n\n" =]
# THEN ensure the output is gone
# ELSE look for local directory include syntax
#
if ( test ! -f ${DESTDIR}/$file || \
cmp $file ${DESTDIR}/$file ) > /dev/null 2>&1
if ( test ! -f ${DESTFILE} || \
cmp ${file} ${DESTFILE} ) > /dev/null 2>&1
then
rm -f ${DESTDIR}/$file
rm -f ${DESTFILE}
else
echo "Fixed $file:${fixlist}"
echo "Fixed ${file}:${fixlist}"
# Find any include directives that use "file".
#
dir=`echo ${file} | sed -e s';/[^/]*$;;'`
ddir=`echo ${DESTDIR} | sed 's;/[^/]*$;;'`/$dir
for include in `
egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${DESTDIR}/$file |
sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`
egrep '^[ ]*#[ ]*include[ ]*"[^/]' ${DESTFILE} |
sed -e 's/^[ ]*#[ ]*include[ ]*"\([^"]*\)".*$/\1/'`
do
dir=`echo $file | sed -e s'|/[^/]*$||'`
required="$required ${SRCDIR} $dir/$include ${DESTDIR}/$dir/$include"
required="$required ${SRCDIR} $dir/$include ${ddir}/$include"
done
fi
done # for file in $files
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