This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[fixinc] soft links to directories are incorrectly removed


The fast fixinc shell script is inadvertently removing links to
directories within the `include' tree because the ``contents'' of the
link don't need fixing.  The attached patch causes such soft links to
be skipped in two different ways.  The first approach (in
hackshell.tpl) is 100% safe, while the second (in inclhack.tpl) is a
bit faster, but I'm not 100% sure about the portability of find -exec.
Is anybody?

I'm inclined to install both, leaving the first as a work-around in
case the first one fails (it's also possible that test -d link fails).
Then, if find -exec is ever found to be a problem, we can always add
the original find command as a fallback later.

BTW, the original fixincludes script did not fall victim of this
problem because it would find -name '*.h', so it would not even
consider fixinc links to directories (unless they were named *.h, of
course :-)

Is this ok to install?

-- 
Alexandre Oliva http://www.dcc.unicamp.br/~oliva IC-Unicamp, Brasil
{oliva,Alexandre.Oliva}@dcc.unicamp.br  aoliva@{acm.org,computer.org}
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
*** E-mail about software projects will be forwarded to mailing lists
Index: ChangeLog
from  Alexandre Oliva  <oliva@dcc.unicamp.br>
	
	* fixinc/hackshell.tpl: skip links to directories, to avoid
	removing them
	* fixinc/inclhack.tpl: ditto, but sooner, at find time
	
Index: fixinc/hackshell.tpl
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/fixinc/hackshell.tpl,v
retrieving revision 1.5
diff -u -r1.5 hackshell.tpl
--- fixinc/hackshell.tpl	1999/04/01 00:25:25	1.5
+++ fixinc/hackshell.tpl	1999/04/02 00:39:00
@@ -8,9 +8,12 @@
   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}`" )
-    then continue ; fi
+    # Skip unreadable files, symlinks to directories and glibc files
+    if test ! -r "${file}" || test -d "${file}/." \
+       || fgrep 'This file is part of the GNU C Library' "${file}" \
+	    > /dev/null 2>&1; then
+      continue
+    fi
 
     fixlist=""
     DESTFILE=${DESTDIR}/`echo ${file} | sed "s;${FIND_BASE}/;;" `
Index: fixinc/inclhack.tpl
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/fixinc/inclhack.tpl,v
retrieving revision 1.4
diff -u -r1.4 inclhack.tpl
--- fixinc/inclhack.tpl	1999/03/31 11:51:29	1.4
+++ fixinc/inclhack.tpl	1999/04/02 00:39:00
@@ -334,7 +334,7 @@
   cd ${INPUT}[=
 _IF PROGRAM _env ! =]
   files=`if $LINKS; then
-    find ${FIND_BASE}/. \( -type f -o -type l \) -print
+    find ${FIND_BASE}/. \( -type f -o \( -type l -exec test ! -d {} \; \) \) -print
   else
     find ${FIND_BASE}/. -type f -print
   fi | \

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]