Compare commits

...

24 Commits

Author SHA1 Message Date
Carsten Sonne Larsen 811644f4c7 Zero out allocated memory 2021-01-30 17:42:13 +01:00
Carsten Sonne Larsen d7fe11d56a Take advantage of memory pools 2021-01-30 17:00:55 +01:00
Carsten Sonne Larsen d7add409cd Identify systems more uniquely 2021-01-17 11:13:42 +01:00
Carsten Sonne Larsen d910b98571 Cleanup and avoid OS conflicts (REQ #3) 2021-01-15 15:56:07 +01:00
Carsten Sonne Larsen ea2bf72d7b MorphOS compatibility (REQ #4) 2021-01-15 15:49:26 +01:00
Carsten Sonne Larsen e788fec496 ARexx only instance 2021-01-15 00:21:28 +01:00
Carsten Sonne Larsen ffa586c694 Allow to quit console with CTRL + C 2021-01-15 00:20:47 +01:00
Carsten Sonne Larsen 0240d3a439 Only show result when using ARexx 2021-01-15 00:01:10 +01:00
Carsten Sonne Larsen 93c8fdbef4 To ensure compatibility, set fraction point to full stop / period 2021-01-14 23:51:15 +01:00
Carsten Sonne Larsen dd7884bc22 Cleanup after building catalogs 2021-01-12 15:03:13 +01:00
Carsten Sonne Larsen 65fafb750f Improved install script 2021-01-12 14:31:35 +01:00
Carsten Sonne Larsen 2164e79aef Distribution files 2021-01-12 14:30:49 +01:00
Carsten Sonne Larsen 87c65aa678 Include Debian build in source 2021-01-11 22:30:56 +01:00
Carsten Sonne Larsen 2c9e8bece3 Update copyright text 2021-01-11 22:30:27 +01:00
Carsten Sonne Larsen ee26a57960 Release 1.9.0 2021-01-11 21:10:34 +01:00
Carsten Sonne Larsen 538ad4ac23 ARexx test script 2021-01-11 21:01:49 +01:00
Carsten Sonne Larsen 524f83f22f Cleanup Amiga specific code 2021-01-11 20:59:15 +01:00
Carsten Sonne Larsen 9e712377a4 Update copyright 2021-01-11 20:37:42 +01:00
Carsten Sonne Larsen 6eb56b056e ARexx support 2021-01-11 20:33:26 +01:00
Carsten Sonne Larsen 3a52c27a9c new AppendNumber method 2021-01-11 20:32:07 +01:00
Carsten Larsen f8cf191a46 Fix PowerPC build 2018-10-31 20:40:07 +01:00
Carsten Sonne Larsen aeb7f2e92c Detect system name 2018-08-12 23:22:44 +02:00
Carsten Sonne Larsen 49b36ce2a3 Remove search option 2018-08-12 23:22:14 +02:00
Carsten Sonne Larsen f7de7b1447 Update links 2018-08-12 23:21:37 +02:00
441 changed files with 2363 additions and 1545 deletions

1
.gitignore vendored
View File

@ -17,3 +17,4 @@ doxygen.warn
*.deb *.deb
*.zip *.zip
Makefile Makefile
/dist

19
.vscode/c_cpp_properties.json vendored Normal file
View File

@ -0,0 +1,19 @@
{
"configurations": [
{
"name": "amiga",
"includePath": [
"/opt/amiga/m68k-amigaos/ndk-include/",
"/opt/amiga/m68k-amigaos/clib2/include/",
"${workspaceFolder}/src/lib/"
],
"defines": ["AMIGA"],
"compilerPath": "/opt/amiga/bin/m68k-amigaos-gcc",
"cStandard": "c99",
"cppStandard": "c++98",
"intelliSenseMode": "${default}",
"compilerArgs": []
}
],
"version": 4
}

View File

@ -1,5 +1,8 @@
amath release history amath release history
v1.9.0 January 11 2021
- AmigaOS ARexx interface.
v1.8.5 August 07 2018 v1.8.5 August 07 2018
- Fix build on compilers with broken endian detection. - Fix build on compilers with broken endian detection.

View File

@ -1,5 +1,5 @@
Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
Copyright (c) 2007 The NetBSD Foundation, Inc. Copyright (c) 2007 The NetBSD Foundation, Inc.
Copyright (c) 1990, 1993 The Regents of the University of California. Copyright (c) 1990, 1993 The Regents of the University of California.
All rights reserved. All rights reserved.

View File

@ -1,4 +1,4 @@
.\" Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> .\" Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
.\" All rights reserved. .\" All rights reserved.
.\" .\"
.\" Redistribution and use in source and binary forms, with or without .\" Redistribution and use in source and binary forms, with or without
@ -20,7 +20,7 @@
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.TH amath 1 "Version 1.8.5" "August 07 2018" .TH amath 1 "Version 1.9.0" "January 11 2021"
.SH NAME .SH NAME
amath \- Simple command line calculator amath \- Simple command line calculator
.SH SYNOPSIS .SH SYNOPSIS

View File

@ -1,7 +1,7 @@
DOXYFILE_ENCODING = UTF-8 DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "amath" PROJECT_NAME = "amath"
PROJECT_NUMBER = "1.8.5" PROJECT_NUMBER = "1.9.0"
PROJECT_BRIEF = "Simple command line calculator" PROJECT_BRIEF = "Simple command line calculator"
PROJECT_LOGO = PROJECT_LOGO =
OUTPUT_DIRECTORY = ../amath-doc OUTPUT_DIRECTORY = ../amath-doc
@ -156,12 +156,12 @@ EXT_LINKS_IN_WINDOW = NO
FORMULA_FONTSIZE = 10 FORMULA_FONTSIZE = 10
FORMULA_TRANSPARENT = YES FORMULA_TRANSPARENT = YES
USE_MATHJAX = NO USE_MATHJAX = NO
SEARCHENGINE = YES SEARCHENGINE = NO
SERVER_BASED_SEARCH = NO SERVER_BASED_SEARCH = NO
EXTERNAL_SEARCH = NO EXTERNAL_SEARCH = NO
SEARCHDATA_FILE = searchdata.xml SEARCHDATA_FILE = searchdata.xml
GENERATE_MAN = YES GENERATE_MAN = NO
MAN_OUTPUT = man MAN_OUTPUT = man
MAN_EXTENSION = .3 MAN_EXTENSION = .3
MAN_SUBDIR = MAN_SUBDIR =

4
arexx/test.rx Normal file
View File

@ -0,0 +1,4 @@
/* Test program */
Options RESULTS
Address AMATH.1 '1.1+1.8'
SAY (RESULT)

166
bin/amath.doc Normal file
View File

@ -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

41
bin/amath.readme Normal file
View File

@ -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

BIN
bin/catalog/english.info Normal file

Binary file not shown.

BIN
bin/prog/Catalog.info Normal file

Binary file not shown.

BIN
bin/prog/HISTORY.info Normal file

Binary file not shown.

BIN
bin/prog/LICENSE.info Normal file

Binary file not shown.

BIN
bin/prog/Script.info Normal file

Binary file not shown.

BIN
bin/prog/Test.info Normal file

Binary file not shown.

BIN
bin/prog/amath.020.info Normal file

Binary file not shown.

BIN
bin/prog/amath.030.info Normal file

Binary file not shown.

BIN
bin/prog/amath.doc.info Normal file

Binary file not shown.

BIN
bin/prog/amath.info Normal file

Binary file not shown.

BIN
bin/root/amath.info Normal file

Binary file not shown.

BIN
bin/script/complex1.info Normal file

Binary file not shown.

BIN
bin/script/complex2.info Normal file

Binary file not shown.

BIN
bin/script/complex3.info Normal file

Binary file not shown.

BIN
bin/script/function1.info Normal file

Binary file not shown.

BIN
bin/script/function2.info Normal file

Binary file not shown.

BIN
bin/script/function3.info Normal file

Binary file not shown.

BIN
bin/script/operators.info Normal file

Binary file not shown.

BIN
bin/script/userfuncs.info Normal file

Binary file not shown.

BIN
bin/script/variables.info Normal file

Binary file not shown.

32
build/doc Executable file
View File

@ -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;
}
'

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright {c} 2014-2018 Carsten Sonne Larsen <cs@innolan.net> # Copyright {c} 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -30,7 +30,7 @@
set -e set -e
version="1.8.5" version="1.9.0"
build_package () { build_package () {
@ -105,7 +105,7 @@ echo "Upstream-Name: amath"
echo "Source: https://amath.innolan.net" echo "Source: https://amath.innolan.net"
echo echo
echo "Files: *" echo "Files: *"
echo "Copyright: 2014-2018 Carsten Sonne Larsen <cs@innolan.net>" echo "Copyright: 2014-2021 Carsten Sonne Larsen <cs@innolan.net>"
echo " 2007 The NetBSD Foundation, Inc." echo " 2007 The NetBSD Foundation, Inc."
echo " 1990, 1993 The Regents of the University of California." echo " 1990, 1993 The Regents of the University of California."
echo "License: BSD-2-Clause" echo "License: BSD-2-Clause"

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright {c} 2014-2018 Carsten Sonne Larsen <cs@innolan.net> # Copyright {c} 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -32,7 +32,7 @@
set -e set -e
version="1.8.5" version="1.9.0"
build_package () { build_package () {
@ -149,7 +149,7 @@ echo "Upstream-Name: amath-dev"
echo "Source: https://amath.innolan.net" echo "Source: https://amath.innolan.net"
echo echo
echo "Files: *" echo "Files: *"
echo "Copyright: 2014-2018 Carsten Sonne Larsen <cs@innolan.net>" echo "Copyright: 2014-2021 Carsten Sonne Larsen <cs@innolan.net>"
echo " 2007 The NetBSD Foundation, Inc." echo " 2007 The NetBSD Foundation, Inc."
echo " 1990, 1993 The Regents of the University of California." echo " 1990, 1993 The Regents of the University of California."
echo "License: BSD-2-Clause" echo "License: BSD-2-Clause"

107
builddist
View File

@ -1,69 +1,128 @@
#!/bin/sh #!/bin/sh
# #
# Build Classic AmigaOS distribtion package
# This file is public domain # This file is public domain
# #
# Project homepage: # Project homepage:
# https://amath.innolan.net # https://amath.innolan.net
# #
# Add compiler path before invoking. Fx:
# export PATH="/opt/m68k-amigaos/bin/:$PATH"
set -e set -e
rm -f amath.lha distdir="dist"
rm -Rf amath builddir="tmp"
rm -Rf dist bindir="bin"
mkdir dist 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" ./configure --disable-test --disable-pic --cross-compile="m68k-amigaos" CFLAGS="-m68000 -noixemul"
make clean make clean
make static make static
mv amath dist/amath.000 mv amath ${builddir}/amath
make clean make clean
./configure --disable-test --disable-pic --cross-compile="m68k-amigaos" CFLAGS="-m68020 -noixemul" ./configure --disable-test --disable-pic --cross-compile="m68k-amigaos" CFLAGS="-m68020 -noixemul"
make static make static
mv amath dist/amath.020 mv amath ${builddir}/amath.020
make clean make clean
./configure --disable-test --disable-pic --cross-compile="m68k-amigaos" CFLAGS="-m68030 -noixemul" ./configure --disable-test --disable-pic --cross-compile="m68k-amigaos" CFLAGS="-m68030 -noixemul"
make static make static
mv amath dist/amath.030 mv amath ${builddir}/amath.030
make clean make clean
# Build test binaries
./configure --enable-test --disable-pic --cross-compile="m68k-amigaos" CFLAGS="-m68000 -noixemul" ./configure --enable-test --disable-pic --cross-compile="m68k-amigaos" CFLAGS="-m68000 -noixemul"
make static make static
mv amath dist/amath-test.000 mv amath ${builddir}/amath-test
make clean make clean
./configure --enable-test --disable-pic --cross-compile="m68k-amigaos" CFLAGS="-m68020 -noixemul" ./configure --enable-test --disable-pic --cross-compile="m68k-amigaos" CFLAGS="-m68020 -noixemul"
make static make static
mv amath dist/amath-test.020 mv amath ${builddir}/amath-test.020
make clean make clean
./configure --enable-test --disable-pic --cross-compile="m68k-amigaos" CFLAGS="-m68030 -noixemul" ./configure --enable-test --disable-pic --cross-compile="m68k-amigaos" CFLAGS="-m68030 -noixemul"
make static make static
mv amath dist/amath-test.030 mv amath ${builddir}/amath-test.030
make clean 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 touch hashkeys
sha1sum amath.000 >>hashkeys sha1sum amath >>hashkeys
sha1sum amath.020 >>hashkeys sha1sum amath.020 >>hashkeys
sha1sum amath.030 >>hashkeys sha1sum amath.030 >>hashkeys
sha1sum amath-test.000 >>hashkeys sha1sum amath-test >>hashkeys
sha1sum amath-test.020 >>hashkeys sha1sum amath-test.020 >>hashkeys
sha1sum amath-test.030 >>hashkeys sha1sum amath-test.030 >>hashkeys
sha256sum amath.000 >>hashkeys sha256sum amath >>hashkeys
sha256sum amath.020 >>hashkeys sha256sum amath.020 >>hashkeys
sha256sum amath.030 >>hashkeys sha256sum amath.030 >>hashkeys
sha256sum amath-test.000 >>hashkeys sha256sum amath-test >>hashkeys
sha256sum amath-test.020 >>hashkeys sha256sum amath-test.020 >>hashkeys
sha256sum amath-test.030 >>hashkeys sha256sum amath-test.030 >>hashkeys
cd .. cd ..
make catalogs # Build distribution directory structure
cp LICENSE dist/ mkdir -m 775 ${distdir}
cp HISTORY dist/ 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 # Install icons
cp script/* dist/script/ install -m 664 ${bindir}/root/*.info ${distdir}/
date -Ru >dist/build_date install -m 664 ${bindir}/prog/*.info ${distdir}/amath/
#uname -srmo >dist/build_host install -m 664 ${bindir}/catalog/*.info ${distdir}/amath/Catalog/
install -m 664 ${bindir}/script/*.info ${distdir}/amath/Script/
mv dist amath # Install documentation
#lha-ac a amath.lha amath 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}/

View File

@ -1,5 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Build source distribtion package
# This file is public domain # This file is public domain
# #
# Project homepage: # Project homepage:
@ -8,14 +9,13 @@
# DO NOT USE THIS SCRIPT UNLESS YOU KNOW WHAT YOU ARE DOING ! # DO NOT USE THIS SCRIPT UNLESS YOU KNOW WHAT YOU ARE DOING !
version='1.8.5' version='1.9.0'
stamp="201808070000" stamp="202101120000"
srcdir="amath-rc" srcdir="."
distdir="amath-${version}" distdir="amath-${version}"
cd ..
rm -f amath-${version}.tar.gz rm -f amath-${version}.tar.gz
rm -Rf amath-${version} rm -Rf ${distdir}
mkdir -m 775 ${distdir} mkdir -m 775 ${distdir}
mkdir -m 775 ${distdir}/src/ mkdir -m 775 ${distdir}/src/
@ -56,6 +56,7 @@ install -m 664 ${srcdir}/LICENSE ${distdir}/
install -m 664 ${srcdir}/README ${distdir}/ install -m 664 ${srcdir}/README ${distdir}/
install -m 664 ${srcdir}/amath.1 ${distdir}/ install -m 664 ${srcdir}/amath.1 ${distdir}/
install -m 775 ${srcdir}/configure ${distdir}/ install -m 775 ${srcdir}/configure ${distdir}/
install -m 775 ${srcdir}/builddeb ${distdir}/
install -m 775 ${srcdir}/builddist ${distdir}/ install -m 775 ${srcdir}/builddist ${distdir}/
install -m 775 ${srcdir}/buildwin ${distdir}/ install -m 775 ${srcdir}/buildwin ${distdir}/

View File

@ -8,7 +8,7 @@
set -e set -e
version="1.8.5" version="1.9.0"
echo "Building amath ${version} for Windows ..." echo "Building amath ${version} for Windows ..."

View File

@ -2,7 +2,7 @@
## language english ## language english
## codeset 0 ## codeset 0
; ############################################################################# ; #############################################################################
; Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> ; Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
; All rights reserved. ; All rights reserved.
; ;
; Redistribution and use in source and binary forms, with or without ; Redistribution and use in source and binary forms, with or without

View File

@ -2,7 +2,7 @@
## language english ## language english
## codeset 0 ## codeset 0
; ############################################################################# ; #############################################################################
; Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> ; Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
; All rights reserved. ; All rights reserved.
; ;
; Redistribution and use in source and binary forms, with or without ; Redistribution and use in source and binary forms, with or without

13
configure vendored
View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# Copyright {c} 2014-2018 Carsten Sonne Larsen <cs@innolan.net> # Copyright {c} 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -27,7 +27,7 @@
set -e set -e
version="1.8.5" version="1.9.0"
clang=false clang=false
debugsym=false debugsym=false
@ -306,6 +306,7 @@ values.cpp
viewer.cpp viewer.cpp
' '
SYSSRCS=' SYSSRCS='
amiga_arexx.cpp
console.cpp console.cpp
console_amiga.cpp console_amiga.cpp
console_stdc.cpp console_stdc.cpp
@ -1193,10 +1194,10 @@ echo " cd src/cplex && \${MAKE} doc"
echo echo
echo "catalogs:" echo "catalogs:"
echo " cd build/flexcat && \${MAKE}" echo " cd build/flexcat && \${MAKE}"
echo " \${MKDIR} dist/catalog/english" echo " \${MKDIR} distcat/catalog/english"
echo " \${FLXCAT} text/help.cd catalog/english/amath-help.ct CATALOG dist/catalog/english/amath-help.catalog" 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 dist/catalog/english/amath-ident.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 dist/catalog/english/amath-text.catalog" echo " \${FLXCAT} text/text.cd catalog/english/amath-text.ct CATALOG distcat/catalog/english/amath-text.catalog"
echo echo
echo "shared-libs:" echo "shared-libs:"
echo " cd src/lib && \${MAKE} shared" echo " cd src/lib && \${MAKE} shared"

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -29,61 +29,90 @@
#ifndef AMATH_H #ifndef AMATH_H
#define AMATH_H #define AMATH_H
/******************************************************************************/
#ifdef __AMIGA__ /* Operating System */
# ifndef AOS3 #if defined(__MORPHOS__)
# define AOS3 # define SYS_NAME "MorphOS"
# endif
#endif
/******************************************************************************/
#ifdef __AROS__
# ifndef AROS
# define AROS
# endif
#endif
/******************************************************************************/
#ifdef __MORPHOS__
# ifndef MORPHOS # ifndef MORPHOS
# define MORPHOS # define MORPHOS
# endif # endif
#endif #elif defined(__amigaos4__)
/******************************************************************************/ # define SYS_NAME "AmigaOS 4"
#ifdef __amigaos4__
# ifndef AOS4 # ifndef AOS4
# define AOS4 # define AOS4
# endif # endif
#endif #elif defined(__AMIGA__) || defined(__amigaos3__)
/******************************************************************************/ # define SYS_NAME "AmigaOS 3"
#ifdef __HAIKU__ # 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 # ifndef HAIKU
# define HAIKU # define HAIKU
# endif # endif
#endif #elif defined(__APPLE__) && defined(__MACH__)
/******************************************************************************/ # define SYS_NAME "Apple"
#ifdef __APPLE__
# ifndef APPLE # ifndef APPLE
# define APPLE # define APPLE
# endif # endif
#endif #elif defined(__FreeBSD__)
/******************************************************************************/ # define SYS_NAME "FreeBSD"
#if defined(_WIN32) || defined(_WIN64) # ifndef FREEBSD
# define FREEBSD
# endif
#elif defined(__NetBSD__)
# define SYS_NAME "NetBSD"
# ifndef NETBSD
# define NETBSD
# endif
#elif defined(__OpenBSD__)
# define SYS_NAME "OpenBSD"
# ifndef OPENBSD
# define OPENBSD
# endif
#elif defined(__DragonFly__)
# define SYS_NAME "DragonFly BSD"
# ifndef DRAGONFLY
# define DRAGONFLY
# endif
#elif defined(__linux__)
# define SYS_NAME "Linux"
# ifndef LINUX
# define LINUX
# endif
#elif defined(_WIN32)
# define SYS_NAME "Windows"
# ifndef WINDOWS
# define WINDOWS
# endif
#elif defined(_WIN64)
# define SYS_NAME "Windows 64 bit"
# ifndef WINDOWS # ifndef WINDOWS
# define WINDOWS # define WINDOWS
# endif # endif
#endif #endif
/******************************************************************************/
#if defined(AOS3) || defined(AOS4) || defined(AROS) || defined (MORPHOS) #if defined(AOS3) || defined(AOS4) || defined(AROS) || defined (MORPHOS)
# ifndef AMIGA # ifndef AMIGA
# define AMIGA # define AMIGA
# endif # endif
#endif #endif
/******************************************************************************/
#if defined(unix) || defined(__unix__) || defined(__unix) #if defined(unix) || defined(__unix__) || defined(__unix)
# ifndef UNIX # ifndef UNIX
# define UNIX # define UNIX
# endif # endif
# ifndef SYS_NAME
# define SYS_NAME "Unix variant"
# endif
#endif #endif
/******************************************************************************/
#if defined(HAIKU) || defined(UNIX) || defined(APPLE) #if defined(HAIKU) || defined(UNIX) || defined(APPLE)
# ifndef TERMIOS # ifndef TERMIOS
# define TERMIOS # define TERMIOS
@ -91,39 +120,38 @@
# include <stdint.h> # include <stdint.h>
# include <unistd.h> # include <unistd.h>
#endif #endif
/******************************************************************************/
#if defined(WINDOWS) #if defined(WINDOWS)
# include <stdint.h> # include <stdint.h>
#endif #endif
/******************************************************************************/
#if defined(AROS) || defined(MORPHOS) || defined(AOS4) #if defined(AROS) || defined(MORPHOS) || defined(AOS4)
# include <stdint.h> # include <stdint.h>
# include <sys/types.h> # include <sys/types.h>
#endif #endif
/******************************************************************************/
#if defined(AOS3) #if defined(AOS3)
# include <sys/types.h> # include <sys/types.h>
# define IPTR LONG*
# define uintptr_t uint32_t # define uintptr_t uint32_t
typedef u_int8_t uint8_t; typedef u_int8_t uint8_t;
typedef u_int16_t uint16_t; typedef u_int16_t uint16_t;
typedef u_int32_t uint32_t; typedef u_int32_t uint32_t;
typedef u_int64_t uint64_t; typedef u_int64_t uint64_t;
#endif #endif
/******************************************************************************/
#if (__cplusplus <= 199711L && !defined(WINDOWS)) || !defined(__cplusplus) #if (__cplusplus <= 199711L && !defined(WINDOWS)) || !defined(__cplusplus)
#ifndef nullptr # ifndef nullptr
#define nullptr 0 # define nullptr 0
#endif # endif
#elif (__cplusplus <= 199711L) && (defined(__GNUC__) || defined(__GNUG__)) #elif (__cplusplus <= 199711L) && (defined(__GNUC__) || defined(__GNUG__))
#ifndef nullptr # ifndef nullptr
#define nullptr 0 # define nullptr 0
# endif
#endif #endif
#endif
/******************************************************************************/
#define assert(x) #define assert(x)
/******************************************************************************/
/* Compilers*/ /* Compilers */
#if defined(__clang__) #if defined(__clang__)
/* Clang */ /* Clang */
# if defined(__apple_build_version__) # if defined(__apple_build_version__)
@ -176,7 +204,9 @@ typedef u_int64_t uint64_t;
# elif (_MSC_VER == 1900) # elif (_MSC_VER == 1900)
# define COMP_VERS "14.0" # define COMP_VERS "14.0"
# elif (_MSC_VER > 1900) # elif (_MSC_VER > 1900)
# define COMP_VERS "15.0+" # define COMP_VERS "15.x"
# elif (_MSC_VER > 1920)
# define COMP_VERS "16.0+"
# else # else
# define str(x) #x # define str(x) #x
# define MSC_VER_STR(x) str(x) # define MSC_VER_STR(x) str(x)
@ -209,29 +239,29 @@ typedef u_int64_t uint64_t;
# define COMP_VERS GCC_VER_STR(__GNUC__) DOT GCC_VER_STR(__GNUC_MINOR__) # define COMP_VERS GCC_VER_STR(__GNUC__) DOT GCC_VER_STR(__GNUC_MINOR__)
# endif # endif
#endif #endif
/******************************************************************************/
#define EMPTYSTRING "" #define EMPTYSTRING ""
#define SPACE " " #define SPACE " "
#define DOT "." #define DOT "."
/******************************************************************************/
#if defined(WINDOWS) #if defined(WINDOWS)
#define NEWLINE "\r\n" #define NEWLINE "\r\n"
#elif defined(APPLE) #elif defined(APPLE)
#define NEWLINE "\r" #define NEWLINE "\n"
#else #else
#define NEWLINE "\n" #define NEWLINE "\n"
#endif #endif
/******************************************************************************/
#ifndef __cplusplus #ifndef __cplusplus
typedef int bool; typedef int bool;
#define true 1 #define true 1
#define false 0 #define false 0
#endif #endif
/******************************************************************************/
#define LONG_BIT 32 #define LONG_BIT 32
#define wsize sizeof(unsigned int) #define wsize sizeof(unsigned int)
#define wmask (wsize - 1) #define wmask (wsize - 1)
/******************************************************************************/
#if defined(INTELCPU) || defined(i386) || defined(i486) || \ #if defined(INTELCPU) || defined(i386) || defined(i486) || \
defined(intel) || defined(x86) || defined(i86pc) || \ defined(intel) || defined(x86) || defined(i86pc) || \
defined(__i386__) || defined(_M_IX86) defined(__i386__) || defined(_M_IX86)
@ -243,18 +273,18 @@ typedef int bool;
#if defined(__x86_64__) || defined(_M_AMD64) #if defined(__x86_64__) || defined(_M_AMD64)
# define TXTCPU "amd64" # define TXTCPU "amd64"
#endif #endif
/******************************************************************************/
#if defined(__powerpc__) || defined(__powerpc64__) #if defined(__powerpc__) || defined(__powerpc64__)
# define TXTCPU "PowerPC" # define TXTCPU "PowerPC"
#endif #endif
/******************************************************************************/
#if defined(__arm__) || defined(_M_ARM) || defined(__ARM_ARCH_6__) #if defined(__arm__) || defined(_M_ARM) || defined(__ARM_ARCH_6__)
# define TXTCPU "arm" # define TXTCPU "arm"
#endif #endif
#if defined(__aarch64__) || defined(_M_ARM64) #if defined(__aarch64__) || defined(_M_ARM64)
# define TXTCPU "arm64" # define TXTCPU "arm64"
#endif #endif
/******************************************************************************/
#if defined(m68060) || defined(mc68060) #if defined(m68060) || defined(mc68060)
# define TXTCPU "68060" # define TXTCPU "68060"
#elif defined(m68040) || defined(mc68040) #elif defined(m68040) || defined(mc68040)
@ -268,47 +298,33 @@ typedef int bool;
#elif defined(m68000) || defined(mc68000) #elif defined(m68000) || defined(mc68000)
# define TXTCPU "68000+" # define TXTCPU "68000+"
#endif #endif
/******************************************************************************/
#ifndef TXTCPU #ifndef TXTCPU
//#error what cpu is this ?! //#error what cpu is this ?!
# define TXTCPU EMPTYSTRING # define TXTCPU EMPTYSTRING
#endif #endif
/******************************************************************************/
#if defined(TXTCPU) && defined(__HAVE_68881__) #if defined(TXTCPU) && defined(__HAVE_68881__)
# define TXTFPU SPACE "FPU" # define TXTFPU SPACE "FPU"
#else #else
# define TXTFPU EMPTYSTRING # define TXTFPU EMPTYSTRING
#endif #endif
/******************************************************************************/
#define TXTARCH TXTCPU TXTFPU #define TXTARCH TXTCPU TXTFPU
#define RELDATESTAMP "(07-08-2018)" #define RELDATESTAMP "(11-01-2021)"
#define TXTDOSVERSION "\0$VER: amath 1.85" SPACE RELDATESTAMP SPACE TXTARCH #define TXTDOSVERSION "\0$VER: amath 1.90" SPACE RELDATESTAMP SPACE TXTARCH
#define TXTTITLE "amath version 1.8.5" #define TXTTITLE "amath version 1.9.0"
#define TXTCOPYRIGHT "(c) 2018 Carsten Sonne Larsen" #define TXTCOPYRIGHT "(c) 2021 Carsten Sonne Larsen"
#define TXTSTARTMSG TXTTITLE SPACE TXTCOPYRIGHT #define TXTSTARTMSG TXTTITLE SPACE TXTCOPYRIGHT
/******************************************************************************/
#define TXTVERSMSG TXTTITLE SPACE RELDATESTAMP SPACE TXTARCH #define TXTVERSMSG TXTTITLE SPACE RELDATESTAMP SPACE TXTARCH
#define TXTCOMPMSG "Compiled with " COMP_NAME SPACE COMP_VERS #define TXTCOMPMSG "Compiled with " COMP_NAME SPACE COMP_VERS
/******************************************************************************/
#define CPROCNAME "amath_console" #ifdef SYS_NAME
/******************************************************************************/ # define TXTSYSMSG TXTCOMPMSG " for " SYS_NAME
#if defined(AMIGA) # define SYSKNOWN 1
#define AMIGADOS_NAME "dos.library" #else
#define AMIGADOS_REV 33L # define TXTSYSMSG TXTCOMPMSG
#define INTUITION_REV 37L
#define INTUITION_NAME "intuition.library"
#define GRAPHICS_REV 37L
#define GRAPHICS_NAME "graphics.library"
#define LOCALE_REV 38L
#define LOCALE_NAME "locale.library"
#define DEVCONSOLE "console.device"
#define PORTCR "RKM.console.read"
#define PORTCW "RKM.console.write"
#define CATALOG_HELP "amath-help.catalog"
#define CATALOG_IDEN "amath-ident.catalog"
#define CATALOG_TEXT "amath-text.catalog"
#define CATALOG_KEYW "amath-keyword.catalog"
#define CATALOG_DEF OC_BuiltInLanguage, "english"
#endif #endif
/******************************************************************************/
#endif #endif

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,4 +1,4 @@
.\" Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> .\" Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
.\" All rights reserved. .\" All rights reserved.
.\" .\"
.\" Redistribution and use in source and binary forms, with or without .\" Redistribution and use in source and binary forms, with or without
@ -20,7 +20,7 @@
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.TH "amathc.h" 3 "Version 1.8.5" "August 07 2018" .TH "amathc.h" 3 "Version 1.9.0" "January 11 2021"
.SH NAME .SH NAME
amathc.h \- C functions for manipulating strings and memory amathc.h \- C functions for manipulating strings and memory
.SH SYNOPSIS .SH SYNOPSIS
@ -479,7 +479,7 @@ Written by Carsten Sonne Larsen <cs@innolan.net>. The code in MemSet and
MemCopy is derived from software contributed to Berkeley by Mike Hibler and MemCopy is derived from software contributed to Berkeley by Mike Hibler and
Chris Torek. Chris Torek.
.SH COPYRIGHT .SH COPYRIGHT
Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
.br .br
Copyright (c) 2007 The NetBSD Foundation, Inc. Copyright (c) 2007 The NetBSD Foundation, Inc.
.br .br

View File

@ -1,7 +1,7 @@
DOXYFILE_ENCODING = UTF-8 DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "amathc" PROJECT_NAME = "amathc"
PROJECT_NUMBER = "1.8.5" PROJECT_NUMBER = "1.9.0"
PROJECT_BRIEF = "C functions for manipulating strings and memory" PROJECT_BRIEF = "C functions for manipulating strings and memory"
PROJECT_LOGO = PROJECT_LOGO =
OUTPUT_DIRECTORY = OUTPUT_DIRECTORY =

View File

@ -5,6 +5,6 @@ libdir=${exec_prefix}/lib
Name: amath C library Name: amath C library
Description: C functions for manipulating strings and memory Description: C functions for manipulating strings and memory
Version: 1.8.5 Version: 1.9.0
Cflags: -I${includedir} Cflags: -I${includedir}
Libs: -L${libdir} -lamathc Libs: -L${libdir} -lamathc

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -35,18 +35,22 @@
#include <exec/memory.h> #include <exec/memory.h>
#include <exec/semaphores.h> #include <exec/semaphores.h>
#include <clib/exec_protos.h> #include <clib/exec_protos.h>
#define ALLOC_MEM(x) AllocVec(x, MEMF_ANY | MEMF_CLEAR) #define ALLOC_LIST(x) AllocVec(x, MEMF_ANY | MEMF_CLEAR)
#define FREE_MEM(x) FreeVec(x) #define FREE_LIST(x) FreeVec(x)
#define Debug(x,y,z) #define ALLOC_MEM(x, y) AllocPooledZero(x, y)
#define FREE_MEM(x, y, z) FreePooled(x, y, z)
#define Debug(x, y, z)
#else #else
#include <stdlib.h> #include <stdlib.h>
#define ALLOC_MEM(x) calloc(1L,x) #define ALLOC_LIST(x) calloc(1L, x)
#define FREE_MEM(x) free(x) #define FREE_LIST(x) free(x)
#define Debug(x,y,z) #define ALLOC_MEM(x, y) calloc(1L, y)
#define FREE_MEM(x, y, z) free(y)
#define Debug(x, y, z)
#endif #endif
#if defined(__x86_64__) || defined(__aarch64__) || \ #if defined(__x86_64__) || defined(__aarch64__) || \
defined(_M_AMD64) || defined(_M_ARM64) || \ defined(_M_AMD64) || defined(_M_ARM64) || \
defined(__powerpc64__) defined(__powerpc64__)
#define P64BIT #define P64BIT
#endif #endif
@ -56,9 +60,9 @@
*/ */
struct MemoryBlock struct MemoryBlock
{ {
struct MemoryBlock* next; struct MemoryBlock *next;
size_t size; size_t size;
void* address; void *address;
}; };
/** /**
@ -66,7 +70,8 @@ struct MemoryBlock
*/ */
struct MemoryList struct MemoryList
{ {
struct MemoryBlock* first; struct MemoryBlock *first;
void *pool;
size_t peak; size_t peak;
size_t size; size_t size;
long count; long count;
@ -75,28 +80,56 @@ struct MemoryList
/** /**
* @brief Global list of allocated memory. * @brief Global list of allocated memory.
*/ */
struct MemoryList* list = nullptr; struct MemoryList *list = nullptr;
void alloc_error(char*, size_t); void alloc_error(char *, size_t);
void dealloc_error(char*, void*); 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. * @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; size_t allocsize;
if (list == nullptr) if (list == nullptr)
{ {
list = (struct MemoryList*)ALLOC_MEM(sizeof(struct MemoryList)); list = (struct MemoryList *)ALLOC_LIST(sizeof(struct MemoryList));
if (!list) if (!list)
{ {
alloc_error("list", sizeof(struct MemoryList)); alloc_error("list", sizeof(struct MemoryList));
return 0; return 0;
} }
#if defined(AMIGA)
list->pool = CreatePool(MEMF_ANY, 4096, 512);
#endif
list->first = nullptr; list->first = nullptr;
list->peak = 0; list->peak = 0;
list->size = 0; list->size = 0;
@ -104,24 +137,24 @@ void* AllocMemSafe(size_t size)
} }
#ifdef P64BIT #ifdef P64BIT
// Align to bytes of 8 // Align to bytes of 8, remove 0 bytes allocations
allocsize = (size + 7) & ~0x07; allocsize = (size + 8) & ~0x07;
#else #else
// Align to bytes of 4 // Align to bytes of 4, remove 0 bytes allocations
allocsize = (size + 3) & ~0x03; allocsize = (size + 4) & ~0x03;
#endif #endif
newblock = (struct MemoryBlock*)ALLOC_MEM(sizeof(struct MemoryBlock)); newblock = (struct MemoryBlock *)ALLOC_MEM(list->pool, sizeof(struct MemoryBlock));
if (!newblock) if (newblock == NULL)
{ {
alloc_error("block", sizeof(struct MemoryBlock)); alloc_error("block", sizeof(struct MemoryBlock));
return 0; return 0;
} }
newblock->address = (struct MemoryBlock*)ALLOC_MEM(allocsize); newblock->address = (struct MemoryBlock *)ALLOC_MEM(list->pool, allocsize);
if (!newblock->address) if (newblock->address == NULL)
{ {
FREE_MEM(newblock); FREE_MEM(list->pool, newblock, sizeof(struct MemoryBlock));
alloc_error("memory", allocsize); alloc_error("memory", allocsize);
return 0; return 0;
} }
@ -141,7 +174,7 @@ void* AllocMemSafe(size_t size)
return newblock->address; return newblock->address;
} }
void RemoveMemSafe(void* block, bool deallocate) void RemoveMemSafe(void *block, bool deallocate)
{ {
struct MemoryBlock *current, *previous; struct MemoryBlock *current, *previous;
@ -185,19 +218,19 @@ void RemoveMemSafe(void* block, bool deallocate)
if (deallocate) if (deallocate)
{ {
FREE_MEM(current->address); FREE_MEM(list->pool, current->address, current->size);
} }
current->address = nullptr; current->address = nullptr;
current->next = nullptr; current->next = nullptr;
current->size = 0; current->size = 0;
FREE_MEM(current); FREE_MEM(list->pool, current, sizeof(struct MemoryBlock));
} }
/** /**
* @brief Deallocate memory from the global memory list. * @brief Deallocate memory from the global memory list.
*/ */
void FreeMemSafe(void* block) void FreeMemSafe(void *block)
{ {
RemoveMemSafe(block, true); RemoveMemSafe(block, true);
} }
@ -206,7 +239,7 @@ void FreeMemSafe(void* block)
* @brief Detach an allocated memory from the global memory list. * @brief Detach an allocated memory from the global memory list.
* @details The memory block is only detached, not deallocated. * @details The memory block is only detached, not deallocated.
*/ */
void DetachMemSafe(void* block) void DetachMemSafe(void *block)
{ {
RemoveMemSafe(block, false); RemoveMemSafe(block, false);
} }
@ -227,29 +260,34 @@ void FreeAllSafe()
while (current != nullptr) while (current != nullptr)
{ {
next = current->next; next = current->next;
FREE_MEM(current->address); FREE_MEM(list->pool, current->address, current->size);
FREE_MEM(current); FREE_MEM(list->pool, current, sizeof(struct MemoryBlock));
current = next; current = next;
} }
FREE_MEM(list); #if defined(AMIGA)
DeletePool(list->pool);
#endif
FREE_LIST(list);
list = nullptr; list = nullptr;
} }
/** /**
* @brief Get memory usage in the global memory list. * @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; *blocks = list->count;
*size = (long)list->size; *size = (long)list->size;
*peak = (long)list->peak;; *peak = (long)list->peak;
;
} }
/** /**
* @brief Log a memory allocation error * @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); Debug("Memory allocation error (%s) with size (%d)\n", descr, size);
//if (size == 0) //if (size == 0)
@ -259,7 +297,7 @@ void alloc_error(char* descr, size_t size)
/** /**
* @brief Log a memory deallocation error * @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); Debug("Memory deallocation error (%s) address (%x)\n", descr, p);
} }

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 1990, 1993 The Regents of the University of California. * Copyright (c) 1990, 1993 The Regents of the University of California.
* All rights reserved. * All rights reserved.
* *

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 1990, 1993 The Regents of the University of California. * Copyright (c) 1990, 1993 The Regents of the University of California.
* All rights reserved. * All rights reserved.
* *

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,4 +1,4 @@
.\" Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> .\" Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
.\" All rights reserved. .\" All rights reserved.
.\" .\"
.\" Redistribution and use in source and binary forms, with or without .\" Redistribution and use in source and binary forms, with or without
@ -20,7 +20,7 @@
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.TH "mathi.h" 3 "Version 1.8.5" "August 07 2018" .TH "mathi.h" 3 "Version 1.9.0" "January 11 2021"
.SH NAME .SH NAME
mathi.h \- Complex numbers math library mathi.h \- Complex numbers math library
.SH SYNOPSIS .SH SYNOPSIS
@ -1745,7 +1745,7 @@ https://amath.innolan.net/
Written by Carsten Sonne Larsen <cs@innolan.net>. Some code in the Written by Carsten Sonne Larsen <cs@innolan.net>. Some code in the
library is derived from software written by Stephen L. Moshier. library is derived from software written by Stephen L. Moshier.
.SH COPYRIGHT .SH COPYRIGHT
Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
.br .br
Copyright (c) 2007 The NetBSD Foundation, Inc. Copyright (c) 2007 The NetBSD Foundation, Inc.
.SH "See also" .SH "See also"

View File

@ -1,7 +1,7 @@
DOXYFILE_ENCODING = UTF-8 DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "amathi" PROJECT_NAME = "amathi"
PROJECT_NUMBER = "1.8.5" PROJECT_NUMBER = "1.9.0"
PROJECT_BRIEF = "Complex numbers math library" PROJECT_BRIEF = "Complex numbers math library"
PROJECT_LOGO = PROJECT_LOGO =
OUTPUT_DIRECTORY = OUTPUT_DIRECTORY =

View File

@ -5,6 +5,6 @@ libdir=${exec_prefix}/lib
Name: amath complex library Name: amath complex library
Description: Complex numbers math library Description: Complex numbers math library
Version: 1.8.5 Version: 1.9.0
Cflags: -I${includedir} Cflags: -I${includedir}
Libs: -L${libdir} -lamathi Libs: -L${libdir} -lamathi

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2007 The NetBSD Foundation, Inc. * Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2007 The NetBSD Foundation, Inc. * Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2007 The NetBSD Foundation, Inc. * Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2007 The NetBSD Foundation, Inc. * Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2007 The NetBSD Foundation, Inc. * Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2007 The NetBSD Foundation, Inc. * Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2007 The NetBSD Foundation, Inc. * Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2007 The NetBSD Foundation, Inc. * Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2007 The NetBSD Foundation, Inc. * Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* Copyright (c) 2007 The NetBSD Foundation, Inc. * Copyright (c) 2007 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -5,6 +5,6 @@ libdir=${exec_prefix}/lib
Name: amath application library Name: amath application library
Description: C++ library for handling numbers Description: C++ library for handling numbers
Version: 1.8.5 Version: 1.9.0
Cflags: -I${includedir} Cflags: -I${includedir}
Libs: -L${libdir} -lamathapp -lamathr -lamathi -lamathc Libs: -L${libdir} -lamathapp -lamathr -lamathi -lamathc

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -66,7 +66,7 @@ void CharBuffer::ClearBuffer()
{ {
if (buf != nullptr) if (buf != nullptr)
{ {
delete [] buf; delete[] buf;
} }
buf = nullptr; buf = nullptr;
@ -78,7 +78,7 @@ void CharBuffer::ClearBuffer()
* @brief Release memory, allocate and copy source. * @brief Release memory, allocate and copy source.
* *
*/ */
void CharBuffer::ClearAndCopy(const char* source) void CharBuffer::ClearAndCopy(const char *source)
{ {
ClearBuffer(); ClearBuffer();
cursize = AllocAndCopy(&buf, source); cursize = AllocAndCopy(&buf, source);
@ -125,7 +125,7 @@ void CharBuffer::EnsureSize(unsigned int size)
} }
else if (buf == ptr) else if (buf == ptr)
{ // Already allocated but buffer is empty. { // Already allocated but buffer is empty.
delete [] buf; delete[] buf;
buf = new char[cursize]; buf = new char[cursize];
ptr = buf; ptr = buf;
} }
@ -134,9 +134,9 @@ void CharBuffer::EnsureSize(unsigned int size)
// Make at least double size // Make at least double size
cursize = cursize < tempsize * 2 ? tempsize * 2 : cursize; cursize = cursize < tempsize * 2 ? tempsize * 2 : cursize;
unsigned int offset = (unsigned int)(ptr - buf); unsigned int offset = (unsigned int)(ptr - buf);
char* temp = new char[cursize]; char *temp = new char[cursize];
MemCopy(temp, buf, tempsize); MemCopy(temp, buf, tempsize);
delete [] buf; delete[] buf;
buf = temp; buf = temp;
ptr = buf + offset; ptr = buf + offset;
} }
@ -156,9 +156,9 @@ void CharBuffer::EnsureSize(unsigned int blocksize, unsigned int blocks)
else else
{ {
unsigned int tptr = (unsigned int)(ptr - buf); unsigned int tptr = (unsigned int)(ptr - buf);
char* temp = new char[blocksize * blocks]; char *temp = new char[blocksize * blocks];
MemCopy(temp, buf, cursize); MemCopy(temp, buf, cursize);
delete [] buf; delete[] buf;
cursize = blocksize * blocks; cursize = blocksize * blocks;
buf = temp; buf = temp;
ptr = buf + tptr; ptr = buf + tptr;
@ -173,7 +173,7 @@ void CharBuffer::EnsureGrowth(unsigned int size)
bool CharBuffer::IsEmpty() const bool CharBuffer::IsEmpty() const
{ {
char* i = buf; char *i = buf;
if (i == nullptr || buf == ptr) if (i == nullptr || buf == ptr)
return true; return true;
@ -185,20 +185,19 @@ bool CharBuffer::IsEmpty() const
return false; return false;
i++; i++;
} } while (i != ptr);
while (i != ptr);
return true; return true;
} }
bool CharBuffer::Is(const char* string) const bool CharBuffer::Is(const char *string) const
{ {
return StrIsEqual(GetString(), string); return StrIsEqual(GetString(), string);
} }
bool CharBuffer::Contains(const char c) const bool CharBuffer::Contains(const char c) const
{ {
char* i = buf; char *i = buf;
if (i == nullptr || buf == ptr) if (i == nullptr || buf == ptr)
return false; return false;
@ -209,8 +208,7 @@ bool CharBuffer::Contains(const char c) const
return true; return true;
i++; i++;
} } while (i != ptr);
while (i != ptr);
return false; return false;
} }
@ -230,14 +228,15 @@ void CharBuffer::DeleteLastChar()
ptr--; ptr--;
} }
void CharBuffer::Copy(CharBuffer* source) void CharBuffer::Copy(CharBuffer *source)
{ {
EnsureSize(source->cursize); EnsureSize(source->cursize);
const char* s = source->GetString(); const char *s = source->GetString();
ptr = buf; ptr = buf;
// ReSharper disable once CppPossiblyErroneousEmptyStatements // ReSharper disable once CppPossiblyErroneousEmptyStatements
while ((*ptr++ = *s++)); while ((*ptr++ = *s++))
;
ptr--; ptr--;
} }
@ -259,14 +258,49 @@ void CharBuffer::Append(const char c, unsigned int count)
*ptr++ = c; *ptr++ = c;
} }
void CharBuffer::Append(const char* source) void CharBuffer::Append(const char *source)
{ {
// ReSharper disable once CppPossiblyErroneousEmptyStatements // ReSharper disable once CppPossiblyErroneousEmptyStatements
while ((*ptr++ = *source++)); while ((*ptr++ = *source++))
;
ptr--; ptr--;
} }
void CharBuffer::AppendNumber(signed long value)
{
static const char *alphaNumerics = "0123456789";
unsigned int count = 0;
unsigned long current = value;
char chars[12];
char *p = chars;
bool negative = false;
if (value < 0)
{
current = -value;
negative = true;
}
do
{
unsigned long remainder = current % 10;
*p++ = alphaNumerics[remainder];
current /= 10;
count++;
} while (current >= 1);
p--;
if (negative)
{
*ptr++ = '-';
}
while (count-- != 0)
*ptr++ = *p--;
}
bool CharBuffer::RemoveTrailing(const char c) bool CharBuffer::RemoveTrailing(const char c)
{ {
if (ptr == buf) if (ptr == buf)
@ -283,10 +317,10 @@ bool CharBuffer::RemoveTrailing(const char c)
return false; return false;
} }
bool CharBuffer::RemoveTrailing(const char* string) bool CharBuffer::RemoveTrailing(const char *string)
{ {
int len = StrLen(string) * sizeof(char); int len = StrLen(string) * sizeof(char);
char* s = ptr - len; char *s = ptr - len;
if (s < buf) if (s < buf)
{ {
return false; return false;
@ -303,8 +337,21 @@ bool CharBuffer::RemoveTrailing(const char* string)
return false; return false;
} }
char* CharBuffer::GetString() const char *CharBuffer::GetString() const
{ {
*ptr = '\0'; *ptr = '\0';
return buf; return buf;
} }
void CharBuffer::CopyTo(char *string)
{
char *q = buf;
char *p = string;
*ptr = '\0';
while ((*p++ = *q++))
;
*p = '\0';
}

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -69,11 +69,14 @@ public:
void Append(const char* source); void Append(const char* source);
void Append(const char c); void Append(const char c);
void Append(const char c, unsigned int count); void Append(const char c, unsigned int count);
void AppendNumber(signed long value);
void DeleteLastChar(); void DeleteLastChar();
bool RemoveTrailing(const char c); bool RemoveTrailing(const char c);
bool RemoveTrailing(const char* string); bool RemoveTrailing(const char* string);
char* GetString() const; char* GetString() const;
void CopyTo(char *string);
private: private:
friend class AnsiConoleEngine; friend class AnsiConoleEngine;

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net> * Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

Some files were not shown because too many files have changed in this diff Show More