mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +03:00
Compare commits
63 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
a547c36f0a | ||
|
1e2698b42d | ||
|
33815f49e6 | ||
|
732279bcc3 | ||
|
7f4e1eb68d | ||
|
1232b59949 | ||
|
90feefc622 | ||
|
c97ee188ad | ||
|
ae85846839 | ||
|
e096bd9ad8 | ||
|
884b1bc81b | ||
|
a30a518ba7 | ||
|
bb3b861090 | ||
|
0a3469125e | ||
|
9b37e79f21 | ||
|
18cd1f9067 | ||
|
43fc022dc8 | ||
|
29695028cd | ||
|
1d37930d22 | ||
|
60698d2130 | ||
|
3e7ccfd31c | ||
|
488d81b809 | ||
|
932d27053e | ||
|
8e8d6c852a | ||
|
54dd89dcf7 | ||
|
d91e966f19 | ||
|
8d6f83ad91 | ||
|
8dd380a9f7 | ||
|
fbaff69c92 | ||
|
c724227ef9 | ||
|
3fd64578a6 | ||
|
c9c4105ddc | ||
|
80b7cd34fe | ||
|
630947d35c | ||
|
45f62fd7b4 | ||
|
8ca980b2bb | ||
|
2ace631d00 | ||
|
41d339c60e | ||
|
cc3bb98fa0 | ||
|
2b506a74e7 | ||
|
826d2d8175 | ||
|
af8ffb3098 | ||
|
71dd30c4c6 | ||
|
8ca96a8c29 | ||
|
0bba80c92b | ||
|
c1882e2ea0 | ||
|
79964338d1 | ||
|
d809ce5cf0 | ||
|
daac7b35af | ||
|
40d6e22318 | ||
|
ab2038ecbc | ||
|
0b57d6b605 | ||
|
01f0605055 | ||
|
0e6016f429 | ||
|
2d2e1c5894 | ||
|
50ba5f9a3e | ||
|
850cdbef1d | ||
|
21cedfcae4 | ||
|
4fa137a638 | ||
|
6ebe707670 | ||
|
885db22315 | ||
|
06a9997da7 | ||
|
fae4b8e81b |
43
.gitignore
vendored
43
.gitignore
vendored
@@ -1,17 +1,17 @@
|
||||
# generic excluded patterns
|
||||
#
|
||||
# We sort the list below via: sort -u -f
|
||||
# We sort the list below via: sort -d -u
|
||||
#
|
||||
*,v
|
||||
*.BAK
|
||||
*.dSYM/
|
||||
*.exe
|
||||
*.o.tmp
|
||||
*.[oa]
|
||||
*~
|
||||
.*.swp
|
||||
*.BAK
|
||||
.DS_Store
|
||||
core*
|
||||
*.dSYM/
|
||||
*.exe
|
||||
*.[oa]
|
||||
*.o.tmp
|
||||
.*.swp
|
||||
*,v
|
||||
|
||||
# files and directories created during the building of calc and other Makefile actions
|
||||
#
|
||||
@@ -19,50 +19,51 @@ core*
|
||||
# not consider development source. Some other file(s) and/or programs
|
||||
# generate these files.
|
||||
#
|
||||
# We sort the list below via: sort -u -f
|
||||
# We sort the list below via: sort -d -u
|
||||
#
|
||||
.dynamic
|
||||
.hsrc
|
||||
.static
|
||||
Makefile.our
|
||||
NOTES
|
||||
align32
|
||||
align32.h
|
||||
align32_tmp
|
||||
arc4random_tmp
|
||||
args.h
|
||||
cal/.all
|
||||
cal/test082.cal
|
||||
calc
|
||||
calc-static
|
||||
calc.1
|
||||
calc.cat1
|
||||
calc.spec
|
||||
calc-static
|
||||
calc.usage
|
||||
cal/test082.cal
|
||||
charbit.h
|
||||
chatbit
|
||||
chk_c
|
||||
conf.h
|
||||
const_tmp
|
||||
cscript/.all
|
||||
cscript/4dsphere
|
||||
cscript/README
|
||||
cscript/.all
|
||||
cscript/fproduct
|
||||
cscript/mersenne
|
||||
cscript/piforever
|
||||
cscript/plus
|
||||
cscript/powerterm
|
||||
cscript/README
|
||||
cscript/simple
|
||||
cscript/square
|
||||
custom/.all
|
||||
custom/libcustcalc*
|
||||
debug.out
|
||||
.dynamic
|
||||
endian
|
||||
endian_calc.h
|
||||
environ_tmp
|
||||
errcode
|
||||
errsym.h
|
||||
fpos_tmp
|
||||
fposval
|
||||
fposval.h
|
||||
fposval_tmp
|
||||
fpos_tmp
|
||||
func.show
|
||||
func.sort
|
||||
getpgid_tmp
|
||||
@@ -127,6 +128,8 @@ have_urandom.h
|
||||
have_ustat
|
||||
have_ustat.h
|
||||
have_varvs
|
||||
help/COPYING
|
||||
help/COPYING-LGPL
|
||||
help/.all
|
||||
help/binding
|
||||
help/bindings
|
||||
@@ -137,8 +140,6 @@ help/change
|
||||
help/changes
|
||||
help/contrib
|
||||
help/copy
|
||||
help/COPYING
|
||||
help/COPYING-LGPL
|
||||
help/cscript
|
||||
help/custom_cal
|
||||
help/errorcode
|
||||
@@ -156,15 +157,14 @@ help/releases
|
||||
help/resource
|
||||
help/type
|
||||
help/usage
|
||||
.hsrc
|
||||
libcalc.*
|
||||
libcustcalc.*
|
||||
ll_tmp
|
||||
longbits
|
||||
longbits.h
|
||||
Makefile.our
|
||||
memmv_tmp
|
||||
newstr_tmp
|
||||
NOTES
|
||||
offscl_tmp
|
||||
outfile
|
||||
posscl_tmp
|
||||
@@ -174,6 +174,7 @@ sample_many-static
|
||||
sample_rand
|
||||
sample_rand-static
|
||||
statfs_tmp
|
||||
.static
|
||||
status.chk_c.h
|
||||
strdup_tmp
|
||||
tags
|
||||
|
4
BUGS
4
BUGS
@@ -101,7 +101,9 @@ Known bugs in calc:
|
||||
The output of the alg_config.cal resource file is bogus.
|
||||
We would welcome a replacement for this code.
|
||||
|
||||
Calc may not compile natively under Windows 11. See README.WINDOWS.
|
||||
Calc may not compile natively under Windows 11, however with
|
||||
MSYS2 Software Distribution (a fork of Cygwin) people compile
|
||||
calc under Windiws just fine. See README.WINDOWS.
|
||||
|
||||
We are sure some more bugs exist. When you find them, please let
|
||||
us know! See the above for details on how to report and were to
|
||||
|
131
CHANGES
131
CHANGES
@@ -1,3 +1,132 @@
|
||||
The following are the changes from calc version 2.15.0.6 to 2.15.0.7:
|
||||
|
||||
Thanks to GitHub user @bambooleafz a critical bug (GitHub issue
|
||||
#148 - https://github.com/lcn2/calc/issues/148) they identified
|
||||
was fixed.
|
||||
|
||||
|
||||
The following are the changes from calc version 2.15.0.5 to 2.15.0.6:
|
||||
|
||||
Thanks to GitHub user @ashamedbit, a long standing memory leak in
|
||||
zrandom.c has been fixed.
|
||||
|
||||
|
||||
The following are the changes from calc version 2.15.0.4 to 2.15.0.5:
|
||||
|
||||
make clobber now removes the legacy files: have_fpos.h, help/man,
|
||||
and help/usage. The latter 2 are now managed as help aliases
|
||||
in help.c.
|
||||
|
||||
make install now removes the legacy files: ${HELPDIR}/man
|
||||
and ${HELPDIR}/usage.
|
||||
|
||||
Fixed a problem where, when calc was linked with and uses GNU
|
||||
readline then for any multi-line copy-and-paste, only the first
|
||||
line is executed. Thanks to GitHub user @malfisya for reporting
|
||||
this problem, and thanks to GitHub user @gromit1811 for doing
|
||||
the research needed to overcome deficiencies in the GNU readline
|
||||
documentation, and for supplying the work-a-round to allow
|
||||
multi-line copy-and-paste to work as expected!
|
||||
|
||||
|
||||
The following are the changes from calc version 2.15.0.3 to 2.15.0.4:
|
||||
|
||||
Fixed bug that caused calc to fail to compile filepos2z() in file.c
|
||||
on little endian machines for the Debian apcalc package. Thanks to
|
||||
Martin Buck (m at rtin-buck dor de) for for fix.
|
||||
|
||||
Removed unused macros from zmath.h:
|
||||
|
||||
SWAP_B32_IN_HASH(dest, src)
|
||||
SWAP_B16_IN_HASH(dest, src)
|
||||
SWAP_B8_IN_HASH(dest, src)
|
||||
SWAP_B32_IN_FLAG(dest, src)
|
||||
SWAP_B16_IN_FLAG(dest, src)
|
||||
SWAP_B8_IN_FLAG(dest, src)
|
||||
|
||||
When SWAP_HALF_IN_B32(dest, src), SWAP_B32_IN_FULL(dest, src),
|
||||
SWAP_B16_IN_HALF(dest, src), SWAP_B32_IN_bool(dest, src),
|
||||
or SWAP_B32_IN_LEN(dest, src), SWAP_HALF_IN_FILEPOS(dest, src)
|
||||
is an assignment such as:
|
||||
|
||||
(*(dest) = *(src))
|
||||
|
||||
We now case the dest and src pointers to the proper type before
|
||||
referencing and performing the assignment.
|
||||
|
||||
Documented unexpected behavior when calc is running in
|
||||
"shell script mode" and the prompt builtin function is used
|
||||
without the -p flag. Updated help/prompt, help/unexpected
|
||||
and the calc man page accordingly.
|
||||
|
||||
Unless calc is given the -p command line option, calc will reopen
|
||||
stdin as /dev/null instead of just closing stdin. This prevents
|
||||
subsequent opens grabbing the 1st file descriptor.
|
||||
|
||||
Disable regress tests 4709, 4710, and 7763 because they print
|
||||
multi-byte sequences, which are just fine for calc, the awk
|
||||
used to evaluate the regression suite output in some legacy
|
||||
systems report a "multibyte conversion failure".
|
||||
|
||||
Added a number of missing Makefile variables to the "make env" rule.
|
||||
|
||||
The man command is used to format the calc.1 man page into calc.usage.
|
||||
|
||||
The "help calc" command now prints the formatted calc man page (calc.usage).
|
||||
The "help man" command now prints the formatted calc man page (calc.usage).
|
||||
The "help usage" command now prints the formatted calc man page (calc.usage).
|
||||
|
||||
The file, calc.cat1, is formed by gzipping the calc.usage
|
||||
formatted man page. The calc.cat1 is installed as the calc
|
||||
cat section 1 man page.
|
||||
|
||||
Updated the Copyright string in version.c to refer to
|
||||
the COPYING file and the "help copying" command.
|
||||
|
||||
Added calc.cat1 to .gitignore. Using "sort -d -u" to sort .gitignore content.
|
||||
|
||||
Avoiding use of modern [[ and ]] in Makefile for those legacy systems
|
||||
whose shell do not support them. Be sure to use ||'s between []'s
|
||||
to avoid problems with legacy shell such as the Bourne shell. *sigh*
|
||||
|
||||
Fixed the order of "help full" to match the order of topics listed
|
||||
buy the "help help" command.
|
||||
|
||||
Sorted the halias[] help topics table in help.c using sort -d -u.
|
||||
|
||||
|
||||
The following are the changes from calc version 2.15.0.1 to 2.15.0.2:
|
||||
|
||||
Updated BUGS about MSYS2 on Windows compiling of calc.
|
||||
|
||||
Added more git related checks and sanity checks to chk_tree.
|
||||
|
||||
Added ${FSANITIZE} make variable to Makefile.config to hold
|
||||
common Address Sanitizer (ASAN) optins to modern Linux and macOS.
|
||||
The Address Sanitizer is NOT enabled not compiled in by default.
|
||||
Improved comments in Makefile.local for RHEL9.2 (Linux) and for
|
||||
macOS 14.0 that, when uncommented and calc is recompiled (i.e.,
|
||||
make clobber all) will enable the Address Sanitizer (ASAN) for calc.
|
||||
|
||||
Fixed memory leaks in the logn, aversin, acoversin, avercos,
|
||||
acovercos, ahaversin, ahavercos, ahacovercos, aexsec,
|
||||
aexcsc, and acrd.
|
||||
|
||||
Fixed a compile error in zmath.h that impacted legacy 32-bit Big
|
||||
Endian machines. Thanks goes to GitHub user @gromit1811 for their
|
||||
pull request.
|
||||
|
||||
Fixed the check for <sys/mount.h> when forming have_sys_mount.h.
|
||||
Thanks goes to GitHub user @gromit1811 for their pull request.
|
||||
|
||||
Added "STATIC bool blum_initialized = false" to zrandom.c to improve
|
||||
how the code detects if the Blum-Blum-Shub pseudo-random number
|
||||
generator is seeded or not, and how to free the state correctly.
|
||||
|
||||
NOTE: There is a very minor memory leak in zrandom.c that will be
|
||||
fixed in a later release.
|
||||
|
||||
|
||||
The following are the changes from calc version 2.14.3.5 to 2.15.0.1:
|
||||
|
||||
The tarball for calc version 2.15.0.0 was missing version.h.
|
||||
@@ -4228,7 +4357,7 @@ The following are the changes from calc version 2.11.5t0 to 2.11.5t1.1:
|
||||
Fixed calc path in help/script.
|
||||
|
||||
Added read-only parameter, config("windows") to indicate if the system
|
||||
is MS windowz WIN32 like system.
|
||||
is MS Windows WIN32 like system.
|
||||
|
||||
Configuration values that used to return "true" or "false" now return
|
||||
1 (a true value) or 0 (a false value). Thus one can do:
|
||||
|
151
Makefile
151
Makefile
@@ -321,14 +321,17 @@ STATIC_FIRST_TARGETS= ${LICENSE} .static
|
||||
|
||||
# late targets - things needed after the main build phase is complete
|
||||
#
|
||||
LATE_TARGETS= calc.1 calc.usage \
|
||||
LATE_TARGETS= calc.1 calc.usage calc.cat1 \
|
||||
cal/.all help/.all help/builtin help/errorcodes \
|
||||
cscript/.all
|
||||
|
||||
# calc tools - tools used by the maintainers of the calc source base
|
||||
#
|
||||
# trailblank - find trailing blanks and other file format picky issues
|
||||
# update_ver - update version numbers in Makefile.config
|
||||
# Calc supplied tools:
|
||||
#
|
||||
# TRAILBLANK - find trailing blanks and other file format picky issues
|
||||
# UPDATE_VER - update version numbers in Makefile.config
|
||||
# CALC_TOOLS - the complete list of calc supplied tools
|
||||
#
|
||||
TRAILBLANK= trailblank
|
||||
UPDATE_VER= update_ver
|
||||
@@ -510,6 +513,8 @@ libcalc${LIB_EXT_VER}: libcalc${LIB_EXT_VERSION}
|
||||
#
|
||||
###
|
||||
|
||||
# Note: The :\(...-sed pattern below allows word wrapping at the separators
|
||||
# of long path names (typically CALCPATH and CALCRC).
|
||||
calc.1: calc.man ${MK_SET}
|
||||
${RM} -f $@
|
||||
${Q} echo forming calc.1 from calc.man
|
||||
@@ -523,18 +528,23 @@ calc.1: calc.man ${MK_SET}
|
||||
-e 's,$${CUSTOMINCDIR},${CUSTOMINCDIR},g' \
|
||||
-e 's,$${HELPDIR},${HELPDIR},g' \
|
||||
-e 's,$${CUSTOMHELPDIR},${CUSTOMHELPDIR},g' \
|
||||
-e 's,$${CALCRC},${CALCRC},g' < calc.man > calc.1
|
||||
-e 's,$${CALCRC},${CALCRC},g' \
|
||||
-e 's,:\([/.~]\),:\\:\1,g' < calc.man > calc.1
|
||||
${Q} echo calc.1 formed
|
||||
|
||||
calc.usage: calc.1 ${MK_SET}
|
||||
calc.usage: calc.1
|
||||
${Q} echo forming $@ from calc.1
|
||||
${RM} -f $@
|
||||
${Q} echo forming calc.usage from calc.1
|
||||
${Q} if [ -z "${NROFF}" ]; then \
|
||||
LESSCHARSET=iso8859 ${CALCPAGER} calc.1; \
|
||||
else \
|
||||
${NROFF} -man calc.1; \
|
||||
fi 2>&1 | ${GREP} -E -v 'cannot adjust line' | ${COL} -b > $@
|
||||
${Q} echo calc.usage formed
|
||||
${MAN} ./calc.1 > $@
|
||||
${CHMOD} 0444 $@
|
||||
${Q} echo $@ formed
|
||||
|
||||
calc.cat1: calc.usage
|
||||
${Q} echo forming $@ from calc.usage
|
||||
${RM} -f $@
|
||||
${GZIP} --best -f -c calc.usage > $@
|
||||
${CHMOD} 0444 $@
|
||||
${Q} echo $@ formed
|
||||
|
||||
|
||||
##
|
||||
@@ -560,7 +570,7 @@ sample_many${EXT}: sample_many.o ${CALC_DYNAMIC_LIBS} ${MK_SET}
|
||||
###
|
||||
|
||||
hist.o: hist.c ${MK_SET}
|
||||
${CC} ${CFLAGS} ${TERMCONTROL} ${USE_READLINE} ${READLINE_INCLUDE} \
|
||||
${CC} ${CFLAGS} -Wno-strict-prototypes ${TERMCONTROL} ${USE_READLINE} ${READLINE_INCLUDE} \
|
||||
-c hist.c
|
||||
|
||||
seed.o: seed.c ${MK_SET}
|
||||
@@ -1821,7 +1831,7 @@ have_sys_mount.h: ${MK_SET}
|
||||
echo '#define HAVE_SYS_MOUNT_H /* yes */' >> $@; \
|
||||
elif [ X"${HAVE_SYS_MOUNT_H}" = X"NO" ]; then \
|
||||
echo '#undef HAVE_SYS_MOUNT_H /* no */' >> $@; \
|
||||
elif echo '#include <sys/param.h>' | ${CC} -E - ${S}; then \
|
||||
elif echo '#include <sys/mount.h>' | ${CC} -E - ${S}; then \
|
||||
echo '#define HAVE_SYS_MOUNT_H /* yes */' >> $@; \
|
||||
else \
|
||||
echo '#undef HAVE_SYS_MOUNT_H /* no */' >> $@; \
|
||||
@@ -2843,23 +2853,25 @@ env:
|
||||
@echo 'BUILD_C_SRC=${BUILD_C_SRC}'; echo ''
|
||||
@echo 'BUILD_H_SRC=${BUILD_H_SRC}'; echo ''
|
||||
@echo 'BYTE_ORDER=${BYTE_ORDER}'; echo ''
|
||||
@echo 'CALC_BYTE_ORDER=${CALC_BYTE_ORDER}'; echo ''
|
||||
@echo 'CALC_CHARBIT=${CALC_CHARBIT}'; echo ''
|
||||
@echo 'CALC_DYNAMIC_LIBS=${CALC_DYNAMIC_LIBS}'; echo ''
|
||||
@echo 'CALC_ENV=${CALC_ENV}'; echo ''
|
||||
@echo 'CALC_INCDIR=${CALC_INCDIR}'; echo ''
|
||||
@echo 'CALCLIBLIST=${CALCLIBLIST}'; echo ''
|
||||
@echo 'CALCOBJS=${CALCOBJS}'; echo ''
|
||||
@echo 'CALCPAGER=${CALCPAGER}'; echo ''
|
||||
@echo 'CALCPATH=${CALCPATH}'; echo ''
|
||||
@echo 'CALCRC=${CALCRC}'; echo ''
|
||||
@echo 'CALCSRC=${CALCSRC}'; echo ''
|
||||
@echo 'CALC_DYNAMIC_LIBS=${CALC_DYNAMIC_LIBS}'; echo ''
|
||||
@echo 'CALC_ENV=${CALC_ENV}'; echo ''
|
||||
@echo 'CALC_INCDIR=${CALC_INCDIR}'; echo ''
|
||||
@echo 'CALC_SHAREDIR=${CALC_SHAREDIR}'; echo ''
|
||||
@echo 'CALCSRC=${CALCSRC}'; echo ''
|
||||
@echo 'CALC_STATIC_LIBS=${CALC_STATIC_LIBS}'; echo ''
|
||||
@echo 'CALC_TOOLS=${CALC_TOOLS}'; echo ''
|
||||
@echo 'CAT=${CAT}'; echo ''
|
||||
@echo 'CATDIR=${CATDIR}'; echo ''
|
||||
@echo 'CATEXT=${CATEXT}'; echo ''
|
||||
@echo 'CATMODE=${CATMODE}'; echo ''
|
||||
@echo 'CC=${CC}'; echo ''
|
||||
@echo 'CCBAN=${CCBAN}'; echo ''
|
||||
@echo 'CC=${CC}'; echo ''
|
||||
@echo 'CCMISC=${CCMISC}'; echo ''
|
||||
@echo 'CCOPT=${CCOPT}'; echo ''
|
||||
@echo 'CCWARN=${CCWARN}'; echo ''
|
||||
@@ -2868,32 +2880,36 @@ env:
|
||||
@echo 'CHMOD=${CHMOD}'; echo ''
|
||||
@echo 'CMP=${CMP}'; echo ''
|
||||
@echo 'CO=${CO}'; echo ''
|
||||
@echo 'COL=${COL}'; echo ''
|
||||
@echo 'COMMON_ADD=${COMMON_ADD}'; echo ''
|
||||
@echo 'COMMON_CFLAGS=${COMMON_CFLAGS}'; echo ''
|
||||
@echo 'COMMON_LDFLAGS=${COMMON_LDFLAGS}'; echo ''
|
||||
@echo 'CONFIG_MKF=${CONFIG_MKF}'; echo ''
|
||||
@echo 'CP=${CP}'; echo ''
|
||||
@echo 'CSCRIPT_TARGETS=${CSCRIPT_TARGETS}'; echo ''
|
||||
@echo 'C_SRC=${C_SRC}'; echo ''
|
||||
@echo 'CTAGS=${CTAGS}'; echo ''
|
||||
@echo 'CUSTOMCALDIR=${CUSTOMCALDIR}'; echo ''
|
||||
@echo 'CUSTOMHELPDIR=${CUSTOMHELPDIR}'; echo ''
|
||||
@echo 'CUSTOMINCDIR=${CUSTOMINCDIR}'; echo ''
|
||||
@echo 'C_SRC=${C_SRC}'; echo ''
|
||||
@echo 'DATE=${DATE}'; echo ''
|
||||
@echo 'DEBUG=${DEBUG}'; echo ''
|
||||
@echo 'DEFAULT_LIB_INSTALL_PATH=${DEFAULT_LIB_INSTALL_PATH}'; echo ''
|
||||
@echo 'DEV_BITS=${DEV_BITS}'; echo ''
|
||||
@echo 'DIFF=${DIFF}'; echo ''
|
||||
@echo 'DISTLIST=${DISTLIST}'; echo ''
|
||||
@echo 'E=${E}'; echo ''
|
||||
@echo 'DYNAMIC_FIRST_TARGETS=${DYNAMIC_FIRST_TARGETS}'; echo ''
|
||||
@echo 'EARLY_TARGETS=${EARLY_TARGETS}'; echo ''
|
||||
@echo 'ECHON=${ECHON}'; echo ''
|
||||
@echo 'E=${E}'; echo ''
|
||||
@echo 'EXT=${EXT}'; echo ''
|
||||
@echo 'EXTRA_CFLAGS=${EXTRA_CFLAGS}'; echo ''
|
||||
@echo 'EXTRA_LDFLAGS=${EXTRA_LDFLAGS}'; echo ''
|
||||
@echo 'FMT=${FMT}'; echo ''
|
||||
@echo 'FPOS_BITS=${FPOS_BITS}'; echo ''
|
||||
@echo 'FPOS_POS_BITS=${FPOS_POS_BITS}'; echo ''
|
||||
@echo 'FSANITIZE=${FSANITIZE}'; echo ''
|
||||
@echo 'GREP=${GREP}'; echo ''
|
||||
@echo 'H=${H}'; echo ''
|
||||
@echo 'GZIP=${GZIP}'; echo ''
|
||||
@echo 'HAVE_ARC4RANDOM=${HAVE_ARC4RANDOM}'; echo ''
|
||||
@echo 'HAVE_CONST=${HAVE_CONST}'; echo ''
|
||||
@echo 'HAVE_ENVIRON=${HAVE_ENVIRON}'; echo ''
|
||||
@@ -2921,11 +2937,11 @@ env:
|
||||
@echo 'HAVE_STRLCPY=${HAVE_STRLCPY}'; echo ''
|
||||
@echo 'HAVE_SYS_MOUNT_H=${HAVE_SYS_MOUNT_H}'; echo ''
|
||||
@echo 'HAVE_SYS_PARAM_H=${HAVE_SYS_PARAM_H}'; echo ''
|
||||
@echo 'HAVE_SYS_TIMES_H=${HAVE_SYS_TIMES_H}'; echo ''
|
||||
@echo 'HAVE_SYS_TIME_H=${HAVE_SYS_TIME_H}'; echo ''
|
||||
@echo 'HAVE_SYS_TIMES_H=${HAVE_SYS_TIMES_H}'; echo ''
|
||||
@echo 'HAVE_SYS_VFS_H=${HAVE_SYS_VFS_H}'; echo ''
|
||||
@echo 'HAVE_TIMES_H=${HAVE_TIMES_H}'; echo ''
|
||||
@echo 'HAVE_TIME_H=${HAVE_TIME_H}'; echo ''
|
||||
@echo 'HAVE_TIMES_H=${HAVE_TIMES_H}'; echo ''
|
||||
@echo 'HAVE_UID_T=${HAVE_UID_T}'; echo ''
|
||||
@echo 'HAVE_UNISTD_H=${HAVE_UNISTD_H}'; echo ''
|
||||
@echo 'HAVE_UNUSED=${HAVE_UNUSED}'; echo ''
|
||||
@@ -2933,6 +2949,7 @@ env:
|
||||
@echo 'HAVE_USTAT=${HAVE_USTAT}'; echo ''
|
||||
@echo 'HAVE_VSNPRINTF=${HAVE_VSNPRINTF}'; echo ''
|
||||
@echo 'HELPDIR=${HELPDIR}'; echo ''
|
||||
@echo 'H=${H}'; echo ''
|
||||
@echo 'HOSTNAME=${HOSTNAME}'; echo ''
|
||||
@echo 'H_SRC=${H_SRC}'; echo ''
|
||||
@echo 'ICFLAGS=${ICFLAGS}'; echo ''
|
||||
@@ -2943,46 +2960,48 @@ env:
|
||||
@echo 'LATE_TARGETS=${LATE_TARGETS}'; echo ''
|
||||
@echo 'LCC=${LCC}'; echo ''
|
||||
@echo 'LDCONFIG=${LDCONFIG}'; echo ''
|
||||
@echo 'LDFLAGS=${LDFLAGS}'; echo ''
|
||||
@echo 'LD_DEBUG=${LD_DEBUG}'; echo ''
|
||||
@echo 'LDFLAGS=${LDFLAGS}'; echo ''
|
||||
@echo 'LD_SHARE=${LD_SHARE}'; echo ''
|
||||
@echo 'LIBCALC_SHLIB=${LIBCALC_SHLIB}'; echo ''
|
||||
@echo 'LIBCUSTCALC_SHLIB=${LIBCUSTCALC_SHLIB}'; echo ''
|
||||
@echo 'LIBDIR=${LIBDIR}'; echo ''
|
||||
@echo 'LIB_EXT=${LIB_EXT}'; echo ''
|
||||
@echo 'LIB_EXT_VER=${LIB_EXT_VER}'; echo ''
|
||||
@echo 'LIB_EXT_VERSION=${LIB_EXT_VERSION}'; echo ''
|
||||
@echo 'LIB_H_SRC=${LIB_H_SRC}'; echo ''
|
||||
@echo 'LIBOBJS=${LIBOBJS}'; echo ''
|
||||
@echo 'LIBSRC=${LIBSRC}'; echo ''
|
||||
@echo 'LIB_H_SRC=${LIB_H_SRC}'; echo ''
|
||||
@echo 'LICENSE=${LICENSE}'; echo ''
|
||||
@echo 'LN=${LN}'; echo ''
|
||||
@echo 'LOCAL_MKF=${LOCAL_MKF}'; echo ''
|
||||
@echo 'LONG_BITS=${LONG_BITS}'; echo ''
|
||||
@echo 'MAKE=${MAKE}'; echo ''
|
||||
@echo 'LS=${LS}'; echo ''
|
||||
@echo 'MAKEDEPEND=${MAKEDEPEND}'; echo ''
|
||||
@echo 'MAKE_FILE=${MAKE_FILE}'; echo ''
|
||||
@echo 'MAKE=${MAKE}'; echo ''
|
||||
@echo 'MAN=${MAN}'; echo ''
|
||||
@echo 'MANDIR=${MANDIR}'; echo ''
|
||||
@echo 'MANEXT=${MANEXT}'; echo ''
|
||||
@echo 'MANMAKE=${MANMAKE}'; echo ''
|
||||
@echo 'MANMODE=${MANMODE}'; echo ''
|
||||
@echo 'MINGW=${MINGW}'; echo ''
|
||||
@echo 'MKDIR=${MKDIR}'; echo ''
|
||||
@echo 'MK_SET=${MK_SET}'; echo ''
|
||||
@echo 'MV=${MV}'; echo ''
|
||||
@echo 'NROFF=${NROFF}'; echo ''
|
||||
@echo 'NROFF_ARG=${NROFF_ARG}'; echo ''
|
||||
@echo 'OBJS=${OBJS}'; echo ''
|
||||
@echo 'OFF_T_BITS=${OFF_T_BITS}'; echo ''
|
||||
@echo 'OSNAME=${OSNAME}'; echo ''
|
||||
@echo 'PHONY=${PHONY}'; echo ''
|
||||
@echo 'PREFIX=${PREFIX}'; echo ''
|
||||
@echo 'PURIFY=${PURIFY}'; echo ''
|
||||
@echo 'PWD=${PWD}'; echo ''
|
||||
@echo 'PWDCMD=${PWDCMD}'; echo ''
|
||||
@echo 'PWD=${PWD}'; echo ''
|
||||
@echo 'Q=${Q}'; echo ''
|
||||
@echo 'RANLIB=${RANLIB}'; echo ''
|
||||
@echo 'READLINE_EXTRAS=${READLINE_EXTRAS}'; echo ''
|
||||
@echo 'READLINE_INCLUDE=${READLINE_INCLUDE}'; echo ''
|
||||
@echo 'READLINE_LIB=${READLINE_LIB}'; echo ''
|
||||
@echo 'RM=${RM}'; echo ''
|
||||
@echo 'RMDIR=${RMDIR}'; echo ''
|
||||
@echo 'S=${S}'; echo ''
|
||||
@echo 'RM=${RM}'; echo ''
|
||||
@echo 'SAMPLE_C_SRC=${SAMPLE_C_SRC}'; echo ''
|
||||
@echo 'SAMPLE_H_SRC=${SAMPLE_H_SRC}'; echo ''
|
||||
@echo 'SAMPLE_OBJ=${SAMPLE_OBJ}'; echo ''
|
||||
@@ -2993,17 +3012,23 @@ env:
|
||||
@echo 'SED=${SED}'; echo ''
|
||||
@echo 'SHELL=${SHELL}'; echo ''
|
||||
@echo 'SORT=${SORT}'; echo ''
|
||||
@echo 'SPLINT=${SPLINT}'; echo ''
|
||||
@echo 'SPLINT_OPTS=${SPLINT_OPTS}'; echo ''
|
||||
@echo 'SPLINT=${SPLINT}'; echo ''
|
||||
@echo 'S=${S}'; echo ''
|
||||
@echo 'STATIC_FIRST_TARGETS=${STATIC_FIRST_TARGETS}'; echo ''
|
||||
@echo 'STRIP=${STRIP}'; echo ''
|
||||
@echo 'SYM_DYNAMIC_LIBS=${SYM_DYNAMIC_LIBS}'; echo ''
|
||||
@echo 'T=${T}'; echo ''
|
||||
@echo 'TARGETS=${TARGETS}'; echo ''
|
||||
@echo 'TAIL=${TAIL}'; echo ''
|
||||
@echo 'TARGET_MKF=${TARGET_MKF}'; echo ''
|
||||
@echo 'TARGETS=${TARGETS}'; echo ''
|
||||
@echo 'TEE=${TEE}'; echo ''
|
||||
@echo 'TERMCONTROL=${TERMCONTROL}'; echo ''
|
||||
@echo 'TOUCH=${TOUCH}'; echo ''
|
||||
@echo 'TRAILBLANK=${TRAILBLANK}'; echo ''
|
||||
@echo 'TRUE=${TRUE}'; echo ''
|
||||
@echo 'T=${T}'; echo ''
|
||||
@echo 'UNAME=${UNAME}'; echo ''
|
||||
@echo 'UPDATE_VER=${UPDATE_VER}'; echo ''
|
||||
@echo 'USE_READLINE=${USE_READLINE}'; echo ''
|
||||
@echo 'UTIL_C_SRC=${UTIL_C_SRC}'; echo ''
|
||||
@echo 'UTIL_FILES=${UTIL_FILES}'; echo ''
|
||||
@@ -3011,8 +3036,9 @@ env:
|
||||
@echo 'UTIL_OBJS=${UTIL_OBJS}'; echo ''
|
||||
@echo 'UTIL_PROGS=${UTIL_PROGS}'; echo ''
|
||||
@echo 'UTIL_TMP=${UTIL_TMP}'; echo ''
|
||||
@echo 'V=${V}'; echo ''
|
||||
@echo 'VERSION=${VERSION}'; echo ''
|
||||
@echo 'VER=${VER}'; echo ''
|
||||
@echo 'V=${V}'; echo ''
|
||||
@echo 'WNO_ERROR_LONG_LONG=${WNO_ERROR_LONG_LONG}'; echo ''
|
||||
@echo 'WNO_IMPLICT=${WNO_IMPLICT};' echo ''
|
||||
@echo 'WNO_LONG_LONG=${WNO_LONG_LONG}'; echo ''
|
||||
@@ -3198,9 +3224,9 @@ prep:
|
||||
${Q}echo
|
||||
${MAKE} -s depend
|
||||
${Q}echo
|
||||
@if [[ -f ${MAKE_FILE}.bak ]]; then echo ${MAKE_FILE}.bak exists 1>&2; exit 1; fi
|
||||
@if [[ -f cscript/${MAKE_FILE}.bak ]]; then echo cscript/${MAKE_FILE}.bak exists 1>&2; exit 2; fi
|
||||
@if [[ -f custom/${MAKE_FILE}.bak ]]; then echo custom/${MAKE_FILE}.bak exists 1>&2; exit 3; fi
|
||||
@if [ -f ${MAKE_FILE}.bak ]; then echo ${MAKE_FILE}.bak exists 1>&2; exit 1; fi
|
||||
@if [ -f cscript/${MAKE_FILE}.bak ]; then echo cscript/${MAKE_FILE}.bak exists 1>&2; exit 2; fi
|
||||
@if [ -f custom/${MAKE_FILE}.bak ]; then echo custom/${MAKE_FILE}.bak exists 1>&2; exit 3; fi
|
||||
${Q}echo '=-=-=-=-=-= end of ${MAKE} depend =-=-=-=-=-='
|
||||
${Q}echo
|
||||
${Q}echo '=-=-=-=-=-= start of ${MAKE} testfuncsort =-=-=-=-=-='
|
||||
@@ -3215,19 +3241,17 @@ prep:
|
||||
${Q}echo
|
||||
${Q}echo '=-=-=-=-=-= end of ${UPDATE_VER} =-=-=-=-=-='
|
||||
${Q}echo
|
||||
${Q}echo '=-=-=-=-=-= start of chk_tree pass #1 =-=-=-=-=-='
|
||||
${Q}echo
|
||||
-./chk_tree
|
||||
${Q}echo
|
||||
${Q}echo '=-=-=-=-=-= end of chk_tree pass #1 =-=-=-=-=-='
|
||||
${Q}echo
|
||||
${Q}echo '=-=-=-=-=-= start of ${MAKE} chk =-=-=-=-=-='
|
||||
${Q}echo
|
||||
${MAKE} -s chk
|
||||
${Q}echo
|
||||
${Q}echo '=-=-=-=-=-= end of ${MAKE} chk =-=-=-=-=-='
|
||||
${Q}echo
|
||||
${Q}echo All is OK
|
||||
@${Q}if ! ./chk_tree >/dev/null 2>&1; then \
|
||||
echo almost satifactory except for chk_tree; \
|
||||
else \
|
||||
echo All is OK; \
|
||||
fi
|
||||
${Q}echo
|
||||
|
||||
run:
|
||||
@@ -3414,7 +3438,7 @@ clobber: clean
|
||||
${RM} -f *.u
|
||||
${RM} -f libcalc.a
|
||||
${RM} -f libcustcalc.a
|
||||
${RM} -f calc.1 calc.usage
|
||||
${RM} -f calc.1 calc.usage calc.cat1
|
||||
${RM} -f calc.pixie calc.rf calc.Counts calc.cord
|
||||
${RM} -f gen_h Makefile.bak tmp.patch
|
||||
${RM} -rf skel
|
||||
@@ -3454,7 +3478,7 @@ clobber: clean
|
||||
${RM} -rf .DS_Store; \
|
||||
fi
|
||||
${RM} -f func.show func.sort
|
||||
${RM} -f outfile
|
||||
${RM} -f outfile have_fpos.h
|
||||
${V} echo '=-=-=-=-= ${MAKE_FILE} end of $@ rule =-=-=-=-='
|
||||
|
||||
# install everything
|
||||
@@ -3750,7 +3774,7 @@ install: ${LIB_H_SRC} ${BUILD_H_SRC} calc.1 all custom/Makefile
|
||||
echo "removed old ${T}${CALC_INCDIR}/string.h"; \
|
||||
fi; \
|
||||
done
|
||||
-${Q} if [ -z "${MANDIR}" ]; then \
|
||||
-${Q} if [ -z "${MANDIR}" ] || [ ! -s calc.1 ]; then \
|
||||
${TRUE}; \
|
||||
else \
|
||||
if ${CMP} -s calc.1 ${T}${MANDIR}/calc.${MANEXT}; then \
|
||||
@@ -3764,24 +3788,17 @@ install: ${LIB_H_SRC} ${BUILD_H_SRC} calc.1 all custom/Makefile
|
||||
echo "installed ${T}${MANDIR}/calc.${MANEXT}"; \
|
||||
fi; \
|
||||
fi
|
||||
-${Q} if [ -z "${CATDIR}" ]; then \
|
||||
-${Q} if [ -z "${CATDIR}" ] || [ ! -s calc.cat1 ]; then \
|
||||
${TRUE}; \
|
||||
else \
|
||||
if ${CMP} -s calc.1 ${T}${MANDIR}/calc.${MANEXT}; then \
|
||||
if ${CMP} -s calc.cat1 ${T}${CATDIR}/calc.${MANEXT}; then \
|
||||
${TRUE}; \
|
||||
else \
|
||||
if [ -n "${NROFF}" ]; then \
|
||||
${RM} -f ${T}${CATDIR}/calc.${CATEXT}.new; \
|
||||
${NROFF} ${NROFF_ARG} calc.1 > \
|
||||
${T}${CATDIR}/calc.${CATEXT}.new; \
|
||||
${CHMOD} ${MANMODE} ${T}${MANDIR}/calc.${CATEXT}.new; \
|
||||
${MV} -f ${T}${CATDIR}/calc.${CATEXT}.new \
|
||||
${T}${CATDIR}/calc.${CATEXT}; \
|
||||
echo "installed ${T}${CATDIR}/calc.${CATEXT}"; \
|
||||
elif [ -x "${MANNAME}" ]; then \
|
||||
echo "${MANMAKE} calc.1 ${T}${CATDIR}"; \
|
||||
${MANMAKE} calc.1 ${T}${CATDIR}; \
|
||||
fi; \
|
||||
${RM} -f ${T}${CATDIR}/calc.${CATEXT}.new; \
|
||||
${CP} -f calc.cat1 ${T}${CATDIR}/calc.${CATEXT}.new; \
|
||||
${MV} -f ${T}${CATDIR}/calc.${CATEXT}.new \
|
||||
${T}${CATDIR}/calc.${CATEXT}; \
|
||||
echo "installed ${T}${CATDIR}/calc.${CATEXT}"; \
|
||||
fi; \
|
||||
fi
|
||||
${V} # NOTE: misc install cleanup
|
||||
|
@@ -997,9 +997,6 @@ endif # ($(target),Darwin)
|
||||
#
|
||||
# Use CATDIR= to disable installation of the calc cat (formatted) page.
|
||||
#
|
||||
# NOTE: If CATDIR is non-empty, then one should have either the
|
||||
# ${NROFF} executable and/or the ${MANMAKE} executable.
|
||||
#
|
||||
CATDIR=
|
||||
#CATDIR= ${PREFIX}/man/cat1
|
||||
#CATDIR= ${PREFIX}/catman/cat1
|
||||
@@ -1026,36 +1023,6 @@ CATEXT= 1
|
||||
#CATEXT= 0
|
||||
#CATEXT= l
|
||||
|
||||
# how to format a man page
|
||||
#
|
||||
# If CATDIR is non-empty, then
|
||||
#
|
||||
# If NROFF is non-empty, then
|
||||
#
|
||||
# ${NROFF} ${NROFF_ARG} calc.1 > ${CATDIR}/calc.${CATEXT}
|
||||
# is used to build and install the cat page
|
||||
#
|
||||
# else (NROFF is empty)
|
||||
#
|
||||
# ${MANMAKE} calc.1 ${CATDIR}
|
||||
# is used to build and install the cat page
|
||||
# else
|
||||
#
|
||||
# The cat page is not built or installed
|
||||
#
|
||||
# If in doubt and you don't want to fool with man pages, set MANDIR
|
||||
# and CATDIR to empty and ignore the NROFF, NROFF_ARG and MANMAKE
|
||||
# lines below.
|
||||
#
|
||||
#NROFF= nroff
|
||||
NROFF=
|
||||
#NROFF= groff
|
||||
NROFF_ARG= -man
|
||||
#NROFF_ARG= -mandoc
|
||||
MANMAKE= ${PREFIX}/bin/manmake
|
||||
#MANMAKE= manmake
|
||||
MANMODE= 0444
|
||||
CATMODE= 0444
|
||||
|
||||
# By default, custom builtin functions may only be executed if calc
|
||||
# is given the -C option. This is because custom builtin functions
|
||||
@@ -1276,7 +1243,7 @@ EXT=
|
||||
|
||||
# The calc version in the form of x.y.z.w
|
||||
#
|
||||
VERSION= 2.15.0.1
|
||||
VERSION= 2.15.0.7
|
||||
|
||||
# The calc major version in the form of x.y.z
|
||||
#
|
||||
@@ -1296,13 +1263,13 @@ CAT= cat
|
||||
CHMOD= chmod
|
||||
CMP= cmp
|
||||
CO= co
|
||||
COL= col
|
||||
CP= cp
|
||||
CTAGS= ctags
|
||||
DATE= date
|
||||
DIFF= diff
|
||||
FMT= fmt
|
||||
GREP= grep
|
||||
GZIP= gzip
|
||||
HOSTNAME= hostname
|
||||
LANG= C
|
||||
LDCONFIG= ldconfig
|
||||
@@ -1310,6 +1277,7 @@ LN= ln
|
||||
LS= ls
|
||||
MAKE= make
|
||||
MAKEDEPEND= makedepend
|
||||
MAN= man
|
||||
MKDIR= mkdir
|
||||
MV= mv
|
||||
PWDCMD= pwd
|
||||
@@ -1321,8 +1289,8 @@ SORT= sort
|
||||
SPLINT= splint
|
||||
SPLINT_OPTS=
|
||||
STRIP= strip
|
||||
TEE= tee
|
||||
TAIL= tail
|
||||
TEE= tee
|
||||
TOUCH= touch
|
||||
TRUE= true
|
||||
UNAME= uname
|
||||
@@ -1382,3 +1350,34 @@ endif # ($(ALLOW_CUSTOM),-DCUSTOM)
|
||||
# intermediate and final calc and calc related programs
|
||||
#
|
||||
COMMON_LDFLAGS= ${EXTRA_LDFLAGS}
|
||||
|
||||
# Common Address Sanitizer (ASAN)
|
||||
#
|
||||
# For more info see: https://github.com/google/sanitizers/wiki/AddressSanitizer
|
||||
# See also: https://developer.apple.com/documentation/xcode/diagnosing-memory-thread-and-crash-issues-early
|
||||
#
|
||||
# The following Address Sanitizer (ASAN) are common to both REHL9.2 (Linux) and macOS 14.0.
|
||||
#
|
||||
# By default, the Address Sanitizer is NOT enabled, not compiled into calc.
|
||||
# To enable the Address Sanitizer, uncomment the appropriate lines in Makefile.local !!!
|
||||
#
|
||||
FSANITIZE:= -Wno-invalid-command-line-argument
|
||||
FSANITIZE+= -fsanitize=address
|
||||
FSANITIZE+= -fsanitize=alignment
|
||||
FSANITIZE+= -fsanitize=bool
|
||||
FSANITIZE+= -fsanitize=enum
|
||||
FSANITIZE+= -fsanitize=vptr
|
||||
FSANITIZE+= -fsanitize=integer-divide-by-zero
|
||||
FSANITIZE+= -fsanitize=float-divide-by-zero
|
||||
FSANITIZE+= -fsanitize=float-cast-overflow
|
||||
FSANITIZE+= -fsanitize=nonnull-attribute
|
||||
FSANITIZE+= -fsanitize=returns-nonnull-attribute
|
||||
FSANITIZE+= -fsanitize=null
|
||||
FSANITIZE+= -fsanitize=object-size
|
||||
FSANITIZE+= -fsanitize=shift
|
||||
FSANITIZE+= -fsanitize=signed-integer-overflow
|
||||
FSANITIZE+= -fsanitize=undefined
|
||||
FSANITIZE+= -fsanitize=unreachable
|
||||
FSANITIZE+= -fsanitize=vla-bound
|
||||
FSANITIZE+= -fno-omit-frame-pointer
|
||||
FSANITIZE+= -fno-common
|
||||
|
@@ -50,75 +50,51 @@
|
||||
###################################################################
|
||||
|
||||
####
|
||||
#
|
||||
# Force calc to install under /usr/local
|
||||
#
|
||||
# BINDIR:= /usr/local/bin
|
||||
# LIBDIR:= /usr/local/lib
|
||||
# CALC_SHAREDIR:= /usr/local/share/calc
|
||||
# CALC_INCDIR:= /usr/local/include/calc
|
||||
#
|
||||
# PREFIX:= /usr/local
|
||||
# BINDIR:= ${PREFIX}/bin
|
||||
# LIBDIR:= ${PREFIX}/lib
|
||||
# CALC_SHAREDIR:= ${PREFIX}/share/calc
|
||||
# CALC_INCDIR:= ${PREFIX}/include/calc
|
||||
####
|
||||
|
||||
####
|
||||
# RHEL Diagnosing memory, thread, and crash issues:
|
||||
#
|
||||
# For more info see: https://github.com/google/sanitizers/wiki/AddressSanitizer
|
||||
# macOS Address Sanitizer (ASAN)
|
||||
#
|
||||
# This comment block was tested under:
|
||||
#
|
||||
# RHEL9 gcc version 11.3.1 20221121 (Red Hat 11.3.1-4) (GCC)
|
||||
# macOS 14.0 with Apple clang version 15.0.0 (clang-1500.0.40.1) for arm64
|
||||
#
|
||||
# with:
|
||||
# See the FSANITIZE comment block in Makefile.config for common FSANITIZE values and more info.
|
||||
#
|
||||
# libasan-11.3.1-4.3.el9.x86_64 libubsan-11.3.1-4.3.el9.x86_64
|
||||
# To use the Address Sanitizer, uncomment this set set of lines and recompile (make clobber all):
|
||||
#
|
||||
# NOTE: With the above version, these are NOT supported:
|
||||
#
|
||||
# UNSUPPORTED_FSANITIZE:= -fsanitize=nullability-arg -fsanitize=nullability-assign
|
||||
#
|
||||
# Uncomment these lines:
|
||||
#
|
||||
# FSANITIZE:= -fsanitize=undefined -fsanitize=address -fsanitize=bool -fsanitize=bounds
|
||||
# FSANITIZE+= -fsanitize=enum -fsanitize=vptr -fsanitize=integer-divide-by-zero
|
||||
# FSANITIZE+= -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow
|
||||
# FSANITIZE+= -fsanitize=nonnull-attribute -fsanitize=returns-nonnull-attribute
|
||||
# FSANITIZE+= -fsanitize=null -fsanitize=shift -fsanitize=signed-integer-overflow
|
||||
# FSANITIZE+= -fsanitize=unreachable -fsanitize=vla-bound
|
||||
# CFLAGS+= -Wno-invalid-command-line-argument ${FSANITIZE} -fno-omit-frame-pointer
|
||||
# LDFLAGS+= -Wno-invalid-command-line-argument ${FSANITIZE} -fno-omit-frame-pointer
|
||||
# CALC_ENV+= ASAN_OPTIONS=detect_stack_use_after_return=1
|
||||
# DEBUG:= -O0 -g
|
||||
####
|
||||
|
||||
####
|
||||
# macOS Diagnosing memory, thread, and crash issues:
|
||||
#
|
||||
# For more info see: https://github.com/google/sanitizers/wiki/AddressSanitizer
|
||||
#
|
||||
# This comment block was tested under:
|
||||
#
|
||||
# macOS 13.5 with clang version 14.0.3 (clang-1403.0.22.14.1)
|
||||
#
|
||||
# For more info for clang to Diagnosing memory, thread, and crash issues early, see:
|
||||
#
|
||||
# https://developer.apple.com/documentation/xcode/diagnosing-memory-thread-and-crash-issues-early
|
||||
#
|
||||
# NOTE: With the above version, these are NOT supported:
|
||||
#
|
||||
# UNSUPPORTED_FSANITIZE:= -fsanitize-nullability-return
|
||||
#
|
||||
# Uncomment these lines:
|
||||
#
|
||||
# FSANITIZE:= -fsanitize=undefined -fsanitize=address -fsanitize=bool -fsanitize=bounds
|
||||
# FSANITIZE+= -fsanitize=enum -fsanitize=vptr -fsanitize=integer-divide-by-zero
|
||||
# FSANITIZE+= -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow
|
||||
# FSANITIZE+= -fsanitize=nonnull-attribute -fsanitize=nullability-arg
|
||||
# FSANITIZE+= -fsanitize=nullability-assign -fsanitize=returns-nonnull-attribute
|
||||
# FSANITIZE+= -fsanitize=null -fsanitize=object-size -fsanitize=shift
|
||||
# FSANITIZE+= -fsanitize=signed-integer-overflow -fsanitize=unreachable -fsanitize=vla-bound
|
||||
# CFLAGS+= -Wno-invalid-command-line-argument ${FSANITIZE} -fno-omit-frame-pointer
|
||||
# LDFLAGS+= -Wno-invalid-command-line-argument ${FSANITIZE} -fno-omit-frame-pointer
|
||||
# CALC_ENV+= ASAN_OPTIONS=detect_stack_use_after_return=1
|
||||
# FSANITIZE+= -fsanitize=nullability-arg
|
||||
# FSANITIZE+= -fsanitize=nullability-assign
|
||||
# FSANITIZE+= -fsanitize=nullability-return
|
||||
# CFLAGS+= ${FSANITIZE}
|
||||
# LDFLAGS+= ${FSANITIZE}
|
||||
# DEBUG:= -O0 -g3
|
||||
####
|
||||
|
||||
####
|
||||
# RHEL (Linux) Address Sanitizer (ASAN)
|
||||
#
|
||||
# This comment block was tested under:
|
||||
#
|
||||
# RHEL9.2 with clang version 15.0.7 (Red Hat 15.0.7-2.el9) for x86_64
|
||||
#
|
||||
# with these RPMs installed:
|
||||
#
|
||||
# libasan-11.3.1-4.3.el9.x86_64 libubsan-11.3.1-4.3.el9.x86_64
|
||||
#
|
||||
# See the FSANITIZE comment block in Makefile.config for common FSANITIZE values and more info.
|
||||
#
|
||||
# To use the Address Sanitizer, uncomment this set set of lines and recompile (make clobber all):
|
||||
#
|
||||
# FSANITIZE+= -fsanitize=bounds
|
||||
# CFLAGS+= ${FSANITIZE}
|
||||
# LDFLAGS+= ${FSANITIZE}
|
||||
# DEBUG:= -O0 -g3
|
||||
###
|
||||
|
@@ -4879,8 +4879,9 @@ define test_charset()
|
||||
vrfy("\123" == char(0123), '4706: "\\123" == char(0123)');
|
||||
vrfy("\123\124" == "ST", '4707: "\\123\\124" == "ST"');
|
||||
vrfy("\311" == char(201), '4708: "\\311" == char(201)');
|
||||
vrfy("\119" == "\t9", '4709: "\\119" == "\t9"');
|
||||
vrfy("\765" == "\365", '4710: "\\765" == "\365"');
|
||||
/* NOTE: We skip non-ASCII to avoid problems with old awk that cannot handle them */
|
||||
/* vrfy("\119" == "\t9", '4709: "\\119" == "\t9"'); */
|
||||
/* vrfy("\765" == "\365", '4710: "\\765" == "\365"'); */
|
||||
vrfy("\x61" == "a", '4711: "\\x61" == "a"');
|
||||
vrfy("\x73" == "s", '4712: "\\x73" == "s"');
|
||||
vrfy("\xea" == char(234), '4713: "\\xea" == char(234)');
|
||||
@@ -8191,7 +8192,8 @@ define test_newstring()
|
||||
vrfy(A == "A\255gdef", '7761: A == "A\\255gdef"');
|
||||
setbit(A, 16, 0);
|
||||
print '7762: setbit(A, 16, 0);';
|
||||
vrfy(A == "A\255fdef", '7763: A == "A\255fdef"');
|
||||
/* NOTE: We skip non-ASCII to avoid problems with old awk that cannot handle them */
|
||||
/* vrfy(A == "A\255fdef", '7763: A == "A\255fdef"'); */
|
||||
|
||||
q = "curds" " and " "whey";
|
||||
print '7764: q = "curds" " and " "whey"';
|
||||
|
4
calc.c
4
calc.c
@@ -543,8 +543,8 @@ main(int argc, char **argv)
|
||||
cmdbuf[cmdlen++] = '\n';
|
||||
cmdbuf[cmdlen] = '\0';
|
||||
if (p_flag != true) {
|
||||
if (fclose(stdin)) {
|
||||
perror("main(): fclose(stdin) failed:");
|
||||
if (freopen("/dev/null", "r", stdin) == NULL) {
|
||||
perror("in main: freopen(\"/dev/null\", \"r\", stdin) failed:");
|
||||
}
|
||||
stdin_closed = true;
|
||||
}
|
||||
|
93
calc.man
93
calc.man
@@ -470,6 +470,24 @@ The
|
||||
flag overrides
|
||||
.BR \-i .
|
||||
|
||||
.sp 1
|
||||
When running calc as a shell script (see
|
||||
.B "SHELL SCRIPT MODE"
|
||||
for details), calc will close standard input (stdin)
|
||||
during startup
|
||||
.B UNLESS
|
||||
the
|
||||
.B \-p
|
||||
flag is given on the command line.
|
||||
When calc is running in
|
||||
.BR "shell script mode" ,
|
||||
shell scripts that call the
|
||||
.BR prompt (str)
|
||||
builtin will not work properly (the prompt builtin
|
||||
will always fail) unless the
|
||||
.B \-p
|
||||
flag is given on the command line.
|
||||
|
||||
.TP
|
||||
.B \-q
|
||||
Disable the reading of the startup scripts.
|
||||
@@ -501,7 +519,7 @@ version number and exit.
|
||||
|
||||
.TP
|
||||
.B \-\-
|
||||
The double dash indicates to calc that no more option follow.
|
||||
The double dash indicates to calc that no more options follow.
|
||||
Thus calc will ignore a later argument on the command line
|
||||
even if it starts with a dash.
|
||||
This is useful when entering negative values on the command line as in:
|
||||
@@ -543,7 +561,7 @@ will not evaluate any
|
||||
arguments but instead make them available
|
||||
as strings to the argv() builtin function.
|
||||
|
||||
Sufficiently simple commands with no no characters like
|
||||
Sufficiently simple commands with no characters like
|
||||
parentheses, brackets, semicolons, '*', which have special
|
||||
interpretations in UNIX shells may be entered, possibly with
|
||||
spaces, until the terminating newline.
|
||||
@@ -651,7 +669,9 @@ echo chongo was here | calc \-i 'print fgetline(files(0));'
|
||||
.fi
|
||||
.in -5n
|
||||
.sp 1
|
||||
This is because without \-p, the interactive parser, in an effort
|
||||
This is because without
|
||||
.BR \-p ,
|
||||
the interactive parser, in an effort
|
||||
to parse interactive commands, flushes data on standard input.
|
||||
|
||||
.PP
|
||||
@@ -804,7 +824,7 @@ the rest of the file will be processed in
|
||||
Note that
|
||||
.B \-s
|
||||
.B \-f
|
||||
must at the end of the initial ``#!'' line.
|
||||
must be at the end of the initial ``#!'' line.
|
||||
Any other optional
|
||||
.B "optional_other_flags"
|
||||
must come before
|
||||
@@ -932,6 +952,67 @@ whereas
|
||||
.sp 1
|
||||
will not.
|
||||
|
||||
.sp 1
|
||||
By default, using calc startup in
|
||||
.BR "shell script mode" ,
|
||||
calc will close standard input (stdin).
|
||||
Thus builtin functions such as
|
||||
.BR prompt (str)
|
||||
will fail (return a null value).
|
||||
Calc shell scripts that call the
|
||||
.BR prompt (str)
|
||||
builtin will not work properly (the prompt builtin
|
||||
will always fail and return a null value) unless the
|
||||
.B \-p
|
||||
flag is given on the command line.
|
||||
|
||||
.sp 1
|
||||
The following shell script will always print "got null" because
|
||||
stdin will be closed by calc during startup:
|
||||
|
||||
.sp 1
|
||||
.in +5n
|
||||
.nf
|
||||
#!/usr/bin/calc \-q \-f
|
||||
|
||||
# The prompt will ALWAYS FAIL and return a null value
|
||||
n = prompt("Test> ");
|
||||
if (isnull(n)) {
|
||||
print("got null");
|
||||
} else {
|
||||
print("got " + n);
|
||||
}
|
||||
.fi
|
||||
.in -5n
|
||||
.sp 1
|
||||
However the following shell script (note the
|
||||
.B \-p
|
||||
before the
|
||||
.B \-f
|
||||
in the 1st line) will be interactive, prompt with "Test> " and print
|
||||
the "got" result as expected:
|
||||
|
||||
.sp 1
|
||||
.in +5n
|
||||
.nf
|
||||
#!/usr/bin/calc \-q \-p \-f
|
||||
|
||||
n = prompt("Test> ");
|
||||
if (isnull(n)) {
|
||||
print("got null");
|
||||
} else {
|
||||
print("got " + n);
|
||||
}
|
||||
.fi
|
||||
.in -5n
|
||||
|
||||
.sp 1
|
||||
Note in the example above, the
|
||||
.B \-p
|
||||
flag must be given before the final
|
||||
.B \-f
|
||||
command line flag.
|
||||
|
||||
.PP
|
||||
|
||||
.SH DATA TYPES
|
||||
@@ -973,7 +1054,7 @@ Before a variable is assigned a value it has the value of zero.
|
||||
.PP
|
||||
The scope of a variable may be global, local to a file, or local to a
|
||||
procedure.
|
||||
Values may be grouped together in a matrix, or into a
|
||||
Values may be grouped together in a matrix, or into
|
||||
a list that permits stack and queue style operations.
|
||||
.PP
|
||||
For more information use the following
|
||||
@@ -1431,7 +1512,7 @@ the following GitHub repo:
|
||||
https://github.com/lcn2/calc
|
||||
.in -0.5i
|
||||
.sp
|
||||
The very latest calc souece is found at the top master branch.
|
||||
The very latest calc source is found at the top master branch.
|
||||
|
||||
.PP
|
||||
|
||||
|
119
chk_tree
119
chk_tree
@@ -46,6 +46,11 @@ fi
|
||||
#
|
||||
declare -a DISTDIR
|
||||
mapfile -t DISTDIR < <(make -s distdir | grep -v '^make\[[0-9]*\]: ' | sort -u)
|
||||
if [[ ${#DISTDIR[@]} -le 0 ]]; then
|
||||
echo "$0: ERROR: distdir is empty" 1>&2
|
||||
EXIT_CODE=11
|
||||
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
|
||||
fi
|
||||
|
||||
# collect directories
|
||||
#
|
||||
@@ -58,6 +63,11 @@ mapfile -t FINDDIR < <(find . -type d \
|
||||
! -path './.git/*' ! -name .git \
|
||||
! -path './.github/*' ! -name .github | \
|
||||
sed -e 's/^\.\///' | sort -u)
|
||||
if [[ ${#FINDDIR[@]} -le 0 ]]; then
|
||||
echo "$0: ERROR: find dir is empty" 1>&2
|
||||
EXIT_CODE=12
|
||||
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
|
||||
fi
|
||||
|
||||
# compare DISTDIR and FINDDIR
|
||||
#
|
||||
@@ -81,7 +91,7 @@ if [[ ${#DIFF_DISTDIR_FINDDIR[@]} -ne 0 ]]; then
|
||||
if [[ ${#ONLY_DISTDIR[@]} -ne 0 ]]; then
|
||||
echo "$0: ERROR: found only in distdir: ${ONLY_DISTDIR[*]}" 1>&2
|
||||
fi
|
||||
EXIT_CODE=11
|
||||
EXIT_CODE=13
|
||||
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
|
||||
fi
|
||||
|
||||
@@ -91,7 +101,7 @@ make distlist >/dev/null 2>&1
|
||||
status="$?"
|
||||
if [[ $status -ne 0 ]]; then
|
||||
echo "$0: ERROR: make distlist exit code: $status" 1>&2
|
||||
EXIT_CODE=12
|
||||
EXIT_CODE=14
|
||||
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
|
||||
fi
|
||||
|
||||
@@ -99,6 +109,11 @@ fi
|
||||
#
|
||||
declare -a DISTLIST
|
||||
mapfile -t DISTLIST < <(make -s distlist | grep -v '^make\[[0-9]*\]: ' | sort -u)
|
||||
if [[ ${#DISTLIST[@]} -le 0 ]]; then
|
||||
echo "$0: ERROR: distlist is empty" 1>&2
|
||||
EXIT_CODE=15
|
||||
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
|
||||
fi
|
||||
declare -A DISTLIST_A
|
||||
for i in "${DISTLIST[@]}"; do
|
||||
DISTLIST_A["$i"]="$i"
|
||||
@@ -116,6 +131,11 @@ if [[ -d .git ]]; then
|
||||
mapfile -t GITLS < <(git ls |
|
||||
grep -v -E '^\.github/|^\.gitignore$|^CODE_OF_CONDUCT\.md$|^CONTRIBUTING\.md$|^SECURITY\.md$' |
|
||||
sort -u)
|
||||
if [[ ${#GITLS[@]} -le 0 ]]; then
|
||||
echo "$0: ERROR: git ls is empty" 1>&2
|
||||
EXIT_CODE=16
|
||||
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
|
||||
fi
|
||||
|
||||
# compare DISTLIST and GITLS
|
||||
#
|
||||
@@ -139,7 +159,58 @@ if [[ -d .git ]]; then
|
||||
if [[ ${#ONLY_DISTLIST[@]} -ne 0 ]]; then
|
||||
echo "$0: ERROR: found only in distlist: ${ONLY_DISTLIST[*]}" 1>&2
|
||||
fi
|
||||
EXIT_CODE=13
|
||||
EXIT_CODE=17
|
||||
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
|
||||
fi
|
||||
|
||||
# verify that there are no staged uncommitted changes under git
|
||||
#
|
||||
GIT_STATUS=$(git status --untracked-files=no --porcelain 2>&1)
|
||||
if [[ -n $GIT_STATUS ]] || ! git diff --cached --quiet --exit-code; then
|
||||
echo "$0: ERROR: there are staged uncommitted changes" 1>&2
|
||||
git status --short
|
||||
EXIT_CODE=18
|
||||
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
|
||||
fi
|
||||
|
||||
# verify that there are no uncommitted changes under git
|
||||
#
|
||||
if ! git diff --quiet --exit-code; then
|
||||
echo "$0: ERROR: there are unstaged changes" 1>&2
|
||||
git status --untracked-files=no --porcelain --short
|
||||
EXIT_CODE=19
|
||||
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
|
||||
fi
|
||||
|
||||
# verify that master branch is not ahead of 'origin/master'
|
||||
#
|
||||
GIT_MASTER=$(git rev-list --count master)
|
||||
GIT_ORIGIN_MASTER=$(git rev-list --count origin/master)
|
||||
if [[ $GIT_MASTER -gt $GIT_ORIGIN_MASTER ]]; then
|
||||
echo "$0: ERROR: master branch is behind of origin/master" 1>&2
|
||||
git status master
|
||||
EXIT_CODE=20
|
||||
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
|
||||
elif [[ $GIT_MASTER -lt $GIT_ORIGIN_MASTER ]]; then
|
||||
echo "$0: ERROR: master branch is ahead of origin/master" 1>&2
|
||||
git status master
|
||||
EXIT_CODE=21
|
||||
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
|
||||
fi
|
||||
|
||||
# verify that branch is not ahead of 'origin/HEAD'
|
||||
#
|
||||
GIT_HEAD=$(git rev-list --count HEAD)
|
||||
GIT_ORIGIN_HEAD=$(git rev-list --count origin/HEAD)
|
||||
if [[ $GIT_HEAD -gt $GIT_ORIGIN_HEAD ]]; then
|
||||
echo "$0: ERROR: HEAD is behind of origin/HEAD" 1>&2
|
||||
git status HEAD
|
||||
EXIT_CODE=22
|
||||
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
|
||||
elif [[ $GIT_HEAD -lt $GIT_ORIGIN_HEAD ]]; then
|
||||
echo "$0: ERROR: HEAD is ahead of origin/HEAD" 1>&2
|
||||
git status HEAD
|
||||
EXIT_CODE=23
|
||||
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
|
||||
fi
|
||||
fi
|
||||
@@ -148,6 +219,11 @@ fi
|
||||
#
|
||||
declare -a BUILDLIST
|
||||
mapfile -t BUILDLIST < <(make -s buildlist | grep -v '^make\[[0-9]*\]: ' | sort -u)
|
||||
if [[ ${#BUILDLIST[@]} -le 0 ]]; then
|
||||
echo "$0: ERROR: buildlist is empty" 1>&2
|
||||
EXIT_CODE=24
|
||||
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
|
||||
fi
|
||||
declare -A BUILDLIST_A
|
||||
for i in "${BUILDLIST[@]}"; do
|
||||
BUILDLIST_A["$i"]="$i"
|
||||
@@ -173,7 +249,7 @@ if [[ ${#DISTLIST_ALSO_IN_BUILDLIST[@]} -ne 0 ]]; then
|
||||
#
|
||||
echo "$0: ERROR: distlist files found in buildlist" 1>&2
|
||||
echo "$0: ERROR: distlist files found in buildlist: ${DISTLIST_ALSO_IN_BUILDLIST[*]}" 1>&2
|
||||
EXIT_CODE=14
|
||||
EXIT_CODE=25
|
||||
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
|
||||
fi
|
||||
|
||||
@@ -184,6 +260,9 @@ fi
|
||||
# We ignore .*.swp files as they are a result of vim sessions.
|
||||
# We ignore *.out files as they are used to collect information.
|
||||
# We ignore single letter files as they are used for temporary files.
|
||||
# We ignore files containing the any of the following in any letter case:
|
||||
#
|
||||
# foo bar baz curds whey rmme
|
||||
#
|
||||
declare -a FINDFILE
|
||||
mapfile -t FINDFILE < <(find . -type f \
|
||||
@@ -191,8 +270,15 @@ mapfile -t FINDFILE < <(find . -type f \
|
||||
! -path './.git/*' ! -name .git \
|
||||
! -path './.github/*' ! -name .github \
|
||||
! -name 'CODE_OF_CONDUCT.md' ! -name 'CONTRIBUTING.md' ! -name '.gitignore' ! -name 'SECURITY.md' \
|
||||
! -name '*.swp' ! -name '*.out' ! -name '?' |
|
||||
! -name '*.swp' ! -name '?' ! -iname '*.out*' \
|
||||
! -iname '*foo*' ! -iname '*bar*' ! -iname '*baz*' \
|
||||
! -iname '*curds*' ! -iname '*whey*' ! -iname '*rmmee' -print |
|
||||
sed -e 's/^\.\///' | sort -u)
|
||||
if [[ ${#FINDFILE[@]} -le 0 ]]; then
|
||||
echo "$0: ERROR: find file is empty" 1>&2
|
||||
EXIT_CODE=26
|
||||
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
|
||||
fi
|
||||
|
||||
# look for something in FINDFILE that in neither DISTLIST nor BUILDLIST
|
||||
#
|
||||
@@ -231,7 +317,28 @@ if [[ ${#UNKNOWN_FILE[@]} -ne 0 ]]; then
|
||||
#
|
||||
echo "$0: ERROR: files that are neither built nor distlist are found" 1>&2
|
||||
echo "$0: ERROR: distlist files found in buildlist: ${UNKNOWN_FILE[*]}" 1>&2
|
||||
EXIT_CODE=15
|
||||
EXIT_CODE=27
|
||||
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
|
||||
fi
|
||||
|
||||
# Look for a find in distlist that would otherwise be ignored
|
||||
#
|
||||
# We ignore for trailblank and FINDFILE, filenames with a single letter, and files
|
||||
# that end in .out, and files containing the any of the following
|
||||
# in any letter case:
|
||||
#
|
||||
# foo bar baz curds whey rmme
|
||||
#
|
||||
# So we will object is any distlist file is one of these ignored filenames.
|
||||
#
|
||||
INVALID_DISTLIST=$(printf '%s\n' "${DISTLIST[@]}" | \
|
||||
tr '[:upper:]' '[:lower:]' | \
|
||||
sed -n -e '/^.$/p' -e '/.*foo.*/p' -e '/.*bar.*/p' -e '/.*baz.*/p' \
|
||||
-e '/.*curds.*/p' -e '/.*whey.*/p' -e '/.*rmme.*/p' |
|
||||
tr '\n' ' ')
|
||||
if [[ -n $INVALID_DISTLIST ]]; then
|
||||
echo "$0: ERROR: distlist contains invalid filename(s): $INVALID_DISTLIST" 1>&2
|
||||
EXIT_CODE=28
|
||||
echo "$0: Warning: set EXIT_CODE: $EXIT_CODE" 1>&2
|
||||
fi
|
||||
|
||||
|
2
file.c
2
file.c
@@ -1387,7 +1387,7 @@ filepos2z(FILEPOS pos)
|
||||
ret.len = FILEPOS_BITS/BASEB;
|
||||
ret.v = alloc(ret.len);
|
||||
zclearval(ret);
|
||||
SWAP_HALF_IN_FILEPOS(ret.v, &pos);
|
||||
SWAP_HALF_IN_FILEPOS(ret.v, (HALF *)&pos);
|
||||
ret.sign = 0;
|
||||
ztrim(&ret);
|
||||
|
||||
|
13
fposval.c
13
fposval.c
@@ -114,15 +114,20 @@ main(int UNUSED(argc), char **argv)
|
||||
/*
|
||||
* Big Endian
|
||||
*/
|
||||
/*
|
||||
* Use casts to (HALF *) because SWAP_HALF_IN_B* might expand to
|
||||
* a simple assignment and SWAP_HALF_IN_FILEPOS might get a
|
||||
* (HALF *) and a (FILEPOS *) which are not assignment-compatible.
|
||||
*/
|
||||
if (fileposlen == 64) {
|
||||
printf("#define SWAP_HALF_IN_FILEPOS(dest, src) \\\n"
|
||||
"\tSWAP_HALF_IN_B64(dest, src)\n");
|
||||
"\tSWAP_HALF_IN_B64((HALF *)dest, (HALF *)src)\n");
|
||||
} else if (fileposlen == 32) {
|
||||
printf("#define SWAP_HALF_IN_FILEPOS(dest, src) \\\n"
|
||||
"\tSWAP_HALF_IN_B32(dest, src)\n");
|
||||
"\tSWAP_HALF_IN_B32((HALF *)dest, (HALF *)src)\n");
|
||||
} else if (fileposlen%BASEB == 0) {
|
||||
printf("#define SWAP_HALF_IN_FILEPOS(dest, src) \\\n"
|
||||
"\tswap_HALFs(dest, src, %d)\n",
|
||||
"\tswap_HALFs((HALF *)dest, (HALF *)src, %d)\n",
|
||||
fileposlen/BASEB);
|
||||
} else {
|
||||
fprintf(stderr, "%s: unexpected BIG_ENDIAN FILEPOS bit size: %d\n",
|
||||
@@ -135,7 +140,7 @@ main(int UNUSED(argc), char **argv)
|
||||
*/
|
||||
#if defined(HAVE_FILEPOS_SCALAR)
|
||||
printf("#define SWAP_HALF_IN_FILEPOS(dest, src) \\\n"
|
||||
"\t(*(dest) = *(src))\n");
|
||||
"\t(*((HALF *)(dest)) = *((HALF *)(src)))\n");
|
||||
#else /* HAVE_FILEPOS_SCALAR */
|
||||
/*
|
||||
* Normally a "(*(dest) = *(src))" would do, but on some
|
||||
|
234
func.c
234
func.c
@@ -2479,6 +2479,7 @@ f_logn(int count, VALUE **vals)
|
||||
ln_of_x_is_complex = true;
|
||||
}
|
||||
} else {
|
||||
ln_x_c = NULL; /* avoid ln_x_c may be uninitialized warning later on */
|
||||
ln_x_r = qln(vals[0]->v_num, err);
|
||||
if (ln_x_r == NULL) {
|
||||
return error_value(E_LOGN_3);
|
||||
@@ -2512,6 +2513,11 @@ f_logn(int count, VALUE **vals)
|
||||
switch (vals[1]->v_type) {
|
||||
case V_NUM:
|
||||
if (qiszero(vals[1]->v_num)) {
|
||||
if (ln_of_x_is_complex == true) {
|
||||
comfree(ln_x_c);
|
||||
} else {
|
||||
qfree(ln_x_r);
|
||||
}
|
||||
return error_value(E_LOGN_4);
|
||||
}
|
||||
if (qisneg(vals[1]->v_num)) {
|
||||
@@ -2520,10 +2526,20 @@ f_logn(int count, VALUE **vals)
|
||||
ctmp.links = 1;
|
||||
ln_n_c = c_ln(&ctmp, err);
|
||||
if (ln_n_c == NULL) {
|
||||
if (ln_of_x_is_complex == true) {
|
||||
comfree(ln_x_c);
|
||||
} else {
|
||||
qfree(ln_x_r);
|
||||
}
|
||||
return error_value(E_LOGN_4);
|
||||
}
|
||||
if (ciszero(ln_n_c)) {
|
||||
comfree(ln_n_c);
|
||||
if (ln_of_x_is_complex == true) {
|
||||
comfree(ln_x_c);
|
||||
} else {
|
||||
qfree(ln_x_r);
|
||||
}
|
||||
return error_value(E_LOGN_4);
|
||||
}
|
||||
if (cisreal(ln_n_c)) {
|
||||
@@ -2534,24 +2550,49 @@ f_logn(int count, VALUE **vals)
|
||||
} else {
|
||||
ln_n_r = qln(vals[1]->v_num, err);
|
||||
if (ln_n_r == NULL) {
|
||||
if (ln_of_x_is_complex == true) {
|
||||
comfree(ln_x_c);
|
||||
} else {
|
||||
qfree(ln_x_r);
|
||||
}
|
||||
return error_value(E_LOGN_4);
|
||||
}
|
||||
if (qiszero(ln_n_r)) {
|
||||
qfree(ln_n_r);
|
||||
if (ln_of_x_is_complex == true) {
|
||||
comfree(ln_x_c);
|
||||
} else {
|
||||
qfree(ln_x_r);
|
||||
}
|
||||
return error_value(E_LOGN_4);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case V_COM:
|
||||
if (ciszero(vals[1]->v_com)) {
|
||||
if (ln_of_x_is_complex == true) {
|
||||
comfree(ln_x_c);
|
||||
} else {
|
||||
qfree(ln_x_r);
|
||||
}
|
||||
return error_value(E_LOGN_4);
|
||||
}
|
||||
ln_n_c = c_ln(vals[1]->v_com, err);
|
||||
if (ln_n_c == NULL) {
|
||||
if (ln_of_x_is_complex == true) {
|
||||
comfree(ln_x_c);
|
||||
} else {
|
||||
qfree(ln_x_r);
|
||||
}
|
||||
return error_value(E_LOGN_4);
|
||||
}
|
||||
if (ciszero(ln_n_c)) {
|
||||
comfree(ln_n_c);
|
||||
if (ln_of_x_is_complex == true) {
|
||||
comfree(ln_x_c);
|
||||
} else {
|
||||
qfree(ln_x_r);
|
||||
}
|
||||
return error_value(E_LOGN_4);
|
||||
}
|
||||
if (cisreal(ln_n_c)) {
|
||||
@@ -2561,6 +2602,11 @@ f_logn(int count, VALUE **vals)
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (ln_of_x_is_complex == true) {
|
||||
comfree(ln_x_c);
|
||||
} else {
|
||||
qfree(ln_x_r);
|
||||
}
|
||||
return error_value(E_LOGN_5);
|
||||
}
|
||||
|
||||
@@ -2574,6 +2620,8 @@ f_logn(int count, VALUE **vals)
|
||||
* case: ln(x) is COMPLEX, ln(n) is COMPLEX
|
||||
*/
|
||||
p_cval = c_div(ln_x_c, ln_n_c);
|
||||
comfree(ln_x_c);
|
||||
comfree(ln_n_c);
|
||||
if (p_cval == NULL) {
|
||||
return error_value(E_LOGN_3);
|
||||
}
|
||||
@@ -2594,6 +2642,8 @@ f_logn(int count, VALUE **vals)
|
||||
* case: ln(x) is COMPLEX, ln(n) is NUMBER
|
||||
*/
|
||||
p_cval = c_divq(ln_x_c, ln_n_r);
|
||||
comfree(ln_x_c);
|
||||
qfree(ln_n_r);
|
||||
if (p_cval == NULL) {
|
||||
return error_value(E_LOGN_3);
|
||||
}
|
||||
@@ -2620,6 +2670,8 @@ f_logn(int count, VALUE **vals)
|
||||
ctmp.imag = qlink(&_qzero_);
|
||||
ctmp.links = 1;
|
||||
p_cval = c_div(&ctmp, ln_n_c);
|
||||
comfree(&ctmp);
|
||||
comfree(ln_n_c);
|
||||
if (p_cval == NULL) {
|
||||
return error_value(E_LOGN_3);
|
||||
}
|
||||
@@ -2640,6 +2692,8 @@ f_logn(int count, VALUE **vals)
|
||||
* case: ln(x) is NUMBER, ln(n) is NUMBER
|
||||
*/
|
||||
result.v_num = qqdiv(ln_x_r, ln_n_r);
|
||||
qfree(ln_x_r);
|
||||
qfree(ln_n_r);
|
||||
if (result.v_com == NULL) {
|
||||
return error_value(E_LOGN_3);
|
||||
}
|
||||
@@ -10900,7 +10954,6 @@ f_versin(int count, VALUE **vals)
|
||||
S_FUNC VALUE
|
||||
f_aversin(int count, VALUE **vals)
|
||||
{
|
||||
VALUE arg1; /* 1st arg if it is a COMPLEX value */
|
||||
VALUE result; /* value to return */
|
||||
COMPLEX *c; /* COMPLEX trig result */
|
||||
NUMBER *eps; /* epsilon error tolerance */
|
||||
@@ -10924,11 +10977,10 @@ f_aversin(int count, VALUE **vals)
|
||||
/*
|
||||
* compute inverse versed trigonometric sine to a given error tolerance
|
||||
*/
|
||||
arg1 = *vals[0];
|
||||
if (arg1.v_type == V_NUM) {
|
||||
if (vals[0]->v_type == V_NUM) {
|
||||
|
||||
/* try to compute result using real trig function */
|
||||
result.v_num = qaversin_or_NULL(arg1.v_num, eps);
|
||||
result.v_num = qaversin_or_NULL(vals[0]->v_num, eps);
|
||||
|
||||
/*
|
||||
* case: trig function returned a NUMBER
|
||||
@@ -10941,17 +10993,17 @@ f_aversin(int count, VALUE **vals)
|
||||
*/
|
||||
} else {
|
||||
/* convert NUMBER argument from NUMBER to COMPLEX */
|
||||
arg1.v_com = qqtoc(arg1.v_num, &_qzero_);
|
||||
arg1.v_type = V_COM;
|
||||
vals[0]->v_com = qqtoc(vals[0]->v_num, &_qzero_);
|
||||
vals[0]->v_type = V_COM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type == V_COM) {
|
||||
if (vals[0]->v_type == V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument was COMPLEX or
|
||||
* trig function returned NULL and argument was converted to COMPLEX
|
||||
*/
|
||||
c = c_aversin(arg1.v_com, eps);
|
||||
c = c_aversin(vals[0]->v_com, eps);
|
||||
if (c == NULL) {
|
||||
return error_value(E_AVERSIN_3);
|
||||
}
|
||||
@@ -10966,7 +11018,7 @@ f_aversin(int count, VALUE **vals)
|
||||
result.v_type = V_NUM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type != V_NUM && arg1.v_type != V_COM) {
|
||||
if (vals[0]->v_type != V_NUM && vals[0]->v_type != V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument type is not valid for this function
|
||||
@@ -11040,7 +11092,6 @@ f_coversin(int count, VALUE **vals)
|
||||
S_FUNC VALUE
|
||||
f_acoversin(int count, VALUE **vals)
|
||||
{
|
||||
VALUE arg1; /* 1st arg if it is a COMPLEX value */
|
||||
VALUE result; /* value to return */
|
||||
COMPLEX *c; /* COMPLEX trig result */
|
||||
NUMBER *eps; /* epsilon error tolerance */
|
||||
@@ -11064,11 +11115,10 @@ f_acoversin(int count, VALUE **vals)
|
||||
/*
|
||||
* compute inverse coversed trigonometric sine to a given error tolerance
|
||||
*/
|
||||
arg1 = *vals[0];
|
||||
if (arg1.v_type == V_NUM) {
|
||||
if (vals[0]->v_type == V_NUM) {
|
||||
|
||||
/* try to compute result using real trig function */
|
||||
result.v_num = qacoversin_or_NULL(arg1.v_num, eps);
|
||||
result.v_num = qacoversin_or_NULL(vals[0]->v_num, eps);
|
||||
|
||||
/*
|
||||
* case: trig function returned a NUMBER
|
||||
@@ -11081,17 +11131,17 @@ f_acoversin(int count, VALUE **vals)
|
||||
*/
|
||||
} else {
|
||||
/* convert NUMBER argument from NUMBER to COMPLEX */
|
||||
arg1.v_com = qqtoc(arg1.v_num, &_qzero_);
|
||||
arg1.v_type = V_COM;
|
||||
vals[0]->v_com = qqtoc(vals[0]->v_num, &_qzero_);
|
||||
vals[0]->v_type = V_COM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type == V_COM) {
|
||||
if (vals[0]->v_type == V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument was COMPLEX or
|
||||
* trig function returned NULL and argument was converted to COMPLEX
|
||||
*/
|
||||
c = c_acoversin(arg1.v_com, eps);
|
||||
c = c_acoversin(vals[0]->v_com, eps);
|
||||
if (c == NULL) {
|
||||
return error_value(E_ACOVERSIN_3);
|
||||
}
|
||||
@@ -11106,7 +11156,7 @@ f_acoversin(int count, VALUE **vals)
|
||||
result.v_type = V_NUM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type != V_NUM && arg1.v_type != V_COM) {
|
||||
if (vals[0]->v_type != V_NUM && vals[0]->v_type != V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument type is not valid for this function
|
||||
@@ -11180,7 +11230,6 @@ f_vercos(int count, VALUE **vals)
|
||||
S_FUNC VALUE
|
||||
f_avercos(int count, VALUE **vals)
|
||||
{
|
||||
VALUE arg1; /* 1st arg if it is a COMPLEX value */
|
||||
VALUE result; /* value to return */
|
||||
COMPLEX *c; /* COMPLEX trig result */
|
||||
NUMBER *eps; /* epsilon error tolerance */
|
||||
@@ -11204,11 +11253,10 @@ f_avercos(int count, VALUE **vals)
|
||||
/*
|
||||
* compute inverse versed trigonometric cosine to a given error tolerance
|
||||
*/
|
||||
arg1 = *vals[0];
|
||||
if (arg1.v_type == V_NUM) {
|
||||
if (vals[0]->v_type == V_NUM) {
|
||||
|
||||
/* try to compute result using real trig function */
|
||||
result.v_num = qavercos_or_NULL(arg1.v_num, eps);
|
||||
result.v_num = qavercos_or_NULL(vals[0]->v_num, eps);
|
||||
|
||||
/*
|
||||
* case: trig function returned a NUMBER
|
||||
@@ -11221,17 +11269,17 @@ f_avercos(int count, VALUE **vals)
|
||||
*/
|
||||
} else {
|
||||
/* convert NUMBER argument from NUMBER to COMPLEX */
|
||||
arg1.v_com = qqtoc(arg1.v_num, &_qzero_);
|
||||
arg1.v_type = V_COM;
|
||||
vals[0]->v_com = qqtoc(vals[0]->v_num, &_qzero_);
|
||||
vals[0]->v_type = V_COM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type == V_COM) {
|
||||
if (vals[0]->v_type == V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument was COMPLEX or
|
||||
* trig function returned NULL and argument was converted to COMPLEX
|
||||
*/
|
||||
c = c_avercos(arg1.v_com, eps);
|
||||
c = c_avercos(vals[0]->v_com, eps);
|
||||
if (c == NULL) {
|
||||
return error_value(E_AVERCOS_3);
|
||||
}
|
||||
@@ -11246,7 +11294,7 @@ f_avercos(int count, VALUE **vals)
|
||||
result.v_type = V_NUM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type != V_NUM && arg1.v_type != V_COM) {
|
||||
if (vals[0]->v_type != V_NUM && vals[0]->v_type != V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument type is not valid for this function
|
||||
@@ -11320,7 +11368,6 @@ f_covercos(int count, VALUE **vals)
|
||||
S_FUNC VALUE
|
||||
f_acovercos(int count, VALUE **vals)
|
||||
{
|
||||
VALUE arg1; /* 1st arg if it is a COMPLEX value */
|
||||
VALUE result; /* value to return */
|
||||
COMPLEX *c; /* COMPLEX trig result */
|
||||
NUMBER *eps; /* epsilon error tolerance */
|
||||
@@ -11344,11 +11391,10 @@ f_acovercos(int count, VALUE **vals)
|
||||
/*
|
||||
* compute inverse coversed trigonometric cosine to a given error tolerance
|
||||
*/
|
||||
arg1 = *vals[0];
|
||||
if (arg1.v_type == V_NUM) {
|
||||
if (vals[0]->v_type == V_NUM) {
|
||||
|
||||
/* try to compute result using real trig function */
|
||||
result.v_num = qacovercos_or_NULL(arg1.v_num, eps);
|
||||
result.v_num = qacovercos_or_NULL(vals[0]->v_num, eps);
|
||||
|
||||
/*
|
||||
* case: trig function returned a NUMBER
|
||||
@@ -11361,17 +11407,17 @@ f_acovercos(int count, VALUE **vals)
|
||||
*/
|
||||
} else {
|
||||
/* convert NUMBER argument from NUMBER to COMPLEX */
|
||||
arg1.v_com = qqtoc(arg1.v_num, &_qzero_);
|
||||
arg1.v_type = V_COM;
|
||||
vals[0]->v_com = qqtoc(vals[0]->v_num, &_qzero_);
|
||||
vals[0]->v_type = V_COM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type == V_COM) {
|
||||
if (vals[0]->v_type == V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument was COMPLEX or
|
||||
* trig function returned NULL and argument was converted to COMPLEX
|
||||
*/
|
||||
c = c_acovercos(arg1.v_com, eps);
|
||||
c = c_acovercos(vals[0]->v_com, eps);
|
||||
if (c == NULL) {
|
||||
return error_value(E_ACOVERCOS_3);
|
||||
}
|
||||
@@ -11386,7 +11432,7 @@ f_acovercos(int count, VALUE **vals)
|
||||
result.v_type = V_NUM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type != V_NUM && arg1.v_type != V_COM) {
|
||||
if (vals[0]->v_type != V_NUM && vals[0]->v_type != V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument type is not valid for this function
|
||||
@@ -11460,7 +11506,6 @@ f_haversin(int count, VALUE **vals)
|
||||
S_FUNC VALUE
|
||||
f_ahaversin(int count, VALUE **vals)
|
||||
{
|
||||
VALUE arg1; /* 1st arg if it is a COMPLEX value */
|
||||
VALUE result; /* value to return */
|
||||
COMPLEX *c; /* COMPLEX trig result */
|
||||
NUMBER *eps; /* epsilon error tolerance */
|
||||
@@ -11484,11 +11529,10 @@ f_ahaversin(int count, VALUE **vals)
|
||||
/*
|
||||
* compute inverse half versed trigonometric sine to a given error tolerance
|
||||
*/
|
||||
arg1 = *vals[0];
|
||||
if (arg1.v_type == V_NUM) {
|
||||
if (vals[0]->v_type == V_NUM) {
|
||||
|
||||
/* try to compute result using real trig function */
|
||||
result.v_num = qahaversin_or_NULL(arg1.v_num, eps);
|
||||
result.v_num = qahaversin_or_NULL(vals[0]->v_num, eps);
|
||||
|
||||
/*
|
||||
* case: trig function returned a NUMBER
|
||||
@@ -11501,17 +11545,17 @@ f_ahaversin(int count, VALUE **vals)
|
||||
*/
|
||||
} else {
|
||||
/* convert NUMBER argument from NUMBER to COMPLEX */
|
||||
arg1.v_com = qqtoc(arg1.v_num, &_qzero_);
|
||||
arg1.v_type = V_COM;
|
||||
vals[0]->v_com = qqtoc(vals[0]->v_num, &_qzero_);
|
||||
vals[0]->v_type = V_COM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type == V_COM) {
|
||||
if (vals[0]->v_type == V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument was COMPLEX or
|
||||
* trig function returned NULL and argument was converted to COMPLEX
|
||||
*/
|
||||
c = c_ahaversin(arg1.v_com, eps);
|
||||
c = c_ahaversin(vals[0]->v_com, eps);
|
||||
if (c == NULL) {
|
||||
return error_value(E_AHAVERSIN_3);
|
||||
}
|
||||
@@ -11526,7 +11570,7 @@ f_ahaversin(int count, VALUE **vals)
|
||||
result.v_type = V_NUM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type != V_NUM && arg1.v_type != V_COM) {
|
||||
if (vals[0]->v_type != V_NUM && vals[0]->v_type != V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument type is not valid for this function
|
||||
@@ -11600,7 +11644,6 @@ f_hacoversin(int count, VALUE **vals)
|
||||
S_FUNC VALUE
|
||||
f_ahacoversin(int count, VALUE **vals)
|
||||
{
|
||||
VALUE arg1; /* 1st arg if it is a COMPLEX value */
|
||||
VALUE result; /* value to return */
|
||||
COMPLEX *c; /* COMPLEX trig result */
|
||||
NUMBER *eps; /* epsilon error tolerance */
|
||||
@@ -11624,11 +11667,10 @@ f_ahacoversin(int count, VALUE **vals)
|
||||
/*
|
||||
* compute inverse half coversed trigonometric sine to a given error tolerance
|
||||
*/
|
||||
arg1 = *vals[0];
|
||||
if (arg1.v_type == V_NUM) {
|
||||
if (vals[0]->v_type == V_NUM) {
|
||||
|
||||
/* try to compute result using real trig function */
|
||||
result.v_num = qahacoversin_or_NULL(arg1.v_num, eps);
|
||||
result.v_num = qahacoversin_or_NULL(vals[0]->v_num, eps);
|
||||
|
||||
/*
|
||||
* case: trig function returned a NUMBER
|
||||
@@ -11641,17 +11683,17 @@ f_ahacoversin(int count, VALUE **vals)
|
||||
*/
|
||||
} else {
|
||||
/* convert NUMBER argument from NUMBER to COMPLEX */
|
||||
arg1.v_com = qqtoc(arg1.v_num, &_qzero_);
|
||||
arg1.v_type = V_COM;
|
||||
vals[0]->v_com = qqtoc(vals[0]->v_num, &_qzero_);
|
||||
vals[0]->v_type = V_COM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type == V_COM) {
|
||||
if (vals[0]->v_type == V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument was COMPLEX or
|
||||
* trig function returned NULL and argument was converted to COMPLEX
|
||||
*/
|
||||
c = c_ahacoversin(arg1.v_com, eps);
|
||||
c = c_ahacoversin(vals[0]->v_com, eps);
|
||||
if (c == NULL) {
|
||||
return error_value(E_AHACOVERSIN_3);
|
||||
}
|
||||
@@ -11666,7 +11708,7 @@ f_ahacoversin(int count, VALUE **vals)
|
||||
result.v_type = V_NUM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type != V_NUM && arg1.v_type != V_COM) {
|
||||
if (vals[0]->v_type != V_NUM && vals[0]->v_type != V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument type is not valid for this function
|
||||
@@ -11740,7 +11782,6 @@ f_havercos(int count, VALUE **vals)
|
||||
S_FUNC VALUE
|
||||
f_ahavercos(int count, VALUE **vals)
|
||||
{
|
||||
VALUE arg1; /* 1st arg if it is a COMPLEX value */
|
||||
VALUE result; /* value to return */
|
||||
COMPLEX *c; /* COMPLEX trig result */
|
||||
NUMBER *eps; /* epsilon error tolerance */
|
||||
@@ -11764,11 +11805,10 @@ f_ahavercos(int count, VALUE **vals)
|
||||
/*
|
||||
* compute inverse half versed trigonometric cosine to a given error tolerance
|
||||
*/
|
||||
arg1 = *vals[0];
|
||||
if (arg1.v_type == V_NUM) {
|
||||
if (vals[0]->v_type == V_NUM) {
|
||||
|
||||
/* try to compute result using real trig function */
|
||||
result.v_num = qahavercos_or_NULL(arg1.v_num, eps);
|
||||
result.v_num = qahavercos_or_NULL(vals[0]->v_num, eps);
|
||||
|
||||
/*
|
||||
* case: trig function returned a NUMBER
|
||||
@@ -11781,17 +11821,17 @@ f_ahavercos(int count, VALUE **vals)
|
||||
*/
|
||||
} else {
|
||||
/* convert NUMBER argument from NUMBER to COMPLEX */
|
||||
arg1.v_com = qqtoc(arg1.v_num, &_qzero_);
|
||||
arg1.v_type = V_COM;
|
||||
vals[0]->v_com = qqtoc(vals[0]->v_num, &_qzero_);
|
||||
vals[0]->v_type = V_COM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type == V_COM) {
|
||||
if (vals[0]->v_type == V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument was COMPLEX or
|
||||
* trig function returned NULL and argument was converted to COMPLEX
|
||||
*/
|
||||
c = c_ahavercos(arg1.v_com, eps);
|
||||
c = c_ahavercos(vals[0]->v_com, eps);
|
||||
if (c == NULL) {
|
||||
return error_value(E_AHAVERCOS_3);
|
||||
}
|
||||
@@ -11806,7 +11846,7 @@ f_ahavercos(int count, VALUE **vals)
|
||||
result.v_type = V_NUM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type != V_NUM && arg1.v_type != V_COM) {
|
||||
if (vals[0]->v_type != V_NUM && vals[0]->v_type != V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument type is not valid for this function
|
||||
@@ -11880,7 +11920,6 @@ f_hacovercos(int count, VALUE **vals)
|
||||
S_FUNC VALUE
|
||||
f_ahacovercos(int count, VALUE **vals)
|
||||
{
|
||||
VALUE arg1; /* 1st arg if it is a COMPLEX value */
|
||||
VALUE result; /* value to return */
|
||||
COMPLEX *c; /* COMPLEX trig result */
|
||||
NUMBER *eps; /* epsilon error tolerance */
|
||||
@@ -11904,11 +11943,10 @@ f_ahacovercos(int count, VALUE **vals)
|
||||
/*
|
||||
* compute inverse half coversed trigonometric cosine to a given error tolerance
|
||||
*/
|
||||
arg1 = *vals[0];
|
||||
if (arg1.v_type == V_NUM) {
|
||||
if (vals[0]->v_type == V_NUM) {
|
||||
|
||||
/* try to compute result using real trig function */
|
||||
result.v_num = qahacovercos_or_NULL(arg1.v_num, eps);
|
||||
result.v_num = qahacovercos_or_NULL(vals[0]->v_num, eps);
|
||||
|
||||
/*
|
||||
* case: trig function returned a NUMBER
|
||||
@@ -11921,17 +11959,17 @@ f_ahacovercos(int count, VALUE **vals)
|
||||
*/
|
||||
} else {
|
||||
/* convert NUMBER argument from NUMBER to COMPLEX */
|
||||
arg1.v_com = qqtoc(arg1.v_num, &_qzero_);
|
||||
arg1.v_type = V_COM;
|
||||
vals[0]->v_com = qqtoc(vals[0]->v_num, &_qzero_);
|
||||
vals[0]->v_type = V_COM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type == V_COM) {
|
||||
if (vals[0]->v_type == V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument was COMPLEX or
|
||||
* trig function returned NULL and argument was converted to COMPLEX
|
||||
*/
|
||||
c = c_ahacovercos(arg1.v_com, eps);
|
||||
c = c_ahacovercos(vals[0]->v_com, eps);
|
||||
if (c == NULL) {
|
||||
return error_value(E_AHACOVERCOS_3);
|
||||
}
|
||||
@@ -11946,7 +11984,7 @@ f_ahacovercos(int count, VALUE **vals)
|
||||
result.v_type = V_NUM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type != V_NUM && arg1.v_type != V_COM) {
|
||||
if (vals[0]->v_type != V_NUM && vals[0]->v_type != V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument type is not valid for this function
|
||||
@@ -12016,7 +12054,6 @@ f_exsec(int count, VALUE **vals)
|
||||
S_FUNC VALUE
|
||||
f_aexsec(int count, VALUE **vals)
|
||||
{
|
||||
VALUE arg1; /* 1st arg if it is a COMPLEX value */
|
||||
VALUE result; /* value to return */
|
||||
COMPLEX *c; /* COMPLEX trig result */
|
||||
NUMBER *eps; /* epsilon error tolerance */
|
||||
@@ -12040,16 +12077,15 @@ f_aexsec(int count, VALUE **vals)
|
||||
/*
|
||||
* compute inverse exterior trigonometric secant to a given error tolerance
|
||||
*/
|
||||
arg1 = *vals[0];
|
||||
if (arg1.v_type == V_NUM) {
|
||||
if (vals[0]->v_type == V_NUM) {
|
||||
|
||||
/* firewall */
|
||||
if (qisnegone(arg1.v_num)) {
|
||||
if (qisnegone(vals[0]->v_num)) {
|
||||
return error_value(E_AEXSEC_3);
|
||||
}
|
||||
|
||||
/* try to compute result using real trig function */
|
||||
result.v_num = qaexsec_or_NULL(arg1.v_num, eps);
|
||||
result.v_num = qaexsec_or_NULL(vals[0]->v_num, eps);
|
||||
|
||||
/*
|
||||
* case: trig function returned a NUMBER
|
||||
@@ -12062,17 +12098,17 @@ f_aexsec(int count, VALUE **vals)
|
||||
*/
|
||||
} else {
|
||||
/* convert NUMBER argument from NUMBER to COMPLEX */
|
||||
arg1.v_com = qqtoc(arg1.v_num, &_qzero_);
|
||||
arg1.v_type = V_COM;
|
||||
vals[0]->v_com = qqtoc(vals[0]->v_num, &_qzero_);
|
||||
vals[0]->v_type = V_COM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type == V_COM) {
|
||||
if (vals[0]->v_type == V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument was COMPLEX or
|
||||
* trig function returned NULL and argument was converted to COMPLEX
|
||||
*/
|
||||
c = c_aexsec(arg1.v_com, eps);
|
||||
c = c_aexsec(vals[0]->v_com, eps);
|
||||
if (c == NULL) {
|
||||
return error_value(E_AEXSEC_3);
|
||||
}
|
||||
@@ -12087,7 +12123,7 @@ f_aexsec(int count, VALUE **vals)
|
||||
result.v_type = V_NUM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type != V_NUM && arg1.v_type != V_COM) {
|
||||
if (vals[0]->v_type != V_NUM && vals[0]->v_type != V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument type is not valid for this function
|
||||
@@ -12163,7 +12199,6 @@ f_excsc(int count, VALUE **vals)
|
||||
S_FUNC VALUE
|
||||
f_aexcsc(int count, VALUE **vals)
|
||||
{
|
||||
VALUE arg1; /* 1st arg if it is a COMPLEX value */
|
||||
VALUE result; /* value to return */
|
||||
COMPLEX *c; /* COMPLEX trig result */
|
||||
NUMBER *eps; /* epsilon error tolerance */
|
||||
@@ -12187,16 +12222,15 @@ f_aexcsc(int count, VALUE **vals)
|
||||
/*
|
||||
* compute inverse exterior trigonometric cosecant to a given error tolerance
|
||||
*/
|
||||
arg1 = *vals[0];
|
||||
if (arg1.v_type == V_NUM) {
|
||||
if (vals[0]->v_type == V_NUM) {
|
||||
|
||||
/* firewall */
|
||||
if (qisnegone(arg1.v_num)) {
|
||||
if (qisnegone(vals[0]->v_num)) {
|
||||
return error_value(E_AEXCSC_3);
|
||||
}
|
||||
|
||||
/* try to compute result using real trig function */
|
||||
result.v_num = qaexcsc_or_NULL(arg1.v_num, eps);
|
||||
result.v_num = qaexcsc_or_NULL(vals[0]->v_num, eps);
|
||||
|
||||
/*
|
||||
* case: trig function returned a NUMBER
|
||||
@@ -12209,17 +12243,17 @@ f_aexcsc(int count, VALUE **vals)
|
||||
*/
|
||||
} else {
|
||||
/* convert NUMBER argument from NUMBER to COMPLEX */
|
||||
arg1.v_com = qqtoc(arg1.v_num, &_qzero_);
|
||||
arg1.v_type = V_COM;
|
||||
vals[0]->v_com = qqtoc(vals[0]->v_num, &_qzero_);
|
||||
vals[0]->v_type = V_COM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type == V_COM) {
|
||||
if (vals[0]->v_type == V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument was COMPLEX or
|
||||
* trig function returned NULL and argument was converted to COMPLEX
|
||||
*/
|
||||
c = c_aexcsc(arg1.v_com, eps);
|
||||
c = c_aexcsc(vals[0]->v_com, eps);
|
||||
if (c == NULL) {
|
||||
return error_value(E_AEXCSC_3);
|
||||
}
|
||||
@@ -12234,7 +12268,7 @@ f_aexcsc(int count, VALUE **vals)
|
||||
result.v_type = V_NUM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type != V_NUM && arg1.v_type != V_COM) {
|
||||
if (vals[0]->v_type != V_NUM && vals[0]->v_type != V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument type is not valid for this function
|
||||
@@ -12304,7 +12338,6 @@ f_crd(int count, VALUE **vals)
|
||||
S_FUNC VALUE
|
||||
f_acrd(int count, VALUE **vals)
|
||||
{
|
||||
VALUE arg1; /* 1st arg if it is a COMPLEX value */
|
||||
VALUE result; /* value to return */
|
||||
COMPLEX *c; /* COMPLEX trig result */
|
||||
NUMBER *eps; /* epsilon error tolerance */
|
||||
@@ -12328,11 +12361,10 @@ f_acrd(int count, VALUE **vals)
|
||||
/*
|
||||
* compute inverse trigonometric chord of a unit circle to a given error tolerance
|
||||
*/
|
||||
arg1 = *vals[0];
|
||||
if (arg1.v_type == V_NUM) {
|
||||
if (vals[0]->v_type == V_NUM) {
|
||||
|
||||
/* try to compute result using real trig function */
|
||||
result.v_num = qacrd_or_NULL(arg1.v_num, eps);
|
||||
result.v_num = qacrd_or_NULL(vals[0]->v_num, eps);
|
||||
|
||||
/*
|
||||
* case: trig function returned a NUMBER
|
||||
@@ -12345,17 +12377,17 @@ f_acrd(int count, VALUE **vals)
|
||||
*/
|
||||
} else {
|
||||
/* convert NUMBER argument from NUMBER to COMPLEX */
|
||||
arg1.v_com = qqtoc(arg1.v_num, &_qzero_);
|
||||
arg1.v_type = V_COM;
|
||||
vals[0]->v_com = qqtoc(vals[0]->v_num, &_qzero_);
|
||||
vals[0]->v_type = V_COM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type == V_COM) {
|
||||
if (vals[0]->v_type == V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument was COMPLEX or
|
||||
* trig function returned NULL and argument was converted to COMPLEX
|
||||
*/
|
||||
c = c_acrd(arg1.v_com, eps);
|
||||
c = c_acrd(vals[0]->v_com, eps);
|
||||
if (c == NULL) {
|
||||
return error_value(E_ACRD_3);
|
||||
}
|
||||
@@ -12370,7 +12402,7 @@ f_acrd(int count, VALUE **vals)
|
||||
result.v_type = V_NUM;
|
||||
}
|
||||
}
|
||||
if (arg1.v_type != V_NUM && arg1.v_type != V_COM) {
|
||||
if (vals[0]->v_type != V_NUM && vals[0]->v_type != V_COM) {
|
||||
|
||||
/*
|
||||
* case: argument type is not valid for this function
|
||||
|
39
help.c
39
help.c
@@ -56,38 +56,41 @@ STATIC struct help_alias {
|
||||
char *topic;
|
||||
char *filename;
|
||||
} halias[] = {
|
||||
/* We sort the list below via: sort -d -u */
|
||||
{"=", "address"},
|
||||
{"->", "arrow"},
|
||||
{"=", "assign"},
|
||||
{"*", "dereference"},
|
||||
{".", "oldvalue"},
|
||||
{"%", "mod"},
|
||||
{"//", "quo"},
|
||||
{".", "oldvalue"},
|
||||
{"#", "pound"},
|
||||
{"calc", "help"},
|
||||
{"//", "quo"},
|
||||
{"COPYING_LGPL", "COPYING-LGPL"},
|
||||
{"COPYLEFT", "copyright"},
|
||||
{"COPYRIGHT", "copyright"},
|
||||
{"Copyleft", "copyright"},
|
||||
{"Copyright", "copyright"},
|
||||
{"abort", "command"},
|
||||
{"cd", "command"},
|
||||
{"copy", "blkcpy"},
|
||||
{"copying", "COPYING"},
|
||||
{"copying-lgpl", "COPYING-LGPL"},
|
||||
{"copying_lgpl", "COPYING-LGPL"},
|
||||
{"COPYING_LGPL", "COPYING-LGPL"},
|
||||
{"Copyright", "copyright"},
|
||||
{"COPYRIGHT", "copyright"},
|
||||
{"Copyleft", "copyright"},
|
||||
{"COPYLEFT", "copyright"},
|
||||
{"define", "command"},
|
||||
{"read", "command"},
|
||||
{"write", "command"},
|
||||
{"quit", "command"},
|
||||
{"exit", "command"},
|
||||
{"abort", "command"},
|
||||
{"cd", "command"},
|
||||
{"show", "command"},
|
||||
{"stdlib", "resource"},
|
||||
{"question", "questions"},
|
||||
{"dm2d", "dms2d"},
|
||||
{"exit", "command"},
|
||||
{"gm2g", "gms2g"},
|
||||
{"hm2d", "hms2d"},
|
||||
{"man", "calc"},
|
||||
{"question", "questions"},
|
||||
{"quit", "command"},
|
||||
{"read", "command"},
|
||||
{"release", "releases"},
|
||||
{"show", "command"},
|
||||
{"stdlib", "resource"},
|
||||
{"usage", "calc"},
|
||||
{"write", "command"},
|
||||
|
||||
/* MUST BE LAST! */
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
101
help/Makefile
101
help/Makefile
@@ -118,76 +118,65 @@ V=@:
|
||||
# Files managed by this Makefile #
|
||||
##################################
|
||||
|
||||
STD_HELP_FILES_1= intro overview help
|
||||
STD_HELP_FILES_1= intro overview
|
||||
BLT_HELP_FILES_1a= calc
|
||||
|
||||
STD_HELP_FILES_2= assoc
|
||||
|
||||
BLT_HELP_FILES_3= builtin man
|
||||
|
||||
STD_HELP_FILES_4= command config custom define environment expression
|
||||
|
||||
BLT_HELP_FILES_3= builtin
|
||||
STD_HELP_FILES_4= command config custom define environment
|
||||
BLT_HELP_FILES_5= errorcodes
|
||||
|
||||
STD_HELP_FILES_6= file history interrupt list mat
|
||||
|
||||
STD_HELP_FILES_6= expression file history interrupt list mat
|
||||
# because obj is built special (due to confusion with it as
|
||||
# a symlink for some built environments, we treat obj specially
|
||||
# and call it obj.file
|
||||
#
|
||||
SPECIAL_HELP_7= obj.file
|
||||
|
||||
STD_HELP_FILES_8= operator statement
|
||||
|
||||
STD_HELP_FILES_8= operator
|
||||
BLT_HELP_FILES_9= resource
|
||||
STD_HELP_FILES_10= script statement types unexpected variable
|
||||
|
||||
STD_HELP_FILES_10= types script
|
||||
|
||||
BLT_HELP_FILES_10a= usage cscript
|
||||
|
||||
STD_HELP_FILES_10b= unexpected variable
|
||||
|
||||
BLT_HELP_FILES_11= bindings custom_cal libcalc new_custom resource
|
||||
BLT_HELP_FILES_11= bindings custom_cal libcalc new_custom cscript
|
||||
|
||||
STD_HELP_FILES_12= archive
|
||||
BLT_HELP_FILES_13= bugs changes contrib
|
||||
STD_HELP_FILES_14= todo wishlist
|
||||
|
||||
BLT_HELP_FILES_13= bugs changes
|
||||
STD_HELP_FILES_15= credit
|
||||
# copyright is printed by help.c is from the Copyright string found in version.c
|
||||
BLT_HELP_FILES_16= COPYING COPYING-LGPL questions releases
|
||||
|
||||
STD_HELP_FILES_14= credit
|
||||
|
||||
BLT_HELP_FILES_14= contrib COPYING COPYING-LGPL questions releases
|
||||
|
||||
STD_HELP_FILES_15= wishlist todo
|
||||
STD_HELP_FILES_17= help
|
||||
|
||||
# These files are used in the following order to construct full
|
||||
#
|
||||
FULL_HELP_FILES= ${STD_HELP_FILES_1} ${STD_HELP_FILES_2} \
|
||||
${BLT_HELP_FILES_3} ${STD_HELP_FILES_4} \
|
||||
${BLT_HELP_FILES_5} ${STD_HELP_FILES_6} \
|
||||
${SPECIAL_HELP_7} ${STD_HELP_FILES_8} \
|
||||
${BLT_HELP_FILES_9} ${STD_HELP_FILES_10} \
|
||||
${BLT_HELP_FILES_10a} ${STD_HELP_FILES_10b} \
|
||||
${BLT_HELP_FILES_11} ${STD_HELP_FILES_12} \
|
||||
${BLT_HELP_FILES_13} ${STD_HELP_FILES_14} \
|
||||
${BLT_HELP_FILES_14} ${STD_HELP_FILES_15}
|
||||
FULL_HELP_FILES= ${STD_HELP_FILES_1} ${BLT_HELP_FILES_1a} \
|
||||
${STD_HELP_FILES_2} \
|
||||
${BLT_HELP_FILES_3} ${STD_HELP_FILES_4} \
|
||||
${BLT_HELP_FILES_5} ${STD_HELP_FILES_6} \
|
||||
${SPECIAL_HELP_7} ${STD_HELP_FILES_8} \
|
||||
${BLT_HELP_FILES_9} ${STD_HELP_FILES_10} \
|
||||
${BLT_HELP_FILES_11} ${STD_HELP_FILES_12} \
|
||||
${BLT_HELP_FILES_13} ${STD_HELP_FILES_14} \
|
||||
${STD_HELP_FILES_15} ${BLT_HELP_FILES_16} \
|
||||
${STD_HELP_FILES_17}
|
||||
|
||||
# These full files are those who are not built or constructed
|
||||
#
|
||||
STD_HELP_FILES= ${STD_HELP_FILES_1} ${STD_HELP_FILES_2} \
|
||||
${STD_HELP_FILES_4} ${STD_HELP_FILES_6} \
|
||||
${STD_HELP_FILES_8} ${STD_HELP_FILES_10} \
|
||||
${STD_HELP_FILES_10b} \
|
||||
STD_HELP_FILES= ${STD_HELP_FILES_1} ${STD_HELP_FILES_2} \
|
||||
${STD_HELP_FILES_4} ${STD_HELP_FILES_6} \
|
||||
${STD_HELP_FILES_8} ${STD_HELP_FILES_10} \
|
||||
${STD_HELP_FILES_12} ${STD_HELP_FILES_14} \
|
||||
${STD_HELP_FILES_15}
|
||||
${STD_HELP_FILES_15} ${STD_HELP_FILES_17}
|
||||
|
||||
# These full files are those who are built by this Makefile
|
||||
#
|
||||
# Note that ${SPECIAL_HELP_7} is not included in this list
|
||||
# because of problems with its name.
|
||||
#
|
||||
BLT_HELP_FILES= ${BLT_HELP_FILES_3} ${BLT_HELP_FILES_5} \
|
||||
${BLT_HELP_FILES_9} \
|
||||
${BLT_HELP_FILES_10a} \
|
||||
${BLT_HELP_FILES_11} ${BLT_HELP_FILES_13} \
|
||||
${BLT_HELP_FILES_14}
|
||||
BLT_HELP_FILES= ${BLT_HELP_FILES_1a} \
|
||||
${BLT_HELP_FILES_3} ${BLT_HELP_FILES_5} \
|
||||
${BLT_HELP_FILES_9} ${BLT_HELP_FILES_11} \
|
||||
${BLT_HELP_FILES_13} ${BLT_HELP_FILES_16}
|
||||
|
||||
# The detailed list of help files to install
|
||||
#
|
||||
@@ -382,7 +371,7 @@ errorcodes: ../errcode${EXT}
|
||||
${TRUE}; \
|
||||
fi
|
||||
|
||||
usage: ../calc.usage
|
||||
calc: ../calc.usage
|
||||
${RM} -f $@
|
||||
${CP} ../calc.usage $@
|
||||
${CHMOD} 0444 $@
|
||||
@@ -433,18 +422,6 @@ copy: blkcpy
|
||||
${TRUE}; \
|
||||
fi
|
||||
|
||||
man: help
|
||||
${RM} -f $@
|
||||
${CP} help $@
|
||||
${CHMOD} 0444 $@
|
||||
-@if [ -z "${Q}" ]; then \
|
||||
echo ''; \
|
||||
echo '=-=-= skipping the ${CAT} of help/$@ =-=-='; \
|
||||
echo ''; \
|
||||
else \
|
||||
${TRUE}; \
|
||||
fi
|
||||
|
||||
COPYING: ../COPYING
|
||||
${RM} -f $@
|
||||
${CP} ../COPYING $@
|
||||
@@ -698,7 +675,7 @@ clean:
|
||||
${RM} -f COPYING COPYING-LGPL questions
|
||||
|
||||
clobber: clean
|
||||
${RM} -f ${BLT_HELP_FILES} full .all calc
|
||||
${RM} -f ${BLT_HELP_FILES} full .all calc man usage
|
||||
${RM} -f ${SINGULAR_FILES} ${DETAIL_CLONE}
|
||||
-${Q} if [ -e .DS_Store ]; then \
|
||||
echo ${RM} -rf .DS_Store; \
|
||||
@@ -766,6 +743,14 @@ install: all
|
||||
${RM} -f ${T}${HELPDIR}/md5; \
|
||||
echo "removed old ${T}${HELPDIR}/md5"; \
|
||||
fi;
|
||||
-${Q} if [ -f "${T}${HELPDIR}/man" ]; then \
|
||||
${RM} -f ${T}${HELPDIR}/man; \
|
||||
echo "removed old ${T}${HELPDIR}/man"; \
|
||||
fi;
|
||||
-${Q} if [ -f "${T}${HELPDIR}/usage" ]; then \
|
||||
${RM} -f ${T}${HELPDIR}/usage; \
|
||||
echo "removed old ${T}${HELPDIR}/usage"; \
|
||||
fi;
|
||||
|
||||
# Try to remove everything that was installed
|
||||
#
|
||||
|
@@ -14,7 +14,7 @@ DESCRIPTION
|
||||
strings available, including the program or script name.
|
||||
|
||||
If the numeric arg is supplied, then the corresponding command line
|
||||
string is return, if it exists. Otherwise a nul() value is returned.
|
||||
string is return, if it exists. Otherwise a null() value is returned.
|
||||
|
||||
In keeping with the argc/argv convention of C, argv(0) will refer
|
||||
to the name of the program. If the -f filename argument is used,
|
||||
|
@@ -152,7 +152,7 @@ Command sequence
|
||||
exit string
|
||||
|
||||
The action of these commands depends on where they are used.
|
||||
At the interactive level, they will cause calc it edit.
|
||||
At the interactive level, they will cause calc to exit.
|
||||
This is the normal way to leave the calculator. In any
|
||||
other use, they will stop the current calculation as if
|
||||
an error had occurred.
|
||||
|
@@ -8,18 +8,17 @@ TYPES
|
||||
return string
|
||||
|
||||
DESCRIPTION
|
||||
The ctime() builtin returns the string formed by the first 24
|
||||
The ctime() builtin returns the string formed by the
|
||||
characters returned by the C library function, ctime(): E.g.
|
||||
|
||||
"Mon Oct 28 00:47:00 1996"
|
||||
|
||||
The 25th ctime() character, '\n' is removed.
|
||||
"Mon Oct 28 00:47:00 1996\n"
|
||||
|
||||
EXAMPLE
|
||||
; ## NOTE: Your output will likely vary:
|
||||
|
||||
; printf("The time is now %s.\n", ctime())
|
||||
The time is now Mon Apr 15 12:41:44 1996.
|
||||
The time is now Mon Apr 15 12:41:44 1996
|
||||
.
|
||||
|
||||
LIMITS
|
||||
none
|
||||
|
@@ -46,7 +46,7 @@ DESCRIPTION
|
||||
|
||||
Some non-POSIX systems such as MS Windows treat text files
|
||||
and binary files differently. In text mode MS Windows consider
|
||||
"\r\n" and end-of-line character. On an Apple MAC, the
|
||||
"\r\n" an end-of-line character. On an Apple MAC, the
|
||||
text mode end-of-line character is "\r".
|
||||
|
||||
Names of files are subject to ~ expansion just like the C or
|
||||
|
@@ -100,7 +100,7 @@ DESCRIPTION
|
||||
|
||||
Some non-POSIX systems such as MS Windows treat text files
|
||||
and binary files differently. In text mode MS Windows consider
|
||||
"\r\n" and end-of-line character. On an Apple MAC, the
|
||||
"\r\n" an end-of-line character. On an Apple MAC, the
|
||||
text mode end-of-line character is "\r".
|
||||
|
||||
Names of files are subject to ~ expansion just like the C or
|
||||
|
10
help/help
10
help/help
@@ -5,7 +5,7 @@ following topics:
|
||||
----- -----------
|
||||
intro introduction to calc
|
||||
overview overview of calc
|
||||
help this file
|
||||
calc calc man page, how to invoke the calc command
|
||||
|
||||
assoc using associations
|
||||
builtin builtin functions
|
||||
@@ -13,7 +13,7 @@ following topics:
|
||||
config configuration parameters
|
||||
custom information about the custom builtin interface
|
||||
define how to define functions
|
||||
environment how environment variables effect calc
|
||||
environment how environment variables affect calc
|
||||
errorcodes calc generated error codes
|
||||
expression expression sequences
|
||||
file using files
|
||||
@@ -23,18 +23,17 @@ following topics:
|
||||
mat using matrices
|
||||
obj user defined data types
|
||||
operator math, relational, logic and variable access operators
|
||||
resource standard calc resource files
|
||||
script using calc shell scripts
|
||||
statement flow control and declaration statements
|
||||
types builtin data types
|
||||
unexpected unexpected syntax/usage surprises for C programmers
|
||||
usage how to invoke the calc command
|
||||
variable variables and variable declarations
|
||||
|
||||
bindings input & history character bindings
|
||||
custom_cal information about custom calc resource files
|
||||
libcalc using the arbitrary precision routines in a C program
|
||||
new_custom information about how to add new custom functions
|
||||
resource standard calc resource files
|
||||
script using calc shell scripts
|
||||
cscript info on the calc shell scripts supplied with calc
|
||||
|
||||
archive where to get the latest versions of calc
|
||||
@@ -51,6 +50,7 @@ following topics:
|
||||
questions how to ask simple general question about calc
|
||||
release on calc versions and releases
|
||||
|
||||
help this file
|
||||
full all of the above (in the above order)
|
||||
|
||||
For example:
|
||||
|
@@ -2,7 +2,7 @@ NAME
|
||||
matfill - fill a matrix with specified value or values
|
||||
|
||||
SYNOPSIS
|
||||
mat(m, x [, y])
|
||||
matfill(m, x [, y])
|
||||
|
||||
TYPES
|
||||
m matrix
|
||||
|
@@ -2,7 +2,7 @@ NAME
|
||||
mattrans - matrix transpose
|
||||
|
||||
SYNOPSIS
|
||||
matdim(m)
|
||||
mattrans(m)
|
||||
|
||||
TYPES
|
||||
m 2-dimensional matrix
|
||||
|
45
help/prompt
45
help/prompt
@@ -10,10 +10,43 @@ TYPES
|
||||
return string
|
||||
|
||||
DESCRIPTION
|
||||
When prompt(str) is called and input is from a terminal, the string
|
||||
str is displayed and execution is halted until a newline ends a line
|
||||
read from the input; the string formed by the characters in the line
|
||||
(other than the newline) is returned as the value of prompt().
|
||||
When prompt(str) is called and input is from a terminal, the string
|
||||
str is displayed and execution is halted until a newline ends a line
|
||||
read from the input; the string formed by the characters in the line
|
||||
(other than the newline) is returned as the value of prompt().
|
||||
|
||||
Be careful when using prompt(str) while calc is being used as a
|
||||
shell script. Unless calc is run with the -p command line option,
|
||||
the prompt builtin will fail and return null. This is because when
|
||||
calc is running as a shell script, calc will close stdin run in in
|
||||
a non-interactive mode.
|
||||
|
||||
The following shell script will always print "got null" because
|
||||
stdin will be closed by calc during startup:
|
||||
|
||||
#!/usr/bin/calc -q -f
|
||||
|
||||
# The prompt will ALWAYS FAIL and return a null value
|
||||
n = prompt("Test> ");
|
||||
if (isnull(n)) {
|
||||
print("got null");
|
||||
} else {
|
||||
print("got " + n);
|
||||
}
|
||||
|
||||
However the following shell script (note the -p before the -f in
|
||||
the 1st line) will be interactive, prompt with "Test> " and print
|
||||
the "got" result as expected:
|
||||
|
||||
#!/usr/bin/calc -q -p -f
|
||||
|
||||
n = prompt("Test> ");
|
||||
if (isnull(n)) {
|
||||
print("got null");
|
||||
} else {
|
||||
print("got " + n);
|
||||
}
|
||||
|
||||
|
||||
EXAMPLE
|
||||
; x = prompt("? ");
|
||||
@@ -35,9 +68,9 @@ LINK LIBRARY
|
||||
none
|
||||
|
||||
SEE ALSO
|
||||
fgetfield, fgetline, fgetstr
|
||||
command, fgetfield, fgetline, fgetstr, unexpected
|
||||
|
||||
## Copyright (C) 1999-2006 Landon Curt Noll
|
||||
## Copyright (C) 1999,2006,2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
|
@@ -1,5 +1,5 @@
|
||||
NAME
|
||||
randbit - Blum-Blum-Shub pseudo-random number generator
|
||||
randombit - Blum-Blum-Shub pseudo-random number generator
|
||||
|
||||
SYNOPSIS
|
||||
randombit([x])
|
||||
|
@@ -534,8 +534,15 @@ Unexpected
|
||||
|
||||
Some might be surprised to discover that all of the trigonometric in calc:
|
||||
|
||||
sin, cos, tan, sec, csc, cot
|
||||
asin, acos, atan, asec, acsc, acot
|
||||
sin, cos, tan, cot, sec, csc
|
||||
asin, acos, atan, acot, asec, acsc
|
||||
versin, coversin, vercos, covercos
|
||||
aversin, acoversin, avercos, acovercos
|
||||
haversin, hacoversin, havercos, hacovercos
|
||||
ahaversin, hacoversin, havercos, ahacovercos
|
||||
exsec, aexsec, excsc, aexcsc
|
||||
crd, acrd
|
||||
cas, cis
|
||||
|
||||
work in only radians.
|
||||
|
||||
@@ -556,6 +563,7 @@ Unexpected
|
||||
; print sin(d2r(30))
|
||||
0.5
|
||||
|
||||
|
||||
* operator has has a higher precedence than <<
|
||||
==============================================
|
||||
|
||||
@@ -563,6 +571,49 @@ Unexpected
|
||||
So 3 << 2*5 evaluates to 3072 in C, whereas 3 << 2*5 evaluates to 60 in calc.
|
||||
|
||||
|
||||
prompt builtin returns null in calc shell scripts unless -p is used
|
||||
===================================================================
|
||||
|
||||
Be careful when using prompt(str) while calc is being used as a
|
||||
shell script. Unless calc is run with the -p command line option,
|
||||
the prompt builtin will fail and return null. This is because when
|
||||
calc is running as a shell script, calc will close stdin run in in
|
||||
a non-interactive mode.
|
||||
|
||||
The following shell script will always print "got null" because
|
||||
stdin will be closed by calc during startup:
|
||||
|
||||
#!/usr/bin/calc -q -f
|
||||
|
||||
n = prompt("Test> ");
|
||||
if (isnull(n)) {
|
||||
print("got null");
|
||||
} else {
|
||||
print("got " + n);
|
||||
}
|
||||
|
||||
However the following shell script (note the -p before the -f in
|
||||
the 1st line) will be interactive, prompt with "Test> " and print
|
||||
the "got" result as expected:
|
||||
|
||||
#!/usr/bin/calc -q -p -f
|
||||
|
||||
n = prompt("Test> ");
|
||||
if (isnull(n)) {
|
||||
print("got null");
|
||||
} else {
|
||||
print("got " + n);
|
||||
}
|
||||
|
||||
Note in the example above, the -p flag must be given before the
|
||||
final -f command line flag.
|
||||
|
||||
A similar problem will occur if the calc shell script attempts
|
||||
to read from standard input (stdin), unless the -p flag is used.
|
||||
|
||||
See "SHELL SCRIPT MODE" in the calc man page for more information
|
||||
about -p and about the "shell script mode".
|
||||
|
||||
## Copyright (C) 1999-2007,2014,2017,2021,2023 Landon Curt Noll
|
||||
##
|
||||
## Calc is open software; you can redistribute it and/or modify it under
|
||||
|
76
hist.c
76
hist.c
@@ -73,6 +73,8 @@
|
||||
#include "banned.h" /* include after system header <> includes */
|
||||
|
||||
|
||||
#define MIN(a,b) (((a) <= (b)) ? (a) : (b))
|
||||
|
||||
#if !defined(USE_READLINE)
|
||||
|
||||
E_FUNC FILE *curstream(void);
|
||||
@@ -1472,37 +1474,69 @@ quit_calc(int UNUSED(ch))
|
||||
* The readline/history libs do most of the dirty work for us, so we can
|
||||
* replace hist_init() and hist_term() with dummies when using readline.
|
||||
* For hist_getline() we have to add a newline that readline removed but
|
||||
* calc expects. For hist_saveline(), we have to undo this. hist_getline()
|
||||
* calc expects. For hist_saveline(), we have to undo this. hist_getline()
|
||||
* also has to cope with the different memory management schemes of calc and
|
||||
* readline.
|
||||
* readline (pointer to target buffer passed to hist_getline() vs. returned
|
||||
* malloc()ed buffer from readline()). While doing that, we also split
|
||||
* multi-line strings potentially returned by readline() in case of
|
||||
* bracketed paste mode even though its documentation promises to only return
|
||||
* single lines. For details, see https://github.com/lcn2/calc/issues/138
|
||||
* and https://lists.gnu.org/archive/html/bug-readline/2024-01/msg00000.html
|
||||
*/
|
||||
|
||||
|
||||
size_t
|
||||
hist_getline(char *prompt, char *buf, size_t len)
|
||||
{
|
||||
char *line;
|
||||
STATIC char *rlbuf, *rlcur;
|
||||
|
||||
buf[0] = '\0';
|
||||
line = readline(prompt);
|
||||
if (!line) {
|
||||
switch (conf->ctrl_d) {
|
||||
case CTRL_D_NEVER_EOF:
|
||||
return 0;
|
||||
case CTRL_D_VIRGIN_EOF:
|
||||
case CTRL_D_EMPTY_EOF:
|
||||
default:
|
||||
quit_calc(0);
|
||||
not_reached();
|
||||
if (!rlbuf) {
|
||||
rlbuf = rlcur = readline(prompt);
|
||||
if (!rlbuf) {
|
||||
buf[0] = '\0';
|
||||
switch (conf->ctrl_d) {
|
||||
case CTRL_D_NEVER_EOF:
|
||||
return 0;
|
||||
case CTRL_D_VIRGIN_EOF:
|
||||
case CTRL_D_EMPTY_EOF:
|
||||
default:
|
||||
quit_calc(0);
|
||||
not_reached();
|
||||
}
|
||||
}
|
||||
}
|
||||
strlcpy(buf, line, len);
|
||||
buf[len - 2] = '\0';
|
||||
len = strlen(buf);
|
||||
buf[len] = '\n';
|
||||
buf[len + 1] = '\0';
|
||||
free(line);
|
||||
return len + 1;
|
||||
|
||||
/* eol: pointer to trailing newline (if there is one) or \0 */
|
||||
char *eol = strchr(rlcur, '\n');
|
||||
if (!eol) {
|
||||
eol = rlcur + strlen(rlcur);
|
||||
}
|
||||
/* len: length of line in target buffer including (possibly added)
|
||||
* newline, truncated if buffer is too small. Note that we reduce
|
||||
* the available buffer size by 1 so that we can safely add the
|
||||
* newline below.
|
||||
*/
|
||||
len = MIN(len - 1, (size_t)(eol - rlcur + 1));
|
||||
strlcpy(buf, rlcur, len);
|
||||
/* make sure we have a newline and NUL */
|
||||
buf[len - 1] = '\n';
|
||||
buf[len] = '\0';
|
||||
|
||||
/* skip over newline in readline buffer */
|
||||
if (*eol) {
|
||||
eol++;
|
||||
}
|
||||
/* prepare for next invocation: point to next line or free readline
|
||||
* buffer if we've reached EOL
|
||||
*/
|
||||
if (*eol) {
|
||||
rlcur = eol;
|
||||
} else {
|
||||
free(rlbuf);
|
||||
rlbuf = rlcur = NULL;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
|
2
qfunc.c
2
qfunc.c
@@ -1953,7 +1953,7 @@ qispowerof2(NUMBER *q, NUMBER **qlog2)
|
||||
* Set *qlog2 to base 2 logarithm of q, which will be a negative value,
|
||||
* and return true.
|
||||
*/
|
||||
*qlog2 = utoq(log2);
|
||||
**qlog2 = *utoq(log2);
|
||||
(*qlog2)->num.sign = !(*qlog2)->num.sign; /* set *qlog2 to -log2 */
|
||||
return true;
|
||||
}
|
||||
|
36
trailblank
36
trailblank
@@ -38,6 +38,14 @@ export EXIT_CODE=0
|
||||
# We exclude binary files, RCS source code history, intermediate
|
||||
# compiled files, patch droppings and compiled binary libraries.
|
||||
#
|
||||
# We also ignore filenames with a single letter, and files
|
||||
# that end in .out, and files containing the any of the following
|
||||
# in any letter case:
|
||||
#
|
||||
# foo bar baz curds whey rmme
|
||||
#
|
||||
# Such files are temporary/test files and are not part of calc.
|
||||
#
|
||||
# Last, we have two files that have long lines that, for now,
|
||||
# we cannot be as picky about without significant work.
|
||||
#
|
||||
@@ -53,7 +61,9 @@ LEADING_SPACES_BEFORE_TAB=$(
|
||||
-path './longbits' -o -name '.*.swp' -o -name 'conf.h' -o \
|
||||
-name '.git' -o -path './custom/libcustcalc*' -o -path './libcustcalc*' -o \
|
||||
-name 'sample_many-static' -o -name 'sample_rand-static' -o \
|
||||
-name 'codeql-analysis.yml' -o -name tags -o -name '*.out' \
|
||||
-name 'codeql-analysis.yml' -o -name tags -o -name '*.out' -o \
|
||||
-name '?' -o -iname '*foo*' -o -iname '*bar*' -o -iname '*baz*' -o \
|
||||
-iname '*curds*' -o -iname '*whey*' -o -iname '*rmme*' \
|
||||
\) -prune -o -type f -print0 | \
|
||||
xargs -0 egrep -l '^ * * '
|
||||
)
|
||||
@@ -69,6 +79,14 @@ fi
|
||||
# We exclude binary files, RCS source code history, intermediate
|
||||
# compiled files, patch droppings and compiled binary libraries.
|
||||
#
|
||||
# We also ignore filenames with a single letter, and files
|
||||
# that end in .out, and files containing the any of the following
|
||||
# in any letter case:
|
||||
#
|
||||
# foo bar baz curds whey rmme
|
||||
#
|
||||
# Such files are temporary/test files and are not part of calc.
|
||||
#
|
||||
# Last, we have two files that have long lines that, for now,
|
||||
# we cannot be as picky about without significant work.
|
||||
#
|
||||
@@ -84,7 +102,8 @@ TRAILING_WHITESPACE=$(
|
||||
-path './longbits' -o -name '.*.swp' -o -name 'conf.h' -o \
|
||||
-name '.git' -o -path './custom/libcustcalc*' -o -path './libcustcalc*' -o \
|
||||
-name 'sample_many-static' -o -name 'sample_rand-static' -o \
|
||||
-name 'codeql-analysis.yml' -o -name tags -o -name '*.out' \
|
||||
-name '?' -o -iname '*foo*' -o -iname '*bar*' -o -iname '*baz*' -o \
|
||||
-iname '*curds*' -o -iname '*whey*' -o -iname '*rmme*' \
|
||||
\) -prune -o -type f -print0 | \
|
||||
xargs -0 egrep -l '[ ]$'
|
||||
)
|
||||
@@ -139,6 +158,14 @@ fi
|
||||
# We exclude binary files, source code history, intermediate
|
||||
# compiled files, patch droppings and compiled binary libraries.
|
||||
#
|
||||
# We also ignore filenames with a single letter, and files
|
||||
# that end in .out, and files containing the any of the following
|
||||
# in any letter case:
|
||||
#
|
||||
# foo bar baz curds whey rmme
|
||||
#
|
||||
# Such files are temporary/test files and are not part of calc.
|
||||
#
|
||||
# Last, we have files that have long lines that, for now,
|
||||
# we cannot be as picky about without significant work.
|
||||
#
|
||||
@@ -155,7 +182,8 @@ PICKY_PHASE_1=$(
|
||||
-name '.git' -o -path './custom/libcustcalc*' -o -path './libcustcalc*' -o \
|
||||
-name 'sample_many-static' -o -name 'sample_rand-static' -o \
|
||||
-name 'codeql-analysis.yml' -o -name tags -o -name '*.out' -o \
|
||||
-name '.gitignore' -o -name 'README.md' -o -name '.lldbinit' \
|
||||
-name '?' -o -iname '*foo*' -o -iname '*bar*' -o -iname '*baz*' -o \
|
||||
-iname '*curds*' -o -iname '*whey*' -o -iname '*rmme*' \
|
||||
\) -prune -o -type f -print0 | \
|
||||
if [[ -x /usr/local/bin/picky ]]; then
|
||||
xargs -0 /usr/local/bin/picky -s -v -w132
|
||||
@@ -184,7 +212,7 @@ if [[ -n $BACKUP_MAKEILES ]]; then
|
||||
echo
|
||||
echo "# You need execute the following to remove backup Makefiles:"
|
||||
echo
|
||||
echo "$BACKUP_MAKEILES" | while read file; do
|
||||
echo "$BACKUP_MAKEILES" | while read -r file; do
|
||||
echo "rm -f $file"
|
||||
done
|
||||
EXIT_CODE=7
|
||||
|
30
update_ver
30
update_ver
@@ -169,6 +169,7 @@ for i in $MK_SET1; do
|
||||
echo "$i: $VER_STRING"
|
||||
fi
|
||||
done
|
||||
echo
|
||||
if [[ -n $VER_ERR ]]; then
|
||||
echo "$0: FATAL: error in finding calc major version string"
|
||||
echo "$0: FATAL: exit 10"
|
||||
@@ -177,15 +178,36 @@ fi
|
||||
|
||||
# print other useful calc strings
|
||||
#
|
||||
export VER_CALC_OUTPUT=$(./ver_calc)
|
||||
echo 'Begin text strings used to produce this release:'
|
||||
echo 'vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv'
|
||||
echo
|
||||
echo "calc $(./ver_calc) release"
|
||||
echo
|
||||
echo 'calc-*'$(./ver_calc)'*'
|
||||
echo
|
||||
echo "Release v$(./ver_calc)"
|
||||
echo "$VER_CALC_OUTPUT"
|
||||
echo
|
||||
echo "v$VER_CALC_OUTPUT"
|
||||
echo
|
||||
echo "Release v$VER_CALC_OUTPUT"
|
||||
echo
|
||||
echo "calc $VER_CALC_OUTPUT release"
|
||||
echo
|
||||
echo 'For use with sourceforge.net:'
|
||||
echo
|
||||
echo 'cd /home/pfs/project/calc/calc'
|
||||
echo "mkdir $VER_CALC_OUTPUT"
|
||||
echo "cd $VER_CALC_OUTPUT"
|
||||
echo 'mput calc-*'"$VER_CALC_OUTPUT"'*'
|
||||
echo 'put /home/chongo/tmp/README.txt'
|
||||
echo 'ls'
|
||||
echo
|
||||
echo
|
||||
echo
|
||||
echo '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'
|
||||
echo 'End text strings used to produce this release:'
|
||||
echo
|
||||
|
||||
# All Done!!! -- Jessica Noll, Age 2
|
||||
#
|
||||
echo
|
||||
echo "VERSION in Makefile.config is up to date"
|
||||
exit 0
|
||||
|
@@ -80,7 +80,13 @@ char *Copyright = "\n"
|
||||
"\n"
|
||||
"Calc is open software; you can redistribute it and/or modify it under\n"
|
||||
"the terms of the version 2.1 of the GNU Lesser General Public License\n"
|
||||
"as published by the Free Software Foundation.\n";
|
||||
"as published by the Free Software Foundation.\n"
|
||||
"\n"
|
||||
"Please see the file COPYING, or use the calc command:\n"
|
||||
"\n"
|
||||
"\thelp copying\n"
|
||||
"\n"
|
||||
"for important copyright and license information!\n";
|
||||
char *Usability = "\n"
|
||||
"Calc is distributed in the hope that it will be useful, but WITHOUT\n"
|
||||
"ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\n"
|
||||
|
@@ -64,7 +64,7 @@
|
||||
#define MAJOR_VER 2 /* level 1: major library version */
|
||||
#define MINOR_VER 15 /* level 2: minor library version */
|
||||
#define MAJOR_PATCH 0 /* level 3: major software version level */
|
||||
#define MINOR_PATCH 1 /* level 4: minor software version level */
|
||||
#define MINOR_PATCH 7 /* level 4: minor software version level */
|
||||
|
||||
|
||||
#endif /* !INCLUDE_VERSION_H*/
|
||||
|
18
zmath.h
18
zmath.h
@@ -79,7 +79,7 @@ typedef USB64 FULL; /* double unit of number storage */
|
||||
typedef SB64 SFULL; /* signed FULL */
|
||||
|
||||
#define SWAP_HALF_IN_B64(dest, src) SWAP_B32_IN_B64(dest, src)
|
||||
#define SWAP_HALF_IN_B32(dest, src) (*(dest) = *(src))
|
||||
#define SWAP_HALF_IN_B32(dest, src) (*((HALF *)(dest)) = *((HALF *)(src)))
|
||||
#define SWAP_HALF_IN_FULL(dest, src) SWAP_B32_IN_B64(dest, src)
|
||||
#define SWAP_HALF_IN_HASH(dest, src) SWAP_B16_IN_HASH(dest, src)
|
||||
#define SWAP_HALF_IN_FLAG(dest, src) SWAP_B16_IN_FLAG(dest, src)
|
||||
@@ -106,9 +106,9 @@ typedef SB32 SFULL; /* signed FULL */
|
||||
#define SWAP_HALF_IN_FLAG(dest, src) SWAP_B16_IN_FLAG(dest, src)
|
||||
#define SWAP_HALF_IN_bool(dest, src) SWAP_B16_IN_bool(dest, src)
|
||||
#define SWAP_HALF_IN_LEN(dest, src) SWAP_B16_IN_LEN(dest, src)
|
||||
#define SWAP_B32_IN_FULL(dest, src) (*(dest) = *(src))
|
||||
#define SWAP_B32_IN_FULL(dest, src) (*((FULL *)(dest)) = *((FULL *)(src)))
|
||||
#define SWAP_B16_IN_FULL(dest, src) SWAP_B16_IN_B32(dest, src)
|
||||
#define SWAP_B16_IN_HALF(dest, src) (*(dest) = *(src))
|
||||
#define SWAP_B16_IN_HALF(dest, src) (*((HALF *)(dest)) = *((HALF *)(src)))
|
||||
#define SWAP_B8_IN_FULL(dest, src) SWAP_B8_IN_B32(dest, src)
|
||||
#define SWAP_B8_IN_HALF(dest, src) SWAP_B8_IN_B16(dest, src)
|
||||
|
||||
@@ -171,19 +171,11 @@ typedef SB32 LEN; /* calc v2 compatible unit of length storage */
|
||||
typedef uintptr_t LEN; /* unit of length storage */
|
||||
#endif /* MAJOR_VER < 3 */
|
||||
|
||||
#define SWAP_B32_IN_HASH(dest, src) (*(dest) = *(src))
|
||||
#define SWAP_B16_IN_HASH(dest, src) SWAP_B16_IN_B32(dest, src)
|
||||
#define SWAP_B8_IN_HASH(dest, src) SWAP_B8_IN_B32(dest, src)
|
||||
|
||||
#define SWAP_B32_IN_FLAG(dest, src) (*(dest) = *(src))
|
||||
#define SWAP_B16_IN_FLAG(dest, src) SWAP_B16_IN_B32(dest, src)
|
||||
#define SWAP_B8_IN_FLAG(dest, src) SWAP_B8_IN_B32(dest, src)
|
||||
|
||||
#define SWAP_B32_IN_bool(dest, src) (*(dest) = *(src))
|
||||
#define SWAP_B32_IN_bool(dest, src) (*((bool *)(dest)) = *((bool *)(src)))
|
||||
#define SWAP_B16_IN_bool(dest, src) SWAP_B16_IN_B32(dest, src)
|
||||
#define SWAP_B8_IN_bool(dest, src) SWAP_B8_IN_B32(dest, src)
|
||||
|
||||
#define SWAP_B32_IN_LEN(dest, src) (*(dest) = *(src))
|
||||
#define SWAP_B32_IN_LEN(dest, src) (*((LEN *)(dest)) = *((LEN *)(src)))
|
||||
#define SWAP_B16_IN_LEN(dest, src) SWAP_B16_IN_B32(dest, src)
|
||||
#define SWAP_B8_IN_LEN(dest, src) SWAP_B8_IN_B32(dest, src)
|
||||
|
||||
|
80
zrandom.c
80
zrandom.c
@@ -1107,6 +1107,7 @@
|
||||
* current Blum generator state
|
||||
*/
|
||||
STATIC RANDOM blum;
|
||||
STATIC bool blum_initialized = false; /* true ==> blum has a seeded and initialized state */
|
||||
|
||||
|
||||
/*
|
||||
@@ -2272,11 +2273,14 @@ zsrandom1(CONST ZVALUE seed, bool need_ret)
|
||||
/*
|
||||
* initialize state if first call
|
||||
*/
|
||||
if (!blum.seeded) {
|
||||
if (blum_initialized == false || !blum.seeded) {
|
||||
p_blum = randomcopy(&init_blum);
|
||||
randomfree(&blum);
|
||||
if (blum_initialized == true) {
|
||||
randomfree(&blum);
|
||||
}
|
||||
blum = *p_blum;
|
||||
free(p_blum);
|
||||
blum_initialized = true;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2342,6 +2346,9 @@ zsrandom1(CONST ZVALUE seed, bool need_ret)
|
||||
* reserved seed
|
||||
*/
|
||||
} else {
|
||||
if (ret != NULL) {
|
||||
randomfree(ret);
|
||||
}
|
||||
math_error("srandom seed must be 0 or >= 2^32");
|
||||
not_reached();
|
||||
}
|
||||
@@ -2384,11 +2391,14 @@ zsrandom2(CONST ZVALUE seed, CONST ZVALUE newn)
|
||||
/*
|
||||
* initialize state if first call
|
||||
*/
|
||||
if (!blum.seeded) {
|
||||
if (blum_initialized == false || !blum.seeded) {
|
||||
p_blum = randomcopy(&init_blum);
|
||||
randomfree(&blum);
|
||||
if (blum_initialized == true) {
|
||||
randomfree(&blum);
|
||||
}
|
||||
blum = *p_blum;
|
||||
free(p_blum);
|
||||
blum_initialized = true;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2409,11 +2419,13 @@ zsrandom2(CONST ZVALUE seed, CONST ZVALUE newn)
|
||||
* preset moduli only if small newn
|
||||
*/
|
||||
if (ziszero(newn)) {
|
||||
randomfree(ret);
|
||||
math_error("srandom newn == 0 reserved for future use");
|
||||
not_reached();
|
||||
}
|
||||
set = (HALF)z1tol(newn);
|
||||
if (!zistiny(newn) || set > BLUM_PREGEN) {
|
||||
randomfree(ret);
|
||||
math_error("srandom small newn must be [1,20]");
|
||||
not_reached();
|
||||
}
|
||||
@@ -2433,7 +2445,7 @@ zsrandom2(CONST ZVALUE seed, CONST ZVALUE newn)
|
||||
* Otherwise non-zero seeds are processed as 1 arg calls
|
||||
*/
|
||||
} else {
|
||||
zsrandom1(seed, false);
|
||||
(void) zsrandom1(seed, false);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2452,6 +2464,7 @@ zsrandom2(CONST ZVALUE seed, CONST ZVALUE newn)
|
||||
* Blum modulus must be 1 mod 4
|
||||
*/
|
||||
if (newn.v[0] % 4 != 1) {
|
||||
randomfree(ret);
|
||||
math_error("srandom large newn must be 1 mod 4");
|
||||
not_reached();
|
||||
}
|
||||
@@ -2498,6 +2511,7 @@ zsrandom2(CONST ZVALUE seed, CONST ZVALUE newn)
|
||||
* reserved newn
|
||||
*/
|
||||
} else {
|
||||
randomfree(ret);
|
||||
math_error("srandom newn must be [1,20] or >= 2^32");
|
||||
not_reached();
|
||||
}
|
||||
@@ -2543,11 +2557,14 @@ zsrandom4(CONST ZVALUE seed, CONST ZVALUE ip, CONST ZVALUE iq, long trials)
|
||||
/*
|
||||
* initialize state if first call
|
||||
*/
|
||||
if (!blum.seeded) {
|
||||
if (blum_initialized == false || !blum.seeded) {
|
||||
p_blum = randomcopy(&init_blum);
|
||||
randomfree(&blum);
|
||||
if (blum_initialized == true) {
|
||||
randomfree(&blum);
|
||||
}
|
||||
blum = *p_blum;
|
||||
free(p_blum);
|
||||
blum_initialized = true;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2559,10 +2576,12 @@ zsrandom4(CONST ZVALUE seed, CONST ZVALUE ip, CONST ZVALUE iq, long trials)
|
||||
* search the 'p' and 'q' Blum prime (3 mod 4) candidates
|
||||
*/
|
||||
if (!znextcand(ip, trials, _zero_, _three_, _four_, &p)) {
|
||||
randomfree(ret);
|
||||
math_error("failed to find 1st Blum prime");
|
||||
not_reached();
|
||||
}
|
||||
if (!znextcand(iq, trials, _zero_, _three_, _four_, &q)) {
|
||||
randomfree(ret);
|
||||
math_error("failed to find 2nd Blum prime");
|
||||
not_reached();
|
||||
}
|
||||
@@ -2640,11 +2659,14 @@ zsetrandom(CONST RANDOM *state)
|
||||
/*
|
||||
* initialize state if first call
|
||||
*/
|
||||
if (!blum.seeded) {
|
||||
if (blum_initialized == false || !blum.seeded) {
|
||||
p_blum = randomcopy(&init_blum);
|
||||
randomfree(&blum);
|
||||
if (blum_initialized == true) {
|
||||
randomfree(&blum);
|
||||
}
|
||||
blum = *p_blum;
|
||||
free(p_blum);
|
||||
blum_initialized = true;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -2657,6 +2679,9 @@ zsetrandom(CONST RANDOM *state)
|
||||
*/
|
||||
if (state != NULL) {
|
||||
p_blum = randomcopy(state);
|
||||
if (blum_initialized == true) {
|
||||
randomfree(&blum);
|
||||
}
|
||||
blum = *p_blum;
|
||||
free(p_blum);
|
||||
}
|
||||
@@ -2684,11 +2709,14 @@ zrandomskip(long cnt)
|
||||
/*
|
||||
* initialize state if first call
|
||||
*/
|
||||
if (!blum.seeded) {
|
||||
if (blum_initialized == false || !blum.seeded) {
|
||||
p_blum = randomcopy(&init_blum);
|
||||
randomfree(&blum);
|
||||
if (blum_initialized == true) {
|
||||
randomfree(&blum);
|
||||
}
|
||||
blum = *p_blum;
|
||||
free(p_blum);
|
||||
blum_initialized = true;
|
||||
}
|
||||
loglogn = (long)blum.loglogn;
|
||||
new_r.len = 0; /* paranoia */
|
||||
@@ -2798,11 +2826,14 @@ zrandom(long cnt, ZVALUE *res)
|
||||
/*
|
||||
* initialize state if first call
|
||||
*/
|
||||
if (!blum.seeded) {
|
||||
if (blum_initialized == false || !blum.seeded) {
|
||||
p_blum = randomcopy(&init_blum);
|
||||
randomfree(&blum);
|
||||
if (blum_initialized == true) {
|
||||
randomfree(&blum);
|
||||
}
|
||||
blum = *p_blum;
|
||||
free(p_blum);
|
||||
blum_initialized = true;
|
||||
}
|
||||
loglogn = blum.loglogn;
|
||||
mask = blum.mask;
|
||||
@@ -3120,16 +3151,18 @@ randomfree(RANDOM *state)
|
||||
not_reached();
|
||||
}
|
||||
|
||||
/* free the values */
|
||||
/* clear the seed */
|
||||
state->seeded = 0;
|
||||
state->bits = 0; /* paranoia */
|
||||
state->loglogn = 0; /* paranoia */
|
||||
state->buffer = 0; /* paranoia */
|
||||
state->mask = 0; /* paranoia */
|
||||
|
||||
/* free the values - unless they are one of the default states */
|
||||
zfree_random(state->n);
|
||||
zfree_random(state->r);
|
||||
|
||||
/* free it if it is not pre-defined */
|
||||
state->seeded = 0;
|
||||
state->bits = 0; /* paranoia */
|
||||
state->buffer = 0;
|
||||
|
||||
/* free it if it is not pre-defined */
|
||||
/* free the RANDOM structure if it is NOT our static blum value */
|
||||
if (state != &blum) {
|
||||
free(state);
|
||||
}
|
||||
@@ -3223,8 +3256,10 @@ randomprint(CONST RANDOM *UNUSED(state), int UNUSED(flags))
|
||||
void
|
||||
random_libcalc_cleanup(void)
|
||||
{
|
||||
/* free our state - let zfree_random protect the default state */
|
||||
randomfree(&blum);
|
||||
/* free our state if seed was initialized - zfree_random protect default states */
|
||||
if (blum_initialized == true && blum.seeded) {
|
||||
randomfree(&blum);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3238,6 +3273,7 @@ random_libcalc_cleanup(void)
|
||||
S_FUNC void
|
||||
zfree_random(ZVALUE z)
|
||||
{
|
||||
/* do not free if NULL or one of the default states */
|
||||
if (z.v != NULL &&
|
||||
z.v != h_ndefvec && z.v != h_rdefvec && z.v != h_rdefvec_2 &&
|
||||
z.v != h_nvec01 && z.v != h_rvec01 &&
|
||||
|
Reference in New Issue
Block a user