Don't repeat the directory-link-chasing loop more than twice.
authorRichard Stallman <rms@gnu.org>
Wed, 29 Jul 1992 04:44:02 +0000 (04:44 +0000)
committerRichard Stallman <rms@gnu.org>
Wed, 29 Jul 1992 04:44:02 +0000 (04:44 +0000)
Combine $prevdirs with $dirs--they had same value.
Properly discard $d itself from the output of find.

From-SVN: r1712

gcc/fixincludes

index eecc3ddda4e7118e31f4301ea35f0b807aabb029..592d0fc1caa32f2e0147b10d29f3dd155d1fd4b4 100755 (executable)
@@ -55,26 +55,25 @@ cd ${INPUT}
 # Note that $files may have duplicates in it;
 # later parts of this file are supposed to ignore them.
 dirs="."
-prevdirs="."
-while [ -n "$dirs" ]
+levels=2
+while [ -n "$dirs" ] && [ $levels -gt 0 ]
 do
+    levels=`expr $levels - 1`
     newdirs=
-    for d in $prevdirs
+    for d in $dirs
     do
        if [ "$d" != . ]
        then
            d=$d/.
        fi
 
-       # Find all directories under $d, relative to $d, including $d itself.
-       # Get rid of ./ at the end!
-        files="$files `find $d -type d -print | sed '/^.$/d' | sed '/\/\.$/ s|/\.$||'`"
+       # Find all directories under $d, relative to $d, excluding $d itself.
+        files="$files `find $d -type d -print | sed '|/\.$|d'`"
        $LINKS && \
          newdirs="$newdirs `find $d -type l -exec test -d '{}' \; -print`"
     done
 
     dirs="$newdirs"
-    prevdirs="$newdirs"
 done
 
 dirs=