Various optimizations.
authorPekka Riikonen <priikone@silcnet.org>
Fri, 22 Apr 2005 20:22:21 +0000 (20:22 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Fri, 22 Apr 2005 20:22:21 +0000 (20:22 +0000)
apps/autodist/CHANGES
apps/autodist/autodist.in
apps/autodist/tests/autodist1.test
apps/autodist/tests/autodist2.test
apps/autodist/tests/autodist3.test
apps/autodist/tests/autodist4.test
apps/autodist/tests/autodist5.test

index 38565e6ef07194626c3842880ee30b4d0ac6ab9c..bb3c794f75c1a9df8de0d906a37df1900817e84a 100644 (file)
@@ -1,3 +1,9 @@
+Fri Apr 22 20:23:06 EEST 2005  Pekka Riikonen <priikone@silcnet.org>
+
+       * Various 'cat' optimizations.
+
+       * More test cases in tests/.
+
 Tue Apr 19 17:12:09 EEST 2005  Pekka Riikonen <priikone@silcnet.org>
 
        * Remove extra ' ' and '\t' when joining backslashed lines.
index b16f696bf61307b3fd041dc9744bbbdd2a6ebeea..099b9abd3a4323ebc948a312b54bc7ca7ebdf782 100755 (executable)
@@ -224,26 +224,29 @@ ad_create_distdefs_h()
 
   fname=$DISTDEFS
   rm -f $fname
-  echo "/*" > $fname
-  echo "  Automatically generated by Autodist $ver.  Do not edit." >> $fname
-  echo >> $fname
-  echo "  Generated: `date` by `whoami`" >> $fname
-  echo "  Distribution: $distribution" >> $fname
-  echo "  License: $license" >> $fname
-  echo "*/" >> $fname
-  echo >> $fname
-  echo "#ifndef _"$DP"_DISTDEFS_H" >> $fname
-  echo "#define _"$DP"_DISTDEFS_H" >> $fname
-  echo >> $fname
+  cat > $fname <<EOF
+/*
+  Automatically generated by Autodist $ver.  Do not edit.
+
+  Generated: `date` by `whoami`
+  Distribution: $distribution
+  License: $license
+*/
+
+#ifndef _`echo $DP`_DISTDEFS_H
+#define _`echo $DP`_DISTDEFS_H
+
+EOF
 
   for i in $distdefs
   do
     echo "#define $i 1" >>$fname
   done
 
-  echo >> $fname
-  echo "#endif /* _"$DP"_DISTDEFS_H */" >> $fname
+  cat >> $fname <<EOF
 
+#endif /* _`echo $DP`_DISTDEFS_H */
+EOF
   ad_debug "<ad_create_distdefs_h"
 }
 
@@ -324,7 +327,7 @@ ad_make_configure_ac()
     ad_fatal "The configure file '$1' does not exist"
   fi
 
-  check="`cat $1 | sed 's/^[   ]*//' | grep -v "^#" | grep -e "AD_INIT"`"
+  check="`sed 's/^[    ]*//' < $1 | grep -v "^#" | grep -e "AD_INIT"`"
   if test -z $check; then
     rm -f configure.ad.cfs
     rm -f $fname $fname.tmp
@@ -344,7 +347,7 @@ ad_make_configure_ac()
   done
 
   if test -f configure.ad.cfs; then
-    check="`cat $1 | sed 's/^[         ]*//' | grep -v "^#" | grep -e "AD_INCLUDE_CONFIGURE"`"
+    check="`sed 's/^[  ]*//' < $1 | grep -v "^#" | grep -e "AD_INCLUDE_CONFIGURE"`"
     if test -z $check; then
       rm -f configure.ad.cfs
       ad_warning "configure.ad fragments found but 'AD_INCLUDE_CONFIGURE' is not set"
@@ -353,14 +356,16 @@ ad_make_configure_ac()
 
   # Header for configure.ac
   fname="configure.tmp.ac"
-  echo "# Automatically generated by Autodist $ver.  Do not edit." > $fname
-  echo "# To make changes edit the configure.ad file in the source tree." >> $fname
-  echo >> $fname
-  echo "# Source: configure.ad" >> $fname
-  echo "# Generated: `date` by `whoami`" >> $fname
-  echo "# Distribution: $distribution" >> $fname
-  echo "# License: $license" >> $fname
-  echo >> $fname
+  cat > $fname <<EOF
+# Automatically generated by Autodist $ver.  Do not edit.
+# To make changes edit the configure.ad file in the source tree.
+
+# Source: configure.ad
+# Generated: `date` by `whoami`
+# Distribution: $distribution
+# License: $license
+
+EOF
 
   ad_debug "creating configure.ac"
   if test -f configure.ad.cfs; then
@@ -380,7 +385,7 @@ ad_make_configure_ac()
 
   # Remove any trailing backslashes
   if test -f "$fname"; then
-    cat $fname | sed -e :a -e '/\\$/N; s/[     ]*\\\n//; ta' > configure.ac
+    sed -e :a -e '/\\$/N; s/[  ]*\\\n//; ta' < $fname > configure.ac
   else
     cp -p $fname.tmp configure.ac
   fi
@@ -426,14 +431,16 @@ ad_make_makefile_ams()
     fname=`echo $ff | sed s/\.ad//`
 
     # Header for the Makefile.am
-    echo "# Automatically generated by Autodist $ver from Makefile.ad.  Do not edit." > $fname.am
-    echo "# To make changes edit the $ff file in the source tree." >> $fname.am
-    echo >> $fname.am
-    echo "# Source: $ff" >> $fname.am
-    echo "# Generated: `date` by `whoami`" >> $fname.am
-    echo "# Distribution: $distribution" >> $fname.am
-    echo "# License: $license" >> $fname.am
-    echo >> $fname.am
+  cat > $fname.am <<EOF
+# Automatically generated by Autodist $ver from Makefile.ad.  Do not edit.
+# To make changes edit the $ff file in the source tree.
+
+# Source: $ff
+# Generated: `date` by `whoami`
+# Distribution: $distribution
+# License: $license
+
+EOF
 
     # Run the distribution processing for this Makefile.ad
     ad_debug "Processing $ff to be $fname.am"
@@ -441,7 +448,7 @@ ad_make_makefile_ams()
 
     # Remove any trailing backslashes
     if test -f "$fname.tmp"; then
-      cat $fname.tmp | sed -e :a -e '/\\$/N; s/[       ]*\\\n//; ta' >> $fname.am
+      sed -e :a -e '/\\$/N; s/[        ]*\\\n//; ta' < $fname.tmp >> $fname.am
     else
       cat $ff >> $fname.am
     fi
@@ -468,14 +475,16 @@ ad_process_ads()
     fname=`echo $i | sed s/\.ad//`
 
     # Header
-    echo "# Automatically generated by Autodist $ver.  Do not edit." > $fname
-    echo "# To make changes edit the $i file in the source tree." >> $fname
-    echo >> $fname
-    echo "# Source: $i" >> $fname
-    echo "# Generated: `date` by `whoami`" >> $fname
-    echo "# Distribution: $distribution" >> $fname
-    echo "# License: $license" >> $fname
-    echo >> $fname
+  cat > $fname <<EOF
+# Automatically generated by Autodist $ver.  Do not edit.
+# To make changes edit the $i file in the source tree.
+
+# Source: $i
+# Generated: `date` by `whoami`
+# Distribution: $distribution
+# License: $license
+
+EOF
 
     # Run the distribution processing for this file
     ad_debug "Processing $i to be $fname"
@@ -605,7 +614,7 @@ ad_dist_includes()
       fi
 
       # Recursively call this function with expanded pathnames.  The
-      # reason why we don't let sh by default expand patnames is that
+      # reason why we don't let sh by default expand pathnames is that
       # the include's destination is optional.  If sh expands by default
       # we don't know the destination.  For this reason, we handle the
       # expansion here ourselves.
@@ -826,9 +835,9 @@ ad_makedist()
   fi
 
   # Parse the requested distribution
-  distribution=`cat autodist.dist | grep "dist:" | cut -d: -f2` || exit 1
-  dist_version=`cat autodist.dist | grep "ver:" | cut -d: -f2` || exit 1
-  am_distdir=`cat autodist.dist | grep "distdir:" | cut -d: -f2` || exit 1
+  distribution=`grep "dist:" < autodist.dist | cut -d: -f2` || exit 1
+  dist_version=`grep "ver:" < autodist.dist | cut -d: -f2` || exit 1
+  am_distdir=`grep "distdir:" < autodist.dist | cut -d: -f2` || exit 1
   ad_parse_distribution $distribution false
   ad_process_distdefs
 
@@ -994,11 +1003,11 @@ ad_parse_distribution()
   fi
 
   # Get inherited
-  inhs=`cat $distdir/$1 | sed 's/^[    ]*//' | grep -v "^#" \
+  inhs=`sed 's/^[      ]*//' < $distdir/$1 | grep -v "^#" \
     | grep "inherit " | cut -d' ' -f2 | sort | uniq`
 
   # Get distdefs
-  defs=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
+  defs=`sed 's/^[      ]*//' < $distdir/$1 | grep -v "^#" \
    | grep "define " | cut -d' ' -f2 | sort | uniq`
 
   if test "$inhs" = "" && test "$defs" = ""; then
@@ -1006,23 +1015,23 @@ ad_parse_distribution()
   fi
 
   # Get undefined distdefs
-  undefs=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
+  undefs=`sed 's/^[    ]*//' < $distdir/$1 | grep -v "^#" \
    | grep "undef " | cut -d' ' -f2 | sort | uniq`
 
   # Get includes
-  incs=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
+  incs=`sed 's/^[      ]*//' < $distdir/$1 | grep -v "^#" \
     | grep "include " | sed 's/include / : /'`
 
   # Get excludes
-  excs=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
+  excs=`sed 's/^[      ]*//' < $distdir/$1 | grep -v "^#" \
     | grep "exclude " | cut -d' ' -f2- | sort | uniq`
 
   # Get noprocesses
-  nops=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
+  nops=`sed 's/^[      ]*//' < $distdir/$1 | grep -v "^#" \
     | grep "noprocess " | cut -d' ' -f2- | sort | uniq`
 
   # Get options
-  opts=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
+  opts=`sed 's/^[      ]*//' < $distdir/$1 | grep -v "^#" \
     | grep "option " | cut -d' ' -f2- | sort | uniq`
 
   # Check options
@@ -1059,9 +1068,9 @@ ad_parse_distribution()
   done
 
   # Get license
-  license=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
+  license=`sed 's/^[   ]*//' < $distdir/$1 | grep -v "^#" \
     | grep "license " | cut -d' ' -f2`
-  licenseh=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
+  licenseh=`sed 's/^[  ]*//' < $distdir/$1 | grep -v "^#" \
     | grep "license-header " | sed 's/license-header / : /'`
 
   ad_debug "license: $license"
@@ -1069,7 +1078,7 @@ ad_parse_distribution()
 
   if test x$2 = xfalse; then
     # Get distribution name
-    dname=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
+    dname=`sed 's/^[   ]*//' < $distdir/$1 | grep -v "^#" \
       | grep "name " | cut -d' ' -f2-`
 
     if test "$dname"; then
@@ -1077,7 +1086,7 @@ ad_parse_distribution()
     fi
 
     # Get distribution package name (optional)
-    dpname=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
+    dpname=`sed 's/^[  ]*//' < $distdir/$1 | grep -v "^#" \
      | grep "package " | cut -d' ' -f2`
 
     if test "$dpname"; then
@@ -1087,7 +1096,7 @@ ad_parse_distribution()
     fi
 
     # Get Bug-report email address (optional)
-    bugr=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
+    bugr=`sed 's/^[    ]*//' < $distdir/$1 | grep -v "^#" \
      | grep "bug-report " | cut -d' ' -f2-`
 
     if test "$bugr"; then
@@ -1099,18 +1108,18 @@ ad_parse_distribution()
     ad_debug "bug-report: $bug_report"
 
     # Get hooks (optional)
-    prh=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
+    prh=`sed 's/^[     ]*//' < $distdir/$1 | grep -v "^#" \
      | grep "pre-hook " | cut -d' ' -f2-`
-    poh=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
+    poh=`sed 's/^[     ]*//' < $distdir/$1 | grep -v "^#" \
      | grep "post-hook " | cut -d' ' -f2-`
-    prdh=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
-     | grep "pre-dist-hook " | sed 's/^[       ]*//' | cut -d' ' -f2-`
-    podh=`cat $distdir/$1 | grep -v "^#" \
-     | grep "post-dist-hook " | sed 's/^[       ]*//' | cut -d' ' -f2-`
-    prpdh=`cat $distdir/$1 | sed 's/^[       ]*//' | grep -v "^#" \
-     | grep "pre-process-dist-hook " | sed 's/^[       ]*//' | cut -d' ' -f2-`
-    popdh=`cat $distdir/$1 | grep -v "^#" \
-     | grep "post-process-dist-hook " | sed 's/^[       ]*//' | cut -d' ' -f2-`
+    prdh=`sed 's/^[    ]*//' < $distdir/$1 | grep -v "^#" \
+     | grep "pre-dist-hook " | cut -d' ' -f2-`
+    podh=`sed 's/^[    ]*//' < $distdir/$1 | grep -v "^#" \
+     | grep "post-dist-hook " | cut -d' ' -f2-`
+    prpdh=`sed 's/^[   ]*//' < $distdir/$1 | grep -v "^#" \
+     | grep "pre-process-dist-hook " | cut -d' ' -f2-`
+    popdh=`sed 's/^[   ]*//' < $distdir/$1 | grep -v "^#" \
+     | grep "post-process-dist-hook " | cut -d' ' -f2-`
 
     pre_hooks="$pre_hooks $prh"
     post_hooks="$post_hooks $poh"
@@ -1159,7 +1168,7 @@ ad_process_distdefs()
   do
     echo $i >>autodist.tmp.defs
   done
-  distdefs=`cat autodist.tmp.defs | sort | uniq`
+  distdefs=`sort < autodist.tmp.defs | uniq`
   distdefs=`echo $distdefs`
   rm -f autodist.tmp.defs
 
index 5175a28089171ac288ebeea53cf8c13d3114ad25..f475436d5f060cfec41d8800ec8dd842a00d1fda 100755 (executable)
@@ -22,6 +22,9 @@ Makefile
 )
 AC_OUTPUT
 echo configure.ad ok
+#else !_DIST_DEFAULT
+echo "ERROR"
+exit 1
 #endif _DIST_DEFAULT
 EOF
 
@@ -46,6 +49,9 @@ cat << EOF > subdir/configure.ad
 # subdir/configure.ad fragment
 #ifndef _DIST_NODEF
 echo "_DIST_NODEF ok"
+#else _DIST_NODEF
+echo "ERROR"
+exit 1
 #endif _DIST_NODEF
 EOF
 
index 780b16829f62330989b3e142a0a52712b1c4547e..16e5f9319a1a47b5caa43315e63f2fc06f125da0 100755 (executable)
@@ -22,6 +22,9 @@ Makefile
 )
 AC_OUTPUT
 echo configure.ad ok
+#else !_DIST_TEST
+echo "ERROR"
+exit 1
 #endif _DIST_TEST
 EOF
 
index 92746fb2eb7030969355b2316122bfc0e8ca232a..e70109d94845e707de05c06fd05e5a229f195ea8 100755 (executable)
@@ -35,6 +35,9 @@ Makefile
 )
 AC_OUTPUT
 echo configure.ad ok
+#else !_DIST_TEST
+echo "ERROR"
+exit 1
 #endif _DIST_TEST
 EOF
 
index 2ed0771d39968d4e6c592ef6a535b0b9503d2406..1de80115ebeeafbe8cd6f5f122ddbef70785072e 100755 (executable)
@@ -35,6 +35,9 @@ Makefile
 )
 AC_OUTPUT
 echo configure.ad ok
+#else !_DIST_TEST
+echo "ERROR"
+exit 1
 #endif _DIST_TEST
 EOF
 
@@ -69,10 +72,10 @@ cp -p ../../default distdir || exit 1
 cp -p ../../autodist.conf distdir || exit 1
 
 cat << EOF > distdir/test
-name Test Distribution
-package test-distro
-bug-report test-dist@test.org
-define _DIST_TEST
+       name Test Distribution
+       package test-distro
+       bug-report test-dist@test.org
+       define _DIST_TEST
 EOF
 
 touch README NEWS AUTHORS ChangeLog
index 96493d908fa50567449188308d0afa9f72b41c87..58691e3fd5d7532041dcdfcd2d1016fcbe907ac8 100755 (executable)
@@ -35,6 +35,9 @@ Makefile
 )
 AC_OUTPUT
 echo configure.ad ok
+#else !_DIST_TEST
+echo "ERROR"
+exit 1
 #endif _DIST_TEST
 EOF
 
@@ -69,10 +72,11 @@ cp -p ../../default distdir || exit 1
 cp -p ../../autodist.conf distdir || exit 1
 
 cat << EOF > distdir/test
-name Test Distribution
-package test-distro
+ name Test Distribution
+       package test-distro
 bug-report test-dist@test.org
 define _DIST_TEST
+#define _DIST_NODEF
 EOF
 
 touch README NEWS AUTHORS ChangeLog