#34: MPFR lib, first attempt

This commit is contained in:
Louis Rubet 2017-04-17 23:10:53 +02:00
parent ccca25ab24
commit 4670aa77c0
19 changed files with 694 additions and 572 deletions

View file

@ -16,6 +16,7 @@ rpn_SOURCES = src/rpn.cpp \
src/rpn-trig.h \
src/stack.h
rpn_LDFLAGS = -Wl,--no-as-needed -lreadline
rpn_CFLAGS = -g
rpn_LDFLAGS = -Wl,--no-as-needed -lreadline -lmpfr
dist_noinst_SCRIPTS = autogen.sh

View file

@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.14.1 from Makefile.am.
# Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -16,7 +16,17 @@
VPATH = @srcdir@
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
@ -79,15 +89,13 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
bin_PROGRAMS = rpn$(EXEEXT)
subdir = .
DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \
$(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/configure $(am__configure_deps) \
$(srcdir)/config.h.in $(dist_noinst_SCRIPTS) depcomp COPYING \
TODO install-sh missing
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
$(am__configure_deps) $(dist_noinst_SCRIPTS) \
$(am__DIST_COMMON)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno config.status.lineno
mkinstalldirs = $(install_sh) -d
@ -173,6 +181,9 @@ ETAGS = etags
CTAGS = ctags
CSCOPE = cscope
AM_RECURSIVE_TARGETS = cscope
am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in AUTHORS \
COPYING ChangeLog INSTALL NEWS README TODO depcomp install-sh \
missing
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
@ -266,6 +277,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@ -289,7 +301,8 @@ rpn_SOURCES = src/rpn.cpp \
src/rpn-trig.h \
src/stack.h
rpn_LDFLAGS = -Wl,--no-as-needed -lreadline
rpn_CFLAGS = -g
rpn_LDFLAGS = -Wl,--no-as-needed -lreadline -lmpfr
dist_noinst_SCRIPTS = autogen.sh
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
@ -311,7 +324,6 @@ $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
@ -539,15 +551,15 @@ dist-xz: distdir
$(am__post_remove_distdir)
dist-tarZ: distdir
@echo WARNING: "Support for shar distribution archives is" \
"deprecated." >&2
@echo WARNING: "Support for distribution archives compressed with" \
"legacy program 'compress' is deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__post_remove_distdir)
dist-shar: distdir
@echo WARNING: "Support for distribution archives compressed with" \
"legacy program 'compress' is deprecated." >&2
@echo WARNING: "Support for shar distribution archives is" \
"deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__post_remove_distdir)
@ -583,17 +595,17 @@ distcheck: dist
esac
chmod -R a-w $(distdir)
chmod u+w $(distdir)
mkdir $(distdir)/_build $(distdir)/_inst
mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst
chmod a-w $(distdir)
test -d $(distdir)/_build || exit 0; \
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& am__cwd=`pwd` \
&& $(am__cd) $(distdir)/_build \
&& ../configure \
&& $(am__cd) $(distdir)/_build/sub \
&& ../../configure \
$(AM_DISTCHECK_CONFIGURE_FLAGS) \
$(DISTCHECK_CONFIGURE_FLAGS) \
--srcdir=.. --prefix="$$dc_install_base" \
--srcdir=../.. --prefix="$$dc_install_base" \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
@ -776,6 +788,8 @@ uninstall-am: uninstall-binPROGRAMS
mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \
uninstall-am uninstall-binPROGRAMS
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.

0
README Normal file
View file

58
aclocal.m4 vendored
View file

@ -1,6 +1,6 @@
# generated automatically by aclocal 1.14.1 -*- Autoconf -*-
# generated automatically by aclocal 1.15 -*- Autoconf -*-
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -20,7 +20,7 @@ You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically 'autoreconf'.])])
# Copyright (C) 2002-2013 Free Software Foundation, Inc.
# Copyright (C) 2002-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -32,10 +32,10 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.])
# generated from the m4 files accompanying Automake X.Y.
# (This private macro should not be called outside this file.)
AC_DEFUN([AM_AUTOMAKE_VERSION],
[am__api_version='1.14'
[am__api_version='1.15'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
m4_if([$1], [1.14.1], [],
m4_if([$1], [1.15], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])
@ -51,14 +51,14 @@ m4_define([_AM_AUTOCONF_VERSION], [])
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.14.1])dnl
[AM_AUTOMAKE_VERSION([1.15])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -103,15 +103,14 @@ _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
# configured tree to be moved without reconfiguration.
AC_DEFUN([AM_AUX_DIR_EXPAND],
[dnl Rely on autoconf to set up CDPATH properly.
AC_PREREQ([2.50])dnl
# expand $ac_aux_dir to an absolute path
am_aux_dir=`cd $ac_aux_dir && pwd`
[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
# Expand $ac_aux_dir to an absolute path.
am_aux_dir=`cd "$ac_aux_dir" && pwd`
])
# AM_CONDITIONAL -*- Autoconf -*-
# Copyright (C) 1997-2013 Free Software Foundation, Inc.
# Copyright (C) 1997-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -142,7 +141,7 @@ AC_CONFIG_COMMANDS_PRE(
Usually this means the macro was only invoked conditionally.]])
fi])])
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -333,7 +332,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
# Generate code to set up dependency tracking. -*- Autoconf -*-
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -409,7 +408,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
# Do all the work for Automake. -*- Autoconf -*-
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -499,8 +498,8 @@ AC_REQUIRE([AC_PROG_MKDIR_P])dnl
# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
# We need awk for the "check" target. The system "awk" is bad on
# some platforms.
# We need awk for the "check" target (and possibly the TAP driver). The
# system "awk" is bad on some platforms.
AC_REQUIRE([AC_PROG_AWK])dnl
AC_REQUIRE([AC_PROG_MAKE_SET])dnl
AC_REQUIRE([AM_SET_LEADING_DOT])dnl
@ -574,6 +573,9 @@ END
AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
fi
fi
dnl The trailing newline in this macro's definition is deliberate, for
dnl backward compatibility and to allow trailing 'dnl'-style comments
dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841.
])
dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not
@ -603,7 +605,7 @@ for _am_header in $config_headers :; do
done
echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -614,7 +616,7 @@ echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_co
# Define $install_sh.
AC_DEFUN([AM_PROG_INSTALL_SH],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
if test x"${install_sh}" != xset; then
if test x"${install_sh+set}" != xset; then
case $am_aux_dir in
*\ * | *\ *)
install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
@ -624,7 +626,7 @@ if test x"${install_sh}" != xset; then
fi
AC_SUBST([install_sh])])
# Copyright (C) 2003-2013 Free Software Foundation, Inc.
# Copyright (C) 2003-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -645,7 +647,7 @@ AC_SUBST([am__leading_dot])])
# Check to see how 'make' treats includes. -*- Autoconf -*-
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -695,7 +697,7 @@ rm -f confinc confmf
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
# Copyright (C) 1997-2013 Free Software Foundation, Inc.
# Copyright (C) 1997-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -734,7 +736,7 @@ fi
# Helper functions for option handling. -*- Autoconf -*-
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -765,7 +767,7 @@ AC_DEFUN([_AM_IF_OPTION],
# Check to make sure that the build environment is sane. -*- Autoconf -*-
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -846,7 +848,7 @@ AC_CONFIG_COMMANDS_PRE(
rm -f conftest.file
])
# Copyright (C) 2009-2013 Free Software Foundation, Inc.
# Copyright (C) 2009-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -906,7 +908,7 @@ AC_SUBST([AM_BACKSLASH])dnl
_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
])
# Copyright (C) 2001-2013 Free Software Foundation, Inc.
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -934,7 +936,7 @@ fi
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
AC_SUBST([INSTALL_STRIP_PROGRAM])])
# Copyright (C) 2006-2013 Free Software Foundation, Inc.
# Copyright (C) 2006-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -953,7 +955,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
# Check how to create a tarball. -*- Autoconf -*-
# Copyright (C) 2004-2013 Free Software Foundation, Inc.
# Copyright (C) 2004-2014 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,

26
configure vendored
View file

@ -651,6 +651,7 @@ infodir
docdir
oldincludedir
includedir
runstatedir
localstatedir
sharedstatedir
sysconfdir
@ -723,6 +724,7 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@ -975,6 +977,15 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
-runstatedir | --runstatedir | --runstatedi | --runstated \
| --runstate | --runstat | --runsta | --runst | --runs \
| --run | --ru | --r)
ac_prev=runstatedir ;;
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
| --run=* | --ru=* | --r=*)
runstatedir=$ac_optarg ;;
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@ -1112,7 +1123,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
libdir localedir mandir
libdir localedir mandir runstatedir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@ -1265,6 +1276,7 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@ -1786,7 +1798,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
am__api_version='1.14'
am__api_version='1.15'
ac_aux_dir=
for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
@ -1987,8 +1999,8 @@ test "$program_suffix" != NONE &&
ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
# expand $ac_aux_dir to an absolute path
am_aux_dir=`cd $ac_aux_dir && pwd`
# Expand $ac_aux_dir to an absolute path.
am_aux_dir=`cd "$ac_aux_dir" && pwd`
if test x"${MISSING+set}" != xset; then
case $am_aux_dir in
@ -2007,7 +2019,7 @@ else
$as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;}
fi
if test x"${install_sh}" != xset; then
if test x"${install_sh+set}" != xset; then
case $am_aux_dir in
*\ * | *\ *)
install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
@ -2326,8 +2338,8 @@ MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
mkdir_p='$(MKDIR_P)'
# We need awk for the "check" target. The system "awk" is bad on
# some platforms.
# We need awk for the "check" target (and possibly the TAP driver). The
# system "awk" is bad on some platforms.
# Always define AMTAR for backward compatibility. Yes, it's still used
# in the wild :-( We should find a proper way to deprecate it ...
AMTAR='$${TAR-tar}'

View file

@ -3,7 +3,7 @@
scriptversion=2013-05-30.07; # UTC
# Copyright (C) 1999-2013 Free Software Foundation, Inc.
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View file

@ -1,7 +1,7 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2011-11-20.07; # UTC
scriptversion=2014-09-12.12; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
@ -41,19 +41,15 @@ scriptversion=2011-11-20.07; # UTC
# This script is compatible with the BSD install script, but was written
# from scratch.
tab=' '
nl='
'
IFS=" "" $nl"
IFS=" $tab$nl"
# set DOITPROG to echo to test this script
# Set DOITPROG to "echo" to test this script.
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit=${DOITPROG-}
if test -z "$doit"; then
doit_exec=exec
else
doit_exec=$doit
fi
doit_exec=${doit:-exec}
# Put in absolute file names if you don't have them in your path;
# or use environment vars.
@ -68,17 +64,6 @@ mvprog=${MVPROG-mv}
rmprog=${RMPROG-rm}
stripprog=${STRIPPROG-strip}
posix_glob='?'
initialize_posix_glob='
test "$posix_glob" != "?" || {
if (set -f) 2>/dev/null; then
posix_glob=
else
posix_glob=:
fi
}
'
posix_mkdir=
# Desired mode of installed file.
@ -97,7 +82,7 @@ dir_arg=
dst_arg=
copy_on_change=false
no_target_directory=
is_target_a_directory=possibly
usage="\
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
@ -137,46 +122,57 @@ while test $# -ne 0; do
-d) dir_arg=true;;
-g) chgrpcmd="$chgrpprog $2"
shift;;
shift;;
--help) echo "$usage"; exit $?;;
-m) mode=$2
case $mode in
*' '* | *' '* | *'
'* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2
exit 1;;
esac
shift;;
case $mode in
*' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2
exit 1;;
esac
shift;;
-o) chowncmd="$chownprog $2"
shift;;
shift;;
-s) stripcmd=$stripprog;;
-t) dst_arg=$2
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
shift;;
-t)
is_target_a_directory=always
dst_arg=$2
# Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
shift;;
-T) no_target_directory=true;;
-T) is_target_a_directory=never;;
--version) echo "$0 $scriptversion"; exit $?;;
--) shift
break;;
--) shift
break;;
-*) echo "$0: invalid option: $1" >&2
exit 1;;
-*) echo "$0: invalid option: $1" >&2
exit 1;;
*) break;;
esac
shift
done
# We allow the use of options -d and -T together, by making -d
# take the precedence; this is for compatibility with GNU install.
if test -n "$dir_arg"; then
if test -n "$dst_arg"; then
echo "$0: target directory not allowed when installing a directory." >&2
exit 1
fi
fi
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
# When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
@ -207,6 +203,15 @@ if test $# -eq 0; then
exit 0
fi
if test -z "$dir_arg"; then
if test $# -gt 1 || test "$is_target_a_directory" = always; then
if test ! -d "$dst_arg"; then
echo "$0: $dst_arg: Is not a directory." >&2
exit 1
fi
fi
fi
if test -z "$dir_arg"; then
do_exit='(exit $ret); exit $ret'
trap "ret=129; $do_exit" 1
@ -223,16 +228,16 @@ if test -z "$dir_arg"; then
*[0-7])
if test -z "$stripcmd"; then
u_plus_rw=
u_plus_rw=
else
u_plus_rw='% 200'
u_plus_rw='% 200'
fi
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
*)
if test -z "$stripcmd"; then
u_plus_rw=
u_plus_rw=
else
u_plus_rw=,u+rw
u_plus_rw=,u+rw
fi
cp_umask=$mode$u_plus_rw;;
esac
@ -269,41 +274,15 @@ do
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
if test -n "$no_target_directory"; then
echo "$0: $dst_arg: Is a directory" >&2
exit 1
if test "$is_target_a_directory" = never; then
echo "$0: $dst_arg: Is a directory" >&2
exit 1
fi
dstdir=$dst
dst=$dstdir/`basename "$src"`
dstdir_status=0
else
# Prefer dirname, but fall back on a substitute if dirname fails.
dstdir=`
(dirname "$dst") 2>/dev/null ||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$dst" : 'X\(//\)[^/]' \| \
X"$dst" : 'X\(//\)$' \| \
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
echo X"$dst" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'
`
dstdir=`dirname "$dst"`
test -d "$dstdir"
dstdir_status=$?
fi
@ -314,74 +293,81 @@ do
if test $dstdir_status != 0; then
case $posix_mkdir in
'')
# Create intermediate dirs using mode 755 as modified by the umask.
# This is like FreeBSD 'install' as of 1997-10-28.
umask=`umask`
case $stripcmd.$umask in
# Optimize common cases.
*[2367][2367]) mkdir_umask=$umask;;
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
# Create intermediate dirs using mode 755 as modified by the umask.
# This is like FreeBSD 'install' as of 1997-10-28.
umask=`umask`
case $stripcmd.$umask in
# Optimize common cases.
*[2367][2367]) mkdir_umask=$umask;;
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
*[0-7])
mkdir_umask=`expr $umask + 22 \
- $umask % 100 % 40 + $umask % 20 \
- $umask % 10 % 4 + $umask % 2
`;;
*) mkdir_umask=$umask,go-w;;
esac
*[0-7])
mkdir_umask=`expr $umask + 22 \
- $umask % 100 % 40 + $umask % 20 \
- $umask % 10 % 4 + $umask % 2
`;;
*) mkdir_umask=$umask,go-w;;
esac
# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
mkdir_mode=-m$mode
else
mkdir_mode=
fi
# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
mkdir_mode=-m$mode
else
mkdir_mode=
fi
posix_mkdir=false
case $umask in
*[123567][0-7][0-7])
# POSIX mkdir -p sets u+wx bits regardless of umask, which
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
posix_mkdir=false
case $umask in
*[123567][0-7][0-7])
# POSIX mkdir -p sets u+wx bits regardless of umask, which
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
# $RANDOM is not portable (e.g. dash); use it when possible to
# lower collision chance
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0
if (umask $mkdir_umask &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
ls_ld_tmpdir=`ls -ld "$tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/d" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
fi
trap '' 0;;
esac;;
# As "mkdir -p" follows symlinks and we work in /tmp possibly; so
# create the $tmpdir first (and fail if unsuccessful) to make sure
# that nobody tries to guess the $tmpdir name.
if (umask $mkdir_umask &&
$mkdirprog $mkdir_mode "$tmpdir" &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
test_tmpdir="$tmpdir/a"
ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
fi
trap '' 0;;
esac;;
esac
if
$posix_mkdir && (
umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
)
then :
else
@ -391,53 +377,51 @@ do
# directory the slow way, step by step, checking for races as we go.
case $dstdir in
/*) prefix='/';;
[-=\(\)!]*) prefix='./';;
*) prefix='';;
/*) prefix='/';;
[-=\(\)!]*) prefix='./';;
*) prefix='';;
esac
eval "$initialize_posix_glob"
oIFS=$IFS
IFS=/
$posix_glob set -f
set -f
set fnord $dstdir
shift
$posix_glob set +f
set +f
IFS=$oIFS
prefixes=
for d
do
test X"$d" = X && continue
test X"$d" = X && continue
prefix=$prefix$d
if test -d "$prefix"; then
prefixes=
else
if $posix_mkdir; then
(umask=$mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
else
case $prefix in
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
*) qprefix=$prefix;;
esac
prefixes="$prefixes '$qprefix'"
fi
fi
prefix=$prefix/
prefix=$prefix$d
if test -d "$prefix"; then
prefixes=
else
if $posix_mkdir; then
(umask=$mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
else
case $prefix in
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
*) qprefix=$prefix;;
esac
prefixes="$prefixes '$qprefix'"
fi
fi
prefix=$prefix/
done
if test -n "$prefixes"; then
# Don't fail if two instances are running concurrently.
(umask $mkdir_umask &&
eval "\$doit_exec \$mkdirprog $prefixes") ||
test -d "$dstdir" || exit 1
obsolete_mkdir_used=true
# Don't fail if two instances are running concurrently.
(umask $mkdir_umask &&
eval "\$doit_exec \$mkdirprog $prefixes") ||
test -d "$dstdir" || exit 1
obsolete_mkdir_used=true
fi
fi
fi
@ -472,15 +456,12 @@ do
# If -C, don't bother to copy if it wouldn't change the file.
if $copy_on_change &&
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
eval "$initialize_posix_glob" &&
$posix_glob set -f &&
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
set -f &&
set X $old && old=:$2:$4:$5:$6 &&
set X $new && new=:$2:$4:$5:$6 &&
$posix_glob set +f &&
set +f &&
test "$old" = "$new" &&
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
then
@ -493,24 +474,24 @@ do
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
{
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
test ! -f "$dst" ||
$doit $rmcmd -f "$dst" 2>/dev/null ||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
} ||
{ echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
}
} &&
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
test ! -f "$dst" ||
$doit $rmcmd -f "$dst" 2>/dev/null ||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
} ||
{ echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
}
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dst"
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dst"
}
fi || exit 1

View file

@ -3,7 +3,7 @@
scriptversion=2013-10-28.13; # UTC
# Copyright (C) 1996-2013 Free Software Foundation, Inc.
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify

View file

@ -336,22 +336,21 @@ static bool get_program(const string& entry, object*& obj, unsigned int& obj_len
static bool get_float(const string& entry, object*& obj, unsigned int& obj_size, string& remaining_entry)
{
static number new_number;
floating_t val;
stringstream token;
char* endptr;
bool ret = false;
token<<entry;
token>>val;
if ( (!token.fail()) && (!token.bad()) )
if (entry.size() > 0)
{
new_number.set(val);
obj = &new_number;
obj_size = sizeof(number);
ret = true;
// remaining string if any
token>>remaining_entry;
if ((mpfr_strtofr(&new_number._value.mpfr, entry.c_str(), &endptr, 0, MPFR_DEF_RND) != -1) && (endptr != entry.c_str()))
{
obj = &new_number;
obj_size = sizeof(number);
ret = true;
// remaining string if any
if (endptr != NULL)
remaining_entry = endptr;
}
}
return ret;
@ -563,8 +562,16 @@ static ret_value parse(const char* entry, program& prog)
// this remaining entry is treated as an entry
if(_obj_from_string(main_entry, obj, obj_size, type, remaining_entry))
{
cout<<"parse->obj = "<<obj<<endl;
prog.push_back(obj, obj_size, type);
_delete_obj_from_string(obj);
if (((object*)prog.back())->_type == cmd_number)
{
cout<<"((number*)prog.back())="<<(void*)prog.back()<<endl;
cout<<" (((number*)prog.back())->_value.mpfr._mpfr_d = "<<((number*)prog.back())->_value.mpfr._mpfr_d<<")"<<endl;
((number*)prog.back())->_value.mpfr._mpfr_d = (mp_limb_t*)((number*)prog.back())->_value.significand;
cout<<" -> (((number*)prog.back())->_value.mpfr._mpfr_d = "<<((number*)prog.back())->_value.mpfr._mpfr_d<<")"<<endl;
}
//_delete_obj_from_string(obj);
}
else
{

View file

@ -20,19 +20,20 @@ void bin()
void rtob()
{
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
binary bin;
bin.set(((integer_t)getf()));
_stack->push_back(&bin, bin.size(), cmd_binary);
//TODO
//MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//binary bin;
//bin.set(((integer_t)getf()));
//_stack->push_back(&bin, bin.size(), cmd_binary);
}
void btor()
{
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_binary);
// TODO
//MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_binary);
putf((floating_t)getb());
//putf((floating_t)getb());
}

View file

@ -5,7 +5,12 @@ int rpn_if(branch& myobj)
// myobj.arg1 = 'if' condition evaluation value
MIN_ARGUMENTS_RET(1, -1);
ARG_MUST_BE_OF_TYPE_RET(0, cmd_number, -1);
myobj.arg1 = ((getf() != 0) ? 1 : 0);
if (mpfr_cmp_si(&((number*)_stack->get_obj(0))->_value.mpfr, 0UL) != 0)
myobj.arg1 = 1;
else
myobj.arg1 = 0;
_stack->pop_back();
return -1;
}
@ -89,7 +94,7 @@ int rpn_next(branch& myobj)
}
// increment then test
myobj.farg1++;
mpfr_add_si(&myobj.farg1.mpfr, &myobj.farg1.mpfr, 1UL, MPFR_DEF_RND);
// for command: increment symbol too
if (start_or_for->arg1 != -1)
@ -134,7 +139,7 @@ int rpn_step(branch& myobj)
}
// increment then test
myobj.farg1 += step;
mpfr_add(&myobj.farg1.mpfr, &myobj.farg1.mpfr, &step.mpfr, MPFR_DEF_RND);
// for command: increment symbol too
if (start_or_for->arg1 != -1)

View file

@ -15,7 +15,7 @@ void verbose()
{
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
g_verbose = (int)getf();
g_verbose = int(getf());
}
void help()
@ -75,7 +75,7 @@ void std()
if (stack_size()>=1)
{
ARG_MUST_BE_OF_TYPE(0, cmd_number);
number::s_default_precision = (int)getf();
number::s_default_precision = int(getf());
}
number::s_current_precision = number::s_default_precision;
number::s_mode = number::std;
@ -89,7 +89,7 @@ void fix()
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
number::s_current_precision = (int)getf();
number::s_current_precision = int(getf());
number::s_mode = number::fix;
cout << setprecision(number::s_current_precision) << fixed;

View file

@ -3,92 +3,103 @@
//
void rpn_e(void)
{
putf(M_E);
//TODO
//putf(M_E);
}
void rpn_log()
{
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
((number*)_stack->get_obj(0))->_value = log10(((number*)_stack->get_obj(0))->_value);
//TODO
//MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value = log10(((number*)_stack->get_obj(0))->_value);
}
void rpn_alog()
{
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
((number*)_stack->get_obj(0))->_value = pow(((number*)_stack->get_obj(0))->_value, 10);
//TODO
//MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value = pow(((number*)_stack->get_obj(0))->_value, 10);
}
void rpn_ln()
{
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
((number*)_stack->get_obj(0))->_value = log(((number*)_stack->get_obj(0))->_value);
//TODO
//MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value = log(((number*)_stack->get_obj(0))->_value);
}
void rpn_exp()
{
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
((number*)_stack->get_obj(0))->_value = exp(((number*)_stack->get_obj(0))->_value);
//TODO
//MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value = exp(((number*)_stack->get_obj(0))->_value);
}
void rpn_sinh()
{
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
((number*)_stack->get_obj(0))->_value = sinh(((number*)_stack->get_obj(0))->_value);
//TODO
//MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value = sinh(((number*)_stack->get_obj(0))->_value);
}
void rpn_asinh()
{
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
//TODO
//MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
floating_t value = ((number*)_stack->get_obj(0))->_value;
if(value>0)
value = log(value + sqrt(value * value + 1));
else
value = -log(-value + sqrt(value * value + 1));
//floating_t value = ((number*)_stack->get_obj(0))->_value;
//if(value>0)
// value = log(value + sqrt(value * value + 1));
//else
// value = -log(-value + sqrt(value * value + 1));
((number*)_stack->get_obj(0))->_value = value;
//((number*)_stack->get_obj(0))->_value = value;
}
void rpn_cosh()
{
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
((number*)_stack->get_obj(0))->_value = cosh(((number*)_stack->get_obj(0))->_value);
//TODO
//MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value = cosh(((number*)_stack->get_obj(0))->_value);
}
void rpn_acosh()
{
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
//TODO
//MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
floating_t value = ((number*)_stack->get_obj(0))->_value;
if(value>0)
value = log(value + sqrt(value * value - 1));
else
value = -log(-value + sqrt(value * value - 1));
//floating_t value = ((number*)_stack->get_obj(0))->_value;
//if(value>0)
// value = log(value + sqrt(value * value - 1));
//else
// value = -log(-value + sqrt(value * value - 1));
((number*)_stack->get_obj(0))->_value = value;
//((number*)_stack->get_obj(0))->_value = value;
}
void rpn_tanh()
{
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
((number*)_stack->get_obj(0))->_value = tanh(((number*)_stack->get_obj(0))->_value);
//TODO
//MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value = tanh(((number*)_stack->get_obj(0))->_value);
}
void rpn_atanh()
{
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
//TODO
//MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
floating_t value = ((number*)_stack->get_obj(0))->_value;
value = (log(1 + value) - log(1 - value)) / 2;
((number*)_stack->get_obj(0))->_value = value;
//floating_t value = ((number*)_stack->get_obj(0))->_value;
//value = (log(1 + value) - log(1 - value)) / 2;
//((number*)_stack->get_obj(0))->_value = value;
}

View file

@ -2,20 +2,22 @@ void plus()
{
MIN_ARGUMENTS(2);
// float
if (IS_ARG_TYPE(0, cmd_number))
{
ARG_MUST_BE_OF_TYPE(1, cmd_number);
//TODO really too slow
putf(getf() + getf());
}
// binary
else if (IS_ARG_TYPE(0, cmd_binary))
{
ARG_MUST_BE_OF_TYPE(1, cmd_binary);
//TODO really too slow
putb(getb() + getb());
}
//TODO
//// float
//if (IS_ARG_TYPE(0, cmd_number))
//{
// ARG_MUST_BE_OF_TYPE(1, cmd_number);
// //TODO really too slow
// putf(getf() + getf());
//}
//// binary
//else if (IS_ARG_TYPE(0, cmd_binary))
//{
// ARG_MUST_BE_OF_TYPE(1, cmd_binary);
// //TODO really too slow
// putb(getb() + getb());
//}
//TODO
#if 0
// string
@ -27,166 +29,177 @@ void plus()
*((ostring*)_stack->back())->_value += second;
}
#endif
else
ERR_CONTEXT(ret_bad_operand_type);
//else
// ERR_CONTEXT(ret_bad_operand_type);
}
void minus()
{
MIN_ARGUMENTS(2);
// float
if (IS_ARG_TYPE(0, cmd_number))
{
ARG_MUST_BE_OF_TYPE(1, cmd_number);
//TODO really too slow
floating_t first = getf();
putf(getf() - first);
}
// binary
else if (IS_ARG_TYPE(0, cmd_binary))
{
ARG_MUST_BE_OF_TYPE(1, cmd_binary);
//TODO really too slow
integer_t first = getb();
putb(getb() - first);
}
else
ERR_CONTEXT(ret_bad_operand_type);
//TODO
//// float
//if (IS_ARG_TYPE(0, cmd_number))
//{
// ARG_MUST_BE_OF_TYPE(1, cmd_number);
// //TODO really too slow
// floating_t first = getf();
// putf(getf() - first);
//}
//// binary
//else if (IS_ARG_TYPE(0, cmd_binary))
//{
// ARG_MUST_BE_OF_TYPE(1, cmd_binary);
// //TODO really too slow
// integer_t first = getb();
// putb(getb() - first);
//}
//else
// ERR_CONTEXT(ret_bad_operand_type);
}
void mul()
{
// float
if (IS_ARG_TYPE(0, cmd_number))
{
ARG_MUST_BE_OF_TYPE(1, cmd_number);
//TODO really too slow
putf(getf() * getf());
}
// binary
else if (IS_ARG_TYPE(0, cmd_binary))
{
ARG_MUST_BE_OF_TYPE(1, cmd_binary);
//TODO really too slow
putb(getb() * getb());
}
else
ERR_CONTEXT(ret_bad_operand_type);
//TODO
//// float
//if (IS_ARG_TYPE(0, cmd_number))
//{
// ARG_MUST_BE_OF_TYPE(1, cmd_number);
// //TODO really too slow
// putf(getf() * getf());
//}
//// binary
//else if (IS_ARG_TYPE(0, cmd_binary))
//{
// ARG_MUST_BE_OF_TYPE(1, cmd_binary);
// //TODO really too slow
// putb(getb() * getb());
//}
//else
// ERR_CONTEXT(ret_bad_operand_type);
}
void div()
{
MIN_ARGUMENTS(2);
//TODO
//MIN_ARGUMENTS(2);
// float
if (IS_ARG_TYPE(0, cmd_number))
{
ARG_MUST_BE_OF_TYPE(1, cmd_number);
//TODO really too slow
//// float
//if (IS_ARG_TYPE(0, cmd_number))
//{
// ARG_MUST_BE_OF_TYPE(1, cmd_number);
// //TODO really too slow
floating_t first = getf();
// arithmetic faults are managed by c++
putf(getf() / first);
}
// binary
else if (IS_ARG_TYPE(0, cmd_binary))
{
ARG_MUST_BE_OF_TYPE(1, cmd_binary);
if (((binary*)_stack->get_obj(0))->_value == 0)
{
ERR_CONTEXT(ret_div_by_zero);
}
else
{
//TODO really too slow
integer_t first = getb();
putb(getb() / first);
}
}
else
ERR_CONTEXT(ret_bad_operand_type);
// floating_t first = getf();
// // arithmetic faults are managed by c++
// putf(getf() / first);
//}
//// binary
//else if (IS_ARG_TYPE(0, cmd_binary))
//{
// ARG_MUST_BE_OF_TYPE(1, cmd_binary);
// if (((binary*)_stack->get_obj(0))->_value == 0)
// {
// ERR_CONTEXT(ret_div_by_zero);
// }
// else
// {
// //TODO really too slow
// integer_t first = getb();
// putb(getb() / first);
// }
//}
//else
// ERR_CONTEXT(ret_bad_operand_type);
}
void neg()
{
MIN_ARGUMENTS(1);
//TODO
//MIN_ARGUMENTS(1);
// float
if (IS_ARG_TYPE(0, cmd_number))
putf(-getf());
// binary
else if (IS_ARG_TYPE(0, cmd_binary))
putb(-getb());
else
ERR_CONTEXT(ret_bad_operand_type);
//// float
//if (IS_ARG_TYPE(0, cmd_number))
// putf(-getf());
//// binary
//else if (IS_ARG_TYPE(0, cmd_binary))
// putb(-getb());
//else
// ERR_CONTEXT(ret_bad_operand_type);
}
void inv()
{
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
//TODO
//MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
// arithmetic faults are managed by c++
putf(1 / getf());
//// arithmetic faults are managed by c++
//putf(1 / getf());
}
void purcent()
{
MIN_ARGUMENTS(2);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
ARG_MUST_BE_OF_TYPE(1, cmd_number);
//TODO
//MIN_ARGUMENTS(2);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//ARG_MUST_BE_OF_TYPE(1, cmd_number);
putf((getf() * getf()) / 100);
//putf((getf() * getf()) / 100);
}
void purcentCH()
{
MIN_ARGUMENTS(2);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
ARG_MUST_BE_OF_TYPE(1, cmd_number);
//TODO
//MIN_ARGUMENTS(2);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//ARG_MUST_BE_OF_TYPE(1, cmd_number);
// arithmetic faults are managed by c++
floating_t first = getf();
putf((100 * first) / getf());
//// arithmetic faults are managed by c++
//floating_t first = getf();
//putf((100 * first) / getf());
}
void power()
{
MIN_ARGUMENTS(2);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
ARG_MUST_BE_OF_TYPE(1, cmd_number);
//TODO
//MIN_ARGUMENTS(2);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//ARG_MUST_BE_OF_TYPE(1, cmd_number);
// arithmetic faults are managed by c++
floating_t first = getf();
putf(powl(getf(), first));
//// arithmetic faults are managed by c++
//floating_t first = getf();
//putf(powl(getf(), first));
}
void squareroot()
{
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
//TODO
//MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
// arithmetic faults are managed by c++
putf(sqrtl(getf()));
//// arithmetic faults are managed by c++
//putf(sqrtl(getf()));
}
void square()
{
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
//TODO
//MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
floating_t first = getf();
putf(first * first);
//floating_t first = getf();
//putf(first * first);
}
void modulo()
{
MIN_ARGUMENTS(2);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
ARG_MUST_BE_OF_TYPE(1, cmd_number);
//TODO
//MIN_ARGUMENTS(2);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//ARG_MUST_BE_OF_TYPE(1, cmd_number);
// arithmetic faults are managed by c++
floating_t first = getf();
putf(fmodl(getf(), first));
//// arithmetic faults are managed by c++
//floating_t first = getf();
//putf(fmodl(getf(), first));
}

View file

@ -77,6 +77,6 @@ void rot(void)
void depth(void)
{
number num;
num.set((floating_t)_stack->size());
num.set((long)_stack->size());
_stack->push_back(&num, num.size(), cmd_number);
}

View file

@ -1,68 +1,74 @@
void sup(void)
{
MIN_ARGUMENTS(2);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
ARG_MUST_BE_OF_TYPE(1, cmd_number);
//TODO
//MIN_ARGUMENTS(2);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//ARG_MUST_BE_OF_TYPE(1, cmd_number);
floating_t first = getf();
putf(getf() > first);
//floating_t first = getf();
//putf(getf() > first);
}
void sup_eq(void)
{
MIN_ARGUMENTS(2);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
ARG_MUST_BE_OF_TYPE(1, cmd_number);
//TODO
//MIN_ARGUMENTS(2);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//ARG_MUST_BE_OF_TYPE(1, cmd_number);
floating_t first = getf();
putf(getf() >= first);
//floating_t first = getf();
//putf(getf() >= first);
}
void inf(void)
{
MIN_ARGUMENTS(2);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
ARG_MUST_BE_OF_TYPE(1, cmd_number);
//TODO
//MIN_ARGUMENTS(2);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//ARG_MUST_BE_OF_TYPE(1, cmd_number);
floating_t first = getf();
putf(getf() < first);
//floating_t first = getf();
//putf(getf() < first);
}
void inf_eq(void)
{
MIN_ARGUMENTS(2);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
ARG_MUST_BE_OF_TYPE(1, cmd_number);
//TODO
//MIN_ARGUMENTS(2);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//ARG_MUST_BE_OF_TYPE(1, cmd_number);
floating_t first = getf();
putf(getf() <= first);
//floating_t first = getf();
//putf(getf() <= first);
}
void diff(void)
{
MIN_ARGUMENTS(2);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
ARG_MUST_BE_OF_TYPE(1, cmd_number);
//TODO
//MIN_ARGUMENTS(2);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//ARG_MUST_BE_OF_TYPE(1, cmd_number);
floating_t first = getf();
putf(getf() != first);
//floating_t first = getf();
//putf(getf() != first);
}
void eq(void)
{
MIN_ARGUMENTS(2);
int type = _stack->get_type(0);
//TODO
//MIN_ARGUMENTS(2);
//int type = _stack->get_type(0);
if (_stack->get_type(1) == type)
{
switch(type)
{
case cmd_number:
{
floating_t first = getf();
putf(getf() == first);
}
break;
//if (_stack->get_type(1) == type)
//{
// switch(type)
// {
// case cmd_number:
// {
// floating_t first = getf();
// putf(getf() == first);
// }
// break;
//TODO
#if 0
case cmd_symbol:
@ -71,62 +77,66 @@ void eq(void)
putf(getn() == first);
}
#endif
break;
default:
_stack->pop_back();
_stack->pop_back();
putf(0);
break;
}
}
else
{
_stack->pop_back();
_stack->pop_back();
putf(0);
}
// break;
// default:
// _stack->pop_back();
// _stack->pop_back();
// putf(0);
// break;
// }
//}
//else
//{
// _stack->pop_back();
// _stack->pop_back();
// putf(0);
//}
}
void test_and(void)
{
MIN_ARGUMENTS(2);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
ARG_MUST_BE_OF_TYPE(1, cmd_number);
//TODO
//MIN_ARGUMENTS(2);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//ARG_MUST_BE_OF_TYPE(1, cmd_number);
floating_t first = getf();
floating_t second = getf();
putf((first != 0) && (second != 0));
//floating_t first = getf();
//floating_t second = getf();
//putf((first != 0) && (second != 0));
}
void test_or(void)
{
MIN_ARGUMENTS(2);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
ARG_MUST_BE_OF_TYPE(1, cmd_number);
//TODO
//MIN_ARGUMENTS(2);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//ARG_MUST_BE_OF_TYPE(1, cmd_number);
floating_t first = getf();
floating_t second = getf();
putf((first != 0) || (second != 0));
//floating_t first = getf();
//floating_t second = getf();
//putf((first != 0) || (second != 0));
}
void test_xor(void)
{
MIN_ARGUMENTS(2);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
ARG_MUST_BE_OF_TYPE(1, cmd_number);
//TODO
//MIN_ARGUMENTS(2);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//ARG_MUST_BE_OF_TYPE(1, cmd_number);
floating_t first = getf();
floating_t second = getf();
putf(((first == 0) && (second != 0)) || ((first != 0) && (second == 0)));
//floating_t first = getf();
//floating_t second = getf();
//putf(((first == 0) && (second != 0)) || ((first != 0) && (second == 0)));
}
void test_not(void)
{
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
//TODO
//MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
floating_t first = getf();
putf((first == 0) ? 1 : 0);
//floating_t first = getf();
//putf((first == 0) ? 1 : 0);
}
void same(void)

View file

@ -3,61 +3,70 @@
//
void pi(void)
{
putf(M_PI);
//TODO
//putf(M_PI);
}
void d2r(void)
{
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
((number*)_stack->get_obj(0))->_value *= M_PI / 360;
//TODO
//MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value *= M_PI / 360;
}
void r2d(void)
{
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
((number*)_stack->get_obj(0))->_value *= 360 / M_PI;
//TODO
//MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value *= 360 / M_PI;
}
void rpn_sin(void)
{
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
((number*)_stack->get_obj(0))->_value = sin(((number*)_stack->get_obj(0))->_value);
//TODO
//MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value = sin(((number*)_stack->get_obj(0))->_value);
}
void rpn_asin(void)
{
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
((number*)_stack->get_obj(0))->_value = asin(((number*)_stack->get_obj(0))->_value);
//TODO
//MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value = asin(((number*)_stack->get_obj(0))->_value);
}
void rpn_cos(void)
{
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
((number*)_stack->get_obj(0))->_value = cos(((number*)_stack->get_obj(0))->_value);
//TODO
//MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value = cos(((number*)_stack->get_obj(0))->_value);
}
void rpn_acos(void)
{
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
((number*)_stack->get_obj(0))->_value = acos(((number*)_stack->get_obj(0))->_value);
//TODO
//MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value = acos(((number*)_stack->get_obj(0))->_value);
}
void rpn_tan(void)
{
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
((number*)_stack->get_obj(0))->_value = tan(((number*)_stack->get_obj(0))->_value);
//TODO
//MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value = tan(((number*)_stack->get_obj(0))->_value);
}
void rpn_atan(void)
{
MIN_ARGUMENTS(1);
ARG_MUST_BE_OF_TYPE(0, cmd_number);
((number*)_stack->get_obj(0))->_value = atan(((number*)_stack->get_obj(0))->_value);
//TODO
//MIN_ARGUMENTS(1);
//ARG_MUST_BE_OF_TYPE(0, cmd_number);
//((number*)_stack->get_obj(0))->_value = atan(((number*)_stack->get_obj(0))->_value);
}

View file

@ -21,6 +21,7 @@
*
*/
#include <stdlib.h>
#include <mpfr.h>
#include <math.h>
extern "C" {
@ -37,6 +38,13 @@ using namespace std;
#include "stack.h"
// MPFR related constants
// 128 bits significand storing length in byters, result of mpfr_custom_get_size (128)
#define MPFR_DEF_FORMAT "%Rf"
#define MPFR_DEF_RND MPFR_RNDN
#define MPFR_128BITS_PREC 128
#define MPFR_128BITS_STORING_LENGTH 16
//
static int g_verbose = 0;
@ -81,13 +89,38 @@ const char* cmd_type_string[cmd_max] = {
"undef", "number", "binary", "string", "symbol", "program", "keyword", "keyword"
};
//
typedef long double floating_t;
// MPFR object
struct floating_t
{
__mpfr_struct mpfr;
char significand[MPFR_128BITS_STORING_LENGTH];
floating_t()
{
mpfr_custom_init(significand, MPFR_128BITS_STORING_LENGTH);
mpfr_custom_init_set(&mpfr, MPFR_NAN_KIND, 0, MPFR_128BITS_PREC, significand);
}
floating_t operator=(const long int val)
{
mpfr_custom_init(significand, MPFR_128BITS_STORING_LENGTH);
mpfr_custom_init_set(&mpfr, MPFR_ZERO_KIND, 0, MPFR_128BITS_PREC, significand);
mpfr_set_si(&mpfr, val, MPFR_DEF_RND);
}
operator int()
{
return (int)mpfr_get_si(&mpfr, MPFR_DEF_RND);
}
};
typedef long long integer_t;
class program;
class object;
class branch;
typedef void (program::*program_fn_t)(void);
typedef union
{
program_fn_t _fn;
@ -102,19 +135,34 @@ struct object
//
void show(ostream& stream = cout);
} __attribute__((packed));
};
struct number : public object
{
number() { _type = cmd_number; }
floating_t _value;
//
void set(floating_t value)
void set(const floating_t& value)
{
_type = cmd_number;
_value = value;
_value.mpfr = value.mpfr;
(void)memcpy(_value.significand, value.significand, sizeof(_value.significand));
}
void set(long value)
{
_type = cmd_number;
_value = (long)value;
}
unsigned int size() { return (unsigned int)sizeof(floating_t); }
//
number operator=(const number& op)
{
number num;
num.set((const floating_t&)op._value);
return num;
}
unsigned int size() { return sizeof(number); }
// representation mode
typedef enum {
@ -124,11 +172,12 @@ struct number : public object
} mode_enum;
static mode_enum s_default_mode;
static mode_enum s_mode;
// precision
static int s_default_precision;
static int s_current_precision;
} __attribute__((packed));
};
number::mode_enum number::s_default_mode = number::std;
number::mode_enum number::s_mode = number::s_default_mode;
int number::s_default_precision = 12;
@ -155,7 +204,7 @@ struct binary : public object
} binary_enum;
static binary_enum s_default_mode;
static binary_enum s_mode;
} __attribute__((packed));
};
binary::binary_enum binary::s_default_mode = binary::dec;
binary::binary_enum binary::s_mode = binary::s_default_mode;
@ -180,7 +229,7 @@ struct ostring : public object
//
unsigned int _len;
char _value[0];
} __attribute__((packed));
};
struct oprogram : public object
{
@ -203,7 +252,7 @@ struct oprogram : public object
//
unsigned int _len;
char _value[0];
} __attribute__((packed));
};
struct symbol : public object
{
@ -228,7 +277,7 @@ struct symbol : public object
bool _auto_eval;
unsigned int _len;
char _value[0];
} __attribute__((packed));
};
struct keyword : public object
{
@ -253,7 +302,7 @@ struct keyword : public object
program_fn_t _fn;
unsigned int _len;
char _value[0];
} __attribute__((packed));
};
struct branch : public object
{
@ -288,37 +337,43 @@ struct branch : public object
bool arg_bool;
unsigned int _len;
char _value[0];
} __attribute__((packed));
};
void object::show(ostream& stream)
{
switch(_type)
{
case cmd_number:
stream << ((number*)this)->_value;
//TODO
//stream << ((number*)this)->_value;
stream<<"number._value.mpfr="<<&((number*)this)->_value.mpfr<<endl;
stream<<"number._value.mpfr._mpfr_d="<<(void*)((number*)this)->_value.mpfr._mpfr_d<<endl;
stream<<"number._value.significand="<<(void*)((number*)this)->_value.significand<<endl;
(void)mpfr_printf(MPFR_DEF_FORMAT, &((number*)this)->_value.mpfr);
break;
case cmd_binary:
{
cout << "# ";
switch(((binary*)this)->s_mode)
{
case binary::dec: stream<<std::right<<std::setw(8)<<std::dec<<((binary*)this)->_value<<" d"; break;
case binary::hex: stream<<std::right<<std::setw(8)<<std::hex<<((binary*)this)->_value<<" h"; break;
case binary::oct: stream<<std::right<<std::setw(8)<<std::oct<<((binary*)this)->_value<<" o"; break;
case binary::bin:
{
string mybin;
for (int i = (int)(log((floating_t)((binary*)this)->_value) / log(2.)); i>=0; i--)
{
if (((binary*)this)->_value & (1 << i))
mybin+='1';
else
mybin+='0';
}
stream<<std::right<<std::setw(20)<<std::oct<<mybin<<" b";
}
break;
}
//TODO
//cout << "# ";
//switch(((binary*)this)->s_mode)
//{
// case binary::dec: stream<<std::right<<std::setw(8)<<std::dec<<((binary*)this)->_value<<" d"; break;
// case binary::hex: stream<<std::right<<std::setw(8)<<std::hex<<((binary*)this)->_value<<" h"; break;
// case binary::oct: stream<<std::right<<std::setw(8)<<std::oct<<((binary*)this)->_value<<" o"; break;
// case binary::bin:
// {
// string mybin;
// for (int i = (int)(log((floating_t)((binary*)this)->_value) / log(2.)); i>=0; i--)
// {
// if (((binary*)this)->_value & (1 << i))
// mybin+='1';
// else
// mybin+='0';
// }
// stream<<std::right<<std::setw(20)<<std::oct<<mybin<<" b";
// }
// break;
//}
}
break;
case cmd_string:

View file

@ -44,6 +44,7 @@ public:
_base = (char*)realloc(_base, _total_size);
}
cout<<"current = "<<(void*)_current<<", index is "<<_count<<endl;
if (!dont_copy)
memcpy(_current, obj, size);
_vlen.push_back(size);