[gcalctool] Kill mp_percent as it is trivial
- From: Robert Ancell <rancell src gnome org>
- To: svn-commits-list gnome org
- Subject: [gcalctool] Kill mp_percent as it is trivial
- Date: Sun, 10 May 2009 04:17:22 -0400 (EDT)
commit f0ecbf0eaead8bc415f2dc6544cd54f3429e7eb2
Author: Robert Ancell <robert ancell gmail com>
Date: Sun May 10 18:16:42 2009 +1000
Kill mp_percent as it is trivial
---
shave-libtool.in | 109 ++++++++++++++++++++++++++++++++++++++++++++++++
shave.in | 102 ++++++++++++++++++++++++++++++++++++++++++++
src/ce_parser.y | 2 +-
src/mp-trigonometric.c | 3 +-
src/mp.c | 9 ----
src/mp.h | 3 -
6 files changed, 214 insertions(+), 14 deletions(-)
diff --git a/shave-libtool.in b/shave-libtool.in
new file mode 100644
index 0000000..54ebd69
--- /dev/null
+++ b/shave-libtool.in
@@ -0,0 +1,109 @@
+#!/bin/sh
+#
+# Copyright (c) 2009, Damien Lespiau <damien lespiau gmail com>
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation
+# files (the "Software"), to deal in the Software without
+# restriction, including without limitation the rights to use,
+# copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following
+# conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+
+# we need sed
+SED= SED@
+if test -z "$SED" ; then
+SED=sed
+fi
+
+lt_unmangle ()
+{
+ last_result=`echo $1 | $SED -e 's#.libs/##' -e 's#[0-9a-zA-Z_\-\.]*_la-##'`
+}
+
+# the real libtool to use
+LIBTOOL="$1"
+shift
+
+# if 1, don't print anything, the underlaying wrapper will do it
+pass_though=0
+
+# scan the arguments, keep the right ones for libtool, and discover the mode
+preserved_args=
+
+# have we seen the --tag option of libtool in the command line ?
+tag_seen=0
+
+while test "$#" -gt 0; do
+ opt="$1"
+ shift
+
+ case $opt in
+ --mode=*)
+ mode=`echo $opt | $SED -e 's/[-_a-zA-Z0-9]*=//'`
+ preserved_args="$preserved_args $opt"
+ ;;
+ -o)
+ lt_output="$1"
+ preserved_args="$preserved_args $opt"
+ ;;
+ --tag=*)
+ tag_seen=1
+ preserved_args="$preserved_args $opt"
+ ;;
+ *)
+ preserved_args="$preserved_args $opt"
+ ;;
+ esac
+done
+
+case "$mode" in
+compile)
+ # shave will be called and print the actual CC/CXX/LINK line
+ preserved_args="$preserved_args --shave-mode=$mode"
+ pass_though=1
+ ;;
+link)
+ preserved_args="$preserved_args --shave-mode=$mode"
+ Q=" LINK "
+ ;;
+*)
+ # let's u
+ # echo "*** libtool: Unimplemented mode: $mode, fill a bug report"
+ ;;
+esac
+
+lt_unmangle "$lt_output"
+output=$last_result
+
+# automake does not add a --tag switch to its libtool invocation when
+# assembling a .s file and rely on libtool to infer the right action based
+# on the compiler name. As shave is using CC to hook a wrapper, libtool gets
+# confused. Let's detect these cases and add a --tag=CC option.
+tag=""
+if test $tag_seen -eq 0 -a x"$mode" = xcompile; then
+ tag="--tag=CC"
+fi
+
+if test -z $V; then
+ if test $pass_though -eq 0; then
+ echo "$Q$output"
+ fi
+ $LIBTOOL --silent $tag $preserved_args
+else
+ echo $LIBTOOL $tag $preserved_args
+ $LIBTOOL $tag $preserved_args
+fi
diff --git a/shave.in b/shave.in
new file mode 100644
index 0000000..afed42e
--- /dev/null
+++ b/shave.in
@@ -0,0 +1,102 @@
+#!/bin/sh
+#
+# Copyright (c) 2009, Damien Lespiau <damien lespiau gmail com>
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation
+# files (the "Software"), to deal in the Software without
+# restriction, including without limitation the rights to use,
+# copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following
+# conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+
+# we need sed
+SED= SED@
+if test -z "$SED" ; then
+SED=sed
+fi
+
+lt_unmangle ()
+{
+ last_result=`echo $1 | $SED -e 's#.libs/##' -e 's#[0-9a-zA-Z_\-\.]*_la-##'`
+}
+
+# the tool to wrap (cc, cxx, ar, ranlib, ..)
+tool="$1"
+shift
+
+# the reel tool (to call)
+REEL_TOOL="$1"
+shift
+
+pass_through=0
+preserved_args=
+while test "$#" -gt 0; do
+ opt="$1"
+ shift
+
+ case $opt in
+ --shave-mode=*)
+ mode=`echo $opt | $SED -e 's/[-_a-zA-Z0-9]*=//'`
+ ;;
+ -o)
+ lt_output="$1"
+ preserved_args="$preserved_args $opt"
+ ;;
+ *)
+ preserved_args="$preserved_args $opt"
+ ;;
+ esac
+done
+
+# mode=link is handled in the libtool wrapper
+case "$mode,$tool" in
+link,*)
+ pass_through=1
+ ;;
+*,cxx)
+ Q=" CXX "
+ ;;
+*,cc)
+ Q=" CC "
+ ;;
+*,fc)
+ Q=" FC "
+ ;;
+*,f77)
+ Q=" F77 "
+ ;;
+*,objc)
+ Q=" OBJC "
+ ;;
+*,*)
+ # should not happen
+ Q=" CC "
+ ;;
+esac
+
+lt_unmangle "$lt_output"
+output=$last_result
+
+if test -z $V; then
+ if test $pass_through -eq 0; then
+ echo "$Q$output"
+ fi
+ $REEL_TOOL $preserved_args
+else
+ echo $REEL_TOOL $preserved_args
+ $REEL_TOOL $preserved_args
+fi
diff --git a/src/ce_parser.y b/src/ce_parser.y
index c01d63e..7e0294c 100644
--- a/src/ce_parser.y
+++ b/src/ce_parser.y
@@ -185,7 +185,7 @@ term:
| term '*' term {mp_multiply(&$1, &$3, &$$);}
| 'e' '^' term {mp_epowy(&$3, &$$);}
| term '!' {mp_factorial(&$1, &$$);}
-| term '%' {mp_percent(&$1, &$$);}
+| term '%' {mp_divide_integer(&$1, 100, &$$);}
| '~' term %prec LNEG {
if (!mp_is_natural(&$2)) {
parser_state.error = -PARSER_ERR_BITWISEOP;
diff --git a/src/mp-trigonometric.c b/src/mp-trigonometric.c
index 4393a83..3f97882 100644
--- a/src/mp-trigonometric.c
+++ b/src/mp-trigonometric.c
@@ -315,7 +315,8 @@ mp_atan(const MPNumber *x, MPNumber *z)
i += 2;
MP.t = ts;
mp_add(z, &t2, z);
- if (t2.sign == 0) break;
+ if (t2.sign == 0)
+ break;
}
/* RESTORE T, CORRECT FOR ARGUMENT REDUCTION, AND EXIT */
diff --git a/src/mp.c b/src/mp.c
index d11b8ed..2461558 100644
--- a/src/mp.c
+++ b/src/mp.c
@@ -2313,12 +2313,3 @@ mp_xpowy(const MPNumber *x, const MPNumber *y, MPNumber *z)
mp_pwr(x, y, z);
}
}
-
-void
-mp_percent(const MPNumber *x, MPNumber *z)
-{
- MPNumber t;
-
- mp_set_from_string("0.01", 10, &t);
- mp_multiply(x, &t, z);
-}
diff --git a/src/mp.h b/src/mp.h
index a64ac97..6a811f2 100644
--- a/src/mp.h
+++ b/src/mp.h
@@ -158,9 +158,6 @@ void mp_factorial(const MPNumber *x, MPNumber *z);
/* Sets z = x modulo y */
int mp_modulus_divide(const MPNumber *x, const MPNumber *y, MPNumber *z);
-/* Sets z = x% (i.e. x / 100)*/
-void mp_percent(const MPNumber *x, MPNumber *z);
-
/* Sets z = x^y */
void mp_xpowy(const MPNumber *x, const MPNumber *y, MPNumber *z);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]