24 Commits

Author SHA1 Message Date
  Carsten Sonne Larsen 811644f4c7 Zero out allocated memory 9 months ago
  Carsten Sonne Larsen d7fe11d56a Take advantage of memory pools 9 months ago
  Carsten Sonne Larsen d7add409cd Identify systems more uniquely 9 months ago
  Carsten Sonne Larsen d910b98571 Cleanup and avoid OS conflicts (REQ #3) 9 months ago
  Carsten Sonne Larsen ea2bf72d7b MorphOS compatibility (REQ #4) 9 months ago
  Carsten Sonne Larsen e788fec496 ARexx only instance 9 months ago
  Carsten Sonne Larsen ffa586c694 Allow to quit console with CTRL + C 9 months ago
  Carsten Sonne Larsen 0240d3a439 Only show result when using ARexx 9 months ago
  Carsten Sonne Larsen 93c8fdbef4 To ensure compatibility, set fraction point to full stop / period 9 months ago
  Carsten Sonne Larsen dd7884bc22 Cleanup after building catalogs 9 months ago
  Carsten Sonne Larsen 65fafb750f Improved install script 9 months ago
  Carsten Sonne Larsen 2164e79aef Distribution files 9 months ago
  Carsten Sonne Larsen 87c65aa678 Include Debian build in source 9 months ago
  Carsten Sonne Larsen 2c9e8bece3 Update copyright text 9 months ago
  Carsten Sonne Larsen ee26a57960 Release 1.9.0 9 months ago
  Carsten Sonne Larsen 538ad4ac23 ARexx test script 9 months ago
  Carsten Sonne Larsen 524f83f22f Cleanup Amiga specific code 9 months ago
  Carsten Sonne Larsen 9e712377a4 Update copyright 9 months ago
  Carsten Sonne Larsen 6eb56b056e ARexx support 9 months ago
  Carsten Sonne Larsen 3a52c27a9c new AppendNumber method 9 months ago
  Carsten Larsen f8cf191a46 Fix PowerPC build 3 years ago
  Carsten Sonne Larsen aeb7f2e92c Detect system name 3 years ago
  Carsten Sonne Larsen 49b36ce2a3 Remove search option 3 years ago
  Carsten Sonne Larsen f7de7b1447 Update links 3 years ago
441 changed files with 2363 additions and 1545 deletions
Split View
  1. +1
    -0
      .gitignore
  2. +19
    -0
      .vscode/c_cpp_properties.json
  3. +4
    -1
      HISTORY
  4. +1
    -1
      LICENSE
  5. +4
    -4
      amath.1
  6. +3
    -3
      amath.doxygen
  7. +4
    -0
      arexx/test.rx
  8. +166
    -0
      bin/amath.doc
  9. +41
    -0
      bin/amath.readme
  10. BIN
      bin/catalog/english.info
  11. BIN
      bin/prog/Catalog.info
  12. BIN
      bin/prog/HISTORY.info
  13. BIN
      bin/prog/LICENSE.info
  14. BIN
      bin/prog/Script.info
  15. BIN
      bin/prog/Test.info
  16. BIN
      bin/prog/amath.020.info
  17. BIN
      bin/prog/amath.030.info
  18. BIN
      bin/prog/amath.doc.info
  19. BIN
      bin/prog/amath.info
  20. BIN
      bin/root/amath.info
  21. BIN
      bin/script/complex1.info
  22. BIN
      bin/script/complex2.info
  23. BIN
      bin/script/complex3.info
  24. BIN
      bin/script/function1.info
  25. BIN
      bin/script/function2.info
  26. BIN
      bin/script/function3.info
  27. BIN
      bin/script/operators.info
  28. BIN
      bin/script/userfuncs.info
  29. BIN
      bin/script/variables.info
  30. +32
    -0
      build/doc
  31. +9
    -9
      builddeb
  32. +9
    -9
      builddebdev
  33. +86
    -27
      builddist
  34. +9
    -8
      buildsrc
  35. +4
    -4
      buildwin
  36. +5
    -5
      catalog/english/amath-help.ct
  37. +5
    -5
      catalog/english/amath-text.ct
  38. +12
    -11
      configure
  39. +100
    -84
      src/amath.h
  40. +2
    -2
      src/amathc.h
  41. +2
    -2
      src/amatht.h
  42. +2
    -2
      src/clib/alloccpy.c
  43. +51
    -51
      src/clib/amathc.3
  44. +2
    -2
      src/clib/amathc.dox
  45. +1
    -1
      src/clib/amathc.pc
  46. +77
    -39
      src/clib/mem.c
  47. +2
    -2
      src/clib/memset.c
  48. +2
    -2
      src/clib/strcmp.c
  49. +2
    -2
      src/clib/strlen.c
  50. +2
    -2
      src/clib/untag.c
  51. +178
    -178
      src/cplex/amathi.3
  52. +2
    -2
      src/cplex/amathi.dox
  53. +1
    -1
      src/cplex/amathi.pc
  54. +2
    -2
      src/cplex/cacos.c
  55. +2
    -2
      src/cplex/cacosh.c
  56. +2
    -2
      src/cplex/cacot.c
  57. +2
    -2
      src/cplex/cacoth.c
  58. +2
    -2
      src/cplex/cacsc.c
  59. +2
    -2
      src/cplex/cacsch.c
  60. +2
    -2
      src/cplex/casec.c
  61. +2
    -2
      src/cplex/casech.c
  62. +2
    -2
      src/cplex/casin.c
  63. +2
    -2
      src/cplex/casinh.c
  64. +2
    -2
      src/cplex/catan.c
  65. +2
    -2
      src/cplex/catanh.c
  66. +2
    -2
      src/cplex/ccbrt.c
  67. +2
    -2
      src/cplex/ccos.c
  68. +2
    -2
      src/cplex/ccosh.c
  69. +2
    -2
      src/cplex/ccot.c
  70. +2
    -2
      src/cplex/ccoth.c
  71. +2
    -2
      src/cplex/ccsc.c
  72. +2
    -2
      src/cplex/ccsch.c
  73. +2
    -2
      src/cplex/cexp.c
  74. +2
    -2
      src/cplex/clog.c
  75. +2
    -2
      src/cplex/clog10.c
  76. +2
    -2
      src/cplex/clogb.c
  77. +2
    -2
      src/cplex/cpow.c
  78. +2
    -2
      src/cplex/csec.c
  79. +2
    -2
      src/cplex/csech.c
  80. +2
    -2
      src/cplex/csgn.c
  81. +2
    -2
      src/cplex/csin.c
  82. +2
    -2
      src/cplex/csinh.c
  83. +2
    -2
      src/cplex/csqrt.c
  84. +2
    -2
      src/cplex/ctan.c
  85. +2
    -2
      src/cplex/ctanh.c
  86. +2
    -2
      src/cplex/prim.c
  87. +2
    -2
      src/cplex/prim.h
  88. +4
    -4
      src/lib/aengine.cpp
  89. +2
    -2
      src/lib/aengine.h
  90. +1
    -1
      src/lib/amatha.pc
  91. +2
    -2
      src/lib/bigint.cpp
  92. +2
    -2
      src/lib/bigint.h
  93. +71
    -24
      src/lib/charbuf.cpp
  94. +5
    -2
      src/lib/charbuf.h
  95. +2
    -2
      src/lib/charval.h
  96. +3
    -3
      src/lib/cplex.cpp
  97. +2
    -2
      src/lib/cplex.h
  98. +5
    -5
      src/lib/nnumb.cpp
  99. +2
    -2
      src/lib/nnumb.h
  100. +2
    -2
      src/lib/ntext.cpp

+ 1
- 0
.gitignore View File

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

+ 19
- 0
.vscode/c_cpp_properties.json 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
}

+ 4
- 1
HISTORY View File

@ -1,5 +1,8 @@
amath release history
v1.9.0 January 11 2021
- AmigaOS ARexx interface.
v1.8.5 August 07 2018
- Fix build on compilers with broken endian detection.
@ -108,7 +111,7 @@ v1.5.3 October 26 2014
v1.5.2 October 11 2014
- Modified character handling code to comply with licenses.
- Modified complex math code to comply with licenses.
- Modified code base to work with Kickstart 2.04.
- Modified code base to work with Kickstart 2.04.
- Square root of negative numbers now yields correct result.
- Implemented scientific notation of numbers.
- Infinity is now shown in division with 0.


+ 1
- 1
LICENSE 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) 1990, 1993 The Regents of the University of California.
All rights reserved.


+ 4
- 4
amath.1 View File

@ -1,6 +1,6 @@
.\" Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net>
.\" Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
.\" All rights reserved.
.\"
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
@ -9,7 +9,7 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
@ -20,7 +20,7 @@
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" 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
amath \- Simple command line calculator
.SH SYNOPSIS


+ 3
- 3
amath.doxygen View File

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


+ 4
- 0
arexx/test.rx View File

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

+ 166
- 0
bin/amath.doc 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
- 0
bin/amath.readme 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 View File


BIN
bin/prog/Catalog.info View File


BIN
bin/prog/HISTORY.info View File


BIN
bin/prog/LICENSE.info View File


BIN
bin/prog/Script.info View File


BIN
bin/prog/Test.info View File


BIN
bin/prog/amath.020.info View File


BIN
bin/prog/amath.030.info View File


BIN
bin/prog/amath.doc.info View File


BIN
bin/prog/amath.info View File


BIN
bin/root/amath.info View File


BIN
bin/script/complex1.info View File


BIN
bin/script/complex2.info View File


BIN
bin/script/complex3.info View File


BIN
bin/script/function1.info View File


BIN
bin/script/function2.info View File


BIN
bin/script/function3.info View File


BIN
bin/script/operators.info View File


BIN
bin/script/userfuncs.info View File


BIN
bin/script/variables.info View File


+ 32
- 0
build/doc 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;
}
'

+ 9
- 9
builddeb View File

@ -1,8 +1,8 @@
#!/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.
#
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
@ -11,7 +11,7 @@
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ -23,14 +23,14 @@
# LIABILITY, OR TORT {INCLUDING NEGLIGENCE OR OTHERWISE} ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
#
# Project homepage:
# https://amath.innolan.net
#
#
set -e
version="1.8.5"
version="1.9.0"
build_package () {
@ -103,9 +103,9 @@ chmod 0755 amath/DEBIAN/control
echo "Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/"
echo "Upstream-Name: amath"
echo "Source: https://amath.innolan.net"
echo
echo
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 " 1990, 1993 The Regents of the University of California."
echo "License: BSD-2-Clause"


+ 9
- 9
builddebdev View File

@ -1,8 +1,8 @@
#!/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.
#
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
@ -11,7 +11,7 @@
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ -23,16 +23,16 @@
# LIABILITY, OR TORT {INCLUDING NEGLIGENCE OR OTHERWISE} ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
#
# Project homepage:
# https://amath.innolan.net
#
#
# THIS SCRIPT IS NOT READY FOR PRODUCTION !
set -e
version="1.8.5"
version="1.9.0"
build_package () {
@ -147,9 +147,9 @@ chmod 0755 amath/DEBIAN/control
echo "Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/"
echo "Upstream-Name: amath-dev"
echo "Source: https://amath.innolan.net"
echo
echo
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 " 1990, 1993 The Regents of the University of California."
echo "License: BSD-2-Clause"


+ 86
- 27
builddist View File

@ -1,69 +1,128 @@
#!/bin/sh
#
#
# Build Classic AmigaOS distribtion package
# This file is public domain
#
#
# Project homepage:
# https://amath.innolan.net
#
#
# Add compiler path before invoking. Fx:
# export PATH="/opt/m68k-amigaos/bin/:$PATH"
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
# 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/
# 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
mkdir dist/script
cp script/* dist/script/
date -Ru >dist/build_date
#uname -srmo >dist/build_host
# Cleanup
rm -Rf distcat
rm -Rf ${builddir}
mv dist amath
#lha-ac a amath.lha amath
# Install source
./buildsrc
mv amath-1.9.0 ${distdir}/

+ 9
- 8
buildsrc View File

@ -1,21 +1,21 @@
#!/bin/sh
#
#
# Build source distribtion package
# This file is public domain
#
#
# Project homepage:
# https://amath.innolan.net
#
#
# DO NOT USE THIS SCRIPT UNLESS YOU KNOW WHAT YOU ARE DOING !
version='1.8.5'
stamp="201808070000"
srcdir="amath-rc"
version='1.9.0'
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/
@ -56,6 +56,7 @@ install -m 664 ${srcdir}/LICENSE ${distdir}/
install -m 664 ${srcdir}/README ${distdir}/
install -m 664 ${srcdir}/amath.1 ${distdir}/
install -m 775 ${srcdir}/configure ${distdir}/
install -m 775 ${srcdir}/builddeb ${distdir}/
install -m 775 ${srcdir}/builddist ${distdir}/
install -m 775 ${srcdir}/buildwin ${distdir}/


+ 4
- 4
buildwin View File

@ -1,14 +1,14 @@
#!/bin/sh
#
#
# This file is public domain
#
#
# Project homepage:
# https://amath.innolan.net
#
#
set -e
version="1.8.5"
version="1.9.0"
echo "Building amath ${version} for Windows ..."


+ 5
- 5
catalog/english/amath-help.ct View File

@ -2,19 +2,19 @@
## language english
## 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.
;
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are met:
;
;
; * Redistributions of source code must retain the above copyright notice, this
; list of conditions and the following disclaimer.
;
;
; * Redistributions in binary form must reproduce the above copyright notice,
; this list of conditions and the following disclaimer in the documentation
; and/or other materials provided with the distribution.
;
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE


+ 5
- 5
catalog/english/amath-text.ct View File

@ -2,19 +2,19 @@
## language english
## 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.
;
;
; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are met:
;
;
; * Redistributions of source code must retain the above copyright notice, this
; list of conditions and the following disclaimer.
;
;
; * Redistributions in binary form must reproduce the above copyright notice,
; this list of conditions and the following disclaimer in the documentation
; and/or other materials provided with the distribution.
;
;
; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE


+ 12
- 11
configure View File

@ -1,8 +1,8 @@
#!/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.
#
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
@ -11,7 +11,7 @@
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ -23,11 +23,11 @@
# LIABILITY, OR TORT {INCLUDING NEGLIGENCE OR OTHERWISE} ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
#
set -e
version="1.8.5"
version="1.9.0"
clang=false
debugsym=false
@ -264,7 +264,7 @@ if $stdlibm; then
mflags="-DLIBM "
dlibm=true
fi
if $openlibm; then
libm="-lopenlibm "
mflags="-DLIBM "
@ -306,6 +306,7 @@ values.cpp
viewer.cpp
'
SYSSRCS='
amiga_arexx.cpp
console.cpp
console_amiga.cpp
console_stdc.cpp
@ -1193,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"


+ 100
- 84
src/amath.h 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.
*
* Redistribution and use in source and binary forms, with or without
@ -24,66 +24,95 @@
*
* Project homepage:
* https://amath.innolan.net
*
*
*/
#ifndef AMATH_H
#define AMATH_H
/******************************************************************************/
#ifdef __AMIGA__
# ifndef AOS3
# define AOS3
# endif
#endif
/******************************************************************************/
#ifdef __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
/******************************************************************************/
#if defined(_WIN32) || defined(_WIN64)
#elif defined(__FreeBSD__)
# define SYS_NAME "FreeBSD"
# 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
# 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
# endif
# ifndef SYS_NAME
# define SYS_NAME "Unix variant"
# endif
#endif
/******************************************************************************/
#if defined(HAIKU) || defined(UNIX) || defined(APPLE)
# ifndef TERMIOS
# define TERMIOS
@ -91,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
#endif
# ifndef nullptr
# define nullptr 0
# endif
#endif
/******************************************************************************/
#define assert(x)
/******************************************************************************/
/* Compilers*/
/* Compilers */
#if defined(__clang__)
/* Clang */
# if defined(__apple_build_version__)
@ -176,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)
@ -209,29 +239,29 @@ 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)
#define NEWLINE "\r"
#define NEWLINE "\n"
#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)
@ -243,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)
@ -268,47 +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 "(07-08-2018)"
#define TXTDOSVERSION "\0$VER: amath 1.85" SPACE RELDATESTAMP SPACE TXTARCH
#define TXTTITLE "amath version 1.8.5"
#define TXTCOPYRIGHT "(c) 2018 Carsten Sonne Larsen"
#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
/******************************************************************************/
#define CPROCNAME "amath_console"
/******************************************************************************/
#if defined(AMIGA)
#define AMIGADOS_NAME "dos.library"
#define AMIGADOS_REV 33L
#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"
#ifdef SYS_NAME
# define TXTSYSMSG TXTCOMPMSG " for " SYS_NAME
# define SYSKNOWN 1
#else
# define TXTSYSMSG TXTCOMPMSG
#endif
/******************************************************************************/
#endif

+ 2
- 2
src/amathc.h 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.
*
* Redistribution and use in source and binary forms, with or without
@ -24,7 +24,7 @@
*
* Project homepage:
* https://amath.innolan.net
*
*
*/
#ifndef AMATHC_H


+ 2
- 2
src/amatht.h 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.
*
* Redistribution and use in source and binary forms, with or without
@ -24,7 +24,7 @@
*
* Project homepage:
* https://amath.innolan.net
*
*
*/
#ifndef AMATHT_H


+ 2
- 2
src/clib/alloccpy.c 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.
*
* Redistribution and use in source and binary forms, with or without
@ -24,7 +24,7 @@
*
* Project homepage:
* https://amath.innolan.net
*
*
*/
#include "amathc.h"


+ 51
- 51
src/clib/amathc.3 View File

@ -1,6 +1,6 @@
.\" Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net>
.\" Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
.\" All rights reserved.
.\"
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
@ -9,7 +9,7 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
@ -20,7 +20,7 @@
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" 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
amathc.h \- C functions for manipulating strings and memory
.SH SYNOPSIS
@ -82,7 +82,7 @@ amathc.h \- C functions for manipulating strings and memory
.PP
.SS "unsigned int AllocAndCopy (char ** destination, const char * source)"
.PP
Allocate memory and copy a string into the array\&.
Allocate memory and copy a string into the array\&.
.PP
Definition at line 40 of file alloccpy\&.c\&.
.PP
@ -90,32 +90,32 @@ Definition at line 40 of file alloccpy\&.c\&.
41 {
42 char *i, *s, *d;
43 unsigned int n, size;
44
44
45 if (source == nullptr)
46 {
47 *destination = nullptr;
48 return 0;
49 }
50
50
51 i = (char*)source;
52 s = (char*)source;
53 while (*i)
54 i++;
55
55
56 n = (unsigned int)(i - s + 1);
57 size = n;
58 *destination = AllocMemSafe(size);
59 d = *destination;
60
60
64 while (n--)
65 *d++ = *s++;
67
67
68 return size;
69 }
.fi
.SS "void* AllocMemSafe (size_t)"
.PP
Allocate memory and add it to the global memory list\&.
Allocate memory and add it to the global memory list\&.
.PP
Definition at line 86 of file mem\&.c\&.
.PP
@ -123,7 +123,7 @@ Definition at line 86 of file mem\&.c\&.
87 {
88 struct MemoryBlock* newblock;
89 size_t allocsize;
90
90
91 if (list == nullptr)
92 {
93 list = (struct MemoryList*)ALLOC_MEM(sizeof(struct MemoryList));
@ -132,13 +132,13 @@ Definition at line 86 of file mem\&.c\&.
96 alloc_error("list", sizeof(struct MemoryList));
97 return 0;
98 }
99
99
100 list->first = nullptr;
101 list->peak = 0;
102 list->size = 0;
103 list->count = 0;
104 }
105
105
106 #ifdef P64BIT
107 // Align to bytes of 8
108 allocsize = (size + 7) & ~0x07;
@ -146,14 +146,14 @@ Definition at line 86 of file mem\&.c\&.
110 // Align to bytes of 4
111 allocsize = (size + 3) & ~0x03;
112 #endif
113
113
114 newblock = (struct MemoryBlock*)ALLOC_MEM(sizeof(struct MemoryBlock));
115 if (!newblock)
116 {
117 alloc_error("block", sizeof(struct MemoryBlock));
118 return 0;
119 }
120
120
121 newblock->address = (struct MemoryBlock*)ALLOC_MEM(allocsize);
122 if (!newblock->address)
123 {
@ -161,25 +161,25 @@ Definition at line 86 of file mem\&.c\&.
125 alloc_error("memory", allocsize);
126 return 0;
127 }
128
128
129 newblock->size = allocsize;
130 newblock->next = list->first;
131 list->first = newblock;
132 list->size += allocsize;
133 list->count++;
134
134
135 if (list->size > list->peak)
136 {
137 list->peak = list->size;
138 }
139
139
140 // Memory allocated
141 return newblock->address;
142 }
.fi
.SS "void DetachMemSafe (void * block)"
.PP
Detach an allocated memory from the global memory list\&. The memory block is only detached, not deallocated\&.
Detach an allocated memory from the global memory list\&. The memory block is only detached, not deallocated\&.
.PP
Definition at line 209 of file mem\&.c\&.
.PP
@ -190,19 +190,19 @@ Definition at line 209 of file mem\&.c\&.
.fi
.SS "void FreeAllSafe ()"
.PP
Deallocate all memory in the global memory list\&.
Deallocate all memory in the global memory list\&.
.PP
Definition at line 217 of file mem\&.c\&.
.PP
.nf
218 {
219 struct MemoryBlock *current, *next;
220
220
221 if (list == nullptr)
222 {
223 return;
224 }
225
225
226 current = list->first;
227 while (current != nullptr)
228 {
@ -211,14 +211,14 @@ Definition at line 217 of file mem\&.c\&.
231 FREE_MEM(current);
232 current = next;
233 }
234
234
235 FREE_MEM(list);
236 list = nullptr;
237 }
.fi
.SS "void FreeMemSafe (void *)"
.PP
Deallocate memory from the global memory list\&.
Deallocate memory from the global memory list\&.
.PP
Definition at line 200 of file mem\&.c\&.
.PP
@ -229,7 +229,7 @@ Definition at line 200 of file mem\&.c\&.
.fi
.SS "void MemCopy (void * destination, const void * source, unsigned int length)"
.PP
Copy a block of memory, handling overlap\&.
Copy a block of memory, handling overlap\&.
.PP
Definition at line 75 of file memcpy\&.c\&.
.PP
@ -238,10 +238,10 @@ Definition at line 75 of file memcpy\&.c\&.
77 char* dst = (char*) destination;
78 const char* src = (const char*) source;
79 unsigned int t;
80
80
81 if (length == 0 || dst == src) // nothing to do
82 return;
83
83
84 if ((mem_ptr)dst < (mem_ptr)src)
85 {
86 // Copy forward
@ -254,14 +254,14 @@ Definition at line 75 of file memcpy\&.c\&.
96 else
97 t = wsize - (t & wmask);
98 length -= t;
99
99
100 TLOOP1(*dst++ = *src++);
101 }
102
102
103 // Copy whole words, then mop up any trailing bytes\&.
104 t = length / wsize;
105 TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize);
106
106
107 t = length & wmask;
108 TLOOP(*dst++ = *src++);
110 }
@ -280,13 +280,13 @@ Definition at line 75 of file memcpy\&.c\&.
123 else
124 t &= wmask;
125 length -= t;
126
126
127 TLOOP1(*--dst = *--src);
128 }
129
129
130 t = length / wsize;
131 TLOOP(src -= wsize; dst -= wsize; *(word *)dst = *(word *)src);
132
132
133 t = length & wmask;
134 TLOOP(*--dst = *--src);
135 }
@ -294,7 +294,7 @@ Definition at line 75 of file memcpy\&.c\&.
.fi
.SS "void MemSet (void * destination, int c0, unsigned int length)"
.PP
Fill block of memory with a constant value\&.
Fill block of memory with a constant value\&.
.PP
Definition at line 56 of file memset\&.c\&.
.PP
@ -303,7 +303,7 @@ Definition at line 56 of file memset\&.c\&.
58 unsigned char* dst = (unsigned char*) dst0;
59 unsigned int t;
60 unsigned int c;
61
61
62 /*
63 * If not enough words, just fill bytes\&. A length >= 2 words
64 * guarantees that at least one of them is `complete' after
@ -325,7 +325,7 @@ Definition at line 56 of file memset\&.c\&.
80 --length;
81 }
82 }
83
83
84 if ((c = (unsigned char)c0) != 0)
85 { /* Fill the word\&. */
86 c = (c << 8) | c; /* u_int is 16 bits\&. */
@ -336,7 +336,7 @@ Definition at line 56 of file memset\&.c\&.
91 c = (c << 32) | c; /* u_int is 64 bits\&. */
92 #endif
93 }
94
94
95 /* Align destination by filling in bytes\&. */
96 if ((t = (mem_ptr)dst & wmask) != 0)
97 {
@ -348,7 +348,7 @@ Definition at line 56 of file memset\&.c\&.
103 }
104 while (--t != 0);
105 }
106
106
107 /* Fill words\&. Length was >= 2*words so we know t >= 1 here\&. */
108 t = length / wsize;
109 do
@ -357,7 +357,7 @@ Definition at line 56 of file memset\&.c\&.
112 dst += wsize;
113 }
114 while (--t != 0);
115
115
116 /* Mop up trailing bytes, if any\&. */
117 t = length & wmask;
118 if (t != 0)
@ -370,7 +370,7 @@ Definition at line 56 of file memset\&.c\&.
.fi
.SS "void MemUsage (long *, long *, long *)"
.PP
Get memory usage in the global memory list\&.
Get memory usage in the global memory list\&.
.PP
Definition at line 242 of file mem\&.c\&.
.PP
@ -383,26 +383,26 @@ Definition at line 242 of file mem\&.c\&.
.fi
.SS "bool StrIsEqual (const char * s1, const char * s2)"
.PP
Compare two null terminated strings to each other\&.
Compare two null terminated strings to each other\&.
.PP
Definition at line 50 of file strcmp\&.c\&.
.PP
.nf
51 {
52 int r;
53
53
54 while (*s1 == *s2++)
55 if (*s1++ == '\0')
56 return true;
57
57
58 r = (*(const unsigned char *)s1 - *(const unsigned char *)(s2 - 1));
59
59
60 return r == 0;
61 }
.fi
.SS "int StrLen (const char * string)"
.PP
Get the length of a null terminated string\&.
Get the length of a null terminated string\&.
.PP
Definition at line 34 of file strlen\&.c\&.
.PP
@ -424,10 +424,10 @@ Definition at line 32 of file untag\&.c\&.
34 const char *pos, *tmp, *tag;
35 char* dest;
36 int unsigned i, j, found;
37
37
38 pos = source;
39 dest = destination;
40
40
41 while (*pos != '\0')
42 {
43 if (*pos != '#')
@ -449,7 +449,7 @@ Definition at line 32 of file untag\&.c\&.
59 tag++;
60 j++;
61 }
62
62
63 if (j > 1 && *(--tag) == '#')
64 {
65 // Tag found\&. Now replace\&.
@ -461,7 +461,7 @@ Definition at line 32 of file untag\&.c\&.
71 break;
72 }
73 }
74
74
75 if (!found)
76 {
77 (*dest++ = *pos++);
@ -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
Chris Torek.
.SH COPYRIGHT
Copyright (c) 2014-2018 Carsten Sonne Larsen <cs@innolan.net>
Copyright (c) 2014-2021 Carsten Sonne Larsen <cs@innolan.net>
.br
Copyright (c) 2007 The NetBSD Foundation, Inc.
.br


+ 2
- 2
src/clib/amathc.dox View File

@ -1,10 +1,10 @@
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "amathc"
PROJECT_NUMBER = "1.8.5"
PROJECT_NUMBER = "1.9.0"
PROJECT_BRIEF = "C functions for manipulating strings and memory"
PROJECT_LOGO =
OUTPUT_DIRECTORY =
OUTPUT_DIRECTORY =
CREATE_SUBDIRS = NO
ALLOW_UNICODE_NAMES = NO
OUTPUT_LANGUAGE = English


+ 1
- 1
src/clib/amathc.pc View File

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

+ 77
- 39
src/clib/mem.c 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.
*
* Redistribution and use in source and binary forms, with or without
@ -24,7 +24,7 @@
*
* Project homepage:
* https://amath