[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
HEAD: option splitting in shell
From: |
Ralf Wildenhues |
Subject: |
HEAD: option splitting in shell |
Date: |
Sun, 11 Feb 2007 16:00:20 +0100 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
This improves script time for compile mode by roughly 7% with bash on
GNU/Linux, for C++ sources, without passing --tag=CXX, i.e., letting
func_infer_tag do its job. With this patch, passing --tag=CXX saves
another 4% on top, as it should be. ;-)
This patch conflicts (trivially) with the other two speedup patches;
apply this one second.
Cheers,
Ralf
2007-02-11 Ralf Wildenhues <address@hidden>
* libltdl/m4/libtool.m4 (_LT_PROG_XSI_SHELLFNS): New function
func_opt_split, for XSI and portable shell.
* libltdl/config/ltmain.m4sh: Move the insertion point for the
configure-generated shell functions to before the first option
parsing loop. Rewrite the separation of the long options to use
func_opt_split.
Index: libltdl/m4/libtool.m4
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/m4/libtool.m4,v
retrieving revision 1.90
diff -u -r1.90 libtool.m4
--- libltdl/m4/libtool.m4 5 Feb 2007 19:40:18 -0000 1.90
+++ libltdl/m4/libtool.m4 11 Feb 2007 14:53:07 -0000
@@ -7041,6 +7040,13 @@
func_stripname_result=${func_stripname_result#"${1}"}
func_stripname_result=${func_stripname_result%"${2}"}
}
+
+# func_opt_split
+func_opt_split ()
+{
+ func_opt_split_opt=${1%%=*}
+ func_opt_split_arg=${1#*=}
+}
_LT_EOF
;;
*) # Bourne compatible functions.
@@ -7080,6 +7086,17 @@
| $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;;
esac
}
+
+# sed scripts:
+my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q'
+my_sed_long_arg='1s/^-[[^=]]*=//'
+
+# func_opt_split
+func_opt_split ()
+{
+ func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"`
+ func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"`
+}
_LT_EOF
esac
Index: libltdl/config/ltmain.m4sh
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/config/ltmain.m4sh,v
retrieving revision 1.59
diff -u -r1.59 ltmain.m4sh
--- libltdl/config/ltmain.m4sh 28 Jan 2007 15:13:25 -0000 1.59
+++ libltdl/config/ltmain.m4sh 11 Feb 2007 14:53:10 -0000
@@ -425,14 +425,12 @@
exit $?
}
+# Generated shell functions inserted here.
+
+
# Parse options once, thoroughly. This comes as soon as possible in
# the script to make things like `libtool --version' happen quickly.
{
- # sed scripts:
- my_sed_single_opt='1s/^\(..\).*$/\1/;q'
- my_sed_single_rest='1s/^..\(.*\)$/\1/;q'
- my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q'
- my_sed_long_arg='1s/^-[[^=]]*=//'
# Shorthand for --mode=foo, only valid as the first argument
case $1 in
@@ -525,28 +522,11 @@
# Separate optargs to long options:
-dlopen=*|--mode=*|--tag=*)
- arg=`$ECHO "X$opt" | $Xsed -e "$my_sed_long_arg"`
- opt=`$ECHO "X$opt" | $Xsed -e "$my_sed_long_opt"`
- set dummy "$opt" "$arg" ${1+"$@"}
+ func_opt_split "$opt"
+ set dummy "$func_opt_split_opt" "$func_opt_split_arg"
${1+"$@"}
shift
;;
- # Separate optargs to short options:
-# -x*|-y*)
-# arg=`$ECHO "X$opt" |$Xsed -e "$my_sed_single_rest"`
-# opt=`$ECHO "X$opt" |$Xsed -e "$my_sed_single_opt"`
-# set dummy "$opt" "$arg" ${1+"$@"}
-# shift
-# ;;
-
- # Separate non-argument short options:
-# -z*|-z*|-y*)
-# rest=`$ECHO "X$opt" |$Xsed -e "$my_sed_single_rest"`
-# opt=`$ECHO "X$opt" |$Xsed -e "$my_sed_single_opt"`
-# set dummy "$opt" "-$rest" ${1+"$@"}
-# shift
-# ;;
-
-\?|-h) func_usage ;;
--help) opt_help=: ;;
--version) func_version ;;
- HEAD: option splitting in shell,
Ralf Wildenhues <=