OSDN Git Service

2004-07-04 Matthias Klose <doko@debian.org>
[pf3gnuchains/gcc-fork.git] / gcc / fixinc / check.tpl
index a4be5ed..9f8750b 100644 (file)
@@ -1,4 +1,4 @@
-[= autogen template sh=check.sh =]
+[= autogen5 template sh=check.sh =]
 [=
 #
 #  This file contanes the shell template to run tests on the fixes
 
 set -e
 TESTDIR=tests
-TESTBASE=`cd $1;pwd`
+TESTBASE=`cd $1;${PWDCMD-pwd}`
 
 [ -d ${TESTDIR} ] || mkdir ${TESTDIR}
 cd ${TESTDIR}
-TESTDIR=`pwd`
+TESTDIR=`${PWDCMD-pwd}`
 
 TARGET_MACHINE='*'
-DESTDIR=`pwd`/res
-SRCDIR=`pwd`/inc
+DESTDIR=`${PWDCMD-pwd}`/res
+SRCDIR=`${PWDCMD-pwd}`/inc
 FIND_BASE='.'
-VERBOSE=1
+VERBOSE=[=` echo ${VERBOSE-1} `=]
+INPUT=`${PWDCMD-pwd}`
+ORIGDIR=${INPUT}
 
-export TARGET_MACHINE DESTDIR SRCDIR FIND_BASE VERBOSE
+export TARGET_MACHINE DESTDIR SRCDIR FIND_BASE VERBOSE INPUT ORIGDIR
 
 rm -rf ${DESTDIR} ${SRCDIR}
 mkdir ${DESTDIR} ${SRCDIR}
-
-( cd ${SRCDIR}
-  set +e
-  for f in [=
-
-  _EVAL fix.files _stack _join "echo `
-
-  for f in %s
-  do case $f in
-     */* ) echo $f | sed 's;/[^/]*$;;' ;;
-     esac
-  done | sort -u
-
-  ` " _printf _shell =]
-  do
-    mkdir $f || mkdir -p $f
-  done ) > /dev/null 2>&1
-
+(
+[=
+  (shellf
+    "for f in %s
+     do case $f in
+        */* ) echo $f | sed 's;/[^/]*$;;' ;;
+        esac
+     done | sort -u | \
+     while read g
+     do echo \"  mkdir \\${SRCDIR}/$g || mkdir -p \\${SRCDIR}/$g || exit 1\"
+     done" (join " " (stack "fix.files"))  ) =]
+) 2> /dev/null[= # suppress 'No such file or directory' messages =]
 cd inc
 [=
+(define sfile "")
+(define HACK  "")
+(define dfile "")              =][=
 
-_FOR fix =][=
+FOR fix                        =][=
 
-  _IF test_text _count 1 > =]
-#
-#  [=hackname=] has [=_EVAL test_text _count=] tests
-#
-sfile=[=
-    _IF files _exist =][=
-      files[0] =][=
-    _ELSE =]testing.h[=
-    _ENDIF =]
-dfile=`dirname $sfile`/[=hackname "_A-Z" "-a-z" _tr=]-[=_EVAL _index=].h
-fixnum=[=_EVAL _index=][=
-    _FOR test_text FROM 1 =]
-cat >> $sfile <<_HACK_EOF_
+  IF (> (count "test_text") 1) =][=
+    (set! HACK (string-upcase! (get "hackname")))
+    (set! sfile (if (exist? "files") (get "files[]") "testing.h"))
+    (set! dfile (string-append
+          (if (*==* sfile "/")
+              (shellf "echo \"%s\"|sed 's,/[^/]*,/,'" sfile )
+              "" )
+          (string-tr! (get "hackname") "_A-Z" "-a-z")
+    )           )              =][=
+
+    FOR test_text (for-from 1) =]
+cat >> [=(. sfile)=] <<_HACK_EOF_
 
 
-#if defined( [=hackname _up=]_CHECK_[=_EVAL _index=] )
+#if defined( [=(. HACK)=]_CHECK_[=(for-index)=] )
 [=test_text=]
-#endif  /* [=hackname _up=]_CHECK_[=_EVAL _index=] */
+#endif  /* [=(. HACK)=]_CHECK_[=(for-index)=] */
 _HACK_EOF_
-echo $sfile | ../../fixincl
-[ -f ${DESTDIR}/$sfile ] && mv ${DESTDIR}/$sfile ${DESTDIR}/$dfile[=
-    /test_text =][=
-  _ENDIF =][=
+echo [=(. sfile)=] | ../../fixincl
+mv -f [=(. sfile)=] [=(. dfile)=]-[=(for-index)=].h
+[ -f ${DESTDIR}/[=(. sfile)=] ] && [=#
+   =]mv ${DESTDIR}/[=(. sfile)=] ${DESTDIR}/[=(. dfile)=]-[=(for-index)=].h[=
+
+    ENDFOR  test_text =][=
+
+  ENDIF  multi-test   =][=
 
-/fix
+ENDFOR  fix
 
 =][=
 
-_FOR fix =][=
-
-  _IF test_text _exist ! =][=
-    _IF replace _exist ! =]
-echo No test for [=hackname=] in inc/[=
-      _IF files _exist =][=
-        files[0] =][=
-      _ELSE =]testing.h[=
-      _ENDIF =][=
-    _ENDIF =][=
-  _ELSE =]
+FOR fix  =][=
+  (set! HACK (string-upcase! (get "hackname")))  =][=
+
+  IF (not (exist? "test_text")) =][=
+    (if (not (exist? "replace"))
+        (error (sprintf "include fix '%s' has no test text"
+                        (get "hackname") )) )
+         =][=
+  ELSE   =]
 cat >> [=
-    _IF files _exist =][=
+    IF (exist? "files") =][=
       files[0] =][=
-    _ELSE =]testing.h[=
-    _ENDIF =] <<_HACK_EOF_
+    ELSE =]testing.h[=
+    ENDIF =] <<_HACK_EOF_
 
 
-#if defined( [=hackname _up=]_CHECK )
+#if defined( [=(. HACK)=]_CHECK )
 [=test_text=]
-#endif  /* [=hackname _up=]_CHECK */
+#endif  /* [=(. HACK)=]_CHECK */
 _HACK_EOF_
-[=_ENDIF =][=
+[=ENDIF =][=
 
-/fix
+ENDFOR  fix
 
 =]
 
-find . -type f | sed 's;\./;;' | sort | ../../fixincl
+find . -type f | sed 's;^\./;;' | sort | ../../fixincl
 cd ${DESTDIR}
 
 exitok=true
 
 find * -type f -print > ${TESTDIR}/LIST
 
+#  Special hack for sys/types.h:  the #define-d types for size_t,
+#  ptrdiff_t and wchar_t are different for each port.  Therefore,
+#  strip off the defined-to type so that the test results are the
+#  same for all platforms.
+#
+sed 's/\(#define __[A-Z_]*_TYPE__\).*/\1/' sys/types.h > XX
+mv -f XX sys/types.h
+
+#  The following subshell weirdness is for saving an exit
+#  status from within a while loop that reads input.  If you can
+#  think of a cleaner way, suggest away, please...
+#
 exitok=`
 exec < ${TESTDIR}/LIST
 while read f
@@ -123,7 +135,7 @@ do
     :
 
   else
-    diff -c $f ${TESTBASE}/$f >&2
+    ${DIFF:-diff} -c $f ${TESTBASE}/$f >&2 || :
     exitok=false
   fi
 done
@@ -159,6 +171,6 @@ else
 fi
 $exitok[=
 
-_eval _outfile "chmod +x %s" _printf _shell
+(if (defined? 'set-writable) (set-writable))
 
 =]