mirror of
https://gitlab.com/rnger/amath
synced 2025-12-08 14:58:29 +00:00
Compare commits
12
Commits
87c65aa678
...
811644f4c7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
811644f4c7 | ||
|
|
d7fe11d56a | ||
|
|
d7add409cd | ||
|
|
d910b98571 | ||
|
|
ea2bf72d7b | ||
|
|
e788fec496 | ||
|
|
ffa586c694 | ||
|
|
0240d3a439 | ||
|
|
93c8fdbef4 | ||
|
|
dd7884bc22 | ||
|
|
65fafb750f | ||
|
|
2164e79aef |
@@ -17,3 +17,4 @@ doxygen.warn
|
||||
*.deb
|
||||
*.zip
|
||||
Makefile
|
||||
/dist
|
||||
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
NAME
|
||||
amath - Simple command line calculator
|
||||
|
||||
SYNOPSIS
|
||||
[ --noansi ] [ --shell | expression ]
|
||||
|
||||
DESCRIPTION
|
||||
amath features a case sensitive command line interface, internal IEEE
|
||||
754 calculations with 15 significant digits, calculations with real and
|
||||
complex numbers, variables and user defined functions, logarithmic and
|
||||
exponential functions, trigonometric and hyperbolic function and
|
||||
selected mathematical constants and rounding functions.
|
||||
|
||||
OPTIONS
|
||||
--noansi
|
||||
Disable output of ANSI escape codes. Default is enable.
|
||||
|
||||
--shell
|
||||
Open an interactive shell.
|
||||
|
||||
OPERATORS
|
||||
+ Mathematical addition
|
||||
- Mathematical subtraction
|
||||
* Mathematical multiplication
|
||||
/ Mathematical division
|
||||
^ Mathematical exponentiation
|
||||
= Assignment of variable values
|
||||
| Absolute value of number
|
||||
|
||||
VARIABLES AND CONSTANT
|
||||
pi Trigonometric constant
|
||||
e Euler's number
|
||||
i Imaginary unit
|
||||
ins Result of last calculation
|
||||
|
||||
MISCELLANEOUS FUNCTIONS
|
||||
abs Absolute value of number
|
||||
sgn Mathematical signum function
|
||||
round Round to nearest integer number
|
||||
trunc Discard fraction part of number
|
||||
floor Mathematical floor function
|
||||
ceil Mathematical ceiling function
|
||||
sqrt Square root function (exp 1/2)
|
||||
cbrt Cube root function (exp 1/3)
|
||||
lb Binary logarithm function (base 2)
|
||||
ln Natural logarithm function (base e)
|
||||
lg Common logarithm function (base 10)
|
||||
|
||||
TRIGONOMETRIC FUNCTIONS
|
||||
sin Trigonometric sine function
|
||||
cos Trigonometric cosine function
|
||||
tan Trigonometric tangent function
|
||||
cot Trigonometric cotangent function
|
||||
sec Trigonometric secant function
|
||||
csc Trigonometric cosecant function
|
||||
crd Trigonometric chord function
|
||||
exsec Trigonometric exsecant function
|
||||
excsc Trigonometric excosecant function
|
||||
arcsin Inverse trigonometric sine function
|
||||
arccos Inverse trigonometric cosine function
|
||||
arctan Inverse trigonometric tangent function
|
||||
arccot Inverse trigonometric cotangent function
|
||||
arcsec Inverse trigonometric secant function
|
||||
arccsc Inverse trigonometric cosecant function
|
||||
arccrd Inverse trigonometric chord function
|
||||
arcexsec Inverse trigonometric exsecant function
|
||||
arcexcsc Inverse trigonometric excosecant function
|
||||
|
||||
HYPERBOLIC FUNCTIONS
|
||||
sinh Hyperbolic sine function
|
||||
cosh Hyperbolic cosine function
|
||||
tanh Hyperbolic tangent function
|
||||
coth Hyperbolic cotangent function
|
||||
sech Hyperbolic secant function
|
||||
csch Hyperbolic cosecant function
|
||||
arcsinh Inverse hyperbolic sine function
|
||||
arccosh Inverse hyperbolic cosine function
|
||||
arctanh Inverse hyperbolic tangent function
|
||||
arccoth Inverse hyperbolic cotangent function
|
||||
arcsech Inverse hyperbolic secant function
|
||||
arccsch Inverse hyperbolic cosecant function
|
||||
|
||||
EARLY TRIGONOMETRIC FUNCTIONS
|
||||
ver Versed sine function
|
||||
vcs Versed cosine function
|
||||
cvs Coversed sine function
|
||||
cvc Coversed cosine function
|
||||
hv Haversed sine function
|
||||
hvc Haversed cosine function
|
||||
hcv Hacoversed sine function
|
||||
hcc Hacoversed cosine function
|
||||
arcver Inverse versed sine function
|
||||
arcvcs Inverse versed cosine function
|
||||
arccvs Inverse coversed sine function
|
||||
arccvc Inverse coversed cosine function
|
||||
archv Inverse haversed sine function
|
||||
archvc Inverse haversed cosine function
|
||||
archcv Inverse hacoversed sine function
|
||||
archcc Inverse hacoversed cosine function
|
||||
|
||||
STATEMENTS
|
||||
about Show about text
|
||||
clear Clear console window
|
||||
def Define function
|
||||
delete Delete variable or function
|
||||
digits Set number of significant digits
|
||||
eval Evaluate arithmetic expression
|
||||
execute Execute statements in a file
|
||||
functions Show list of user defined functions
|
||||
input Change numeral input system
|
||||
help Show basic help text
|
||||
output Change numeral output system
|
||||
list Show content of a directory
|
||||
show Show content of a file
|
||||
load Load variable and functions from file
|
||||
save Save variable and functions to file
|
||||
variables Show list of variables
|
||||
version Show version string
|
||||
license Show copyright and license texts
|
||||
memory Show internal memory usage
|
||||
exit Exit program
|
||||
|
||||
EXIT STATUS
|
||||
amath exits 0 on success and >0 if an error occurs.
|
||||
|
||||
EXAMPLES
|
||||
Add two numbers:
|
||||
$ amath 1.3 + 2.6
|
||||
|
||||
Find cosine of pi/2:
|
||||
$ amath "cos(pi/2)"
|
||||
|
||||
Find square root of minus 25:
|
||||
$ amath "sqrt(-25)"
|
||||
|
||||
Show only 5 digits in the result of a division:
|
||||
$ amath "digits 5;34/11"
|
||||
|
||||
Script block with functions:
|
||||
round(1.5461);round(-1.5461);
|
||||
ceil(43.5461);ceil(-43.5461);
|
||||
floor(39.9531);floor(-39.9531);
|
||||
trunc(23.827);trunc(-23.827);
|
||||
sqrt(100);sqrt(52.23);
|
||||
|
||||
Script block with user defined functions:
|
||||
f(x)=x*2+1;
|
||||
g(y)=y^2+y*1.5+2;
|
||||
a=2;b=3;c=a+b;
|
||||
f(2.2);c+1.1;
|
||||
|
||||
BUGS
|
||||
Please report any other bugs that you encounter via:
|
||||
https://gitlab.com/rnger/amath/issues.
|
||||
|
||||
HOMEPAGE
|
||||
https://amath.innolan.net/
|
||||
|
||||
AUTHORS
|
||||
Written by Carsten Sonne Larsen <cs@innolan.net>. Floating point to
|
||||
string conversion is based on software written by Ryan Juckett. The
|
||||
code in complex calculations is derived from software written by
|
||||
Stephen L. Moshier. The code in MemSet and MemCopy is derived from
|
||||
software contributed to Berkeley by Mike Hibler and Chris Torek.
|
||||
|
||||
January 11 2021 Version 1.9.0
|
||||
@@ -0,0 +1,41 @@
|
||||
Short: Simple command line calculator
|
||||
Author: Carsten Larsen
|
||||
Uploader: carsten.larsen@mail.com
|
||||
Type: misc/math
|
||||
Version: 1.9.0
|
||||
Architecture: m68k-amigaos >= 2.04
|
||||
URL: https://amath.innolan.net
|
||||
|
||||
Features
|
||||
========
|
||||
|
||||
- Case sensitive command line interface
|
||||
- Native IEEE 754 with 15 significant digits
|
||||
- Calculations with real and complex numbers
|
||||
- Variables and user defined functions
|
||||
- Logarithmic and exponential functions
|
||||
- Trigonometric and hyperbolic functions
|
||||
- Mathematical constants and rounding functions
|
||||
- Disk functions to load, save and view content
|
||||
- Comprehensive and easy to use builtin help
|
||||
- Optimized 68000, 68020 and 68030 versions
|
||||
- Unlimited number of ARexx interfaces
|
||||
- Freely distributable sources (BSD license)
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
Open amath in its own window:
|
||||
> amath
|
||||
|
||||
Do a calculation in shell:
|
||||
> amath 1.2+1.4
|
||||
|
||||
Get an interactive prompt in shell:
|
||||
> amath shell
|
||||
|
||||
Show version string:
|
||||
> amath version
|
||||
|
||||
Run regression tests:
|
||||
> amath --test
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,32 @@
|
||||
#! /bin/sh
|
||||
|
||||
# This file is in the public domain, so clarified as of
|
||||
# 2009-05-17 by Arthur David Olson.
|
||||
|
||||
# Tell groff not to emit SGR escape sequences (ANSI color escapes).
|
||||
GROFF_NO_SGR=1
|
||||
export GROFF_NO_SGR
|
||||
|
||||
echo ".am TH
|
||||
.hy 0
|
||||
.na
|
||||
..
|
||||
.rm }H
|
||||
.rm }F" | nroff -man - ${1+"$@"} | perl -ne '
|
||||
binmode STDIN, '\'':encoding(utf8)'\'';
|
||||
binmode STDOUT, '\'':encoding(utf8)'\'';
|
||||
chomp;
|
||||
s/.\010//g;
|
||||
s/\s*$//;
|
||||
if (/^$/) {
|
||||
$sawblank = 1;
|
||||
next;
|
||||
} else {
|
||||
if ($sawblank && $didprint) {
|
||||
print "\n";
|
||||
$sawblank = 0;
|
||||
}
|
||||
print "$_\n";
|
||||
$didprint = 1;
|
||||
}
|
||||
'
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Build Classic AmigaOS distribtion package
|
||||
# This file is public domain
|
||||
#
|
||||
# Project homepage:
|
||||
@@ -11,62 +12,117 @@
|
||||
|
||||
set -e
|
||||
|
||||
rm -f amath.lha
|
||||
rm -Rf amath
|
||||
rm -Rf dist
|
||||
mkdir dist
|
||||
distdir="dist"
|
||||
builddir="tmp"
|
||||
bindir="bin"
|
||||
stamp="202101120000"
|
||||
|
||||
rm -Rf ${distdir}
|
||||
rm -Rf ${builddir}
|
||||
mkdir -p ${builddir}
|
||||
|
||||
# Build binaries
|
||||
./configure --disable-test --disable-pic --cross-compile="m68k-amigaos" CFLAGS="-m68000 -noixemul"
|
||||
make clean
|
||||
make static
|
||||
mv amath dist/amath.000
|
||||
mv amath ${builddir}/amath
|
||||
make clean
|
||||
./configure --disable-test --disable-pic --cross-compile="m68k-amigaos" CFLAGS="-m68020 -noixemul"
|
||||
make static
|
||||
mv amath dist/amath.020
|
||||
mv amath ${builddir}/amath.020
|
||||
make clean
|
||||
./configure --disable-test --disable-pic --cross-compile="m68k-amigaos" CFLAGS="-m68030 -noixemul"
|
||||
make static
|
||||
mv amath dist/amath.030
|
||||
mv amath ${builddir}/amath.030
|
||||
make clean
|
||||
|
||||
# Build test binaries
|
||||
./configure --enable-test --disable-pic --cross-compile="m68k-amigaos" CFLAGS="-m68000 -noixemul"
|
||||
make static
|
||||
mv amath dist/amath-test.000
|
||||
mv amath ${builddir}/amath-test
|
||||
make clean
|
||||
./configure --enable-test --disable-pic --cross-compile="m68k-amigaos" CFLAGS="-m68020 -noixemul"
|
||||
make static
|
||||
mv amath dist/amath-test.020
|
||||
mv amath ${builddir}/amath-test.020
|
||||
make clean
|
||||
./configure --enable-test --disable-pic --cross-compile="m68k-amigaos" CFLAGS="-m68030 -noixemul"
|
||||
make static
|
||||
mv amath dist/amath-test.030
|
||||
mv amath ${builddir}/amath-test.030
|
||||
make clean
|
||||
|
||||
cd dist
|
||||
# Build catalogs
|
||||
make catalogs
|
||||
make clean
|
||||
|
||||
# Build documentation
|
||||
#./build/doc >${builddir}/amath.doc amath.1
|
||||
groff >${builddir}/amath.html amath.1 -mandoc -Thtml
|
||||
|
||||
# Generate hashkeys
|
||||
cd ${builddir}
|
||||
touch hashkeys
|
||||
sha1sum amath.000 >>hashkeys
|
||||
sha1sum amath >>hashkeys
|
||||
sha1sum amath.020 >>hashkeys
|
||||
sha1sum amath.030 >>hashkeys
|
||||
sha1sum amath-test.000 >>hashkeys
|
||||
sha1sum amath-test >>hashkeys
|
||||
sha1sum amath-test.020 >>hashkeys
|
||||
sha1sum amath-test.030 >>hashkeys
|
||||
sha256sum amath.000 >>hashkeys
|
||||
sha256sum amath >>hashkeys
|
||||
sha256sum amath.020 >>hashkeys
|
||||
sha256sum amath.030 >>hashkeys
|
||||
sha256sum amath-test.000 >>hashkeys
|
||||
sha256sum amath-test >>hashkeys
|
||||
sha256sum amath-test.020 >>hashkeys
|
||||
sha256sum amath-test.030 >>hashkeys
|
||||
cd ..
|
||||
|
||||
make catalogs
|
||||
cp LICENSE dist/
|
||||
cp HISTORY dist/
|
||||
# Build distribution directory structure
|
||||
mkdir -m 775 ${distdir}
|
||||
mkdir -m 775 ${distdir}/amath
|
||||
mkdir -m 775 ${distdir}/amath/ARexx
|
||||
mkdir -m 775 ${distdir}/amath/Catalog
|
||||
mkdir -m 775 ${distdir}/amath/Catalog/english
|
||||
mkdir -m 775 ${distdir}/amath/Script
|
||||
mkdir -m 775 ${distdir}/amath/Test
|
||||
|
||||
mkdir dist/script
|
||||
cp script/* dist/script/
|
||||
date -Ru >dist/build_date
|
||||
#uname -srmo >dist/build_host
|
||||
# Install icons
|
||||
install -m 664 ${bindir}/root/*.info ${distdir}/
|
||||
install -m 664 ${bindir}/prog/*.info ${distdir}/amath/
|
||||
install -m 664 ${bindir}/catalog/*.info ${distdir}/amath/Catalog/
|
||||
install -m 664 ${bindir}/script/*.info ${distdir}/amath/Script/
|
||||
|
||||
mv dist amath
|
||||
#lha-ac a amath.lha amath
|
||||
# Install documentation
|
||||
install -m 664 HISTORY ${distdir}/amath/
|
||||
install -m 664 LICENSE ${distdir}/amath/
|
||||
install -m 664 ${builddir}/hashkeys ${distdir}/amath/
|
||||
install -m 664 ${builddir}/amath.html ${distdir}/amath/
|
||||
install -m 664 ${bindir}/amath.doc ${distdir}/amath/
|
||||
install -m 664 ${bindir}/amath.readme ${distdir}/amath/
|
||||
|
||||
# Install scripts
|
||||
install -m 755 arexx/* ${distdir}/amath/ARexx/
|
||||
install -m 755 script/* ${distdir}/amath/Script/
|
||||
|
||||
# Install binaries
|
||||
install -m 755 ${builddir}/amath ${distdir}/amath/
|
||||
install -m 755 ${builddir}/amath.020 ${distdir}/amath/
|
||||
install -m 755 ${builddir}/amath.030 ${distdir}/amath/
|
||||
install -m 755 ${builddir}/amath-test ${distdir}/amath/Test/
|
||||
install -m 755 ${builddir}/amath-test.020 ${distdir}/amath/Test/
|
||||
install -m 755 ${builddir}/amath-test.030 ${distdir}/amath/Test/
|
||||
|
||||
# Install catalogs
|
||||
install -m 755 distcat/catalog/english/*.catalog ${distdir}/amath/Catalog/english/
|
||||
|
||||
# Sign build with date
|
||||
date -Ru >${distdir}/amath/build_date
|
||||
#uname -srmo >${distdir}/amath/build_host
|
||||
|
||||
for f in $(find ${distdir} -name '*'); do touch -amt ${stamp}.00 $f; done
|
||||
|
||||
# Cleanup
|
||||
rm -Rf distcat
|
||||
rm -Rf ${builddir}
|
||||
|
||||
# Install source
|
||||
./buildsrc
|
||||
mv amath-1.9.0 ${distdir}/
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Build source distribtion package
|
||||
# This file is public domain
|
||||
#
|
||||
# Project homepage:
|
||||
@@ -9,13 +10,12 @@
|
||||
# DO NOT USE THIS SCRIPT UNLESS YOU KNOW WHAT YOU ARE DOING !
|
||||
|
||||
version='1.9.0'
|
||||
stamp="202101110000"
|
||||
srcdir="amath-rc"
|
||||
stamp="202101120000"
|
||||
srcdir="."
|
||||
distdir="amath-${version}"
|
||||
cd ..
|
||||
|
||||
rm -f amath-${version}.tar.gz
|
||||
rm -Rf amath-${version}
|
||||
rm -Rf ${distdir}
|
||||
|
||||
mkdir -m 775 ${distdir}
|
||||
mkdir -m 775 ${distdir}/src/
|
||||
|
||||
@@ -1194,10 +1194,10 @@ echo " cd src/cplex && \${MAKE} doc"
|
||||
echo
|
||||
echo "catalogs:"
|
||||
echo " cd build/flexcat && \${MAKE}"
|
||||
echo " \${MKDIR} dist/catalog/english"
|
||||
echo " \${FLXCAT} text/help.cd catalog/english/amath-help.ct CATALOG dist/catalog/english/amath-help.catalog"
|
||||
echo " \${FLXCAT} text/ident.cd catalog/english/amath-ident.ct CATALOG dist/catalog/english/amath-ident.catalog"
|
||||
echo " \${FLXCAT} text/text.cd catalog/english/amath-text.ct CATALOG dist/catalog/english/amath-text.catalog"
|
||||
echo " \${MKDIR} distcat/catalog/english"
|
||||
echo " \${FLXCAT} text/help.cd catalog/english/amath-help.ct CATALOG distcat/catalog/english/amath-help.catalog"
|
||||
echo " \${FLXCAT} text/ident.cd catalog/english/amath-ident.ct CATALOG distcat/catalog/english/amath-ident.catalog"
|
||||
echo " \${FLXCAT} text/text.cd catalog/english/amath-text.ct CATALOG distcat/catalog/english/amath-text.catalog"
|
||||
echo
|
||||
echo "shared-libs:"
|
||||
echo " cd src/lib && \${MAKE} shared"
|
||||
|
||||
+56
-78
@@ -29,104 +29,81 @@
|
||||
|
||||
#ifndef AMATH_H
|
||||
#define AMATH_H
|
||||
/******************************************************************************/
|
||||
#ifdef __AMIGA__
|
||||
# define SYS_NAME "AmigaOS 3"
|
||||
# ifndef AOS3
|
||||
# define AOS3
|
||||
# endif
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
#ifdef __AROS__
|
||||
# define SYS_NAME "Aros"
|
||||
# ifndef AROS
|
||||
# define AROS
|
||||
# endif
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
#ifdef __MORPHOS__
|
||||
|
||||
/* Operating System */
|
||||
#if defined(__MORPHOS__)
|
||||
# define SYS_NAME "MorphOS"
|
||||
# ifndef MORPHOS
|
||||
# define MORPHOS
|
||||
# endif
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
#ifdef __amigaos4__
|
||||
#elif defined(__amigaos4__)
|
||||
# define SYS_NAME "AmigaOS 4"
|
||||
# ifndef AOS4
|
||||
# define AOS4
|
||||
# endif
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
#ifdef __HAIKU__
|
||||
#elif defined(__AMIGA__) || defined(__amigaos3__)
|
||||
# define SYS_NAME "AmigaOS 3"
|
||||
# ifndef AOS3
|
||||
# define AOS3
|
||||
# endif
|
||||
#elif defined(__AROS__)
|
||||
# define SYS_NAME "AROS"
|
||||
# ifndef AROS
|
||||
# define AROS
|
||||
# endif
|
||||
#elif defined(__HAIKU__)
|
||||
# define SYS_NAME "Haiku"
|
||||
# ifndef HAIKU
|
||||
# define HAIKU
|
||||
# endif
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
#ifdef __APPLE__
|
||||
#elif defined(__APPLE__) && defined(__MACH__)
|
||||
# define SYS_NAME "Apple"
|
||||
# ifndef APPLE
|
||||
# define APPLE
|
||||
# endif
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
#ifdef __FreeBSD__
|
||||
#elif defined(__FreeBSD__)
|
||||
# define SYS_NAME "FreeBSD"
|
||||
# ifndef FREEBSD
|
||||
# define FREEBSD
|
||||
# endif
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
#ifdef __NetBSD__
|
||||
#elif defined(__NetBSD__)
|
||||
# define SYS_NAME "NetBSD"
|
||||
# ifndef NETBSD
|
||||
# define NETBSD
|
||||
# endif
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
#ifdef __OpenBSD__
|
||||
#elif defined(__OpenBSD__)
|
||||
# define SYS_NAME "OpenBSD"
|
||||
# ifndef OPENBSD
|
||||
# define OPENBSD
|
||||
# endif
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
#ifdef __DragonFly__
|
||||
#elif defined(__DragonFly__)
|
||||
# define SYS_NAME "DragonFly BSD"
|
||||
# ifndef DRAGONFLY
|
||||
# define DRAGONFLY
|
||||
# endif
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
#ifdef __linux__
|
||||
#elif defined(__linux__)
|
||||
# define SYS_NAME "Linux"
|
||||
# ifndef LINUX
|
||||
# define LINUX
|
||||
# endif
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
#ifdef _WIN32
|
||||
#elif defined(_WIN32)
|
||||
# define SYS_NAME "Windows"
|
||||
# ifndef WINDOWS
|
||||
# define WINDOWS
|
||||
# endif
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
#ifdef _WIN64
|
||||
#elif defined(_WIN64)
|
||||
# define SYS_NAME "Windows 64 bit"
|
||||
# ifndef WINDOWS
|
||||
# define WINDOWS
|
||||
# endif
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
|
||||
#if defined(AOS3) || defined(AOS4) || defined(AROS) || defined (MORPHOS)
|
||||
# ifndef AMIGA
|
||||
# define AMIGA
|
||||
# endif
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
|
||||
#if defined(unix) || defined(__unix__) || defined(__unix)
|
||||
# ifndef UNIX
|
||||
# define UNIX
|
||||
@@ -135,7 +112,7 @@
|
||||
# define SYS_NAME "Unix variant"
|
||||
# endif
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
|
||||
#if defined(HAIKU) || defined(UNIX) || defined(APPLE)
|
||||
# ifndef TERMIOS
|
||||
# define TERMIOS
|
||||
@@ -143,39 +120,38 @@
|
||||
# include <stdint.h>
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
|
||||
#if defined(WINDOWS)
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
|
||||
#if defined(AROS) || defined(MORPHOS) || defined(AOS4)
|
||||
# include <stdint.h>
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
|
||||
#if defined(AOS3)
|
||||
# include <sys/types.h>
|
||||
# define IPTR LONG*
|
||||
# define uintptr_t uint32_t
|
||||
typedef u_int8_t uint8_t;
|
||||
typedef u_int16_t uint16_t;
|
||||
typedef u_int32_t uint32_t;
|
||||
typedef u_int64_t uint64_t;
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
|
||||
#if (__cplusplus <= 199711L && !defined(WINDOWS)) || !defined(__cplusplus)
|
||||
#ifndef nullptr
|
||||
#define nullptr 0
|
||||
#endif
|
||||
# ifndef nullptr
|
||||
# define nullptr 0
|
||||
# endif
|
||||
#elif (__cplusplus <= 199711L) && (defined(__GNUC__) || defined(__GNUG__))
|
||||
#ifndef nullptr
|
||||
#define nullptr 0
|
||||
# ifndef nullptr
|
||||
# define nullptr 0
|
||||
# endif
|
||||
#endif
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
|
||||
#define assert(x)
|
||||
/******************************************************************************/
|
||||
/* Compilers*/
|
||||
|
||||
/* Compilers */
|
||||
#if defined(__clang__)
|
||||
/* Clang */
|
||||
# if defined(__apple_build_version__)
|
||||
@@ -228,7 +204,9 @@ typedef u_int64_t uint64_t;
|
||||
# elif (_MSC_VER == 1900)
|
||||
# define COMP_VERS "14.0"
|
||||
# elif (_MSC_VER > 1900)
|
||||
# define COMP_VERS "15.0+"
|
||||
# define COMP_VERS "15.x"
|
||||
# elif (_MSC_VER > 1920)
|
||||
# define COMP_VERS "16.0+"
|
||||
# else
|
||||
# define str(x) #x
|
||||
# define MSC_VER_STR(x) str(x)
|
||||
@@ -261,11 +239,11 @@ typedef u_int64_t uint64_t;
|
||||
# define COMP_VERS GCC_VER_STR(__GNUC__) DOT GCC_VER_STR(__GNUC_MINOR__)
|
||||
# endif
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
|
||||
#define EMPTYSTRING ""
|
||||
#define SPACE " "
|
||||
#define DOT "."
|
||||
/******************************************************************************/
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#define NEWLINE "\r\n"
|
||||
#elif defined(APPLE)
|
||||
@@ -273,17 +251,17 @@ typedef u_int64_t uint64_t;
|
||||
#else
|
||||
#define NEWLINE "\n"
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
|
||||
#ifndef __cplusplus
|
||||
typedef int bool;
|
||||
#define true 1
|
||||
#define false 0
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
|
||||
#define LONG_BIT 32
|
||||
#define wsize sizeof(unsigned int)
|
||||
#define wmask (wsize - 1)
|
||||
/******************************************************************************/
|
||||
|
||||
#if defined(INTELCPU) || defined(i386) || defined(i486) || \
|
||||
defined(intel) || defined(x86) || defined(i86pc) || \
|
||||
defined(__i386__) || defined(_M_IX86)
|
||||
@@ -295,18 +273,18 @@ typedef int bool;
|
||||
#if defined(__x86_64__) || defined(_M_AMD64)
|
||||
# define TXTCPU "amd64"
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
|
||||
#if defined(__powerpc__) || defined(__powerpc64__)
|
||||
# define TXTCPU "PowerPC"
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
|
||||
#if defined(__arm__) || defined(_M_ARM) || defined(__ARM_ARCH_6__)
|
||||
# define TXTCPU "arm"
|
||||
#endif
|
||||
#if defined(__aarch64__) || defined(_M_ARM64)
|
||||
# define TXTCPU "arm64"
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
|
||||
#if defined(m68060) || defined(mc68060)
|
||||
# define TXTCPU "68060"
|
||||
#elif defined(m68040) || defined(mc68040)
|
||||
@@ -320,33 +298,33 @@ typedef int bool;
|
||||
#elif defined(m68000) || defined(mc68000)
|
||||
# define TXTCPU "68000+"
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
|
||||
#ifndef TXTCPU
|
||||
//#error what cpu is this ?!
|
||||
# define TXTCPU EMPTYSTRING
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
|
||||
#if defined(TXTCPU) && defined(__HAVE_68881__)
|
||||
# define TXTFPU SPACE "FPU"
|
||||
#else
|
||||
# define TXTFPU EMPTYSTRING
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
|
||||
#define TXTARCH TXTCPU TXTFPU
|
||||
#define RELDATESTAMP "(11-01-2021)"
|
||||
#define TXTDOSVERSION "\0$VER: amath 1.90" SPACE RELDATESTAMP SPACE TXTARCH
|
||||
#define TXTTITLE "amath version 1.9.0"
|
||||
#define TXTCOPYRIGHT "(c) 2021 Carsten Sonne Larsen"
|
||||
#define TXTSTARTMSG TXTTITLE SPACE TXTCOPYRIGHT
|
||||
/******************************************************************************/
|
||||
|
||||
#define TXTVERSMSG TXTTITLE SPACE RELDATESTAMP SPACE TXTARCH
|
||||
#define TXTCOMPMSG "Compiled with " COMP_NAME SPACE COMP_VERS
|
||||
/******************************************************************************/
|
||||
|
||||
#ifdef SYS_NAME
|
||||
# define TXTSYSMSG TXTCOMPMSG " for " SYS_NAME
|
||||
# define SYSKNOWN 1
|
||||
#else
|
||||
# define TXTSYSMSG TXTCOMPMSG
|
||||
#endif
|
||||
/******************************************************************************/
|
||||
|
||||
#endif
|
||||
|
||||
+75
-37
@@ -35,18 +35,22 @@
|
||||
#include <exec/memory.h>
|
||||
#include <exec/semaphores.h>
|
||||
#include <clib/exec_protos.h>
|
||||
#define ALLOC_MEM(x) AllocVec(x, MEMF_ANY | MEMF_CLEAR)
|
||||
#define FREE_MEM(x) FreeVec(x)
|
||||
#define Debug(x,y,z)
|
||||
#define ALLOC_LIST(x) AllocVec(x, MEMF_ANY | MEMF_CLEAR)
|
||||
#define FREE_LIST(x) FreeVec(x)
|
||||
#define ALLOC_MEM(x, y) AllocPooledZero(x, y)
|
||||
#define FREE_MEM(x, y, z) FreePooled(x, y, z)
|
||||
#define Debug(x, y, z)
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#define ALLOC_MEM(x) calloc(1L,x)
|
||||
#define FREE_MEM(x) free(x)
|
||||
#define Debug(x,y,z)
|
||||
#define ALLOC_LIST(x) calloc(1L, x)
|
||||
#define FREE_LIST(x) free(x)
|
||||
#define ALLOC_MEM(x, y) calloc(1L, y)
|
||||
#define FREE_MEM(x, y, z) free(y)
|
||||
#define Debug(x, y, z)
|
||||
#endif
|
||||
|
||||
#if defined(__x86_64__) || defined(__aarch64__) || \
|
||||
defined(_M_AMD64) || defined(_M_ARM64) || \
|
||||
defined(_M_AMD64) || defined(_M_ARM64) || \
|
||||
defined(__powerpc64__)
|
||||
#define P64BIT
|
||||
#endif
|
||||
@@ -56,9 +60,9 @@
|
||||
*/
|
||||
struct MemoryBlock
|
||||
{
|
||||
struct MemoryBlock* next;
|
||||
struct MemoryBlock *next;
|
||||
size_t size;
|
||||
void* address;
|
||||
void *address;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -66,7 +70,8 @@ struct MemoryBlock
|
||||
*/
|
||||
struct MemoryList
|
||||
{
|
||||
struct MemoryBlock* first;
|
||||
struct MemoryBlock *first;
|
||||
void *pool;
|
||||
size_t peak;
|
||||
size_t size;
|
||||
long count;
|
||||
@@ -75,28 +80,56 @@ struct MemoryList
|
||||
/**
|
||||
* @brief Global list of allocated memory.
|
||||
*/
|
||||
struct MemoryList* list = nullptr;
|
||||
struct MemoryList *list = nullptr;
|
||||
|
||||
void alloc_error(char*, size_t);
|
||||
void dealloc_error(char*, void*);
|
||||
void alloc_error(char *, size_t);
|
||||
void dealloc_error(char *, void *);
|
||||
|
||||
#if defined(AMIGA)
|
||||
|
||||
static void MemZero(void *address, ULONG size)
|
||||
{
|
||||
char *c = (char *)address;
|
||||
int n = size;
|
||||
do
|
||||
{
|
||||
*c++ = '\0';
|
||||
} while (--n);
|
||||
}
|
||||
|
||||
static void *AllocPooledZero(void *pool, size_t size)
|
||||
{
|
||||
ULONG memSize = (ULONG)size;
|
||||
void *memory = AllocPooled(pool, memSize);
|
||||
if (memory != NULL)
|
||||
{
|
||||
MemZero(memory, memSize);
|
||||
}
|
||||
return memory;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Allocate memory and add it to the global memory list.
|
||||
*/
|
||||
void* AllocMemSafe(size_t size)
|
||||
void *AllocMemSafe(size_t size)
|
||||
{
|
||||
struct MemoryBlock* newblock;
|
||||
struct MemoryBlock *newblock;
|
||||
size_t allocsize;
|
||||
|
||||
if (list == nullptr)
|
||||
{
|
||||
list = (struct MemoryList*)ALLOC_MEM(sizeof(struct MemoryList));
|
||||
list = (struct MemoryList *)ALLOC_LIST(sizeof(struct MemoryList));
|
||||
if (!list)
|
||||
{
|
||||
alloc_error("list", sizeof(struct MemoryList));
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(AMIGA)
|
||||
list->pool = CreatePool(MEMF_ANY, 4096, 512);
|
||||
#endif
|
||||
list->first = nullptr;
|
||||
list->peak = 0;
|
||||
list->size = 0;
|
||||
@@ -104,24 +137,24 @@ void* AllocMemSafe(size_t size)
|
||||
}
|
||||
|
||||
#ifdef P64BIT
|
||||
// Align to bytes of 8
|
||||
allocsize = (size + 7) & ~0x07;
|
||||
// Align to bytes of 8, remove 0 bytes allocations
|
||||
allocsize = (size + 8) & ~0x07;
|
||||
#else
|
||||
// Align to bytes of 4
|
||||
allocsize = (size + 3) & ~0x03;
|
||||
// Align to bytes of 4, remove 0 bytes allocations
|
||||
allocsize = (size + 4) & ~0x03;
|
||||
#endif
|
||||
|
||||
newblock = (struct MemoryBlock*)ALLOC_MEM(sizeof(struct MemoryBlock));
|
||||
if (!newblock)
|
||||
newblock = (struct MemoryBlock *)ALLOC_MEM(list->pool, sizeof(struct MemoryBlock));
|
||||
if (newblock == NULL)
|
||||
{
|
||||
alloc_error("block", sizeof(struct MemoryBlock));
|
||||
return 0;
|
||||
}
|
||||
|
||||
newblock->address = (struct MemoryBlock*)ALLOC_MEM(allocsize);
|
||||
if (!newblock->address)
|
||||
newblock->address = (struct MemoryBlock *)ALLOC_MEM(list->pool, allocsize);
|
||||
if (newblock->address == NULL)
|
||||
{
|
||||
FREE_MEM(newblock);
|
||||
FREE_MEM(list->pool, newblock, sizeof(struct MemoryBlock));
|
||||
alloc_error("memory", allocsize);
|
||||
return 0;
|
||||
}
|
||||
@@ -141,7 +174,7 @@ void* AllocMemSafe(size_t size)
|
||||
return newblock->address;
|
||||
}
|
||||
|
||||
void RemoveMemSafe(void* block, bool deallocate)
|
||||
void RemoveMemSafe(void *block, bool deallocate)
|
||||
{
|
||||
struct MemoryBlock *current, *previous;
|
||||
|
||||
@@ -185,19 +218,19 @@ void RemoveMemSafe(void* block, bool deallocate)
|
||||
|
||||
if (deallocate)
|
||||
{
|
||||
FREE_MEM(current->address);
|
||||
FREE_MEM(list->pool, current->address, current->size);
|
||||
}
|
||||
|
||||
current->address = nullptr;
|
||||
current->next = nullptr;
|
||||
current->size = 0;
|
||||
FREE_MEM(current);
|
||||
FREE_MEM(list->pool, current, sizeof(struct MemoryBlock));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Deallocate memory from the global memory list.
|
||||
*/
|
||||
void FreeMemSafe(void* block)
|
||||
void FreeMemSafe(void *block)
|
||||
{
|
||||
RemoveMemSafe(block, true);
|
||||
}
|
||||
@@ -206,7 +239,7 @@ void FreeMemSafe(void* block)
|
||||
* @brief Detach an allocated memory from the global memory list.
|
||||
* @details The memory block is only detached, not deallocated.
|
||||
*/
|
||||
void DetachMemSafe(void* block)
|
||||
void DetachMemSafe(void *block)
|
||||
{
|
||||
RemoveMemSafe(block, false);
|
||||
}
|
||||
@@ -227,29 +260,34 @@ void FreeAllSafe()
|
||||
while (current != nullptr)
|
||||
{
|
||||
next = current->next;
|
||||
FREE_MEM(current->address);
|
||||
FREE_MEM(current);
|
||||
FREE_MEM(list->pool, current->address, current->size);
|
||||
FREE_MEM(list->pool, current, sizeof(struct MemoryBlock));
|
||||
current = next;
|
||||
}
|
||||
|
||||
FREE_MEM(list);
|
||||
#if defined(AMIGA)
|
||||
DeletePool(list->pool);
|
||||
#endif
|
||||
|
||||
FREE_LIST(list);
|
||||
list = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get memory usage in the global memory list.
|
||||
*/
|
||||
void MemUsage(long* blocks, long* size, long* peak)
|
||||
void MemUsage(long *blocks, long *size, long *peak)
|
||||
{
|
||||
*blocks = list->count;
|
||||
*size = (long)list->size;
|
||||
*peak = (long)list->peak;;
|
||||
*peak = (long)list->peak;
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Log a memory allocation error
|
||||
*/
|
||||
void alloc_error(char* descr, size_t size)
|
||||
void alloc_error(char *descr, size_t size)
|
||||
{
|
||||
Debug("Memory allocation error (%s) with size (%d)\n", descr, size);
|
||||
//if (size == 0)
|
||||
@@ -259,7 +297,7 @@ void alloc_error(char* descr, size_t size)
|
||||
/**
|
||||
* @brief Log a memory deallocation error
|
||||
*/
|
||||
void dealloc_error(char* descr, void* p)
|
||||
void dealloc_error(char *descr, void *p)
|
||||
{
|
||||
Debug("Memory deallocation error (%s) address (%x)\n", descr, p);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ Evaluator::Evaluator(const char* input)
|
||||
{
|
||||
this->input = input;
|
||||
output = new CharBuffer();
|
||||
ResultOnly = false;
|
||||
}
|
||||
|
||||
Evaluator::~Evaluator()
|
||||
@@ -52,6 +53,7 @@ void Evaluator::Evaluate() const
|
||||
output->ClearBuffer();
|
||||
|
||||
Parser* parser = new Parser(input);
|
||||
parser->ResultOnly = ResultOnly;
|
||||
SyntaxNode* node = parser->Parse();
|
||||
delete parser;
|
||||
|
||||
|
||||
+10
-4
@@ -35,14 +35,20 @@
|
||||
class Evaluator
|
||||
{
|
||||
public:
|
||||
explicit Evaluator(const char* input);
|
||||
explicit Evaluator(const char *input);
|
||||
~Evaluator();
|
||||
|
||||
/**
|
||||
* @brief Do not include expression string in evaluation result.
|
||||
*/
|
||||
bool ResultOnly;
|
||||
|
||||
void Evaluate() const;
|
||||
char* GetResult() const;
|
||||
char *GetResult() const;
|
||||
|
||||
private:
|
||||
const char* input;
|
||||
CharBuffer* output;
|
||||
const char *input;
|
||||
CharBuffer *output;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+3
-2
@@ -46,6 +46,7 @@ Parser::Parser(const char* input)
|
||||
token = nullptr;
|
||||
errorNode = nullptr;
|
||||
syntaxError = 0;
|
||||
ResultOnly = false;
|
||||
}
|
||||
|
||||
Parser::~Parser()
|
||||
@@ -224,7 +225,7 @@ SyntaxNode* Parser::ParseStatement()
|
||||
res = new ListFunctionsStatement();
|
||||
break;
|
||||
case symeval:
|
||||
res = new EvalStatement(ParseExpression());
|
||||
res = new EvalStatement(ParseExpression(), ResultOnly);
|
||||
break;
|
||||
default:
|
||||
PutToken();
|
||||
@@ -266,7 +267,7 @@ SyntaxNode* Parser::ParseEvaluation()
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
StatementNode* sta = new EvalStatement(exp);
|
||||
StatementNode* sta = new EvalStatement(exp, ResultOnly);
|
||||
if (exp->IsSilent())
|
||||
{
|
||||
sta = new SilentStatement(sta);
|
||||
|
||||
@@ -52,6 +52,11 @@ public:
|
||||
explicit Parser(const char* input);
|
||||
~Parser();
|
||||
|
||||
/**
|
||||
* @brief Do not include expression string in evaluation result.
|
||||
*/
|
||||
bool ResultOnly;
|
||||
|
||||
/**
|
||||
* @brief Parses the input into a syntax tree.
|
||||
*
|
||||
|
||||
+32
-21
@@ -32,9 +32,10 @@
|
||||
#include "amathc.h"
|
||||
#include "system/program.h"
|
||||
|
||||
EvalStatement::EvalStatement(ExpressionNode* expression) :
|
||||
EvalStatement::EvalStatement(ExpressionNode *expression, bool resultOnly) :
|
||||
StatementNode(), expression(expression)
|
||||
{
|
||||
this->resultOnly = resultOnly;
|
||||
}
|
||||
|
||||
EvalStatement::~EvalStatement()
|
||||
@@ -45,31 +46,41 @@ EvalStatement::~EvalStatement()
|
||||
}
|
||||
}
|
||||
|
||||
char* EvalStatement::Execute()
|
||||
char *EvalStatement::Execute()
|
||||
{
|
||||
Number* result = expression->Evaluate();
|
||||
Number* temp = result->Clone();
|
||||
const char* text = expression->GetText();
|
||||
const char* val = Program->Output->GetText(result);
|
||||
Number *result = expression->Evaluate();
|
||||
Number *temp = result->Clone();
|
||||
const char *val = Program->Output->GetText(result);
|
||||
|
||||
Program->SetLastResult(temp);
|
||||
delete temp;
|
||||
|
||||
output->Empty();
|
||||
output->EnsureSize(
|
||||
StrLen(text) + 3 +
|
||||
StrLen(val) +
|
||||
StrLen(NEWLINE) + 1);
|
||||
if (resultOnly)
|
||||
{
|
||||
output->Empty();
|
||||
output->EnsureSize(StrLen(val) + 1);
|
||||
output->Append(val);
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *text = expression->GetText();
|
||||
|
||||
output->Append(text);
|
||||
output->Append(" = ");
|
||||
output->Append(val);
|
||||
output->Append(NEWLINE);
|
||||
output->Empty();
|
||||
output->EnsureSize(
|
||||
StrLen(text) + 3 +
|
||||
StrLen(val) +
|
||||
StrLen(NEWLINE) + 1);
|
||||
|
||||
output->Append(text);
|
||||
output->Append(" = ");
|
||||
output->Append(val);
|
||||
output->Append(NEWLINE);
|
||||
}
|
||||
|
||||
return output->GetString();
|
||||
}
|
||||
|
||||
SyntaxNode* EvalStatement::GetNext()
|
||||
SyntaxNode *EvalStatement::GetNext()
|
||||
{
|
||||
if (iterator == nullptr)
|
||||
{
|
||||
@@ -80,16 +91,16 @@ SyntaxNode* EvalStatement::GetNext()
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void EvalStatement::Attach(SyntaxNode* node)
|
||||
void EvalStatement::Attach(SyntaxNode *node)
|
||||
{
|
||||
if (expression == nullptr)
|
||||
{
|
||||
expression = static_cast<ExpressionNode*>(node);
|
||||
expression = static_cast<ExpressionNode *>(node);
|
||||
node->SetParent(this);
|
||||
}
|
||||
}
|
||||
|
||||
void EvalStatement::Detach(SyntaxNode* node)
|
||||
void EvalStatement::Detach(SyntaxNode *node)
|
||||
{
|
||||
if (expression == node)
|
||||
{
|
||||
@@ -97,11 +108,11 @@ void EvalStatement::Detach(SyntaxNode* node)
|
||||
}
|
||||
}
|
||||
|
||||
void EvalStatement::Replace(SyntaxNode* n, SyntaxNode* x)
|
||||
void EvalStatement::Replace(SyntaxNode *n, SyntaxNode *x)
|
||||
{
|
||||
if (expression == n)
|
||||
{
|
||||
delete expression;
|
||||
expression = static_cast<ExpressionNode*>(x);
|
||||
expression = static_cast<ExpressionNode *>(x);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
class EvalStatement : public virtual StatementNode
|
||||
{
|
||||
public:
|
||||
explicit EvalStatement(ExpressionNode* expression);
|
||||
explicit EvalStatement(ExpressionNode* expression, bool resultOnly);
|
||||
~EvalStatement();
|
||||
|
||||
char* Execute();
|
||||
@@ -50,6 +50,7 @@ public:
|
||||
|
||||
private:
|
||||
ExpressionNode* expression;
|
||||
bool resultOnly;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -193,15 +193,17 @@ bool AmigaARexx::HandleMessage(struct RexxMsg *message)
|
||||
|
||||
message->rm_Result1 = 0;
|
||||
|
||||
Evaluator *evaluator = new Evaluator(message->rm_Args[0]);
|
||||
evaluator->ResultOnly = true;
|
||||
evaluator->Evaluate();
|
||||
|
||||
if (message->rm_Action & RXFF_RESULT)
|
||||
{
|
||||
Evaluator *evaluator = new Evaluator(message->rm_Args[0]);
|
||||
evaluator->Evaluate();
|
||||
const char *result = evaluator->GetResult();
|
||||
message->rm_Result2 = (LONG)CreateArgstring((STRPTR)result, (LONG)StrLen(result));
|
||||
delete evaluator;
|
||||
}
|
||||
|
||||
delete evaluator;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,11 @@ void AmigaShellConsole::ReadLine()
|
||||
{
|
||||
Flush(Input());
|
||||
FGets(Input(), line, linesize);
|
||||
|
||||
if (CheckSignal(SIGBREAKF_CTRL_C))
|
||||
{
|
||||
exit = true;
|
||||
}
|
||||
}
|
||||
|
||||
void AmigaShellConsole::WriteString(const char* string)
|
||||
|
||||
@@ -104,7 +104,12 @@ char* AmigaLanguage::Translate(identhelpdef *def)
|
||||
|
||||
char AmigaLanguage::GetFractionPoint()
|
||||
{
|
||||
#if defined(STRICT_LOCAL)
|
||||
return locale->loc_DecimalPoint[0];
|
||||
#else
|
||||
// To ensure compatibility, set fraction point to full stop / period
|
||||
return '.';
|
||||
#endif
|
||||
}
|
||||
|
||||
bool AmigaLanguage::CharIsAlNum(long unsigned int character)
|
||||
|
||||
@@ -71,12 +71,12 @@ static struct GfxBase *GfxBase = nullptr;
|
||||
static struct LocaleBase *LocaleBase = nullptr;
|
||||
static struct IntuitionBase *IntuitionBase = nullptr;
|
||||
|
||||
#define ARGS_FORMAT "SHELL/S,NOANSI/S,INPUT/F"
|
||||
#define ARGS_FORMAT "SHELL/S,NOANSI/S,AREXX/S,INPUT/F"
|
||||
|
||||
#if defined(AOS3)
|
||||
#define RDPTR LONG *
|
||||
#else
|
||||
#if defined(AROS)
|
||||
#define RDPTR IPTR *
|
||||
#else
|
||||
#define RDPTR LONG *
|
||||
#endif
|
||||
|
||||
AmigaProgram::AmigaProgram()
|
||||
@@ -90,6 +90,7 @@ AmigaProgram::AmigaProgram()
|
||||
rdargs = nullptr;
|
||||
args.shell = FALSE;
|
||||
args.noansi = FALSE;
|
||||
args.arexx = FALSE;
|
||||
args.input = nullptr;
|
||||
Console = nullptr;
|
||||
}
|
||||
@@ -179,7 +180,14 @@ void AmigaProgram::Start()
|
||||
AmigaARexx *arexx = new AmigaARexx();
|
||||
arexx->Start();
|
||||
|
||||
Console->Start();
|
||||
if (args.arexx)
|
||||
{
|
||||
Wait(SIGBREAKF_CTRL_C);
|
||||
}
|
||||
else
|
||||
{
|
||||
Console->Start();
|
||||
}
|
||||
|
||||
arexx->Stop();
|
||||
delete arexx;
|
||||
|
||||
@@ -37,6 +37,7 @@ struct amathargs
|
||||
{
|
||||
long shell;
|
||||
long noansi;
|
||||
long arexx;
|
||||
char* input;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user