diff --git a/.gitignore b/.gitignore index 99c06fb..b409073 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ # .dynamic .hsrc +Makefile.our NOTES align32.h args.h @@ -49,12 +50,16 @@ have_newstr.h have_offscl.h have_posscl.h have_rusage.h +have_statfs.h have_stdlib.h have_stdvs have_strdup.h have_string.h have_strlcat.h have_strlcpy.h +have_sys_mount.h +have_sys_param.h +have_sys_vfs.h have_times.h have_uid_t.h have_unistd.h @@ -93,7 +98,6 @@ libcalc* libcustcalc* longbits longbits.h -Makefile.our sample_many sample_rand tags diff --git a/BUGS b/BUGS index 4dbbb32..3ec66e9 100644 --- a/BUGS +++ b/BUGS @@ -28,7 +28,7 @@ Click in the triangle to open up the Assets then click on the approptiate package to download. If you made and modifications to calc beyond the simple Makefile -configuration, try backing those changges out and see if things get +configuration, try backing those changes out and see if things get better. If you have tried all of the above and things still are not right, @@ -60,44 +60,7 @@ GitHub web page, click on this button: ((New Issue)) -=-= - -If you prefer to not use GitHub, then you -may send bug and bug fixes reports to: - - calc-bugrept-mail at asthe dot com - - NOTE: Remove spaces and replace 'at' with @, 'dot' with . - - NOTE: This replaces the old calc-bugs at asthe dot com address. - -PLEASE put following the SPECIAL PHRASE somewhere in your Email Subject line: - - calc bug report - -You may add additional words to your subject line. - -Suggestion: - - From time to time, the Email address and Subject SPECIAL PHRASE - may change so verify you have the current info by visiting: - - http://www.isthe.com/chongo/tech/comp/calc/calc-bugrept.html - -IMPORTANT: - - PLEASE use the above SPECIAL PHRASE somewhere in the Subject line or - the mail system won't deliver your Email message. - -Keep in mind that the best way to report on a calc bug is -via the above mentioned calc GitHub issue URL. - -Please be patient as we cannot always respond to Email messages quickly. - -=-= - -When you send your report, via the calc GitHub issue URL or Email, -please include the following information: +Please include the following information in the new issue: * A description of the problem @@ -123,12 +86,13 @@ please include the following information: * If calc dumped core, try to send us a core dump stack trace * cd to the calc source directory, and send the contents - of debug.out produced by this command: + of debug.out.txt produced by this command: - make debug > debug.out 2>&1 + make debug > debug.out.txt 2>&1 -Fell free to use the above address to send in bug fixes (in the form -of a context diff patch). +PLEASE attach the debug.out.txt file to your GitHub issue (bug report)!! + +Please be patient as we cannot always respond to pull requests quickly. =-= @@ -192,9 +156,18 @@ mis-features in calc: will not. + * The numerator is assumed + + The numerator value of 1 appears to be assumed. In calc: + + / 2 + + will produce a value of 0.5 as if the numerator 1 was given. + + =-= -## Copyright (C) 1999-2014,2021 Landon Curt Noll +## Copyright (C) 1999-2014,2021,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 diff --git a/CHANGES b/CHANGES index 0d77919..0400892 100644 --- a/CHANGES +++ b/CHANGES @@ -10,6 +10,70 @@ The following are the changes from calc version 2.14.2.3 to date: Set SHELL in Makefiles to the basename of the shell. + Updated COPYING file to indicate that these files are now + covered under "The Unlicense" (see https://unlicense.org): + + sha1.c + sha1.h + cal/dotest.cal + cal/screen.cal + + Updated help/credit to match the above changes to COPYING. + + Updated CONTRIB-CODE and calc.man to refer to using GitHub pull requests + for contributing to calc (instead of using Email). + + Updated BUGS and calc.man to refer to using GitHub issues + for reporting calc bugs (instead of using Email). + + Updated QUESTIONS and calc.man to refer to using GitHub issues + for asking calc questions (instead of using Email). + + Fixed Makefile.local command example to refer to overriding the + Makefile variable DEBUG (instead of CDEBUG). + + Fixed all make chk ASAN warnings under macOS 13.2.1 when calc is compiled + with the following uncommented lines in Makefile.local: + + DEBUG:= -O0 -g + CFLAGS+= -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined + LDFLAGS+= -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined + CALC_ENV+= ASAN_OPTIONS=detect_stack_use_after_return=1 + + Improved how pointers to functions are declared for the builtins + array in func.c to avoid function declarations without a prototype + that is now deprecated in C. + + Improved how pointers to functions are declared for the opcodes + array in opcodes.c to avoid function declarations without a prototype + + Replaced use of egrep with grep -E in Makefiles. + + Fixed cases where variables were set but not used in symbol.c, calc.c, + and the main function in func.c as used by funclist.c. + + Added rule name to "DO NOT EDIT -- generated by the Makefile" lines + in constructed files. + + Test if exists and set HAVE_SYS_VFS_H accordingly + in have_sys_vfs.h. Added HAVE_SYS_VFS_H to allow one to force + this value. + + Test if exists and set HAVE_SYS_PARAM_H accordingly + in have_sys_param.h. Added HAVE_SYS_PARAM_H to allow one to force + this value. + + Test if exists and set HAVE_SYS_MOUNT_H accordingly + in have_sys_mount.h. Added HAVE_SYS_MOUNT_H to allow one to force + this value. + + Test if the system as the statfs() system call and set HAVE_STATFS + accordingly in have_statfs.h. Added HAVE_STATFS to allow one + to force this value. + + The pseudo_seed() function will also try to call statfs() if + possible and permitted by the HAVE_STATFS value. + The following are the changes from calc version 2.14.2.0 to 2.14.1.2: diff --git a/CONTRIB-CODE b/CONTRIB-CODE index b32edd5..a36e8db 100644 --- a/CONTRIB-CODE +++ b/CONTRIB-CODE @@ -1,73 +1,37 @@ Calc is open source. Contributions of code are welcome. -We welcome and encourage you to send us: +In order to consider integrating your contributions, we need: - * calc resource files (cal/*.cal files) - * calc shell scripts (cscript/*.calc files) - * builtin functions that you have modified or written, i.e.: - assocfunc.c comfunc.c func.c func.h - listfunc.c matfunc.c qfunc.c zfunc.c - * custom functions that you have modified or written - * help files modified or written (help/*) - * Makefile improvements (Makefile, */Makefile) - * other source code modifications (*.c, *.h) - * etc. (* */* :) ) + * your changes applied agsinst the top of the calc master branch: -In order to consider integrating your code, we need: + https://github.com/lcn2/calc/ - * calc version you are working with (please try use the latest version) * new help files or help file patches, if applicable (documentation) - * proposed text for the CHANGES file (brief description of what it does) - * regress.cal test patch as needed - * your source code and/or source code changes (:-)) -If you add functionality to calc, please be sure to modify/patch/add + * Update CHANGES file (brief description of what it does) + + * regress.cal test patch as needed + +If you add functionality to calc, please be sure to modify Makefiles, help files, cal/regress.cal test code as well. Regression test cases are vital to maintaining calc's level of correctness and helps us avoid code bug regression. -Please try to generate a patch against the most recent -version of calc, and if you use GitHub, the top of the -master branch: - - https://github.com/lcn2/calc - The best way contribute to calc bug is to generate calc -GitHub pull request: +GitHub pull request against the calc GitHub repo: https://github.com/lcn2/calc/pulls +Please be patient as we cannot always respond pull requests quickly. + +=-= + +IMPORTANT: + Your code needs to be contributed under either the 2.1 of the GNU -Lesser General Public License (LGPL 2.1) or in the public domain. +Lesser General Public License (LGPL 2.1) or under "The Unlicense": -If you do not want to use calc GitHub, then send Email to: - - calc-contrib-mail at asthe dot com - - NOTE: Remove spaces and replace 'at' with @, 'dot' with . - -You MUST use following SPECIAL PHRASE in your Email Subject line: - - calc contribution - -You may add additional words to your subject line. - -Suggestion: - - From time to time, the Email address and Subject SPECIAL PHRASE - may change so verify you have the current info by visiting: - - http://www.isthe.com/chongo/tech/comp/calc/calc-contrib.html - -IMPORTANT: If your Email doesn't contain the above phrase, - then we WILL NOT SEE your Email. - -PLEASE BE SURE you have that SPECIAL PHRASE somewhere in the subject line! - -Keep in mind that the best way to report on a calc bug is to use -the above mentioned calc GitHub procedure. - -Please be patient as we cannot always respond to Email messages quickly. + https://unlicense.org =-= @@ -77,7 +41,7 @@ See also the calc wishlist by running the calc command: =-= -## Copyright (C) 1999,2014,2021 Landon Curt Noll +## Copyright (C) 1999,2014,2021,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 diff --git a/COPYING b/COPYING index 9a4d7f8..5a6d421 100644 --- a/COPYING +++ b/COPYING @@ -4,9 +4,10 @@ This file is Copyrighted ------------------------ + This file is not covered under version 2.1 of the GNU LGPL. This file is covered under the following Copyright: - Copyright (C) 1999-2022 Landon Curt Noll + Copyright (C) 1999-2023 Landon Curt Noll All rights reserved. Everyone is permitted to copy and distribute verbatim copies @@ -121,11 +122,12 @@ Calc copyrights and exception files Copyright (C) year Petteri Kettunen and Landon Curt Noll Copyright (C) year Christoph Zurnieden Copyright (C) year Landon Curt Noll and Thomas Jones-Low + Copyright (C) year Klaus Alexander Seistrup and Landon Curt Noll These files are not covered under one of the Copyrights listed above: sha1.c sha1.h COPYING - COPYING-LGPL cal/qtime.cal cal/screen.cal + COPYING-LGPL cal/screen.cal The file COPYING-LGPL, which contains a copy of the version 2.1 GNU Lesser General Public License, is itself Copyrighted by the @@ -137,8 +139,16 @@ Calc copyrights and exception files top of this file. It is important to note that you may distribute verbatim copies of this file but you may not modify this file. - Some of these exception files are in the public domain. Other files - are under the LGPL but have different authors that those listed above. + These files are covered under "The Unlicense": + + sha1.c + sha1.h + cal/dotest.cal + cal/screen.cal + + For more information on this license, see: + + https://unlicense.org In all cases one may use and distribute these exception files freely. And because one may freely distribute the LGPL covered files, the diff --git a/Makefile b/Makefile index ad899f7..6f20b8b 100644 --- a/Makefile +++ b/Makefile @@ -490,6 +490,62 @@ HAVE_MEMMOVE= HAVE_USTAT= #HAVE_USTAT= -DHAVE_NO_USTAT +# Determine if we have statfs() +# +# If HAVE_STATFS is empty, this Makefile will run the have_statfs program +# to determine if statfs() is supported. If HAVE_STATFS is set to +# -DHAVE_NO_STATFS, then calc will use internal functions to simulate +# the statfs() function that gets file system statistics. +# +# Select HAVE_STATFS= -DHAVE_NO_STATFS for DJGPP. +# +# If in doubt, leave HAVE_STATFS empty and this Makefile will figure it out. +# +HAVE_STATFS= +#HAVE_STATFS= -DHAVE_NO_STATFS + +# Determine if we have the include file. +# +# HAVE_SYS_VFS_H= let the Makefile look for the include file +# HAVE_SYS_VFS_H= YES assume that the include file exists +# HAVE_SYS_VFS_H= NO assume that the include file does not exist +# +# Select HAVE_SYS_VFS_H= NO for DJGPP. +# +# When in doubt, leave HAVE_SYS_VFS_H empty. +# +HAVE_SYS_VFS_H= +#HAVE_SYS_VFS_H= YES +#HAVE_SYS_VFS_H= NO + +# Determine if we have the include file. +# +# HAVE_SYS_PARAM_H= let the Makefile look for the include file +# HAVE_SYS_PARAM_H= YES assume that the include file exists +# HAVE_SYS_PARAM_H= NO assume that the include file does not exist +# +# Select HAVE_SYS_PARAM_H= NO for DJGPP. +# +# When in doubt, leave HAVE_SYS_PARAM_H empty. +# +HAVE_SYS_PARAM_H= +#HAVE_SYS_PARAM_H= YES +#HAVE_SYS_PARAM_H= NO + +# Determine if we have the include file. +# +# HAVE_SYS_MOUNT_H= let the Makefile look for the include file +# HAVE_SYS_MOUNT_H= YES assume that the include file exists +# HAVE_SYS_MOUNT_H= NO assume that the include file does not exist +# +# Select HAVE_SYS_MOUNT_H= NO for DJGPP. +# +# When in doubt, leave HAVE_SYS_MOUNT_H empty. +# +HAVE_SYS_MOUNT_H= +#HAVE_SYS_MOUNT_H= YES +#HAVE_SYS_MOUNT_H= NO + # Determine if we have getsid() # # If HAVE_GETSID is empty, this Makefile will run the have_getsid program @@ -1332,7 +1388,7 @@ CTAGS= ctags DATE= date DIFF= diff FMT= fmt -GREP= egrep +GREP= grep HOSTNAME= hostname LANG= C LDCONFIG= ldconfig @@ -2086,7 +2142,8 @@ BUILD_H_SRC= align32.h args.h calcerr.h conf.h endian_calc.h \ have_string.h have_strlcat.h have_strlcpy.h have_times.h \ have_uid_t.h have_unistd.h have_unused.h have_urandom.h \ have_ustat.h longbits.h terminal.h have_environ.h \ - have_arc4random.h have_limits.h charbit.h + have_arc4random.h have_limits.h charbit.h have_sys_vfs.h \ + have_sys_param.h have_sys_mount.h have_statfs.h # we build these .c files during the make # @@ -2102,7 +2159,7 @@ UTIL_C_SRC= align32.c endian.c longbits.c have_newstr.c have_uid_t.c \ have_ustat.c have_getsid.c have_getpgid.c have_environ.c \ have_gettime.c have_getprid.c have_rusage.c have_strdup.c \ have_unused.c have_ban_pragma.c have_strlcpy.c have_strlcat.c \ - have_arc4random.c charbit.c + have_arc4random.c charbit.c have_statfs.c # these awk and sed tools are used in the process of building BUILD_H_SRC # and BUILD_C_SRC @@ -2120,7 +2177,7 @@ UTIL_OBJS= endian.o longbits.o have_newstr.o have_uid_t.o \ have_ustat.o have_getsid.o have_getpgid.o have_environ.o \ have_gettime.o have_getprid.o ver_calc.o have_rusage.o have_strdup.o \ have_unused.o have_ban_pragma.o have_strlcpy.o have_strlcat.o \ - have_arc4random.o charbit.o + have_arc4random.o charbit.o have_statfs.o # these temp files may be created (and removed) during the build of BUILD_C_SRC # @@ -2139,7 +2196,7 @@ UTIL_PROGS= align32${EXT} fposval${EXT} have_uid_t${EXT} have_const${EXT} \ have_unused${EXT} have_fpos${EXT} have_fpos_pos${EXT} \ have_offscl${EXT} have_rusage${EXT} have_ban_pragma${EXT} \ have_strlcpy${EXT} have_strlcat${EXT} have_arc4random${EXT} \ - charbit${EXT} + charbit${EXT} have_statfs${ENT} # these utility files and scripts may be created in the process of building # the BUILD_H_SRC file set @@ -2660,7 +2717,7 @@ calc.usage: calc.1 ${MAKE_FILE} ${LOC_MKF} LESSCHARSET=iso8859 ${CALCPAGER} calc.1; \ else \ ${NROFF} -man calc.1; \ - fi 2>&1 | ${GREP} -v 'cannot adjust line' | ${COL} -b > $@ + fi 2>&1 | ${GREP} -E -v 'cannot adjust line' | ${COL} -b > $@ ${Q} echo calc.usage formed @@ -2723,7 +2780,7 @@ conf.h: ${MAKE_FILE} ${LOC_MKF} ${Q} ${RM} -f $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -2808,7 +2865,7 @@ endian_calc.h: endian.c have_stdlib.h have_unistd.h \ ${Q} ${RM} -f endian.o endian${EXT} $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -2860,7 +2917,7 @@ charbit.h: charbit.c have_limits.h \ ${Q} ${RM} -f charbit.o charbit${EXT} $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -2896,7 +2953,7 @@ longbits.h: longbits.c charbit.h have_unistd.h have_stdlib.h \ ${Q} ${RM} -f longbits.o longbits${EXT} $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -2926,7 +2983,7 @@ have_times.h: ${MAKE_FILE} ${LOC_MKF} ${Q} ${RM} -f $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -2992,7 +3049,7 @@ have_stdlib.h: ${MAKE_FILE} ${LOC_MKF} ${Q} ${RM} -f $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3028,7 +3085,7 @@ have_unistd.h: ${MAKE_FILE} ${LOC_MKF} ${Q} ${RM} -f $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3064,7 +3121,7 @@ have_limits.h: ${MAKE_FILE} ${LOC_MKF} ${Q} ${RM} -f $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3100,7 +3157,7 @@ have_string.h: ${MAKE_FILE} ${LOC_MKF} ${Q} ${RM} -f $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3136,7 +3193,7 @@ terminal.h: ${MAKE_FILE} ${LOC_MKF} ${Q} ${RM} -f $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3190,7 +3247,7 @@ have_fgetsetpos.h: have_fgetsetpos.c banned.h have_ban_pragma.h ${MAKE_FILE} ${L ${Q} ${RM} -f fpos_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3233,7 +3290,7 @@ have_fpos_pos.h: have_fpos_pos.c have_fgetsetpos.h have_posscl.h have_string.h \ ${Q} ${RM} -f fpos_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3279,7 +3336,7 @@ fposval.h: fposval.c have_fgetsetpos.h have_fpos_pos.h have_offscl.h have_posscl ${Q} ${RM} -f fposval_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3321,7 +3378,7 @@ have_const.h: have_const.c banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF} ${Q} ${RM} -f have_const const_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3364,7 +3421,7 @@ have_offscl.h: have_offscl.c have_unistd.h \ ${Q} ${RM} -f offscl_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3405,7 +3462,7 @@ have_posscl.h: have_posscl.c have_fgetsetpos.h have_unistd.h \ ${Q} ${RM} -f have_posscl have_posscl.o posscl_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3446,7 +3503,7 @@ align32.h: align32.c longbits.h have_unistd.h \ ${Q} ${RM} -f align32 align32_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3501,7 +3558,7 @@ have_uid_t.h: have_uid_t.c have_unistd.h \ ${Q} ${RM} -f have_uid_t uid_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3542,7 +3599,7 @@ have_environ.h: have_environ.c \ ${Q} ${RM} -f have_environ environ_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3583,7 +3640,7 @@ have_arc4random.h: have_arc4random.c have_stdlib.h \ ${Q} ${RM} -f have_arc4random arc4random_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3624,7 +3681,7 @@ have_newstr.h: have_newstr.c banned.h have_ban_pragma.h have_string.h ${MAKE_FIL ${Q} ${RM} -f newstr_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3664,7 +3721,7 @@ have_memmv.h: have_memmv.c banned.h have_ban_pragma.h have_string.h ${MAKE_FILE} ${Q} ${RM} -f have_memmv have_memmv.o memmv_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3704,7 +3761,7 @@ have_ustat.h: have_ustat.c banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF} ${Q} ${RM} -f ustat_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3739,12 +3796,161 @@ have_ustat.h: have_ustat.c banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF} ${TRUE}; \ fi +have_statfs.h: have_statfs.c banned.h have_ban_pragma.h have_sys_vfs.h have_sys_param.h \ + have_sys_mount.h ${MAKE_FILE} ${LOC_MKF} + ${Q} ${RM} -f statfs_tmp $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_STATFS_H)' >> $@ + ${Q} echo '#define CALC_HAVE_STATFS_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have or want statfs()? */' >> $@ + ${Q} ${RM} -f have_statfs.o have_statfs${EXT} + -${Q} ${LCC} ${ICFLAGS} ${HAVE_STATFS} have_statfs.c -c ${S} \ + || ${TRUE} + -${Q} ${LCC} ${ILDFLAGS} have_statfs.o -o have_statfs ${S} \ + || ${TRUE} + -${Q} ./have_statfs${EXT} > statfs_tmp ${E} \ + || ${TRUE} + -${Q} if [ -s statfs_tmp ]; then \ + ${CAT} statfs_tmp >> $@; \ + else \ + echo '#undef HAVE_STATFS /* no */' >> $@; \ + fi + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_STATFS_H */' >> $@ + ${Q} ${RM} -f have_statfs${EXT} have_statfs.o statfs_tmp + ${H} echo '$@ formed' + -@if [ -z "${Q}" ]; then \ + echo ''; \ + echo '=-=-= start of $@ =-=-='; \ + ${CAT} $@; \ + echo '=-=-= end of $@ =-=-='; \ + echo ''; \ + else \ + ${TRUE}; \ + fi + +have_sys_vfs.h: ${MAKE_FILE} ${LOC_MKF} + ${Q} ${RM} -f $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_SYS_VFS_H)' >> $@ + ${Q} echo '#define CALC_HAVE_SYS_VFS_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have ? */' >> $@ + -${Q} if [ X"${HAVE_SYS_VFS_H}" = X"YES" ]; then \ + echo '#define HAVE_SYS_VFS_H /* yes */' >> $@; \ + elif [ X"${HAVE_SYS_VFS_H}" = X"NO" ]; then \ + echo '#undef HAVE_SYS_VFS_H /* no */' >> $@; \ + elif echo '#include ' | ${CC} -E - ${S}; then \ + echo '#define HAVE_SYS_VFS_H /* yes */' >> $@; \ + else \ + echo '#undef HAVE_SYS_VFS_H /* no */' >> $@; \ + fi + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_SYS_VFS_H */' >> $@ + ${H} echo '$@ formed' + -@if [ -z "${Q}" ]; then \ + echo ''; \ + echo '=-=-= start of $@ =-=-='; \ + ${CAT} $@; \ + echo '=-=-= end of $@ =-=-='; \ + echo ''; \ + else \ + ${TRUE}; \ + fi + +have_sys_param.h: ${MAKE_FILE} ${LOC_MKF} + ${Q} ${RM} -f $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_SYS_PARAM_H)' >> $@ + ${Q} echo '#define CALC_HAVE_SYS_PARAM_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have ? */' >> $@ + -${Q} if [ X"${HAVE_SYS_PARAM_H}" = X"YES" ]; then \ + echo '#define HAVE_SYS_PARAM_H /* yes */' >> $@; \ + elif [ X"${HAVE_SYS_PARAM_H}" = X"NO" ]; then \ + echo '#undef HAVE_SYS_PARAM_H /* no */' >> $@; \ + elif echo '#include ' | ${CC} -E - ${S}; then \ + echo '#define HAVE_SYS_PARAM_H /* yes */' >> $@; \ + else \ + echo '#undef HAVE_SYS_PARAM_H /* no */' >> $@; \ + fi + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_SYS_PARAM_H */' >> $@ + ${H} echo '$@ formed' + -@if [ -z "${Q}" ]; then \ + echo ''; \ + echo '=-=-= start of $@ =-=-='; \ + ${CAT} $@; \ + echo '=-=-= end of $@ =-=-='; \ + echo ''; \ + else \ + ${TRUE}; \ + fi + +have_sys_mount.h: ${MAKE_FILE} ${LOC_MKF} + ${Q} ${RM} -f $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_SYS_MOUNT_H)' >> $@ + ${Q} echo '#define CALC_HAVE_SYS_MOUNT_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have ? */' >> $@ + -${Q} if [ X"${HAVE_SYS_MOUNT_H}" = X"YES" ]; then \ + 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 ' | ${CC} -E - ${S}; then \ + echo '#define HAVE_SYS_MOUNT_H /* yes */' >> $@; \ + else \ + echo '#undef HAVE_SYS_MOUNT_H /* no */' >> $@; \ + fi + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_SYS_MOUNT_H */' >> $@ + ${H} echo '$@ formed' + -@if [ -z "${Q}" ]; then \ + echo ''; \ + echo '=-=-= start of $@ =-=-='; \ + ${CAT} $@; \ + echo '=-=-= end of $@ =-=-='; \ + echo ''; \ + else \ + ${TRUE}; \ + fi + have_getsid.h: have_getsid.c have_unistd.h \ banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF} ${Q} ${RM} -f getsid_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3785,7 +3991,7 @@ have_getpgid.h: have_getpgid.c have_unistd.h \ ${Q} ${RM} -f getpgid_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3826,7 +4032,7 @@ have_gettime.h: have_gettime.c banned.h have_ban_pragma.h \ ${Q} ${RM} -f gettime_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3867,7 +4073,7 @@ have_getprid.h: have_getprid.c have_unistd.h \ ${Q} ${RM} -f getprid_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3907,7 +4113,7 @@ have_urandom.h: ${MAKE_FILE} ${LOC_MKF} ${Q} ${RM} -f $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3943,7 +4149,7 @@ have_rusage.h: have_rusage.c banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF} ${Q} ${RM} -f rusage_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3983,7 +4189,7 @@ have_strdup.h: have_strdup.c banned.h have_ban_pragma.h have_string.h ${MAKE_FIL ${Q} ${RM} -f strdup_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -4024,7 +4230,7 @@ args.h: have_stdvs.c have_varvs.c have_string.h have_unistd.h \ ${Q} ${RM} -f $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -4137,7 +4343,7 @@ have_unused.h: have_unused.c have_stdlib.h have_ban_pragma.h \ ${Q} ${RM} -f unused_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -4179,7 +4385,7 @@ have_ban_pragma.h: have_ban_pragma.c banned.h ${MAKE_FILE} ${LOC_MKF} ${Q} ${RM} -f unused_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -4222,7 +4428,7 @@ have_strlcpy.h: have_strlcpy.c banned.h have_ban_pragma.h have_string.h \ ${Q} ${RM} -f unused_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -4264,7 +4470,7 @@ have_strlcat.h: have_strlcat.c banned.h have_ban_pragma.h have_string.h \ ${Q} ${RM} -f unused_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -4480,7 +4686,7 @@ depend: hsrc custom/Makefile ${Q} ${MKDIR} -p skel -${Q} for i in ${C_SRC} ${BUILD_C_SRC}; do \ ${SED} -n '/^#[ ]*include[ ]*"/p' "$$i" | \ - ${GREP} -v '\.\./getopt/getopt\.h' > "skel/$$i"; \ + ${GREP} -E -v '\.\./getopt/getopt\.h' > "skel/$$i"; \ done ${Q} ${MKDIR} -p skel/custom -${Q} for i in ${H_SRC} ${BUILD_H_SRC} custom.h /dev/null; do \ @@ -4524,7 +4730,7 @@ depend: hsrc custom/Makefile ${Q} ${MV} ${MAKE_FILE} ${MAKE_FILE}.bak ${Q} ${SED} -n '1,/^# DO NOT DELETE THIS LINE/p' \ ${MAKE_FILE}.bak > ${MAKE_FILE} - ${Q} ${GREP} -v '^#' skel/makedep.out >> ${MAKE_FILE} + ${Q} ${GREP} -E -v '^#' skel/makedep.out >> ${MAKE_FILE} ${Q} echo removing top level skel ${Q} ${RM} -rf skel -${Q} if ${CMP} -s ${MAKE_FILE}.bak ${MAKE_FILE}; then \ @@ -4848,13 +5054,17 @@ env: @echo 'HAVE_OFFSCL=${HAVE_OFFSCL}'; echo '' @echo 'HAVE_POSSCL=${HAVE_POSSCL}'; echo '' @echo 'HAVE_PRAGMA_GCC_POSION=${HAVE_PRAGMA_GCC_POSION}'; echo '' + @echo 'HAVE_STATFS=${HAVE_STATFS}'; echo '' @echo 'HAVE_STDLIB_H=${HAVE_STDLIB_H}'; echo '' @echo 'HAVE_STRDUP=${HAVE_STRDUP}'; echo '' @echo 'HAVE_STRING_H=${HAVE_STRING_H}'; echo '' @echo 'HAVE_STRLCAT=${HAVE_STRLCAT}'; echo '' @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_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_UID_T=${HAVE_UID_T}'; echo '' @@ -4894,18 +5104,18 @@ env: @echo 'MANEXT=${MANEXT}'; echo '' @echo 'MANMAKE=${MANMAKE}'; echo '' @echo 'MANMODE=${MANMODE}'; echo '' - @echo 'MKDIR=${MKDIR}'; echo '' @echo 'MINGW=${MINGW}'; echo '' + @echo 'MKDIR=${MKDIR}'; 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 'PREFIX=${PREFIX}'; echo '' @echo 'PURIFY=${PURIFY}'; echo '' @echo 'PWD=${PWD}'; echo '' @echo 'PWDCMD=${PWDCMD}'; echo '' @echo 'Q=${Q}'; echo '' - @echo 'PREFIX=${PREFIX}'; echo '' @echo 'RANLIB=${RANLIB}'; echo '' @echo 'READLINE_EXTRAS=${READLINE_EXTRAS}'; echo '' @echo 'READLINE_INCLUDE=${READLINE_INCLUDE}'; echo '' @@ -5096,16 +5306,16 @@ inst_files: ${MAKE_FILE} ${LOC_MKF} help/Makefile cal/Makefile \ ${Q} echo ${BINDIR}/calc${EXT} > inst_files ${Q} cd help; LANG=C \ ${MAKE} -f Makefile ${HELP_PASSDOWN} echo_inst_files | \ - ${GREP} '__file__..' | ${SED} -e s'/.*__file__ //' >> ../inst_files + ${GREP} -E '__file__..' | ${SED} -e s'/.*__file__ //' >> ../inst_files ${Q} cd cal; LANG=C \ ${MAKE} -f Makefile ${CAL_PASSDOWN} echo_inst_files | \ - ${GREP} '__file__..' | ${SED} -e s'/.*__file__ //' >> ../inst_files + ${GREP} -E '__file__..' | ${SED} -e s'/.*__file__ //' >> ../inst_files ${Q} cd custom; LANG=C \ ${MAKE} -f Makefile ${CUSTOM_PASSDOWN} echo_inst_files | \ - ${GREP} '__file__..' | ${SED} -e s'/.*__file__ //' >> ../inst_files + ${GREP} -E '__file__..' | ${SED} -e s'/.*__file__ //' >> ../inst_files ${Q} cd cscript; LANG=C \ ${MAKE} -f Makefile ${CSCRIPT_PASSDOWN} echo_inst_files | \ - ${GREP} '__file__..' | ${SED} -e s'/.*__file__ //' >> ../inst_files + ${GREP} -E '__file__..' | ${SED} -e s'/.*__file__ //' >> ../inst_files ${Q} echo ${LIBDIR}/libcalc.a >> inst_files ${Q} for i in ${LIB_H_SRC} ${BUILD_H_SRC} /dev/null; do \ if [ X"$$i" != X"/dev/null" ]; then \ @@ -5157,7 +5367,7 @@ olduninstall: tags: ${CALCSRC} ${LIBSRC} ${H_SRC} ${BUILD_H_SRC} ${MAKE_FILE} -${CTAGS} ${CALCSRC} ${LIBSRC} ${H_SRC} ${BUILD_H_SRC} 2>&1 | \ - ${GREP} -v 'Duplicate entry|Second entry ignored' + ${GREP} -E -v 'Duplicate entry|Second entry ignored' clean: ${V} echo '=-=-=-=-= ${MAKE_FILE} start of $@ rule =-=-=-=-=' diff --git a/Makefile.local b/Makefile.local index 281f417..01281cf 100644 --- a/Makefile.local +++ b/Makefile.local @@ -25,16 +25,16 @@ # For example, a AddressSanitizer. You do NOT want to do this by # by default! Do this only if you are debugging with libasan: # -# For Linux gcc version 4.8.5 with libasan-4.8.5-4 you might try: +# For Linux gcc version 11.3.1 with libasan-11.3.1-2.1 you might try: # -# CDEBUG:= -O0 -g +# DEBUG:= -O0 -g # CFLAGS+= -fsanitize=address -fno-omit-frame-pointer # LDFLAGS+= -fsanitize=address -fno-omit-frame-pointer # CALC_ENV+= ASAN_OPTIONS=detect_stack_use_after_return=1 # -# For macOS 12.1 with clang version 13.0.0 (clang-1300.0.29.30) you might try: +# For macOS 13.2.1 with clang version 14.0.0 (clang-1400.0.29.202) you might try: # -# CDEBUG:= -O0 -g +# DEBUG:= -O0 -g # CFLAGS+= -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined # LDFLAGS+= -fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined # CALC_ENV+= ASAN_OPTIONS=detect_stack_use_after_return=1 diff --git a/Makefile.simple b/Makefile.simple index ef55f76..a9dc525 100644 --- a/Makefile.simple +++ b/Makefile.simple @@ -446,6 +446,62 @@ HAVE_MEMMOVE= HAVE_USTAT= #HAVE_USTAT= -DHAVE_NO_USTAT +# Determine if we have statfs() +# +# If HAVE_STATFS is empty, this Makefile will run the have_statfs program +# to determine if statfs() is supported. If HAVE_STATFS is set to +# -DHAVE_NO_STATFS, then calc will use internal functions to simulate +# the statfs() function that gets file system statistics. +# +# Select HAVE_STATFS= -DHAVE_NO_STATFS for DJGPP. +# +# If in doubt, leave HAVE_STATFS empty and this Makefile will figure it out. +# +HAVE_STATFS= +#HAVE_STATFS= -DHAVE_NO_STATFS + +# Determine if we have the include file. +# +# HAVE_SYS_VFS_H= let the Makefile look for the include file +# HAVE_SYS_VFS_H= YES assume that the include file exists +# HAVE_SYS_VFS_H= NO assume that the include file does not exist +# +# Select HAVE_SYS_VFS_H= NO for DJGPP. +# +# When in doubt, leave HAVE_SYS_VFS_H empty. +# +HAVE_SYS_VFS_H= +#HAVE_SYS_VFS_H= YES +#HAVE_SYS_VFS_H= NO + +# Determine if we have the include file. +# +# HAVE_SYS_PARAM_H= let the Makefile look for the include file +# HAVE_SYS_PARAM_H= YES assume that the include file exists +# HAVE_SYS_PARAM_H= NO assume that the include file does not exist +# +# Select HAVE_SYS_PARAM_H= NO for DJGPP. +# +# When in doubt, leave HAVE_SYS_PARAM_H empty. +# +HAVE_SYS_PARAM_H= +#HAVE_SYS_PARAM_H= YES +#HAVE_SYS_PARAM_H= NO + +# Determine if we have the include file. +# +# HAVE_SYS_MOUNT_H= let the Makefile look for the include file +# HAVE_SYS_MOUNT_H= YES assume that the include file exists +# HAVE_SYS_MOUNT_H= NO assume that the include file does not exist +# +# Select HAVE_SYS_MOUNT_H= NO for DJGPP. +# +# When in doubt, leave HAVE_SYS_MOUNT_H empty. +# +HAVE_SYS_MOUNT_H= +#HAVE_SYS_MOUNT_H= YES +#HAVE_SYS_MOUNT_H= NO + # Determine if we have getsid() # # If HAVE_GETSID is empty, this Makefile will run the have_getsid program @@ -1190,7 +1246,7 @@ CTAGS= ctags DATE= date DIFF= diff FMT= fmt -GREP= egrep +GREP= grep HOSTNAME= hostname LANG= C LDCONFIG= ldconfig @@ -1509,7 +1565,8 @@ BUILD_H_SRC= align32.h args.h calcerr.h conf.h endian_calc.h \ have_string.h have_strlcat.h have_strlcpy.h have_times.h \ have_uid_t.h have_unistd.h have_unused.h have_urandom.h \ have_ustat.h longbits.h terminal.h have_environ.h \ - have_arc4random.h have_limits.h charbit.h + have_arc4random.h have_limits.h charbit.h have_sys_vfs.h \ + have_sys_param.h have_sys_mount.h have_statfs.h # we build these .c files during the make # @@ -1525,7 +1582,7 @@ UTIL_C_SRC= align32.c endian.c longbits.c have_newstr.c have_uid_t.c \ have_ustat.c have_getsid.c have_getpgid.c have_environ.c \ have_gettime.c have_getprid.c have_rusage.c have_strdup.c \ have_unused.c have_ban_pragma.c have_strlcpy.c have_strlcat.c \ - have_arc4random.c charbit.c + have_arc4random.c charbit.c have_statfs.c # these awk and sed tools are used in the process of building BUILD_H_SRC # and BUILD_C_SRC @@ -1543,7 +1600,7 @@ UTIL_OBJS= endian.o longbits.o have_newstr.o have_uid_t.o \ have_ustat.o have_getsid.o have_getpgid.o have_environ.o \ have_gettime.o have_getprid.o ver_calc.o have_rusage.o have_strdup.o \ have_unused.o have_ban_pragma.o have_strlcpy.o have_strlcat.o \ - have_arc4random.o charbit.o + have_arc4random.o charbit.o have_statfs.o # these temp files may be created (and removed) during the build of BUILD_C_SRC # @@ -1562,7 +1619,7 @@ UTIL_PROGS= align32${EXT} fposval${EXT} have_uid_t${EXT} have_const${EXT} \ have_unused${EXT} have_fpos${EXT} have_fpos_pos${EXT} \ have_offscl${EXT} have_rusage${EXT} have_ban_pragma${EXT} \ have_strlcpy${EXT} have_strlcat${EXT} have_arc4random${EXT} \ - charbit${EXT} + charbit${EXT} have_statfs${ENT} # these utility files and scripts may be created in the process of building # the BUILD_H_SRC file set @@ -2024,7 +2081,7 @@ calc.usage: calc.1 ${MAKE_FILE} ${LOC_MKF} LESSCHARSET=iso8859 ${CALCPAGER} calc.1; \ else \ ${NROFF} -man calc.1; \ - fi 2>&1 | ${GREP} -v 'cannot adjust line' | ${COL} -b > $@ + fi 2>&1 | ${GREP} -E -v 'cannot adjust line' | ${COL} -b > $@ ${Q} echo calc.usage formed @@ -2087,7 +2144,7 @@ conf.h: ${MAKE_FILE} ${LOC_MKF} ${Q} ${RM} -f $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -2138,7 +2195,7 @@ endian_calc.h: endian.c have_stdlib.h have_unistd.h \ ${Q} ${RM} -f endian.o endian${EXT} $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -2190,7 +2247,7 @@ charbit.h: charbit.c have_limits.h \ ${Q} ${RM} -f charbit.o charbit${EXT} $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -2226,7 +2283,7 @@ longbits.h: longbits.c charbit.h have_unistd.h have_stdlib.h \ ${Q} ${RM} -f longbits.o longbits${EXT} $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -2256,7 +2313,7 @@ have_times.h: ${MAKE_FILE} ${LOC_MKF} ${Q} ${RM} -f $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -2322,7 +2379,7 @@ have_stdlib.h: ${MAKE_FILE} ${LOC_MKF} ${Q} ${RM} -f $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -2358,7 +2415,7 @@ have_unistd.h: ${MAKE_FILE} ${LOC_MKF} ${Q} ${RM} -f $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -2394,7 +2451,7 @@ have_limits.h: ${MAKE_FILE} ${LOC_MKF} ${Q} ${RM} -f $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -2430,7 +2487,7 @@ have_string.h: ${MAKE_FILE} ${LOC_MKF} ${Q} ${RM} -f $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -2466,7 +2523,7 @@ terminal.h: ${MAKE_FILE} ${LOC_MKF} ${Q} ${RM} -f $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -2520,7 +2577,7 @@ have_fgetsetpos.h: have_fgetsetpos.c banned.h have_ban_pragma.h ${MAKE_FILE} ${L ${Q} ${RM} -f fpos_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -2563,7 +2620,7 @@ have_fpos_pos.h: have_fpos_pos.c have_fgetsetpos.h have_posscl.h have_string.h \ ${Q} ${RM} -f fpos_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -2609,7 +2666,7 @@ fposval.h: fposval.c have_fgetsetpos.h have_fpos_pos.h have_offscl.h have_posscl ${Q} ${RM} -f fposval_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -2651,7 +2708,7 @@ have_const.h: have_const.c banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF} ${Q} ${RM} -f have_const const_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -2694,7 +2751,7 @@ have_offscl.h: have_offscl.c have_unistd.h \ ${Q} ${RM} -f offscl_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -2735,7 +2792,7 @@ have_posscl.h: have_posscl.c have_fgetsetpos.h have_unistd.h \ ${Q} ${RM} -f have_posscl have_posscl.o posscl_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -2776,7 +2833,7 @@ align32.h: align32.c longbits.h have_unistd.h \ ${Q} ${RM} -f align32 align32_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -2831,7 +2888,7 @@ have_uid_t.h: have_uid_t.c have_unistd.h \ ${Q} ${RM} -f have_uid_t uid_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -2872,7 +2929,7 @@ have_environ.h: have_environ.c \ ${Q} ${RM} -f have_environ environ_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -2913,7 +2970,7 @@ have_arc4random.h: have_arc4random.c have_stdlib.h \ ${Q} ${RM} -f have_arc4random arc4random_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -2954,7 +3011,7 @@ have_newstr.h: have_newstr.c banned.h have_ban_pragma.h have_string.h ${MAKE_FIL ${Q} ${RM} -f newstr_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -2994,7 +3051,7 @@ have_memmv.h: have_memmv.c banned.h have_ban_pragma.h have_string.h ${MAKE_FILE} ${Q} ${RM} -f have_memmv have_memmv.o memmv_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3034,7 +3091,7 @@ have_ustat.h: have_ustat.c banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF} ${Q} ${RM} -f ustat_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3069,12 +3126,161 @@ have_ustat.h: have_ustat.c banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF} ${TRUE}; \ fi +have_statfs.h: have_statfs.c banned.h have_ban_pragma.h have_sys_vfs.h have_sys_param.h \ + have_sys_mount.h ${MAKE_FILE} ${LOC_MKF} + ${Q} ${RM} -f statfs_tmp $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_STATFS_H)' >> $@ + ${Q} echo '#define CALC_HAVE_STATFS_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have or want statfs()? */' >> $@ + ${Q} ${RM} -f have_statfs.o have_statfs${EXT} + -${Q} ${LCC} ${ICFLAGS} ${HAVE_STATFS} have_statfs.c -c ${S} \ + || ${TRUE} + -${Q} ${LCC} ${ILDFLAGS} have_statfs.o -o have_statfs ${S} \ + || ${TRUE} + -${Q} ./have_statfs${EXT} > statfs_tmp ${E} \ + || ${TRUE} + -${Q} if [ -s statfs_tmp ]; then \ + ${CAT} statfs_tmp >> $@; \ + else \ + echo '#undef HAVE_STATFS /* no */' >> $@; \ + fi + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_STATFS_H */' >> $@ + ${Q} ${RM} -f have_statfs${EXT} have_statfs.o statfs_tmp + ${H} echo '$@ formed' + -@if [ -z "${Q}" ]; then \ + echo ''; \ + echo '=-=-= start of $@ =-=-='; \ + ${CAT} $@; \ + echo '=-=-= end of $@ =-=-='; \ + echo ''; \ + else \ + ${TRUE}; \ + fi + +have_sys_vfs.h: ${MAKE_FILE} ${LOC_MKF} + ${Q} ${RM} -f $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_SYS_VFS_H)' >> $@ + ${Q} echo '#define CALC_HAVE_SYS_VFS_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have ? */' >> $@ + -${Q} if [ X"${HAVE_SYS_VFS_H}" = X"YES" ]; then \ + echo '#define HAVE_SYS_VFS_H /* yes */' >> $@; \ + elif [ X"${HAVE_SYS_VFS_H}" = X"NO" ]; then \ + echo '#undef HAVE_SYS_VFS_H /* no */' >> $@; \ + elif echo '#include ' | ${CC} -E - ${S}; then \ + echo '#define HAVE_SYS_VFS_H /* yes */' >> $@; \ + else \ + echo '#undef HAVE_SYS_VFS_H /* no */' >> $@; \ + fi + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_SYS_VFS_H */' >> $@ + ${H} echo '$@ formed' + -@if [ -z "${Q}" ]; then \ + echo ''; \ + echo '=-=-= start of $@ =-=-='; \ + ${CAT} $@; \ + echo '=-=-= end of $@ =-=-='; \ + echo ''; \ + else \ + ${TRUE}; \ + fi + +have_sys_param.h: ${MAKE_FILE} ${LOC_MKF} + ${Q} ${RM} -f $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_SYS_PARAM_H)' >> $@ + ${Q} echo '#define CALC_HAVE_SYS_PARAM_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have ? */' >> $@ + -${Q} if [ X"${HAVE_SYS_PARAM_H}" = X"YES" ]; then \ + echo '#define HAVE_SYS_PARAM_H /* yes */' >> $@; \ + elif [ X"${HAVE_SYS_PARAM_H}" = X"NO" ]; then \ + echo '#undef HAVE_SYS_PARAM_H /* no */' >> $@; \ + elif echo '#include ' | ${CC} -E - ${S}; then \ + echo '#define HAVE_SYS_PARAM_H /* yes */' >> $@; \ + else \ + echo '#undef HAVE_SYS_PARAM_H /* no */' >> $@; \ + fi + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_SYS_PARAM_H */' >> $@ + ${H} echo '$@ formed' + -@if [ -z "${Q}" ]; then \ + echo ''; \ + echo '=-=-= start of $@ =-=-='; \ + ${CAT} $@; \ + echo '=-=-= end of $@ =-=-='; \ + echo ''; \ + else \ + ${TRUE}; \ + fi + +have_sys_mount.h: ${MAKE_FILE} ${LOC_MKF} + ${Q} ${RM} -f $@ + ${H} echo 'forming $@' + ${Q} echo '/*' > $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ + ${Q} echo ' */' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#if !defined(CALC_HAVE_SYS_MOUNT_H)' >> $@ + ${Q} echo '#define CALC_HAVE_SYS_MOUNT_H' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '/* do we have ? */' >> $@ + -${Q} if [ X"${HAVE_SYS_MOUNT_H}" = X"YES" ]; then \ + 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 ' | ${CC} -E - ${S}; then \ + echo '#define HAVE_SYS_MOUNT_H /* yes */' >> $@; \ + else \ + echo '#undef HAVE_SYS_MOUNT_H /* no */' >> $@; \ + fi + ${Q} echo '' >> $@ + ${Q} echo '' >> $@ + ${Q} echo '#endif /* !CALC_HAVE_SYS_MOUNT_H */' >> $@ + ${H} echo '$@ formed' + -@if [ -z "${Q}" ]; then \ + echo ''; \ + echo '=-=-= start of $@ =-=-='; \ + ${CAT} $@; \ + echo '=-=-= end of $@ =-=-='; \ + echo ''; \ + else \ + ${TRUE}; \ + fi + have_getsid.h: have_getsid.c have_unistd.h \ banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF} ${Q} ${RM} -f getsid_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3115,7 +3321,7 @@ have_getpgid.h: have_getpgid.c have_unistd.h \ ${Q} ${RM} -f getpgid_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3156,7 +3362,7 @@ have_gettime.h: have_gettime.c banned.h have_ban_pragma.h \ ${Q} ${RM} -f gettime_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3197,7 +3403,7 @@ have_getprid.h: have_getprid.c have_unistd.h \ ${Q} ${RM} -f getprid_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3237,7 +3443,7 @@ have_urandom.h: ${MAKE_FILE} ${LOC_MKF} ${Q} ${RM} -f $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3273,7 +3479,7 @@ have_rusage.h: have_rusage.c banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF} ${Q} ${RM} -f rusage_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3313,7 +3519,7 @@ have_strdup.h: have_strdup.c banned.h have_ban_pragma.h have_string.h ${MAKE_FIL ${Q} ${RM} -f strdup_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3354,7 +3560,7 @@ args.h: have_stdvs.c have_varvs.c have_string.h have_unistd.h \ ${Q} ${RM} -f $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3467,7 +3673,7 @@ have_unused.h: have_unused.c have_stdlib.h have_ban_pragma.h \ ${Q} ${RM} -f unused_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3509,7 +3715,7 @@ have_ban_pragma.h: have_ban_pragma.c banned.h ${MAKE_FILE} ${LOC_MKF} ${Q} ${RM} -f unused_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3552,7 +3758,7 @@ have_strlcpy.h: have_strlcpy.c banned.h have_ban_pragma.h have_string.h \ ${Q} ${RM} -f unused_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3594,7 +3800,7 @@ have_strlcat.h: have_strlcat.c banned.h have_ban_pragma.h have_string.h \ ${Q} ${RM} -f unused_tmp $@ ${H} echo 'forming $@' ${Q} echo '/*' > $@ - ${Q} echo ' * DO NOT EDIT -- generated by the Makefile' >> $@ + ${Q} echo ' * DO NOT EDIT -- generated by the Makefile rule $@' >> $@ ${Q} echo ' */' >> $@ ${Q} echo '' >> $@ ${Q} echo '' >> $@ @@ -3790,7 +3996,7 @@ depend: hsrc custom/Makefile ${Q} ${MKDIR} -p skel -${Q} for i in ${C_SRC} ${BUILD_C_SRC}; do \ ${SED} -n '/^#[ ]*include[ ]*"/p' "$$i" | \ - ${GREP} -v '\.\./getopt/getopt\.h' > "skel/$$i"; \ + ${GREP} -E -v '\.\./getopt/getopt\.h' > "skel/$$i"; \ done ${Q} ${MKDIR} -p skel/custom -${Q} for i in ${H_SRC} ${BUILD_H_SRC} custom.h /dev/null; do \ @@ -3834,7 +4040,7 @@ depend: hsrc custom/Makefile ${Q} ${MV} ${MAKE_FILE} ${MAKE_FILE}.bak ${Q} ${SED} -n '1,/^# DO NOT DELETE THIS LINE/p' \ ${MAKE_FILE}.bak > ${MAKE_FILE} - ${Q} ${GREP} -v '^#' skel/makedep.out >> ${MAKE_FILE} + ${Q} ${GREP} -E -v '^#' skel/makedep.out >> ${MAKE_FILE} ${Q} echo removing top level skel ${Q} ${RM} -rf skel -${Q} if ${CMP} -s ${MAKE_FILE}.bak ${MAKE_FILE}; then \ @@ -4152,13 +4358,17 @@ env: @echo 'HAVE_OFFSCL=${HAVE_OFFSCL}'; echo '' @echo 'HAVE_POSSCL=${HAVE_POSSCL}'; echo '' @echo 'HAVE_PRAGMA_GCC_POSION=${HAVE_PRAGMA_GCC_POSION}'; echo '' + @echo 'HAVE_STATFS=${HAVE_STATFS}'; echo '' @echo 'HAVE_STDLIB_H=${HAVE_STDLIB_H}'; echo '' @echo 'HAVE_STRDUP=${HAVE_STRDUP}'; echo '' @echo 'HAVE_STRING_H=${HAVE_STRING_H}'; echo '' @echo 'HAVE_STRLCAT=${HAVE_STRLCAT}'; echo '' @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_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_UID_T=${HAVE_UID_T}'; echo '' @@ -4198,18 +4408,18 @@ env: @echo 'MANEXT=${MANEXT}'; echo '' @echo 'MANMAKE=${MANMAKE}'; echo '' @echo 'MANMODE=${MANMODE}'; echo '' - @echo 'MKDIR=${MKDIR}'; echo '' @echo 'MINGW=${MINGW}'; echo '' + @echo 'MKDIR=${MKDIR}'; 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 'PREFIX=${PREFIX}'; echo '' @echo 'PURIFY=${PURIFY}'; echo '' @echo 'PWD=${PWD}'; echo '' @echo 'PWDCMD=${PWDCMD}'; echo '' @echo 'Q=${Q}'; echo '' - @echo 'PREFIX=${PREFIX}'; echo '' @echo 'RANLIB=${RANLIB}'; echo '' @echo 'READLINE_EXTRAS=${READLINE_EXTRAS}'; echo '' @echo 'READLINE_INCLUDE=${READLINE_INCLUDE}'; echo '' @@ -4400,16 +4610,16 @@ inst_files: ${MAKE_FILE} ${LOC_MKF} help/Makefile cal/Makefile \ ${Q} echo ${BINDIR}/calc${EXT} > inst_files ${Q} cd help; LANG=C \ ${MAKE} -f Makefile ${HELP_PASSDOWN} echo_inst_files | \ - ${GREP} '__file__..' | ${SED} -e s'/.*__file__ //' >> ../inst_files + ${GREP} -E '__file__..' | ${SED} -e s'/.*__file__ //' >> ../inst_files ${Q} cd cal; LANG=C \ ${MAKE} -f Makefile ${CAL_PASSDOWN} echo_inst_files | \ - ${GREP} '__file__..' | ${SED} -e s'/.*__file__ //' >> ../inst_files + ${GREP} -E '__file__..' | ${SED} -e s'/.*__file__ //' >> ../inst_files ${Q} cd custom; LANG=C \ ${MAKE} -f Makefile ${CUSTOM_PASSDOWN} echo_inst_files | \ - ${GREP} '__file__..' | ${SED} -e s'/.*__file__ //' >> ../inst_files + ${GREP} -E '__file__..' | ${SED} -e s'/.*__file__ //' >> ../inst_files ${Q} cd cscript; LANG=C \ ${MAKE} -f Makefile ${CSCRIPT_PASSDOWN} echo_inst_files | \ - ${GREP} '__file__..' | ${SED} -e s'/.*__file__ //' >> ../inst_files + ${GREP} -E '__file__..' | ${SED} -e s'/.*__file__ //' >> ../inst_files ${Q} echo ${LIBDIR}/libcalc.a >> inst_files ${Q} for i in ${LIB_H_SRC} ${BUILD_H_SRC} /dev/null; do \ if [ X"$$i" != X"/dev/null" ]; then \ @@ -4461,7 +4671,7 @@ olduninstall: tags: ${CALCSRC} ${LIBSRC} ${H_SRC} ${BUILD_H_SRC} ${MAKE_FILE} -${CTAGS} ${CALCSRC} ${LIBSRC} ${H_SRC} ${BUILD_H_SRC} 2>&1 | \ - ${GREP} -v 'Duplicate entry|Second entry ignored' + ${GREP} -E -v 'Duplicate entry|Second entry ignored' clean: ${V} echo '=-=-=-=-= ${MAKE_FILE} start of $@ rule =-=-=-=-=' diff --git a/QUESTIONS b/QUESTIONS index 2d160f9..0aceb32 100644 --- a/QUESTIONS +++ b/QUESTIONS @@ -1,37 +1,28 @@ -If you have a simple general question about calc, send Email to: +If you have a general question about calc, consider opening +a new Github discussion under: - calc-quest-mail at asthe dot com + https://github.com/lcn2/calc/discussions - NOTE: Remove spaces and replace 'at' with @, and 'dot' with . +Look over the existing discussions to see of your question fits +under one of those exiting discussions. -PLEASE put following the SPECIAL PHRASE somewhere in your Email Subject line: +You may wish to add your question as a comment to an existing discussion. +Otherwise click on: - calc question + ((New discussion)) -You may add additional words to your subject line. - -IMPORTANT: If your Email doesn't contain the above phrase, - then we WILL NOT SEE your Email. - -PLEASE BE SURE you have that SPECIAL PHRASE somewhere in the subject line! - -Suggestion: - - From time to time, the Email address and Subject SPECIAL PHRASE - may change so verify you have the current info by visiting: - - http://www.isthe.com/chongo/tech/comp/calc/calc-question.html +and ask your question in that new discussion. Please limit your questions to general questions about calc. We cannot go into great detail in our answers, nor can we do your -homework, nor can we do much more than answer short general questions +homework, nor can we do much more than answer general questions about calc. -Please be patient as we cannot always respond to Email messages quickly. +Please be patient as we cannot always respond to discussion messages quickly. =-= -## Copyright (C) 2021 Landon Curt Noll +## Copyright (C) 2021,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 diff --git a/cal/dotest.cal b/cal/dotest.cal index 523ef98..831a81c 100644 --- a/cal/dotest.cal +++ b/cal/dotest.cal @@ -4,19 +4,37 @@ * This file was created by Ernest Bowen * and modified by Landon Curt Noll. * - * This dotest_code has been placed in the public domain. Please do not - * copyright this dotest_code. - * - * ERNEST BOWEN AND LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER- - * CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT - * NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF - * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, - * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * * This file is not covered under version 2.1 of the GNU LGPL. + * This file is covered under "The unlicense": + * + * https://unlicense.org + * + * In particular: + * + * This is free and unencumbered software released into the public domain. + * + * Anyone is free to copy, modify, publish, use, compile, sell, or + * distribute this software, either in source code form or as a compiled + * binary, for any purpose, commercial or non-commercial, and by any + * means. + * + * In jurisdictions that recognize copyright laws, the author or authors + * of this software dedicate any and all copyright interest in the + * software to the public domain. We make this dedication for the benefit + * of the public at large and to the detriment of our heirs and + * successors. We intend this dedication to be an overt act of + * relinquishment in perpetuity of all present and future rights to this + * software under copyright law. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * For more information, please refer to * * Under source dotest_code control: 2006/03/08 05:54:09 * File existed as early as: 2006 diff --git a/cal/screen.cal b/cal/screen.cal index 06b9111..9c051f6 100644 --- a/cal/screen.cal +++ b/cal/screen.cal @@ -3,19 +3,37 @@ * * This file was created by Ernest Bowen . * - * This code has been placed in the public domain. Please do not - * copyright this code. - * - * ERNEST BOWEN DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER- - * CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT - * NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF - * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, - * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * * This file is not covered under version 2.1 of the GNU LGPL. + * This file is covered under "The unlicense": + * + * https://unlicense.org + * + * In particular: + * + * This is free and unencumbered software released into the public domain. + * + * Anyone is free to copy, modify, publish, use, compile, sell, or + * distribute this software, either in source code form or as a compiled + * binary, for any purpose, commercial or non-commercial, and by any + * means. + * + * In jurisdictions that recognize copyright laws, the author or authors + * of this software dedicate any and all copyright interest in the + * software to the public domain. We make this dedication for the benefit + * of the public at large and to the detriment of our heirs and + * successors. We intend this dedication to be an overt act of + * relinquishment in perpetuity of all present and future rights to this + * software under copyright law. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * For more information, please refer to * * Under source code control: 2006/03/08 05:54:09 * File existed as early as: 2006 diff --git a/calc.c b/calc.c index 3f574cb..cb42dee 100644 --- a/calc.c +++ b/calc.c @@ -108,8 +108,6 @@ main(int argc, char **argv) int c; /* option */ int index; int maxindex; - /* fix gcc warning bug */ - int unusedint = 0; char *cp; char *endcp; char *bp; @@ -289,9 +287,7 @@ main(int argc, char **argv) exit(6); } calc_debug = cp; - /* fix gcc warning bug */ - unusedint = - strtol(cp, &endcp, 10); + (void) strtol(cp, &endcp, 10); cp = endcp; if (*cp != '\0' && *cp != ' ' && *cp != ':') { @@ -323,9 +319,7 @@ main(int argc, char **argv) exit(9); } resource_debug = cp; - /* fix gcc warning bug */ - unusedint = - strtol(cp, &endcp, 10); + (void) strtol(cp, &endcp, 10); cp = endcp; if (*cp != '\0' && *cp != ' ' && *cp != ':') { @@ -355,8 +349,7 @@ main(int argc, char **argv) exit(12); } user_debug = cp; - /* unusedint avoids gcc warning bug */ - unusedint = strtol(cp, &endcp, 10); + (void) strtol(cp, &endcp, 10); cp = endcp; if (*cp != '\0' && *cp != ' ') { fprintf(stderr, "Bad syntax in" @@ -765,8 +758,6 @@ main(int argc, char **argv) /* * All done! - Jessica Noll, Age 2 */ - /* fix gcc warning bug */ - unusedint++; libcalc_call_me_last(); return (run_state == RUN_EXIT_WITH_ERROR || run_state == RUN_ZERO) ? 1 : 0; diff --git a/calc.man b/calc.man index 173e205..3f08d78 100644 --- a/calc.man +++ b/calc.man @@ -1225,6 +1225,7 @@ The calc commands: help copyright help copying help copying-lgpl +help credit .fi .in -0.5i .sp @@ -1259,6 +1260,10 @@ Copyright (C) year David I. Bell, Landon Curt Noll and Ernest Bowen Copyright (C) year Landon Curt Noll Copyright (C) year Ernest Bowen and Landon Curt Noll Copyright (C) year Ernest Bowen +Copyright (C) year Petteri Kettunen and Landon Curt Noll +Copyright (C) year Christoph Zurnieden +Copyright (C) year Landon Curt Noll and Thomas Jones-Low +Copyright (C) year Klaus Alexander Seistrup and Landon Curt Noll .fi .in -0.5i .sp @@ -1266,12 +1271,22 @@ This man page is: .sp .in +0.5i .nf -Copyright (C) 1999-2021 Landon Curt Noll +Copyright (C) 1999-2023 Landon Curt Noll .fi .in -0.5i .sp and is covered under version 2.1 GNU Lesser General Public License. +.sp +A few files in calc are covered under "The Unlicense". +For more information on this license, see: +.sp +.in +0.5i +.nf +https://unlicense.org +.fi +.in -0.5i +.sp .PP @@ -1279,61 +1294,27 @@ Public License. .PP -If you have a simple general question about calc, send Email to: -.sp -.in +0.5i -calc-quest-mail at asthe dot com -.sp -NOTE: Remove spaces and replace 'at' with @, and 'dot' with . -.in -0.5i -.sp -.in +0.5i -NOTE: Yes, the Email address uses 'asthe', -while the web site uses 'isthe'. -.in -0.5i -.sp -.B PLEASE -put following the -.B SPECIAL PHRASE -somewhere in your Email Subject line: -.sp -.in +0.5i -.B calc question -.in -0.5i -.sp -You may add additional words to your subject line. -.sp -.B IMPORTANT: -If your Email doesn't contain the above phrase, -then we -.B WILL NOT SEE -your Email. -.sp -.B PLEASE BE SURE -you have that -.B SPECIAL PHRASE -somewhere in the subject line! -.sp -.B Suggestion: -.sp -.in +0.5i -From time to time, the Email address and Subject -.B SPECIAL PHRASE -may change so verify you have the current info by visiting: +To ask the calc maintainers a general question about calc, +see the output of: + .sp .in +0.5i .nf -http://www.isthe.com/chongo/tech/comp/calc/calc-question.html +; help question .fi -.in -0.5i -.in -0.5i +.in +0.5i .sp -Please limit your questions to general questions about calc. -We cannot go into great detail in our answers, -nor can we do your homework, nor can -we do much more than answer short general questions about calc. +.PP + +or read the source file: + +.sp +.in +0.5i +.nf +QUESTIONS +.fi +.in +0.5i .sp -Please be patient as we cannot always respond to Email messages quickly. .PP @@ -1341,71 +1322,27 @@ Please be patient as we cannot always respond to Email messages quickly. .PP -Send bug reports and bug fixes to: +To inform the calc maintainers about a bug, +or to submit a bug fix, see the output of: + .sp .in +0.5i .nf -calc-bugrept at asthe dot com +; help bugs .fi -.sp -NOTE: Remove spaces and replace 'at' with @, 'dot' with . -.sp -NOTE: Yes, the Email address uses 'asthe', -while the web site uses 'isthe'. -.in -0.5i -.sp -You -.B MUST -use following -.B SPECIAL PHRASE -in your Email Subject line: -.sp .in +0.5i -.B calc bug report -.in -0.5i .sp -You may add additional words to your subject line. -.sp -.B Suggestion: -.sp -.in +0.5i -From time to time, the Email address and Subject -.B SPECIAL PHRASE -may change so verify you have the current info by visiting: +.PP + +or read the source file: + .sp .in +0.5i .nf -http://www.isthe.com/chongo/tech/comp/calc/calc-bugrept.html +BUGS .fi -.in -0.5i -.in -0.5i -.sp -.B IMPORTANT: -If your Email doesn't contain the above phrase, -then we -.B WILL NOT SEE -your Email. -.sp -.B PLEASE BE SURE -you have that -.B SPECIAL PHRASE -somewhere in the subject line! -.sp -See the -.I BUGS -source file or use the -.I calc -command: -.sp .in +0.5i -.nf -help bugs -.fi -.in -0.5i .sp -for more information about bug reporting. -.sp -Please be patient as we cannot always respond to Email messages quickly. .PP @@ -1415,126 +1352,27 @@ Please be patient as we cannot always respond to Email messages quickly. .I Calc is open source. -Contributions of code are welcome. -.sp -We welcome and encourage you to send us: +You are welcome to contribute code to calc, or submit bug fixes to to calc. .sp +To contribute code to calc, please see see the output of: + .sp .in +0.5i .nf -* calc resource files (cal/*.cal) -* calc shell scripts (cscript/*.calc) -* builtin functions that you have modified or written, i.e.: - assocfunc.c comfunc.c func.c func.h - listfunc.c matfunc.c qfunc.c zfunc.c -* custom functions that you have modified or written (custom/*) -* help files modified or written (help/*) -* brief description of you added, fixed, improved in CHANGES -* regression test cases (cal/regress.cal) -* Makefile improvements (Makefile, */Makefile) -* other source code modifications (*.c, *.h) -* etc. (* */* :) ) +; help contrib .fi -.in -0.5i -.sp -If you add functionality to calc, please be sure to modify/patch/add -Makefiles, help files, cal/regress.cal test code as well. -Regression test cases are vital to maintaining calc's level -of correctness and helps us avoid code bug regression. -.sp -In order to consider integrating your code, we need: -.sp -.nf .in +0.5i -* calc version you are working with (please try use the latest version) -* new help files or help file patches, if applicable (documentation) -* proposed text for the CHANGES file (brief description of what it does) -* regress.cal test patch as needed -* your source code and/or source code changes (:-)) -.in -0.5i -.fi .sp -The best way to send us new code, if your changes are small, is -via a patch (diff -c from the latest alpha code to your code). -If your change is large, you should send entire files (either -as a diff -c /dev/null your-file patch, or as a uuencoded and -gziped (or compressed) tar file). -.sp -Please try to generate a patch against the most recent -version of calc, and if you use GitHub, the top of the -master branch: -.sp -.nf -.in +0.5i -https://github.com/lcn2/calc -.in -0.5i -.fi -.sp -.sp -The best way contribute to calc bug is to generate calc -GitHub pull request: -.sp -.nf -.in +0.5i -https://github.com/lcn2/calc/pulls -.in -0.5i -.fi -.sp -Your code needs to be contributed under either the 2.1 of the -.B GNU Lesser General Public License (LGPL 2.1) -or be in the public domain. -.sp -If you do not want to use calc GitHub, then send Email to: +.PP + +or read the source file: + .sp .in +0.5i .nf -calc-contrib at asthe dot com +CONTRIB-CODE .fi -.sp -NOTE: Remove spaces and replace 'at' with @, 'dot' with . -.sp -NOTE: Yes, the Email address uses 'asthe', -while the web site uses 'isthe'. -.in -0.5i -.sp -You -.B MUST -use following -.B SPECIAL PHRASE -in your Email Subject line: -.sp .in +0.5i -.B calc contribution -.in -0.5i -.sp -You may add additional words to your subject line. -.sp -.B Suggestion: -.sp -.in +0.5i -From time to time, the Email address and Subject -.B SPECIAL PHRASE -may change so verify you have the current info by visiting: -.sp -.in +0.5i -.nf -http://www.isthe.com/chongo/tech/comp/calc/calc-contrib.html -.fi -.in -0.5i -.in -0.5i -.sp -.B IMPORTANT: -If your Email doesn't contain the above phrase, -then we -.B WILL NOT SEE -your Email. -.sp -.B PLEASE BE SURE -you have that -.B SPECIAL PHRASE -somewhere in the subject line! -.sp -Please be patient as we cannot always respond to Email messages quickly. .PP diff --git a/custom/Makefile b/custom/Makefile index feaa721..3e81608 100644 --- a/custom/Makefile +++ b/custom/Makefile @@ -492,7 +492,7 @@ CO= co CP= cp DIFF= diff FMT= fmt -GREP= egrep +GREP= grep LN= ln LS= ls MAKE= make @@ -847,7 +847,7 @@ depend: ${C_SRC} 2>/dev/null ${Q} ${CP} -f skel/custom/makedep.out skel/custom/makedep.in ${Q} ${SED} -e 's|: ../../|: |' -E < skel/custom/makedep.in | \ - ${GREP} -v /usr/include > skel/custom/makedep.out + ${GREP} -E -v /usr/include > skel/custom/makedep.out -${Q} for i in ${C_SRC} /dev/null; do \ if [ X"$$i" != X"/dev/null" ]; then \ echo "$$i" | ${SED} 's/^\(.*\)\.c/\1.o: \1.c/'; \ @@ -861,7 +861,7 @@ depend: ${Q} ${MV} ${MAKE_FILE} ${MAKE_FILE}.bak ${Q} ${SED} -n '1,/^# DO NOT DELETE THIS LINE/p' \ ${MAKE_FILE}.bak > ${MAKE_FILE} - ${Q} ${GREP} -v '^#' skel/custom/makedep.out >> ${MAKE_FILE} + ${Q} ${GREP} -E -v '^#' skel/custom/makedep.out >> ${MAKE_FILE} ${Q} echo removing skel ${Q} ${RM} -rf skel -${Q} if ${CMP} -s ${MAKE_FILE}.bak ${MAKE_FILE}; then \ diff --git a/custom/Makefile.simple b/custom/Makefile.simple index 4f08262..65d5069 100644 --- a/custom/Makefile.simple +++ b/custom/Makefile.simple @@ -462,7 +462,7 @@ CO= co CP= cp DIFF= diff FMT= fmt -GREP= egrep +GREP= grep LN= ln LS= ls MAKE= make @@ -851,7 +851,7 @@ depend: ${C_SRC} 2>/dev/null ${Q} ${CP} -f skel/custom/makedep.out skel/custom/makedep.in ${Q} ${SED} -e 's|: ../../|: |' -E < skel/custom/makedep.in | \ - ${GREP} -v /usr/include > skel/custom/makedep.out + ${GREP} -E -v /usr/include > skel/custom/makedep.out -${Q} for i in ${C_SRC} /dev/null; do \ if [ X"$$i" != X"/dev/null" ]; then \ echo "$$i" | ${SED} 's/^\(.*\)\.c/\1.o: \1.c/'; \ @@ -865,7 +865,7 @@ depend: ${Q} ${MV} ${MAKE_FILE} ${MAKE_FILE}.bak ${Q} ${SED} -n '1,/^# DO NOT DELETE THIS LINE/p' \ ${MAKE_FILE}.bak > ${MAKE_FILE} - ${Q} ${GREP} -v '^#' skel/custom/makedep.out >> ${MAKE_FILE} + ${Q} ${GREP} -E -v '^#' skel/custom/makedep.out >> ${MAKE_FILE} ${Q} echo removing skel ${Q} ${RM} -rf skel -${Q} if ${CMP} -s ${MAKE_FILE}.bak ${MAKE_FILE}; then \ diff --git a/func.c b/func.c index 1b7ca6c..5a3aac3 100644 --- a/func.c +++ b/func.c @@ -1,7 +1,7 @@ /* * func - built-in functions implemented here * - * Copyright (C) 1999-2007,2018,2021,2022 David I. Bell, Landon Curt Noll and Ernest Bowen + * Copyright (C) 1999-2007,2018,2021-2023 David I. Bell, Landon Curt Noll and Ernest Bowen * * Primary author: David I. Bell * @@ -193,14 +193,39 @@ STATIC STRINGHEAD newerrorstr; /* * builtins - List of primitive built-in functions */ + +typedef union { + char *null; /* no b_numfunc function */ + NUMBER *(*numfunc_0)(void); +#if !defined(FUNCLIST) + NUMBER *(*numfunc_1)(NUMBER *); + NUMBER *(*numfunc_2)(NUMBER *, NUMBER *); + NUMBER *(*numfunc_3)(NUMBER *, NUMBER *, NUMBER *); + NUMBER *(*numfunc_4)(NUMBER *, NUMBER *, NUMBER *, NUMBER *); + NUMBER *(*numfunc_cnt)(int, NUMBER **); +#endif /* !FUNCLIST */ +} numfunc; + +typedef union { + char *null; /* no b_valfunc function */ + VALUE (*valfunc_0)(void); +#if !defined(FUNCLIST) + VALUE (*valfunc_1)(VALUE *); + VALUE (*valfunc_2)(VALUE *, VALUE *); + VALUE (*valfunc_3)(VALUE *, VALUE *, VALUE *); + VALUE (*valfunc_4)(VALUE *, VALUE *, VALUE *, VALUE *); + VALUE (*valfunc_cnt)(int, VALUE **); +#endif /* !FUNCLIST */ +} valfunc; + struct builtin { char *b_name; /* name of built-in function */ short b_minargs; /* minimum number of arguments */ short b_maxargs; /* maximum number of arguments */ short b_flags; /* special handling flags */ short b_opcode; /* opcode which makes the call quick */ - NUMBER *(*b_numfunc)(); /* routine to calculate numeric function */ - VALUE (*b_valfunc)(); /* routine to calculate general values */ + numfunc b_numfunc; /* routine to calculate numeric function */ + valfunc b_valfunc; /* routine to calculate general values */ char *b_desc; /* description of function */ }; @@ -3908,7 +3933,7 @@ f_quomod(int count, VALUE **vals) VALUE result; long rnd; BOOL res; - short s3, s4; /* to preserve subtypes of v3, v4 */ + short s3, s4; /* to preserve subtypes of v3, v4 */ v1 = vals[0]; v2 = vals[1]; @@ -3971,7 +3996,7 @@ f_d2dms(int count, VALUE **vals) NUMBER *tmp, *tmp_m; VALUE result; long rnd; - short s2, s3, s4; /* to preserve subtypes of v2, v3, v4 */ + short s2, s3, s4; /* to preserve subtypes of v2, v3, v4 */ /* collect required args */ v1 = vals[0]; @@ -4091,7 +4116,7 @@ f_d2dm(int count, VALUE **vals) NUMBER *tmp; VALUE result; long rnd; - short s2, s3; /* to preserve subtypes of v2, v3 */ + short s2, s3; /* to preserve subtypes of v2, v3 */ /* collect required args */ v1 = vals[0]; @@ -4188,7 +4213,7 @@ f_g2gms(int count, VALUE **vals) NUMBER *tmp, *tmp_m; VALUE result; long rnd; - short s2, s3, s4; /* to preserve subtypes of v2, v3, v4 */ + short s2, s3, s4; /* to preserve subtypes of v2, v3, v4 */ /* collect required args */ v1 = vals[0]; @@ -4308,7 +4333,7 @@ f_g2gm(int count, VALUE **vals) NUMBER *tmp; VALUE result; long rnd; - short s2, s3; /* to preserve subtypes of v2, v3 */ + short s2, s3; /* to preserve subtypes of v2, v3 */ /* collect required args */ v1 = vals[0]; @@ -4405,7 +4430,7 @@ f_h2hms(int count, VALUE **vals) NUMBER *tmp, *tmp_m; VALUE result; long rnd; - short s2, s3, s4; /* to preserve subtypes of v2, v3, v4 */ + short s2, s3, s4; /* to preserve subtypes of v2, v3, v4 */ /* collect required args */ v1 = vals[0]; @@ -4525,7 +4550,7 @@ f_h2hm(int count, VALUE **vals) NUMBER *tmp; VALUE result; long rnd; - short s2, s3; /* to preserve subtypes of v2, v3 */ + short s2, s3; /* to preserve subtypes of v2, v3 */ /* collect required args */ v1 = vals[0]; @@ -8952,7 +8977,7 @@ f_putenv(int count, VALUE **vals) * * however compilers like gcc would issue warnings such as: * - * null destination pointer + * null destination pointer * * even though we check that putenv_str is non-NULL * above before using it. Therefore we call strlcpy() @@ -9862,667 +9887,667 @@ f_version(void) * b_desc description of function */ STATIC CONST struct builtin builtins[] = { - {"abs", 1, 2, 0, OP_ABS, 0, 0, + {"abs", 1, 2, 0, OP_ABS, {.null = NULL}, {.null = NULL}, "absolute value within accuracy b"}, - {"access", 1, 2, 0, OP_NOP, 0, f_access, + {"access", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_access}, "determine accessibility of file a for mode b"}, - {"acos", 1, 2, 0, OP_NOP, 0, f_acos, + {"acos", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_acos}, "arccosine of a within accuracy b"}, - {"acosh", 1, 2, 0, OP_NOP, 0, f_acosh, + {"acosh", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_acosh}, "inverse hyperbolic cosine of a within accuracy b"}, - {"acot", 1, 2, 0, OP_NOP, 0, f_acot, + {"acot", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_acot}, "arccotangent of a within accuracy b"}, - {"acoth", 1, 2, 0, OP_NOP, 0, f_acoth, + {"acoth", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_acoth}, "inverse hyperbolic cotangent of a within accuracy b"}, - {"acsc", 1, 2, 0, OP_NOP, 0, f_acsc, + {"acsc", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_acsc}, "arccosecant of a within accuracy b"}, - {"acsch", 1, 2, 0, OP_NOP, 0, f_acsch, + {"acsch", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_acsch}, "inverse csch of a within accuracy b"}, - {"agd", 1, 2, 0, OP_NOP, 0, f_agd, + {"agd", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_agd}, "inverse Gudermannian function"}, - {"append", 1, IN, FA, OP_NOP, 0, f_listappend, + {"append", 1, IN, FA, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_listappend}, "append values to end of list"}, - {"appr", 1, 3, 0, OP_NOP, 0, f_appr, + {"appr", 1, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_appr}, "approximate a by multiple of b using rounding c"}, - {"arg", 1, 2, 0, OP_NOP, 0, f_arg, + {"arg", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_arg}, "argument (the angle) of complex number"}, - {"argv", 0, 1, 0, OP_NOP, 0, f_argv, + {"argv", 0, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_argv}, "calc argc or argv string"}, - {"asec", 1, 2, 0, OP_NOP, 0, f_asec, + {"asec", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_asec}, "arcsecant of a within accuracy b"}, - {"asech", 1, 2, 0, OP_NOP, 0, f_asech, + {"asech", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_asech}, "inverse hyperbolic secant of a within accuracy b"}, - {"asin", 1, 2, 0, OP_NOP, 0, f_asin, + {"asin", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_asin}, "arcsine of a within accuracy b"}, - {"asinh", 1, 2, 0, OP_NOP, 0, f_asinh, + {"asinh", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_asinh}, "inverse hyperbolic sine of a within accuracy b"}, - {"assoc", 0, 0, 0, OP_NOP, 0, f_assoc, + {"assoc", 0, 0, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_assoc}, "create new association array"}, - {"atan", 1, 2, 0, OP_NOP, 0, f_atan, + {"atan", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_atan}, "arctangent of a within accuracy b"}, - {"atan2", 2, 3, FE, OP_NOP, qatan2, 0, + {"atan2", 2, 3, FE, OP_NOP, {.numfunc_3 = qatan2}, {.null = NULL}, "angle to point (b,a) within accuracy c"}, - {"atanh", 1, 2, 0, OP_NOP, 0, f_atanh, + {"atanh", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_atanh}, "inverse hyperbolic tangent of a within accuracy b"}, - {"avg", 0, IN, 0, OP_NOP, 0, f_avg, + {"avg", 0, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_avg}, "arithmetic mean of values"}, - {"base", 0, 1, 0, OP_NOP, f_base, 0, + {"base", 0, 1, 0, OP_NOP, {.numfunc_cnt = f_base}, {.null = NULL}, "set default output base"}, - {"base2", 0, 1, 0, OP_NOP, f_base2, 0, + {"base2", 0, 1, 0, OP_NOP, {.numfunc_cnt = f_base2}, {.null = NULL}, "set default secondary output base"}, - {"bernoulli", 1, 1, 0, OP_NOP, 0, f_bern, + {"bernoulli", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_bern}, "Bernoulli number for index a"}, - {"bit", 2, 2, 0, OP_BIT, 0, 0, + {"bit", 2, 2, 0, OP_BIT, {.null = NULL}, {.null = NULL}, "whether bit b in value a is set"}, - {"blk", 0, 3, 0, OP_NOP, 0, f_blk, + {"blk", 0, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_blk}, "block with or without name, octet number, chunksize"}, - {"blkcpy", 2, 5, 0, OP_NOP, 0, f_blkcpy, + {"blkcpy", 2, 5, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_blkcpy}, "copy value to/from a block: blkcpy(d,s,len,di,si)"}, - {"blkfree", 1, 1, 0, OP_NOP, 0, f_blkfree, + {"blkfree", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_blkfree}, "free all storage from a named block"}, - {"blocks", 0, 1, 0, OP_NOP, 0, f_blocks, + {"blocks", 0, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_blocks}, "named block with specified index, or null value"}, - {"bround", 1, 3, 0, OP_NOP, 0, f_bround, + {"bround", 1, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_bround}, "round value a to b number of binary places"}, - {"btrunc", 1, 2, 0, OP_NOP, f_btrunc, 0, + {"btrunc", 1, 2, 0, OP_NOP, {.numfunc_cnt = f_btrunc}, {.null = NULL}, "truncate a to b number of binary places"}, - {"calc_tty", 0, 0, 0, OP_NOP, 0, f_calc_tty, + {"calc_tty", 0, 0, 0, OP_NOP, {.null = NULL}, {.valfunc_0 = f_calc_tty}, "set tty for interactivity"}, - {"calclevel", 0, 0, 0, OP_NOP, 0, f_calclevel, + {"calclevel", 0, 0, 0, OP_NOP, {.null = NULL}, {.valfunc_0 = f_calclevel}, "current calculation level"}, - {"calcpath", 0, 0, 0, OP_NOP, 0, f_calcpath, + {"calcpath", 0, 0, 0, OP_NOP, {.null = NULL}, {.valfunc_0 = f_calcpath}, "current CALCPATH search path value"}, - {"catalan", 1, 1, 0, OP_NOP, 0, f_catalan, + {"catalan", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_catalan}, "catalan number for index a"}, - {"ceil", 1, 1, 0, OP_NOP, 0, f_ceil, + {"ceil", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_ceil}, "smallest integer greater than or equal to number"}, - {"cfappr", 1, 3, 0, OP_NOP, f_cfappr, 0, + {"cfappr", 1, 3, 0, OP_NOP, {.numfunc_cnt = f_cfappr}, {.null = NULL}, "approximate a within accuracy b using\n" "\t\t\tcontinued fractions"}, - {"cfsim", 1, 2, 0, OP_NOP, f_cfsim, 0, + {"cfsim", 1, 2, 0, OP_NOP, {.numfunc_cnt = f_cfsim}, {.null = NULL}, "simplify number using continued fractions"}, - {"char", 1, 1, 0, OP_NOP, 0, f_char, + {"char", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_char}, "character corresponding to integer value"}, - {"cmdbuf", 0, 0, 0, OP_NOP, 0, f_cmdbuf, + {"cmdbuf", 0, 0, 0, OP_NOP, {.null = NULL}, {.valfunc_0 = f_cmdbuf}, "command buffer"}, - {"cmp", 2, 2, 0, OP_CMP, 0, 0, + {"cmp", 2, 2, 0, OP_CMP, {.null = NULL}, {.null = NULL}, "compare values returning -1, 0, or 1"}, - {"comb", 2, 2, 0, OP_NOP, 0, f_comb, + {"comb", 2, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_2 = f_comb}, "combinatorial number a!/b!(a-b)!"}, - {"config", 1, 2, 0, OP_SETCONFIG, 0, 0, + {"config", 1, 2, 0, OP_SETCONFIG, {.null = NULL}, {.null = NULL}, "set or read configuration value"}, - {"conj", 1, 1, 0, OP_CONJUGATE, 0, 0, + {"conj", 1, 1, 0, OP_CONJUGATE, {.null = NULL}, {.null = NULL}, "complex conjugate of value"}, - {"copy", 2, 5, 0, OP_NOP, 0, f_copy, + {"copy", 2, 5, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_copy}, "copy value to/from a block: copy(s,d,len,si,di)"}, - {"cos", 1, 2, 0, OP_NOP, 0, f_cos, + {"cos", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_cos}, "cosine of value a within accuracy b"}, - {"cosh", 1, 2, 0, OP_NOP, 0, f_cosh, + {"cosh", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_cosh}, "hyperbolic cosine of a within accuracy b"}, - {"cot", 1, 2, 0, OP_NOP, 0, f_cot, + {"cot", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_cot}, "cotangent of a within accuracy b"}, - {"coth", 1, 2, 0, OP_NOP, 0, f_coth, + {"coth", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_coth}, "hyperbolic cotangent of a within accuracy b"}, - {"count", 2, 2, 0, OP_NOP, 0, f_count, + {"count", 2, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_2 = f_count}, "count listr/matrix elements satisfying some condition"}, - {"cp", 2, 2, 0, OP_NOP, 0, f_cp, + {"cp", 2, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_2 = f_cp}, "cross product of two vectors"}, - {"csc", 1, 2, 0, OP_NOP, 0, f_csc, + {"csc", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_csc}, "cosecant of a within accuracy b"}, - {"csch", 1, 2, 0, OP_NOP, 0, f_csch, + {"csch", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_csch}, "hyperbolic cosecant of a within accuracy b"}, - {"ctime", 0, 0, 0, OP_NOP, 0, f_ctime, + {"ctime", 0, 0, 0, OP_NOP, {.null = NULL}, {.valfunc_0 = f_ctime}, "date and time as string"}, - {"custom", 0, IN, 0, OP_NOP, 0, f_custom, + {"custom", 0, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_custom}, "custom builtin function interface"}, - {"d2dm", 3, 4, FA, OP_NOP, 0, f_d2dm, + {"d2dm", 3, 4, FA, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_d2dm}, "convert a to b deg, c min, rounding type d\n"}, - {"d2dms", 4, 5, FA, OP_NOP, 0, f_d2dms, + {"d2dms", 4, 5, FA, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_d2dms}, "convert a to b deg, c min, d sec, rounding type e\n"}, - {"d2g", 1, 2, 0, OP_NOP, 0, f_d2g, + {"d2g", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_d2g}, "convert degrees to gradians"}, - {"d2r", 1, 2, 0, OP_NOP, 0, f_d2r, + {"d2r", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_d2r}, "convert degrees to radians"}, - {"delete", 2, 2, FA, OP_NOP, 0, f_listdelete, + {"delete", 2, 2, FA, OP_NOP, {.null = NULL}, {.valfunc_2 = f_listdelete}, "delete element from list a at position b"}, - {"den", 1, 1, 0, OP_DENOMINATOR, qden, 0, + {"den", 1, 1, 0, OP_DENOMINATOR, {.numfunc_1 = qden}, {.null = NULL}, "denominator of fraction"}, - {"det", 1, 1, 0, OP_NOP, 0, f_det, + {"det", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_det}, "determinant of matrix"}, - {"digit", 2, 3, 0, OP_NOP, 0, f_digit, + {"digit", 2, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_digit}, "digit at specified decimal place of number"}, - {"digits", 1, 2, 0, OP_NOP, 0, f_digits, + {"digits", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_digits}, "number of digits in base b representation of a"}, - {"display", 0, 1, 0, OP_NOP, 0, f_display, + {"display", 0, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_display}, "number of decimal digits for displaying numbers"}, - {"dm2d", 2, 3, 0, OP_NOP, 0, f_dm2d, + {"dm2d", 2, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_dm2d}, "convert a deg, b min to degrees, rounding type c\n"}, - {"dms2d", 3, 4, 0, OP_NOP, 0, f_dms2d, + {"dms2d", 3, 4, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_dms2d}, "convert a deg, b min, c sec to degrees, rounding type d\n"}, - {"dp", 2, 2, 0, OP_NOP, 0, f_dp, + {"dp", 2, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_2 = f_dp}, "dot product of two vectors"}, - {"epsilon", 0, 1, 0, OP_SETEPSILON, 0, 0, + {"epsilon", 0, 1, 0, OP_SETEPSILON, {.null = NULL}, {.null = NULL}, "set or read allowed error for real calculations"}, - {"errcount", 0, 1, 0, OP_NOP, 0, f_errcount, + {"errcount", 0, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_errcount}, "set or read error count"}, - {"errmax", 0, 1, 0, OP_NOP, 0, f_errmax, + {"errmax", 0, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_errmax}, "set or read maximum for error count"}, - {"errno", 0, 1, 0, OP_NOP, 0, f_errno, + {"errno", 0, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_errno}, "set or read calc_errno"}, - {"error", 0, 1, 0, OP_NOP, 0, f_error, + {"error", 0, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_error}, "generate error value"}, - {"estr", 1, 1, 0, OP_NOP, 0, f_estr, + {"estr", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_estr}, "exact text string representation of value"}, - {"euler", 1, 1, 0, OP_NOP, 0, f_euler, + {"euler", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_euler}, "Euler number"}, - {"eval", 1, 1, 0, OP_NOP, 0, f_eval, + {"eval", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_eval}, "evaluate expression from string to value"}, - {"exp", 1, 2, 0, OP_NOP, 0, f_exp, + {"exp", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_exp}, "exponential of value a within accuracy b"}, - {"factor", 1, 3, 0, OP_NOP, f_factor, 0, + {"factor", 1, 3, 0, OP_NOP, {.numfunc_cnt = f_factor}, {.null = NULL}, "lowest prime factor < b of a, return c if error"}, - {"fcnt", 2, 2, 0, OP_NOP, f_faccnt, 0, + {"fcnt", 2, 2, 0, OP_NOP, {.numfunc_2 = f_faccnt}, {.null = NULL}, "count of times one number divides another"}, - {"fib", 1, 1, 0, OP_NOP, qfib, 0, + {"fib", 1, 1, 0, OP_NOP, {.numfunc_1 = qfib}, {.null = NULL}, "Fibonacci number F(n)"}, - {"forall", 2, 2, 0, OP_NOP, 0, f_forall, + {"forall", 2, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_2 = f_forall}, "do function for all elements of list or matrix"}, - {"frem", 2, 2, 0, OP_NOP, qfacrem, 0, + {"frem", 2, 2, 0, OP_NOP, {.numfunc_2 = qfacrem}, {.null = NULL}, "number with all occurrences of factor removed"}, - {"fact", 1, 1, 0, OP_NOP, 0, f_fact, + {"fact", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_fact}, "factorial"}, - {"fclose", 0, IN, 0, OP_NOP, 0, f_fclose, + {"fclose", 0, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_fclose}, "close file"}, - {"feof", 1, 1, 0, OP_NOP, 0, f_feof, + {"feof", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_feof}, "whether EOF reached for file"}, - {"ferror", 1, 1, 0, OP_NOP, 0, f_ferror, + {"ferror", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_ferror}, "whether error occurred for file"}, - {"fflush", 0, IN, 0, OP_NOP, 0, f_fflush, + {"fflush", 0, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_fflush}, "flush output to file(s)"}, - {"fgetc", 1, 1, 0, OP_NOP, 0, f_fgetc, + {"fgetc", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_fgetc}, "read next char from file"}, - {"fgetfield", 1, 1, 0, OP_NOP, 0, f_fgetfield, + {"fgetfield", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_fgetfield}, "read next white-space delimited field from file"}, - {"fgetfile", 1, 1, 0, OP_NOP, 0, f_fgetfile, + {"fgetfile", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_fgetfile}, "read to end of file"}, - {"fgetline", 1, 1, 0, OP_NOP, 0, f_fgetline, + {"fgetline", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_fgetline}, "read next line from file, newline removed"}, - {"fgets", 1, 1, 0, OP_NOP, 0, f_fgets, + {"fgets", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_fgets}, "read next line from file, newline is kept"}, - {"fgetstr", 1, 1, 0, OP_NOP, 0, f_fgetstr, + {"fgetstr", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_fgetstr}, "read next null-terminated string from file, null\n" "\t\t\tcharacter is kept"}, - {"files", 0, 1, 0, OP_NOP, 0, f_files, + {"files", 0, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_files}, "return opened file or max number of opened files"}, - {"floor", 1, 1, 0, OP_NOP, 0, f_floor, + {"floor", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_floor}, "greatest integer less than or equal to number"}, - {"fopen", 2, 2, 0, OP_NOP, 0, f_fopen, + {"fopen", 2, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_2 = f_fopen}, "open file name a in mode b"}, - {"fpathopen", 2, 3, 0, OP_NOP, 0, f_fpathopen, + {"fpathopen", 2, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_fpathopen}, "open file name a in mode b, search for a along\n" "\t\t\tCALCPATH or path c"}, - {"fprintf", 2, IN, 0, OP_NOP, 0, f_fprintf, + {"fprintf", 2, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_fprintf}, "print formatted output to opened file"}, - {"fputc", 2, 2, 0, OP_NOP, 0, f_fputc, + {"fputc", 2, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_2 = f_fputc}, "write a character to a file"}, - {"fputs", 2, IN, 0, OP_NOP, 0, f_fputs, + {"fputs", 2, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_fputs}, "write one or more strings to a file"}, - {"fputstr", 2, IN, 0, OP_NOP, 0, f_fputstr, + {"fputstr", 2, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_fputstr}, "write one or more null-terminated strings to a file"}, - {"free", 0, IN, FA, OP_NOP, 0, f_free, + {"free", 0, IN, FA, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_free}, "free listed or all global variables"}, - {"freebernoulli", 0, 0, 0, OP_NOP, 0, f_freebern, + {"freebernoulli", 0, 0, 0, OP_NOP, {.null = NULL}, {.valfunc_0 = f_freebern}, "free stored Bernoulli numbers"}, - {"freeeuler", 0, 0, 0, OP_NOP, 0, f_freeeuler, + {"freeeuler", 0, 0, 0, OP_NOP, {.null = NULL}, {.valfunc_0 = f_freeeuler}, "free stored Euler numbers"}, - {"freeglobals", 0, 0, 0, OP_NOP, 0, f_freeglobals, + {"freeglobals", 0, 0, 0, OP_NOP, {.null = NULL}, {.valfunc_0 = f_freeglobals}, "free all global and visible static variables"}, - {"freeredc", 0, 0, 0, OP_NOP, 0, f_freeredc, + {"freeredc", 0, 0, 0, OP_NOP, {.null = NULL}, {.valfunc_0 = f_freeredc}, "free redc data cache"}, - {"freestatics", 0, 0, 0, OP_NOP, 0, f_freestatics, + {"freestatics", 0, 0, 0, OP_NOP, {.null = NULL}, {.valfunc_0 = f_freestatics}, "free all un-scoped static variables"}, - {"freopen", 2, 3, 0, OP_NOP, 0, f_freopen, + {"freopen", 2, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_freopen}, "reopen a file stream to a named file"}, - {"fscan", 2, IN, FA, OP_NOP, 0, f_fscan, + {"fscan", 2, IN, FA, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_fscan}, "scan a file for assignments to one or\n" "\t\t\tmore variables"}, - {"fscanf", 2, IN, FA, OP_NOP, 0, f_fscanf, + {"fscanf", 2, IN, FA, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_fscanf}, "formatted scan of a file for assignment to one\n" "\t\t\tor more variables"}, - {"fseek", 2, 3, 0, OP_NOP, 0, f_fseek, + {"fseek", 2, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_fseek}, "seek to position b (offset from c) in file a"}, - {"fsize", 1, 1, 0, OP_NOP, 0, f_fsize, + {"fsize", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_fsize}, "return the size of the file"}, - {"ftell", 1, 1, 0, OP_NOP, 0, f_ftell, + {"ftell", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_ftell}, "return the file position"}, - {"frac", 1, 1, 0, OP_FRAC, qfrac, 0, + {"frac", 1, 1, 0, OP_FRAC, {.numfunc_1 = qfrac}, {.null = NULL}, "fractional part of value"}, - {"g2d", 1, 2, 0, OP_NOP, 0, f_g2d, + {"g2d", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_g2d}, "convert gradians to degrees"}, - {"g2gm", 3, 4, FA, OP_NOP, 0, f_g2gm, + {"g2gm", 3, 4, FA, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_g2gm}, "convert a to b grads, c min, rounding type d\n"}, - {"g2gms", 4, 5, FA, OP_NOP, 0, f_g2gms, + {"g2gms", 4, 5, FA, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_g2gms}, "convert a to b grads, c min, d sec, rounding type e\n"}, - {"g2r", 1, 2, 0, OP_NOP, 0, f_g2r, + {"g2r", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_g2r}, "convert gradians to radians"}, - {"gcd", 1, IN, 0, OP_NOP, f_gcd, 0, + {"gcd", 1, IN, 0, OP_NOP, {.numfunc_cnt = f_gcd}, {.null = NULL}, "greatest common divisor"}, - {"gcdrem", 2, 2, 0, OP_NOP, qgcdrem, 0, + {"gcdrem", 2, 2, 0, OP_NOP, {.numfunc_2 = qgcdrem}, {.null = NULL}, "a divided repeatedly by gcd with b"}, - {"gd", 1, 2, 0, OP_NOP, 0, f_gd, + {"gd", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_gd}, "Gudermannian function"}, - {"getenv", 1, 1, 0, OP_NOP, 0, f_getenv, + {"getenv", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_getenv}, "value of environment variable (or NULL)"}, - {"gm2g", 2, 3, 0, OP_NOP, 0, f_gm2g, + {"gm2g", 2, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_gm2g}, "convert a grads, b min to grads, rounding type c\n"}, - {"gms2g", 3, 4, 0, OP_NOP, 0, f_gms2g, + {"gms2g", 3, 4, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_gms2g}, "convert a grads, b min, c sec to grads, rounding type d\n"}, - {"h2hm", 3, 4, FA, OP_NOP, 0, f_h2hm, + {"h2hm", 3, 4, FA, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_h2hm}, "convert a to b hours, c min, rounding type d\n"}, - {"h2hms", 4, 5, FA, OP_NOP, 0, f_h2hms, + {"h2hms", 4, 5, FA, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_h2hms}, "convert a to b hours, c min, d sec, rounding type e\n"}, - {"hash", 1, IN, 0, OP_NOP, 0, f_hash, + {"hash", 1, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_hash}, "return non-negative hash value for one or\n" "\t\t\tmore values"}, - {"head", 2, 2, 0, OP_NOP, 0, f_head, + {"head", 2, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_2 = f_head}, "return list of specified number at head of a list"}, - {"highbit", 1, 1, 0, OP_HIGHBIT, 0, 0, + {"highbit", 1, 1, 0, OP_HIGHBIT, {.null = NULL}, {.null = NULL}, "high bit number in base 2 representation"}, - {"hm2h", 2, 3, 0, OP_NOP, 0, f_hm2h, + {"hm2h", 2, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_hm2h}, "convert a hours, b min to hours, rounding type c\n"}, - {"hms2h", 3, 4, 0, OP_NOP, 0, f_hms2h, + {"hms2h", 3, 4, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_hms2h}, "convert a hours, b min, c sec to hours, rounding type d\n"}, - {"hmean", 0, IN, 0, OP_NOP, 0, f_hmean, + {"hmean", 0, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_hmean}, "harmonic mean of values"}, - {"hnrmod", 4, 4, 0, OP_NOP, f_hnrmod, 0, - "v mod h*2^n+r, h>0, n>0, r = -1, 0 or 1"}, - {"hypot", 2, 3, FE, OP_NOP, qhypot, 0, + {"hnrmod", 4, 4, 0, OP_NOP, {.numfunc_4 = f_hnrmod}, {.null = NULL}, + "v mod h*2^n+r, h>0, n>0, r = -1, 0 or 1"}, + {"hypot", 2, 3, FE, OP_NOP, {.numfunc_3 = qhypot}, {.null = NULL}, "hypotenuse of right triangle within accuracy c"}, - {"ilog", 2, 2, 0, OP_NOP, 0, f_ilog, + {"ilog", 2, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_2 = f_ilog}, "integral log of a to integral base b"}, - {"ilog10", 1, 1, 0, OP_NOP, 0, f_ilog10, + {"ilog10", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_ilog10}, "integral log of a number base 10"}, - {"ilog2", 1, 1, 0, OP_NOP, 0, f_ilog2, + {"ilog2", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_ilog2}, "integral log of a number base 2"}, - {"im", 1, 1, 0, OP_IM, 0, 0, + {"im", 1, 1, 0, OP_IM, {.null = NULL}, {.null = NULL}, "imaginary part of complex number"}, - {"indices", 2, 2, 0, OP_NOP, 0, f_indices, + {"indices", 2, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_2 = f_indices}, "indices of a specified assoc or mat value"}, - {"inputlevel", 0, 0, 0, OP_NOP, 0, f_inputlevel, + {"inputlevel", 0, 0, 0, OP_NOP, {.null = NULL}, {.valfunc_0 = f_inputlevel}, "current input depth"}, - {"insert", 2, IN, FA, OP_NOP, 0, f_listinsert, + {"insert", 2, IN, FA, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_listinsert}, "insert values c ... into list a at position b"}, - {"int", 1, 1, 0, OP_INT, qint, 0, + {"int", 1, 1, 0, OP_INT, {.numfunc_1 = qint}, {.null = NULL}, "integer part of value"}, - {"inverse", 1, 1, 0, OP_INVERT, 0, 0, + {"inverse", 1, 1, 0, OP_INVERT, {.null = NULL}, {.null = NULL}, "multiplicative inverse of value"}, - {"iroot", 2, 2, 0, OP_NOP, qiroot, 0, + {"iroot", 2, 2, 0, OP_NOP, {.numfunc_2 = qiroot}, {.null = NULL}, "integer b'th root of a"}, - {"isassoc", 1, 1, 0, OP_ISASSOC, 0, 0, + {"isassoc", 1, 1, 0, OP_ISASSOC, {.null = NULL}, {.null = NULL}, "whether a value is an association"}, - {"isatty", 1, 1, 0, OP_NOP, 0, f_isatty, + {"isatty", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_isatty}, "whether a file is a tty"}, - {"isblk", 1, 1, 0, OP_ISBLK, 0, 0, + {"isblk", 1, 1, 0, OP_ISBLK, {.null = NULL}, {.null = NULL}, "whether a value is a block"}, - {"isconfig", 1, 1, 0, OP_ISCONFIG, 0, 0, + {"isconfig", 1, 1, 0, OP_ISCONFIG, {.null = NULL}, {.null = NULL}, "whether a value is a config state"}, - {"isdefined", 1, 1, 0, OP_ISDEFINED, 0, 0, + {"isdefined", 1, 1, 0, OP_ISDEFINED, {.null = NULL}, {.null = NULL}, "whether a string names a function"}, - {"iserror", 1, 1, 0, OP_NOP, 0, f_iserror, + {"iserror", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_iserror}, "where a value is an error"}, - {"iseven", 1, 1, 0, OP_ISEVEN, 0, 0, + {"iseven", 1, 1, 0, OP_ISEVEN, {.null = NULL}, {.null = NULL}, "whether a value is an even integer"}, - {"isfile", 1, 1, 0, OP_ISFILE, 0, 0, + {"isfile", 1, 1, 0, OP_ISFILE, {.null = NULL}, {.null = NULL}, "whether a value is a file"}, - {"ishash", 1, 1, 0, OP_ISHASH, 0, 0, + {"ishash", 1, 1, 0, OP_ISHASH, {.null = NULL}, {.null = NULL}, "whether a value is a hash state"}, - {"isident", 1, 1, 0, OP_NOP, 0, f_isident, + {"isident", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_isident}, "returns 1 if identity matrix"}, - {"isint", 1, 1, 0, OP_ISINT, 0, 0, + {"isint", 1, 1, 0, OP_ISINT, {.null = NULL}, {.null = NULL}, "whether a value is an integer"}, - {"islist", 1, 1, 0, OP_ISLIST, 0, 0, + {"islist", 1, 1, 0, OP_ISLIST, {.null = NULL}, {.null = NULL}, "whether a value is a list"}, - {"ismat", 1, 1, 0, OP_ISMAT, 0, 0, + {"ismat", 1, 1, 0, OP_ISMAT, {.null = NULL}, {.null = NULL}, "whether a value is a matrix"}, - {"ismult", 2, 2, 0, OP_NOP, f_ismult, 0, + {"ismult", 2, 2, 0, OP_NOP, {.numfunc_2 = f_ismult}, {.null = NULL}, "whether a is a multiple of b"}, - {"isnull", 1, 1, 0, OP_ISNULL, 0, 0, + {"isnull", 1, 1, 0, OP_ISNULL, {.null = NULL}, {.null = NULL}, "whether a value is the null value"}, - {"isnum", 1, 1, 0, OP_ISNUM, 0, 0, + {"isnum", 1, 1, 0, OP_ISNUM, {.null = NULL}, {.null = NULL}, "whether a value is a number"}, - {"isobj", 1, 1, 0, OP_ISOBJ, 0, 0, + {"isobj", 1, 1, 0, OP_ISOBJ, {.null = NULL}, {.null = NULL}, "whether a value is an object"}, - {"isobjtype", 1, 1, 0, OP_ISOBJTYPE, 0,0, + {"isobjtype", 1, 1, 0, OP_ISOBJTYPE, {.null = NULL}, {.null = NULL}, "whether a string names an object type"}, - {"isodd", 1, 1, 0, OP_ISODD, 0, 0, + {"isodd", 1, 1, 0, OP_ISODD, {.null = NULL}, {.null = NULL}, "whether a value is an odd integer"}, - {"isoctet", 1, 1, 0, OP_ISOCTET, 0, 0, + {"isoctet", 1, 1, 0, OP_ISOCTET, {.null = NULL}, {.null = NULL}, "whether a value is an octet"}, - {"isprime", 1, 2, 0, OP_NOP, f_isprime, 0, + {"isprime", 1, 2, 0, OP_NOP, {.numfunc_cnt = f_isprime}, {.null = NULL}, "whether a is a small prime, return b if error"}, - {"isptr", 1, 1, 0, OP_ISPTR, 0, 0, + {"isptr", 1, 1, 0, OP_ISPTR, {.null = NULL}, {.null = NULL}, "whether a value is a pointer"}, - {"isqrt", 1, 1, 0, OP_NOP, qisqrt, 0, + {"isqrt", 1, 1, 0, OP_NOP, {.numfunc_1 = qisqrt}, {.null = NULL}, "integer part of square root"}, - {"isrand", 1, 1, 0, OP_ISRAND, 0, 0, + {"isrand", 1, 1, 0, OP_ISRAND, {.null = NULL}, {.null = NULL}, "whether a value is a subtractive 100 state"}, - {"israndom", 1, 1, 0, OP_ISRANDOM, 0, 0, + {"israndom", 1, 1, 0, OP_ISRANDOM, {.null = NULL}, {.null = NULL}, "whether a value is a Blum state"}, - {"isreal", 1, 1, 0, OP_ISREAL, 0, 0, + {"isreal", 1, 1, 0, OP_ISREAL, {.null = NULL}, {.null = NULL}, "whether a value is a real number"}, - {"isrel", 2, 2, 0, OP_NOP, f_isrel, 0, + {"isrel", 2, 2, 0, OP_NOP, {.numfunc_2 = f_isrel}, {.null = NULL}, "whether two numbers are relatively prime"}, - {"isstr", 1, 1, 0, OP_ISSTR, 0, 0, + {"isstr", 1, 1, 0, OP_ISSTR, {.null = NULL}, {.null = NULL}, "whether a value is a string"}, - {"issimple", 1, 1, 0, OP_ISSIMPLE, 0, 0, + {"issimple", 1, 1, 0, OP_ISSIMPLE, {.null = NULL}, {.null = NULL}, "whether value is a simple type"}, - {"issq", 1, 1, 0, OP_NOP, f_issquare, 0, + {"issq", 1, 1, 0, OP_NOP, {.numfunc_1 = f_issquare}, {.null = NULL}, "whether or not number is a square"}, - {"istype", 2, 2, 0, OP_ISTYPE, 0, 0, + {"istype", 2, 2, 0, OP_ISTYPE, {.null = NULL}, {.null = NULL}, "whether the type of a is same as the type of b"}, - {"jacobi", 2, 2, 0, OP_NOP, qjacobi, 0, - "-1 => a is not quadratic residue mod b\n" - "\t\t\t1 => b is composite, or a is quad residue of b"}, - {"join", 1, IN, 0, OP_NOP, 0, f_join, + {"jacobi", 2, 2, 0, OP_NOP, {.numfunc_2 = qjacobi}, {.null = NULL}, + "-1 = > a is not quadratic residue mod b\n" + "\t\t\t1 = > b is composite, or a is quad residue of b"}, + {"join", 1, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_join}, "join one or more lists into one list"}, - {"lcm", 1, IN, 0, OP_NOP, f_lcm, 0, + {"lcm", 1, IN, 0, OP_NOP, {.numfunc_cnt = f_lcm}, {.null = NULL}, "least common multiple"}, - {"lcmfact", 1, 1, 0, OP_NOP, qlcmfact, 0, + {"lcmfact", 1, 1, 0, OP_NOP, {.numfunc_1 = qlcmfact}, {.null = NULL}, "lcm of all integers up till number"}, - {"lfactor", 2, 2, 0, OP_NOP, qlowfactor, 0, + {"lfactor", 2, 2, 0, OP_NOP, {.numfunc_2 = qlowfactor}, {.null = NULL}, "lowest prime factor of a in first b primes"}, - {"links", 1, 1, 0, OP_LINKS, 0, 0, + {"links", 1, 1, 0, OP_LINKS, {.null = NULL}, {.null = NULL}, "links to number or string value"}, - {"list", 0, IN, 0, OP_NOP, 0, f_list, + {"list", 0, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_list}, "create list of specified values"}, - {"ln", 1, 2, 0, OP_NOP, 0, f_ln, + {"ln", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_ln}, "natural logarithm of value a within accuracy b"}, - {"log", 1, 2, 0, OP_NOP, 0, f_log, + {"log", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_log}, "base 10 logarithm of value a within accuracy b"}, - {"lowbit", 1, 1, 0, OP_LOWBIT, 0, 0, + {"lowbit", 1, 1, 0, OP_LOWBIT, {.null = NULL}, {.null = NULL}, "low bit number in base 2 representation"}, - {"ltol", 1, 2, FE, OP_NOP, f_legtoleg, 0, + {"ltol", 1, 2, FE, OP_NOP, {.numfunc_2 = f_legtoleg}, {.null = NULL}, "leg-to-leg of unit right triangle (sqrt(1 - a^2))"}, - {"makelist", 1, 1, 0, OP_NOP, 0, f_makelist, + {"makelist", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_makelist}, "create a list with a null elements"}, - {"matdim", 1, 1, 0, OP_NOP, 0, f_matdim, + {"matdim", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_matdim}, "number of dimensions of matrix"}, - {"matfill", 2, 3, FA, OP_NOP, 0, f_matfill, + {"matfill", 2, 3, FA, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_matfill}, "fill matrix with value b (value c on diagonal)"}, - {"matmax", 2, 2, 0, OP_NOP, 0, f_matmax, + {"matmax", 2, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_2 = f_matmax}, "maximum index of matrix a dim b"}, - {"matmin", 2, 2, 0, OP_NOP, 0, f_matmin, + {"matmin", 2, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_2 = f_matmin}, "minimum index of matrix a dim b"}, - {"matsum", 1, 1, 0, OP_NOP, 0, f_matsum, + {"matsum", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_matsum}, "sum the numeric values in a matrix"}, - {"mattrace", 1, 1, 0, OP_NOP, 0, f_mattrace, + {"mattrace", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_mattrace}, "return the trace of a square matrix"}, - {"mattrans", 1, 1, 0, OP_NOP, 0, f_mattrans, + {"mattrans", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_mattrans}, "transpose of matrix"}, - {"max", 0, IN, 0, OP_NOP, 0, f_max, + {"max", 0, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_max}, "maximum value"}, - {"memsize", 1, 1, 0, OP_NOP, 0, f_memsize, + {"memsize", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_memsize}, "number of octets used by the value, including overhead"}, - {"meq", 3, 3, 0, OP_NOP, f_meq, 0, + {"meq", 3, 3, 0, OP_NOP, {.numfunc_3 = f_meq}, {.null = NULL}, "whether a and b are equal modulo c"}, - {"min", 0, IN, 0, OP_NOP, 0, f_min, + {"min", 0, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_min}, "minimum value"}, - {"minv", 2, 2, 0, OP_NOP, qminv, 0, + {"minv", 2, 2, 0, OP_NOP, {.numfunc_2 = qminv}, {.null = NULL}, "inverse of a modulo b"}, - {"mmin", 2, 2, 0, OP_NOP, 0, f_mmin, + {"mmin", 2, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_2 = f_mmin}, "a mod b value with smallest abs value"}, - {"mne", 3, 3, 0, OP_NOP, f_mne, 0, + {"mne", 3, 3, 0, OP_NOP, {.numfunc_3 = f_mne}, {.null = NULL}, "whether a and b are not equal modulo c"}, - {"mod", 2, 3, 0, OP_NOP, 0, f_mod, + {"mod", 2, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_mod}, "residue of a modulo b, rounding type c"}, - {"modify", 2, 2, FA, OP_NOP, 0, f_modify, + {"modify", 2, 2, FA, OP_NOP, {.null = NULL}, {.valfunc_2 = f_modify}, "modify elements of a list or matrix"}, - {"name", 1, 1, 0, OP_NOP, 0, f_name, + {"name", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_name}, "name assigned to block or file"}, - {"near", 2, 3, 0, OP_NOP, f_near, 0, + {"near", 2, 3, 0, OP_NOP, {.numfunc_cnt = f_near}, {.null = NULL}, "sign of (abs(a-b) - c)"}, - {"newerror", 0, 1, 0, OP_NOP, 0, f_newerror, + {"newerror", 0, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_newerror}, "create new error type with message a"}, - {"nextcand", 1, 5, 0, OP_NOP, f_nextcand, 0, - "smallest value == d mod e > a, ptest(a,b,c) true"}, - {"nextprime", 1, 2, 0, OP_NOP, f_nprime, 0, + {"nextcand", 1, 5, 0, OP_NOP, {.numfunc_cnt = f_nextcand}, {.null = NULL}, + "smallest value = = d mod e > a, ptest(a,b,c) true"}, + {"nextprime", 1, 2, 0, OP_NOP, {.numfunc_cnt = f_nprime}, {.null = NULL}, "return next small prime, return b if err"}, - {"norm", 1, 1, 0, OP_NORM, 0, 0, + {"norm", 1, 1, 0, OP_NORM, {.null = NULL}, {.null = NULL}, "norm of a value (square of absolute value)"}, - {"null", 0, IN, 0, OP_NOP, 0, f_null, + {"null", 0, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_null}, "null value"}, - {"num", 1, 1, 0, OP_NUMERATOR, qnum, 0, + {"num", 1, 1, 0, OP_NUMERATOR, {.numfunc_1 = qnum}, {.null = NULL}, "numerator of fraction"}, - {"ord", 1, 1, 0, OP_NOP, 0, f_ord, + {"ord", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_ord}, "integer corresponding to character value"}, - {"isupper", 1, 1, 0, OP_NOP, 0, f_isupper, + {"isupper", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_isupper}, "whether character is upper case"}, - {"islower", 1, 1, 0, OP_NOP, 0, f_islower, + {"islower", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_islower}, "whether character is lower case"}, - {"isalnum", 1, 1, 0, OP_NOP, 0, f_isalnum, + {"isalnum", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_isalnum}, "whether character is alpha-numeric"}, - {"isalpha", 1, 1, 0, OP_NOP, 0, f_isalpha, + {"isalpha", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_isalpha}, "whether character is alphabetic"}, - {"iscntrl", 1, 1, 0, OP_NOP, 0, f_iscntrl, + {"iscntrl", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_iscntrl}, "whether character is a control character"}, - {"isdigit", 1, 1, 0, OP_NOP, 0, f_isdigit, + {"isdigit", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_isdigit}, "whether character is a digit"}, - {"isgraph", 1, 1, 0, OP_NOP, 0, f_isgraph, + {"isgraph", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_isgraph}, "whether character is a graphical character"}, - {"isprint", 1, 1, 0, OP_NOP, 0, f_isprint, + {"isprint", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_isprint}, "whether character is printable"}, - {"ispunct", 1, 1, 0, OP_NOP, 0, f_ispunct, + {"ispunct", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_ispunct}, "whether character is a punctuation"}, - {"isspace", 1, 1, 0, OP_NOP, 0, f_isspace, + {"isspace", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_isspace}, "whether character is a space character"}, - {"isxdigit", 1, 1, 0, OP_NOP, 0, f_isxdigit, + {"isxdigit", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_isxdigit}, "whether character is a hexadecimal digit"}, - {"param", 1, 1, 0, OP_ARGVALUE, 0, 0, + {"param", 1, 1, 0, OP_ARGVALUE, {.null = NULL}, {.null = NULL}, "value of parameter n (or parameter count if n\n" "\t\t\tis zero)"}, - {"perm", 2, 2, 0, OP_NOP, qperm, 0, + {"perm", 2, 2, 0, OP_NOP, {.numfunc_2 = qperm}, {.null = NULL}, "permutation number a!/(a-b)!"}, - {"prevcand", 1, 5, 0, OP_NOP, f_prevcand, 0, - "largest value == d mod e < a, ptest(a,b,c) true"}, - {"prevprime", 1, 2, 0, OP_NOP, f_pprime, 0, + {"prevcand", 1, 5, 0, OP_NOP, {.numfunc_cnt = f_prevcand}, {.null = NULL}, + "largest value = = d mod e < a, ptest(a,b,c) true"}, + {"prevprime", 1, 2, 0, OP_NOP, {.numfunc_cnt = f_pprime}, {.null = NULL}, "return previous small prime, return b if err"}, - {"pfact", 1, 1, 0, OP_NOP, qpfact, 0, + {"pfact", 1, 1, 0, OP_NOP, {.numfunc_1 = qpfact}, {.null = NULL}, "product of primes up till number"}, - {"pi", 0, 1, FE, OP_NOP, qpi, 0, + {"pi", 0, 1, FE, OP_NOP, {.numfunc_1 = qpi}, {.null = NULL}, "value of pi accurate to within epsilon"}, - {"pix", 1, 2, 0, OP_NOP, f_pix, 0, - "number of primes <= a < 2^32, return b if error"}, - {"places", 1, 2, 0, OP_NOP, 0, f_places, + {"pix", 1, 2, 0, OP_NOP, {.numfunc_cnt = f_pix}, {.null = NULL}, + "number of primes < = a < 2^32, return b if error"}, + {"places", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_places}, "places after \"decimal\" point (-1 if infinite)"}, - {"pmod", 3, 3, 0, OP_NOP, qpowermod,0, + {"pmod", 3, 3, 0, OP_NOP, {.numfunc_3 = qpowermod}, {.null = NULL}, "mod of a power (a ^ b (mod c))"}, - {"polar", 2, 3, 0, OP_NOP, 0, f_polar, + {"polar", 2, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_polar}, "complex value of polar coordinate (a * exp(b*1i))"}, - {"poly", 1, IN, 0, OP_NOP, 0, f_poly, + {"poly", 1, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_poly}, "evaluates a polynomial given its coefficients\n" "\t\t\tor coefficient-list"}, - {"pop", 1, 1, FA, OP_NOP, 0, f_listpop, + {"pop", 1, 1, FA, OP_NOP, {.null = NULL}, {.valfunc_1 = f_listpop}, "pop value from front of list"}, - {"popcnt", 1, 2, 0, OP_NOP, f_popcnt, 0, + {"popcnt", 1, 2, 0, OP_NOP, {.numfunc_cnt = f_popcnt}, {.null = NULL}, "number of bits in a that match b (or 1)"}, - {"power", 2, 3, 0, OP_NOP, 0, f_power, + {"power", 2, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_power}, "value a raised to the power b within accuracy c"}, - {"protect", 1, 3, FA, OP_NOP, 0, f_protect, + {"protect", 1, 3, FA, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_protect}, "read or set protection level for variable"}, - {"ptest", 1, 3, 0, OP_NOP, f_primetest, 0, + {"ptest", 1, 3, 0, OP_NOP, {.numfunc_cnt = f_primetest}, {.null = NULL}, "probabilistic primality test"}, - {"printf", 1, IN, 0, OP_NOP, 0, f_printf, + {"printf", 1, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_printf}, "print formatted output to stdout"}, - {"prompt", 1, 1, 0, OP_NOP, 0, f_prompt, + {"prompt", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_prompt}, "prompt for input line using value a"}, - {"push", 1, IN, FA, OP_NOP, 0, f_listpush, + {"push", 1, IN, FA, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_listpush}, "push values onto front of list"}, - {"putenv", 1, 2, 0, OP_NOP, 0, f_putenv, + {"putenv", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_putenv}, "define an environment variable"}, - {"quo", 2, 3, 0, OP_NOP, 0, f_quo, + {"quo", 2, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_quo}, "integer quotient of a by b, rounding type c"}, - {"quomod", 4, 5, FA, OP_NOP, 0, f_quomod, + {"quomod", 4, 5, FA, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_quomod}, "set c and d to quotient and remainder of a\n" "\t\t\tdivided by b"}, - {"r2d", 1, 2, 0, OP_NOP, 0, f_r2d, + {"r2d", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_r2d}, "convert radians to degrees"}, - {"r2g", 1, 2, 0, OP_NOP, 0, f_r2g, + {"r2g", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_r2g}, "convert radians to gradians"}, - {"rand", 0, 2, 0, OP_NOP, f_rand, 0, + {"rand", 0, 2, 0, OP_NOP, {.numfunc_cnt = f_rand}, {.null = NULL}, "subtractive 100 random number [0,2^64), [0,a), or [a,b)"}, - {"randbit", 0, 1, 0, OP_NOP, f_randbit, 0, + {"randbit", 0, 1, 0, OP_NOP, {.numfunc_cnt = f_randbit}, {.null = NULL}, "subtractive 100 random number [0,2^a)"}, - {"random", 0, 2, 0, OP_NOP, f_random, 0, + {"random", 0, 2, 0, OP_NOP, {.numfunc_cnt = f_random}, {.null = NULL}, "Blum-Blum-Shub random number [0,2^64), [0,a), or [a,b)"}, - {"randombit", 0, 1, 0, OP_NOP, f_randombit, 0, + {"randombit", 0, 1, 0, OP_NOP, {.numfunc_cnt = f_randombit}, {.null = NULL}, "Blum-Blum-Sub random number [0,2^a)"}, - {"randperm", 1, 1, 0, OP_NOP, 0, f_randperm, + {"randperm", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_randperm}, "random permutation of a list or matrix"}, - {"rcin", 2, 2, 0, OP_NOP, qredcin, 0, + {"rcin", 2, 2, 0, OP_NOP, {.numfunc_2 = qredcin}, {.null = NULL}, "convert normal number a to REDC number mod b"}, - {"rcmul", 3, 3, 0, OP_NOP, qredcmul, 0, + {"rcmul", 3, 3, 0, OP_NOP, {.numfunc_3 = qredcmul}, {.null = NULL}, "multiply REDC numbers a and b mod c"}, - {"rcout", 2, 2, 0, OP_NOP, qredcout, 0, + {"rcout", 2, 2, 0, OP_NOP, {.numfunc_2 = qredcout}, {.null = NULL}, "convert REDC number a mod b to normal number"}, - {"rcpow", 3, 3, 0, OP_NOP, qredcpower, 0, + {"rcpow", 3, 3, 0, OP_NOP, {.numfunc_3 = qredcpower}, {.null = NULL}, "raise REDC number a to power b mod c"}, - {"rcsq", 2, 2, 0, OP_NOP, qredcsquare, 0, + {"rcsq", 2, 2, 0, OP_NOP, {.numfunc_2 = qredcsquare}, {.null = NULL}, "square REDC number a mod b"}, - {"re", 1, 1, 0, OP_RE, 0, 0, + {"re", 1, 1, 0, OP_RE, {.null = NULL}, {.null = NULL}, "real part of complex number"}, - {"remove", 1, 1, FA, OP_NOP, 0, f_listremove, + {"remove", 1, 1, FA, OP_NOP, {.null = NULL}, {.valfunc_1 = f_listremove}, "remove value from end of list"}, - {"reverse", 1, 1, 0, OP_NOP, 0, f_reverse, + {"reverse", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_reverse}, "reverse a copy of a matrix or list"}, - {"rewind", 0, IN, 0, OP_NOP, 0, f_rewind, + {"rewind", 0, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_rewind}, "rewind file(s)"}, - {"rm", 1, IN, 0, OP_NOP, 0, f_rm, + {"rm", 1, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_rm}, "remove file(s), -f turns off no-such-file errors"}, - {"root", 2, 3, 0, OP_NOP, 0, f_root, + {"root", 2, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_root}, "value a taken to the b'th root within accuracy c"}, - {"round", 1, 3, 0, OP_NOP, 0, f_round, + {"round", 1, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_round}, "round value a to b number of decimal places"}, - {"rsearch", 2, 4, 0, OP_NOP, 0, f_rsearch, + {"rsearch", 2, 4, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_rsearch}, "reverse search matrix or list for value b\n" "\t\t\tstarting at index c"}, - {"runtime", 0, 0, 0, OP_NOP, f_runtime, 0, + {"runtime", 0, 0, 0, OP_NOP, {.numfunc_0 = f_runtime}, {.null = NULL}, "user and kernel mode CPU time in seconds"}, - {"saveval", 1, 1, 0, OP_SAVEVAL, 0, 0, + {"saveval", 1, 1, 0, OP_SAVEVAL, {.null = NULL}, {.null = NULL}, "set flag for saving values"}, - {"scale", 2, 2, 0, OP_SCALE, 0, 0, + {"scale", 2, 2, 0, OP_SCALE, {.null = NULL}, {.null = NULL}, "scale value up or down by a power of two"}, - {"scan", 1, IN, FA, OP_NOP, 0, f_scan, + {"scan", 1, IN, FA, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_scan}, "scan standard input for assignment to one\n" "\t\t\tor more variables"}, - {"scanf", 2, IN, FA, OP_NOP, 0, f_scanf, + {"scanf", 2, IN, FA, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_scanf}, "formatted scan of standard input for assignment\n" "\t\t\tto variables"}, - {"search", 2, 4, 0, OP_NOP, 0, f_search, + {"search", 2, 4, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_search}, "search matrix or list for value b starting\n" "\t\t\tat index c"}, - {"sec", 1, 2, 0, OP_NOP, 0, f_sec, + {"sec", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_sec}, "sec of a within accuracy b"}, - {"sech", 1, 2, 0, OP_NOP, 0, f_sech, + {"sech", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_sech}, "hyperbolic secant of a within accuracy b"}, - {"seed", 0, 0, 0, OP_NOP, f_seed, 0, + {"seed", 0, 0, 0, OP_NOP, {.numfunc_0 = f_seed}, {.null = NULL}, "return a 64 bit seed for a pseudo-random generator"}, - {"segment", 2, 3, 0, OP_NOP, 0, f_segment, + {"segment", 2, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_segment}, "specified segment of specified list"}, - {"select", 2, 2, 0, OP_NOP, 0, f_select, + {"select", 2, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_2 = f_select}, "form sublist of selected elements from list"}, - {"setbit", 2, 3, 0, OP_NOP, 0, f_setbit, + {"setbit", 2, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_setbit}, "set specified bit in string"}, - {"sgn", 1, 1, 0, OP_SGN, qsign, 0, + {"sgn", 1, 1, 0, OP_SGN, {.numfunc_1 = qsign}, {.null = NULL}, "sign of value (-1, 0, 1)"}, - {"sha1", 0, IN, 0, OP_NOP, 0, f_sha1, + {"sha1", 0, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_sha1}, "Secure Hash Algorithm (SHS-1 FIPS Pub 180-1)"}, - {"sin", 1, 2, 0, OP_NOP, 0, f_sin, + {"sin", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_sin}, "sine of value a within accuracy b"}, - {"sinh", 1, 2, 0, OP_NOP, 0, f_sinh, + {"sinh", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_sinh}, "hyperbolic sine of a within accuracy b"}, - {"size", 1, 1, 0, OP_NOP, 0, f_size, + {"size", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_size}, "total number of elements in value"}, - {"sizeof", 1, 1, 0, OP_NOP, 0, f_sizeof, + {"sizeof", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_sizeof}, "number of octets used to hold the value"}, - {"sleep", 0, 1, 0, OP_NOP, 0, f_sleep, + {"sleep", 0, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_sleep}, "suspend operation for a seconds"}, - {"sort", 1, 1, 0, OP_NOP, 0, f_sort, + {"sort", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_sort}, "sort a copy of a matrix or list"}, - {"sqrt", 1, 3, 0, OP_NOP, 0, f_sqrt, + {"sqrt", 1, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_sqrt}, "square root of value a within accuracy b"}, - {"srand", 0, 1, 0, OP_NOP, 0, f_srand, + {"srand", 0, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_srand}, "seed the rand() function"}, - {"srandom", 0, 4, 0, OP_NOP, 0, f_srandom, + {"srandom", 0, 4, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_srandom}, "seed the random() function"}, - {"ssq", 1, IN, 0, OP_NOP, 0, f_ssq, + {"ssq", 1, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_ssq}, "sum of squares of values"}, - {"stoponerror", 0, 1, 0, OP_NOP, 0, f_stoponerror, + {"stoponerror", 0, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_stoponerror}, "assign value to stoponerror flag"}, - {"str", 1, 1, 0, OP_NOP, 0, f_str, + {"str", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_str}, "simple value converted to string"}, - {"strtoupper", 1, 1, 0, OP_NOP, 0, f_strtoupper, + {"strtoupper", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_strtoupper}, "Make string upper case"}, - {"strtolower", 1, 1, 0, OP_NOP, 0, f_strtolower, + {"strtolower", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_strtolower}, "Make string lower case"}, - {"strcat", 1,IN, 0, OP_NOP, 0, f_strcat, + {"strcat", 1,IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_strcat}, "concatenate strings together"}, - {"strcmp", 2, 2, 0, OP_NOP, 0, f_strcmp, + {"strcmp", 2, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_2 = f_strcmp}, "compare two strings"}, - {"strcasecmp", 2, 2, 0, OP_NOP, 0, f_strcasecmp, + {"strcasecmp", 2, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_2 = f_strcasecmp}, "compare two strings case independent"}, - {"strcpy", 2, 2, 0, OP_NOP, 0, f_strcpy, + {"strcpy", 2, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_2 = f_strcpy}, "copy string to string"}, - {"strerror", 0, 1, 0, OP_NOP, 0, f_strerror, + {"strerror", 0, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_strerror}, "string describing error type"}, - {"strlen", 1, 1, 0, OP_NOP, 0, f_strlen, + {"strlen", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_strlen}, "length of string"}, - {"strncmp", 3, 3, 0, OP_NOP, 0, f_strncmp, + {"strncmp", 3, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_3 = f_strncmp}, "compare strings a, b to c characters"}, - {"strncasecmp", 3, 3, 0, OP_NOP, 0, f_strncasecmp, + {"strncasecmp", 3, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_3 = f_strncasecmp}, "compare strings a, b to c characters case independent"}, - {"strncpy", 3, 3, 0, OP_NOP, 0, f_strncpy, + {"strncpy", 3, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_3 = f_strncpy}, "copy up to c characters from string to string"}, - {"strpos", 2, 2, 0, OP_NOP, 0, f_strpos, + {"strpos", 2, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_2 = f_strpos}, "index of first occurrence of b in a"}, - {"strprintf", 1, IN, 0, OP_NOP, 0, f_strprintf, + {"strprintf", 1, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_strprintf}, "return formatted output as a string"}, - {"strscan", 2, IN, FA, OP_NOP, 0, f_strscan, + {"strscan", 2, IN, FA, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_strscan}, "scan a string for assignments to one or more variables"}, - {"strscanf", 2, IN, FA, OP_NOP, 0, f_strscanf, + {"strscanf", 2, IN, FA, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_strscanf}, "formatted scan of string for assignments to variables"}, - {"substr", 3, 3, 0, OP_NOP, 0, f_substr, + {"substr", 3, 3, 0, OP_NOP, {.null = NULL}, {.valfunc_3 = f_substr}, "substring of a from position b for c chars"}, - {"sum", 0, IN, 0, OP_NOP, 0, f_sum, + {"sum", 0, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_sum}, "sum of list or object sums and/or other terms"}, - {"swap", 2, 2, 0, OP_SWAP, 0, 0, + {"swap", 2, 2, 0, OP_SWAP, {.null = NULL}, {.null = NULL}, "swap values of variables a and b (can be dangerous)"}, - {"system", 1, 1, 0, OP_NOP, 0, f_system, + {"system", 1, 1, 0, OP_NOP, {.null = NULL}, {.valfunc_1 = f_system}, "call Unix command"}, - {"systime", 0, 0, 0, OP_NOP, f_systime, 0, + {"systime", 0, 0, 0, OP_NOP, {.numfunc_0 = f_systime}, {.null = NULL}, "kernel mode CPU time in seconds"}, - {"tail", 2, 2, 0, OP_NOP, 0, f_tail, + {"tail", 2, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_2 = f_tail}, "retain list of specified number at tail of list"}, - {"tan", 1, 2, 0, OP_NOP, 0, f_tan, + {"tan", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_tan}, "tangent of a within accuracy b"}, - {"tanh", 1, 2, 0, OP_NOP, 0, f_tanh, + {"tanh", 1, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_tanh}, "hyperbolic tangent of a within accuracy b"}, - {"test", 1, 1, 0, OP_TEST, 0, 0, + {"test", 1, 1, 0, OP_TEST, {.null = NULL}, {.null = NULL}, "test that value is nonzero"}, - {"time", 0, 0, 0, OP_NOP, f_time, 0, + {"time", 0, 0, 0, OP_NOP, {.numfunc_0 = f_time}, {.null = NULL}, "number of seconds since 00:00:00 1 Jan 1970 UTC"}, - {"trunc", 1, 2, 0, OP_NOP, f_trunc, 0, + {"trunc", 1, 2, 0, OP_NOP, {.numfunc_cnt = f_trunc}, {.null = NULL}, "truncate a to b number of decimal places"}, - {"ungetc", 2, 2, 0, OP_NOP, 0, f_ungetc, + {"ungetc", 2, 2, 0, OP_NOP, {.null = NULL}, {.valfunc_2 = f_ungetc}, "unget char read from file"}, - {"usertime", 0, 0, 0, OP_NOP, f_usertime, 0, + {"usertime", 0, 0, 0, OP_NOP, {.numfunc_0 = f_usertime}, {.null = NULL}, "user mode CPU time in seconds"}, - {"version", 0, 0, 0, OP_NOP, 0, f_version, + {"version", 0, 0, 0, OP_NOP, {.null = NULL}, {.valfunc_0 = f_version}, "calc version string"}, - {"xor", 1, IN, 0, OP_NOP, 0, f_xor, + {"xor", 1, IN, 0, OP_NOP, {.null = NULL}, {.valfunc_cnt = f_xor}, "logical xor"}, /* end of table */ - {NULL, 0, 0, 0, 0, 0, 0, + {NULL, 0, 0, 0, 0, {.null = NULL}, {.null = NULL}, NULL} }; @@ -10537,9 +10562,8 @@ STATIC CONST struct builtin builtins[] = { * See the builtin rule in the help/Makefile for details. */ #if defined(FUNCLIST) -/*ARGSUSED*/ int -main(int argc, char *argv[]) +main(void) { CONST struct builtin *bp; /* current function */ @@ -10642,18 +10666,18 @@ builtinfunc(long index, int argcount, VALUE *stck) /* * Handle general values if the function accepts them. */ - if (bp->b_valfunc) { + if (bp->b_valfunc.null != NULL) { vpp = valargs; if ((bp->b_minargs == 1) && (bp->b_maxargs == 1)) - result = (*bp->b_valfunc)(vpp[0]); + result = (*bp->b_valfunc.valfunc_1)(vpp[0]); else if ((bp->b_minargs == 2) && (bp->b_maxargs == 2)) - result = (*bp->b_valfunc)(vpp[0], vpp[1]); + result = (*bp->b_valfunc.valfunc_2)(vpp[0], vpp[1]); else if ((bp->b_minargs == 3) && (bp->b_maxargs == 3)) - result = (*bp->b_valfunc)(vpp[0], vpp[1], vpp[2]); + result = (*bp->b_valfunc.valfunc_3)(vpp[0], vpp[1], vpp[2]); else if ((bp->b_minargs == 4) && (bp->b_maxargs == 4)) - result = (*bp->b_valfunc)(vpp[0],vpp[1],vpp[2],vpp[3]); + result = (*bp->b_valfunc.valfunc_4)(vpp[0],vpp[1],vpp[2],vpp[3]); else - result = (*bp->b_valfunc)(argcount, vpp); + result = (*bp->b_valfunc.valfunc_cnt)(argcount, vpp); return result; } /* @@ -10672,7 +10696,7 @@ builtinfunc(long index, int argcount, VALUE *stck) result.v_type = V_NUM; result.v_subtype = V_NOSUBTYPE; if (!(bp->b_flags & FE) && (bp->b_minargs != bp->b_maxargs)) { - result.v_num = (*bp->b_numfunc)(argcount, numargs); + result.v_num = (*bp->b_numfunc.numfunc_cnt)(argcount, numargs); return result; } if ((bp->b_flags & FE) && (argcount < bp->b_maxargs)) @@ -10680,20 +10704,20 @@ builtinfunc(long index, int argcount, VALUE *stck) switch (argcount) { case 0: - result.v_num = (*bp->b_numfunc)(); + result.v_num = (*bp->b_numfunc.numfunc_0)(); break; case 1: - result.v_num = (*bp->b_numfunc)(numargs[0]); + result.v_num = (*bp->b_numfunc.numfunc_1)(numargs[0]); break; case 2: - result.v_num = (*bp->b_numfunc)(numargs[0], numargs[1]); + result.v_num = (*bp->b_numfunc.numfunc_2)(numargs[0], numargs[1]); break; case 3: - result.v_num = (*bp->b_numfunc)(numargs[0], + result.v_num = (*bp->b_numfunc.numfunc_3)(numargs[0], numargs[1], numargs[2]); break; case 4: - result.v_num = (*bp->b_numfunc)(numargs[0], numargs[1], + result.v_num = (*bp->b_numfunc.numfunc_4)(numargs[0], numargs[1], numargs[2], numargs[3]); break; default: diff --git a/have_statfs.c b/have_statfs.c new file mode 100644 index 0000000..eacb66a --- /dev/null +++ b/have_statfs.c @@ -0,0 +1,82 @@ +/* + * have_statfs - Determine if we have statfs() + * + * Copyright (C) 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 + * as published by the Free Software Foundation. + * + * Calc is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General + * Public License for more details. + * + * A copy of version 2.1 of the GNU Lesser General Public License is + * distributed with calc under the filename COPYING-LGPL. You should have + * received a copy with calc; if not, write to Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Under source code control: 2023/03/06 00:51:53 + * File existed as early as: 2023 + * + * chongo /\oo/\ http://www.isthe.com/chongo/ + * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ + */ + +/* + * usage: + * have_statfs + * + * Not all systems have the statfs() function, so this may not + * compile on your system. + * + * This prog outputs several defines: + * + * HAVE_STATFS + * defined ==> use statfs() + * undefined ==> do not call or cannot call statfs() + */ + +#include +#include +#include + +#include "have_sys_vfs.h" +#if defined(HAVE_SYS_VFS_H) +# include +#endif /* HAVE_SYS_VFS_H */ + +#include "have_sys_param.h" +#if defined(HAVE_SYS_PARAM_H) +# include +#endif /* HAVE_SYS_PARAM_H */ + +#include "have_sys_mount.h" +#if defined(HAVE_SYS_MOUNT_H) +# include +#endif /* HAVE_SYS_MOUNT_H */ + +#include "banned.h" /* include after system header <> includes */ + + +int +main(void) +{ +#if defined(HAVE_NO_STATFS) + + printf("#undef HAVE_STATFS /* no */\n"); + +#else /* HAVE_NO_STATFS */ + + struct statfs statfs_dot; /* usage stat of "." */ + + (void) statfs(".", &statfs_dot); + + printf("#define HAVE_STATFS /* yes */\n"); + +#endif /* HAVE_NO_STATFS */ + + /* exit(0); */ + return 0; +} diff --git a/help/Makefile b/help/Makefile index e436fc6..88ea564 100644 --- a/help/Makefile +++ b/help/Makefile @@ -247,7 +247,7 @@ CHMOD= chmod CMP= cmp CP= cp FMT= fmt -GREP= egrep +GREP= grep ICFLAGS= ILDFLAGS= LCC= cc @@ -717,7 +717,7 @@ builtin: builtin.top builtin.end ../func.c funclist.sed -I.. funclist.c -c ${S} ${Q} ${LCC} ${ILDFLAGS} funclist.o -o funclist${EXT} ${S} ${Q} ${RM} -f builtin - ${Q} ${GREP} -v '^#' builtin.top > builtin + ${Q} ${GREP} -E -v '^#' builtin.top > builtin ${Q} ./funclist${EXT} | \ ${SED} -e 's/^/ /' -e 's/[ ][ ]*$$//' >> builtin ${Q} ${CAT} builtin.end >> builtin diff --git a/help/credit b/help/credit index 2818af8..1235fcb 100644 --- a/help/credit +++ b/help/credit @@ -26,13 +26,22 @@ Credits Most of this source and binary has one of the following copyrights: - Copyright (C) year David I. Bell - Copyright (C) year David I. Bell and Landon Curt Noll - Copyright (C) year David I. Bell and Ernest Bowen - Copyright (C) year David I. Bell, Landon Curt Noll and Ernest Bowen - Copyright (C) year Landon Curt Noll - Copyright (C) year Ernest Bowen and Landon Curt Noll - Copyright (C) year Ernest Bowen + Copyright (C) year David I. Bell + Copyright (C) year David I. Bell and Landon Curt Noll + Copyright (C) year David I. Bell and Ernest Bowen + Copyright (C) year David I. Bell, Landon Curt Noll and Ernest Bowen + Copyright (C) year Landon Curt Noll + Copyright (C) year Ernest Bowen and Landon Curt Noll + Copyright (C) year Ernest Bowen + Copyright (C) year Petteri Kettunen and Landon Curt Noll + Copyright (C) year Christoph Zurnieden + Copyright (C) year Landon Curt Noll and Thomas Jones-Low + Copyright (C) year Klaus Alexander Seistrup and Landon Curt Noll + + A few files in calc are covered under "The Unlicense". For more + information on this license, see: + + https://unlicense.org Copying / Calc GNU Lesser General Public License @@ -61,11 +70,11 @@ Copying / Calc GNU Lesser General Public License See also: - help copyright - help copying - help copying-lgpl + help copyright + help copying + help copying-lgpl -## Copyright (C) 1999 Landon Curt Noll +## Copyright (C) 1999,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 diff --git a/opcodes.c b/opcodes.c index 0216f24..a9efab5 100644 --- a/opcodes.c +++ b/opcodes.c @@ -76,7 +76,7 @@ long funcline; /* function line being executed */ */ S_FUNC void showsizes(void); S_FUNC void o_paramaddr(FUNC *fp, int argcnt, VALUE *args, long index); -S_FUNC void o_getvalue(void); +S_FUNC void o_getvalue(FUNC *fp); /* @@ -98,8 +98,22 @@ S_FUNC void o_getvalue(void); /* * opcode - info about each opcode */ +typedef union { + void (*func_nul)(FUNC *); /* OPNUL */ + void (*func_one)(FUNC *, long); /* OPONE */ + void (*func_two)(FUNC *, long, long); /* OPTWO */ + void (*func_jmp)(FUNC *, BOOL *); /* OPJMP */ + void (*func_ret)(FUNC *); /* OPRET */ + void (*func_glb)(FUNC *, GLOBAL *); /* OPGLB */ + void (*func_par)(FUNC *, int, VALUE *, long); /* OPPAR */ + void (*func_loc)(FUNC *, VALUE *, long); /* OPLOC */ + /* has a string constant arg is unused */ /* OPSTR */ + void (*func_arg)(FUNC *, int, VALUE *); /* OPARG */ + void (*func_sti)(FUNC *); /* OPSTI */ +} opfunc; + struct opcode { - void (*o_func)(); /* routine to call for opcode */ + opfunc o_func; /* routine to call for opcode */ int o_type; /* type of opcode */ char *o_name; /* name of opcode */ }; @@ -144,7 +158,7 @@ initstack(void) * The various opcodes */ S_FUNC void -o_nop(void) +o_nop(FUNC *UNUSED(fp)) { } @@ -164,7 +178,6 @@ o_localaddr(FUNC *fp, VALUE *locals, long index) } -/*ARGSUSED*/ S_FUNC void o_globaladdr(FUNC *UNUSED(fp), GLOBAL *sp) { @@ -180,7 +193,6 @@ o_globaladdr(FUNC *UNUSED(fp), GLOBAL *sp) } -/*ARGSUSED*/ S_FUNC void o_paramaddr(FUNC *UNUSED(fp), int argcount, VALUE *args, long index) { @@ -212,7 +224,6 @@ o_localvalue(FUNC *fp, VALUE *locals, long index) } -/*ARGSUSED*/ S_FUNC void o_globalvalue(FUNC *UNUSED(fp), GLOBAL *sp) { @@ -224,7 +235,6 @@ o_globalvalue(FUNC *UNUSED(fp), GLOBAL *sp) } -/*ARGSUSED*/ S_FUNC void o_paramvalue(FUNC *UNUSED(fp), int argcount, VALUE *args, long index) { @@ -269,7 +279,6 @@ o_argvalue(FUNC *fp, int argcount, VALUE *args) } -/*ARGSUSED*/ S_FUNC void o_number(FUNC *UNUSED(fp), long arg) { @@ -287,7 +296,6 @@ o_number(FUNC *UNUSED(fp), long arg) } -/*ARGSUSED*/ S_FUNC void o_imaginary(FUNC *UNUSED(fp), long arg) { @@ -314,7 +322,6 @@ o_imaginary(FUNC *UNUSED(fp), long arg) } -/*ARGSUSED*/ S_FUNC void o_string(FUNC *UNUSED(fp), long arg) { @@ -326,7 +333,7 @@ o_string(FUNC *UNUSED(fp), long arg) S_FUNC void -o_undef(void) +o_undef(FUNC *UNUSED(fp)) { stack++; stack->v_type = V_NULL; @@ -334,7 +341,6 @@ o_undef(void) } -/*ARGSUSED*/ S_FUNC void o_matcreate(FUNC *UNUSED(fp), long dim) { @@ -402,7 +408,6 @@ o_matcreate(FUNC *UNUSED(fp), long dim) } -/*ARGSUSED*/ S_FUNC void o_eleminit(FUNC *UNUSED(fp), long index) { @@ -543,7 +548,6 @@ o_eleminit(FUNC *UNUSED(fp), long index) * dim dimension of matrix * writeflag nonzero if element will be written */ -/*ARGSUSED*/ S_FUNC void o_indexaddr(FUNC *UNUSED(fp), long dim, long writeflag) { @@ -696,7 +700,6 @@ o_indexaddr(FUNC *UNUSED(fp), long dim, long writeflag) } -/*ARGSUSED*/ S_FUNC void o_elemaddr(FUNC *UNUSED(fp), long index) { @@ -751,7 +754,6 @@ o_elemvalue(FUNC *fp, long index) } -/*ARGSUSED*/ S_FUNC void o_objcreate(FUNC *UNUSED(fp), long arg) { @@ -763,7 +765,7 @@ o_objcreate(FUNC *UNUSED(fp), long arg) S_FUNC void -o_assign(void) +o_assign(FUNC *UNUSED(fp)) { VALUE *var; /* variable value */ VALUE *vp; @@ -879,27 +881,27 @@ o_assign(void) S_FUNC void -o_assignback(void) +o_assignback(FUNC *fp) { VALUE tmp; tmp = stack[-1]; stack[-1] = stack[0]; stack[0] = tmp; - o_assign(); + o_assign(fp); } S_FUNC void -o_assignpop(void) +o_assignpop(FUNC *fp) { - o_assign(); + o_assign(fp); stack--; } S_FUNC void -o_ptr(void) +o_ptr(FUNC *UNUSED(fp)) { switch (stack->v_type) { case V_ADDR: @@ -924,7 +926,7 @@ o_ptr(void) S_FUNC void -o_deref(void) +o_deref(FUNC *UNUSED(fp)) { VALUE *vp; @@ -994,7 +996,7 @@ o_deref(void) S_FUNC void -o_swap(void) +o_swap(FUNC *UNUSED(fp)) { VALUE *v1, *v2; /* variables to be swapped */ VALUE tmp; @@ -1034,7 +1036,7 @@ o_swap(void) S_FUNC void -o_add(void) +o_add(FUNC *UNUSED(fp)) { VALUE *v1, *v2; VALUE tmp; @@ -1071,7 +1073,7 @@ o_add(void) S_FUNC void -o_sub(void) +o_sub(FUNC *UNUSED(fp)) { VALUE *v1, *v2; VALUE tmp; @@ -1108,7 +1110,7 @@ o_sub(void) S_FUNC void -o_mul(void) +o_mul(FUNC *UNUSED(fp)) { VALUE *v1, *v2; VALUE tmp; @@ -1144,7 +1146,7 @@ o_mul(void) S_FUNC void -o_power(void) +o_power(FUNC *UNUSED(fp)) { VALUE *v1, *v2; VALUE tmp; @@ -1163,7 +1165,7 @@ o_power(void) S_FUNC void -o_div(void) +o_div(FUNC *UNUSED(fp)) { VALUE *v1, *v2; VALUE tmp; @@ -1199,7 +1201,7 @@ o_div(void) S_FUNC void -o_quo(void) +o_quo(FUNC *UNUSED(fp)) { VALUE *v1, *v2; VALUE tmp, null; @@ -1220,7 +1222,7 @@ o_quo(void) S_FUNC void -o_mod(void) +o_mod(FUNC *UNUSED(fp)) { VALUE *v1, *v2; VALUE tmp, null; @@ -1241,7 +1243,7 @@ o_mod(void) S_FUNC void -o_and(void) +o_and(FUNC *UNUSED(fp)) { VALUE *v1, *v2; VALUE tmp; @@ -1261,7 +1263,7 @@ o_and(void) S_FUNC void -o_or(void) +o_or(FUNC *UNUSED(fp)) { VALUE *v1, *v2; VALUE tmp; @@ -1280,7 +1282,7 @@ o_or(void) } S_FUNC void -o_xor (void) +o_xor(FUNC *UNUSED(fp)) { VALUE *v1, *v2; VALUE tmp; @@ -1301,7 +1303,7 @@ o_xor (void) S_FUNC void -o_comp (void) +o_comp(FUNC *UNUSED(fp)) { VALUE *vp; VALUE tmp; @@ -1316,7 +1318,7 @@ o_comp (void) S_FUNC void -o_not(void) +o_not(FUNC *UNUSED(fp)) { VALUE *vp; VALUE val; @@ -1340,7 +1342,7 @@ o_not(void) S_FUNC void -o_plus (void) +o_plus(FUNC *UNUSED(fp)) { VALUE *vp; VALUE tmp; @@ -1367,7 +1369,7 @@ o_plus (void) S_FUNC void -o_negate(void) +o_negate(FUNC *UNUSED(fp)) { VALUE *vp; NUMBER *q; @@ -1392,7 +1394,7 @@ o_negate(void) S_FUNC void -o_invert(void) +o_invert(FUNC *UNUSED(fp)) { VALUE *vp; VALUE tmp; @@ -1408,7 +1410,7 @@ o_invert(void) S_FUNC void -o_scale(void) +o_scale(FUNC *UNUSED(fp)) { VALUE *v1, *v2; VALUE tmp; @@ -1427,7 +1429,7 @@ o_scale(void) S_FUNC void -o_int(void) +o_int(FUNC *UNUSED(fp)) { VALUE *vp; VALUE tmp; @@ -1442,7 +1444,7 @@ o_int(void) S_FUNC void -o_frac(void) +o_frac(FUNC *UNUSED(fp)) { VALUE *vp; VALUE tmp; @@ -1457,7 +1459,7 @@ o_frac(void) S_FUNC void -o_abs(void) +o_abs(FUNC *UNUSED(fp)) { VALUE *v1, *v2; NUMBER *q; @@ -1492,7 +1494,7 @@ o_abs(void) S_FUNC void -o_norm(void) +o_norm(FUNC *UNUSED(fp)) { VALUE *vp; NUMBER *q; @@ -1517,7 +1519,7 @@ o_norm(void) S_FUNC void -o_square(void) +o_square(FUNC *UNUSED(fp)) { VALUE *vp; NUMBER *q; @@ -1542,7 +1544,7 @@ o_square(void) S_FUNC void -o_test(void) +o_test(FUNC *UNUSED(fp)) { VALUE *vp; int i; @@ -1559,7 +1561,7 @@ o_test(void) S_FUNC void -o_links(void) +o_links(FUNC *UNUSED(fp)) { VALUE *vp; long links; @@ -1591,7 +1593,7 @@ o_links(void) S_FUNC void -o_bit (void) +o_bit(FUNC *UNUSED(fp)) { VALUE *v1, *v2; long index; @@ -1640,7 +1642,7 @@ o_bit (void) } S_FUNC void -o_highbit (void) +o_highbit(FUNC *UNUSED(fp)) { VALUE *vp; long index; @@ -1688,7 +1690,7 @@ o_highbit (void) S_FUNC void -o_lowbit (void) +o_lowbit(FUNC *UNUSED(fp)) { VALUE *vp; long index; @@ -1740,7 +1742,7 @@ o_lowbit (void) S_FUNC void -o_content (void) +o_content(FUNC *UNUSED(fp)) { VALUE *vp; VALUE tmp; @@ -1755,7 +1757,7 @@ o_content (void) S_FUNC void -o_hashop (void) +o_hashop(FUNC *UNUSED(fp)) { VALUE *v1, *v2; VALUE tmp; @@ -1774,7 +1776,7 @@ o_hashop (void) S_FUNC void -o_backslash (void) +o_backslash(FUNC *UNUSED(fp)) { VALUE *vp; VALUE tmp; @@ -1789,7 +1791,7 @@ o_backslash (void) S_FUNC void -o_setminus (void) +o_setminus(FUNC *UNUSED(fp)) { VALUE *v1, *v2; VALUE tmp; @@ -1808,7 +1810,7 @@ o_setminus (void) S_FUNC void -o_istype(void) +o_istype(FUNC *UNUSED(fp)) { VALUE *v1, *v2; int r; @@ -1832,7 +1834,7 @@ o_istype(void) S_FUNC void -o_isint(void) +o_isint(FUNC *UNUSED(fp)) { VALUE *vp; NUMBER *q; @@ -1860,7 +1862,7 @@ o_isint(void) S_FUNC void -o_isnum(void) +o_isnum(FUNC *UNUSED(fp)) { VALUE *vp; @@ -1890,7 +1892,7 @@ o_isnum(void) S_FUNC void -o_ismat(void) +o_ismat(FUNC *UNUSED(fp)) { VALUE *vp; @@ -1912,7 +1914,7 @@ o_ismat(void) S_FUNC void -o_islist(void) +o_islist(FUNC *UNUSED(fp)) { VALUE *vp; int r; @@ -1929,7 +1931,7 @@ o_islist(void) S_FUNC void -o_isobj(void) +o_isobj(FUNC *UNUSED(fp)) { VALUE *vp; int r; @@ -1946,7 +1948,7 @@ o_isobj(void) S_FUNC void -o_isstr(void) +o_isstr(FUNC *UNUSED(fp)) { VALUE *vp; int r; @@ -1963,7 +1965,7 @@ o_isstr(void) S_FUNC void -o_isfile(void) +o_isfile(FUNC *UNUSED(fp)) { VALUE *vp; int r; @@ -1980,7 +1982,7 @@ o_isfile(void) S_FUNC void -o_isrand(void) +o_isrand(FUNC *UNUSED(fp)) { VALUE *vp; int r; @@ -1997,7 +1999,7 @@ o_isrand(void) S_FUNC void -o_israndom(void) +o_israndom(FUNC *UNUSED(fp)) { VALUE *vp; int r; @@ -2014,7 +2016,7 @@ o_israndom(void) S_FUNC void -o_isconfig(void) +o_isconfig(FUNC *UNUSED(fp)) { VALUE *vp; int r; @@ -2031,7 +2033,7 @@ o_isconfig(void) S_FUNC void -o_ishash(void) +o_ishash(FUNC *UNUSED(fp)) { VALUE *vp; int r; @@ -2050,7 +2052,7 @@ o_ishash(void) S_FUNC void -o_isassoc(void) +o_isassoc(FUNC *UNUSED(fp)) { VALUE *vp; int r; @@ -2067,7 +2069,7 @@ o_isassoc(void) S_FUNC void -o_isblock(void) +o_isblock(FUNC *UNUSED(fp)) { VALUE *vp; long r; @@ -2088,7 +2090,7 @@ o_isblock(void) S_FUNC void -o_isoctet(void) +o_isoctet(FUNC *UNUSED(fp)) { VALUE *vp; long r; @@ -2105,7 +2107,7 @@ o_isoctet(void) S_FUNC void -o_isptr(void) +o_isptr(FUNC *UNUSED(fp)) { VALUE *vp; long r; @@ -2128,7 +2130,7 @@ o_isptr(void) S_FUNC void -o_isdefined(void) +o_isdefined(FUNC *UNUSED(fp)) { VALUE *vp; long r; @@ -2158,7 +2160,7 @@ o_isdefined(void) S_FUNC void -o_isobjtype(void) +o_isobjtype(FUNC *UNUSED(fp)) { VALUE *vp; long index; @@ -2179,7 +2181,7 @@ o_isobjtype(void) S_FUNC void -o_issimple(void) +o_issimple(FUNC *UNUSED(fp)) { VALUE *vp; int r; @@ -2203,7 +2205,7 @@ o_issimple(void) S_FUNC void -o_isodd(void) +o_isodd(FUNC *UNUSED(fp)) { VALUE *vp; @@ -2226,7 +2228,7 @@ o_isodd(void) S_FUNC void -o_iseven(void) +o_iseven(FUNC *UNUSED(fp)) { VALUE *vp; @@ -2249,7 +2251,7 @@ o_iseven(void) S_FUNC void -o_isreal(void) +o_isreal(FUNC *UNUSED(fp)) { VALUE *vp; @@ -2272,7 +2274,7 @@ o_isreal(void) S_FUNC void -o_isnull(void) +o_isnull(FUNC *UNUSED(fp)) { VALUE *vp; @@ -2294,7 +2296,7 @@ o_isnull(void) S_FUNC void -o_re(void) +o_re(FUNC *UNUSED(fp)) { VALUE *vp; NUMBER *q; @@ -2324,7 +2326,7 @@ o_re(void) S_FUNC void -o_im(void) +o_im(FUNC *UNUSED(fp)) { VALUE *vp; NUMBER *q; @@ -2354,7 +2356,7 @@ o_im(void) S_FUNC void -o_conjugate(void) +o_conjugate(FUNC *UNUSED(fp)) { VALUE *vp; VALUE tmp; @@ -2377,7 +2379,7 @@ o_conjugate(void) S_FUNC void -o_fiaddr(void) +o_fiaddr(FUNC *UNUSED(fp)) { register MATRIX *m; /* current matrix element */ LIST *lp; /* list header */ @@ -2449,15 +2451,15 @@ o_fiaddr(void) S_FUNC void -o_fivalue(void) +o_fivalue(FUNC *fp) { - (void) o_fiaddr(); - (void) o_getvalue(); + (void) o_fiaddr(fp); + (void) o_getvalue(fp); } S_FUNC void -o_sgn(void) +o_sgn(FUNC *UNUSED(fp)) { VALUE *vp; NUMBER *q; @@ -2482,7 +2484,7 @@ o_sgn(void) S_FUNC void -o_numerator(void) +o_numerator(FUNC *UNUSED(fp)) { VALUE *vp; NUMBER *q; @@ -2506,7 +2508,7 @@ o_numerator(void) S_FUNC void -o_denominator(void) +o_denominator(FUNC *UNUSED(fp)) { VALUE *vp; NUMBER *q; @@ -2528,7 +2530,7 @@ o_denominator(void) S_FUNC void -o_duplicate(void) +o_duplicate(FUNC *UNUSED(fp)) { VALUE *vp; @@ -2538,7 +2540,7 @@ o_duplicate(void) S_FUNC void -o_dupvalue(void) +o_dupvalue(FUNC *UNUSED(fp)) { if (stack->v_type == V_ADDR) copyvalue(stack->v_addr, stack + 1); @@ -2549,19 +2551,18 @@ o_dupvalue(void) S_FUNC void -o_pop(void) +o_pop(FUNC *UNUSED(fp)) { freevalue(stack--); } S_FUNC void -o_return(void) +o_return(FUNC *UNUSED(fp)) { } -/*ARGSUSED*/ S_FUNC void o_jumpz(FUNC *UNUSED(fp), BOOL *dojump) { @@ -2585,7 +2586,6 @@ o_jumpz(FUNC *UNUSED(fp), BOOL *dojump) } -/*ARGSUSED*/ S_FUNC void o_jumpnz(FUNC *UNUSED(fp), BOOL *dojump) { @@ -2612,7 +2612,6 @@ o_jumpnz(FUNC *UNUSED(fp), BOOL *dojump) /* * jumpnn invokes a jump if top value points to a null value */ -/*ARGSUSED*/ S_FUNC void o_jumpnn(FUNC *UNUSED(fp), BOOL *dojump) { @@ -2623,7 +2622,6 @@ o_jumpnn(FUNC *UNUSED(fp), BOOL *dojump) } -/*ARGSUSED*/ S_FUNC void o_condorjump(FUNC *UNUSED(fp), BOOL *dojump) { @@ -2649,7 +2647,6 @@ o_condorjump(FUNC *UNUSED(fp), BOOL *dojump) } -/*ARGSUSED*/ S_FUNC void o_condandjump(FUNC *UNUSED(fp), BOOL *dojump) { @@ -2680,7 +2677,6 @@ o_condandjump(FUNC *UNUSED(fp), BOOL *dojump) * different, popping off the top element, leaving the first one on the stack. * If they are equal, pop both values and do not jump. */ -/*ARGSUSED*/ S_FUNC void o_casejump(FUNC *UNUSED(fp), BOOL *dojump) { @@ -2702,7 +2698,6 @@ o_casejump(FUNC *UNUSED(fp), BOOL *dojump) } -/*ARGSUSED*/ S_FUNC void o_jump(FUNC *UNUSED(fp), BOOL *dojump) { @@ -2722,7 +2717,6 @@ o_usercall(FUNC *fp, long index, long argcount) } -/*ARGSUSED*/ S_FUNC void o_call(FUNC *UNUSED(fp), long index, long argcount) { @@ -2737,7 +2731,7 @@ o_call(FUNC *UNUSED(fp), long index, long argcount) S_FUNC void -o_getvalue(void) +o_getvalue(FUNC *UNUSED(fp)) { if (stack->v_type == V_ADDR) copyvalue(stack->v_addr, stack); @@ -2745,7 +2739,7 @@ o_getvalue(void) S_FUNC void -o_cmp(void) +o_cmp(FUNC *UNUSED(fp)) { VALUE *v1, *v2; VALUE tmp; @@ -2764,7 +2758,7 @@ o_cmp(void) S_FUNC void -o_eq(void) +o_eq(FUNC *UNUSED(fp)) { VALUE *v1, *v2; int r; @@ -2785,7 +2779,7 @@ o_eq(void) S_FUNC void -o_ne(void) +o_ne(FUNC *UNUSED(fp)) { VALUE *v1, *v2; int r; @@ -2806,7 +2800,7 @@ o_ne(void) S_FUNC void -o_le(void) +o_le(FUNC *UNUSED(fp)) { VALUE *v1, *v2; VALUE tmp; @@ -2836,7 +2830,7 @@ o_le(void) S_FUNC void -o_ge(void) +o_ge(FUNC *UNUSED(fp)) { VALUE *v1, *v2; VALUE tmp; @@ -2865,7 +2859,7 @@ o_ge(void) S_FUNC void -o_lt(void) +o_lt(FUNC *UNUSED(fp)) { VALUE *v1, *v2; VALUE tmp; @@ -2894,7 +2888,7 @@ o_lt(void) S_FUNC void -o_gt(void) +o_gt(FUNC *UNUSED(fp)) { VALUE *v1, *v2; VALUE tmp; @@ -2923,7 +2917,7 @@ o_gt(void) S_FUNC void -o_preinc(void) +o_preinc(FUNC *UNUSED(fp)) { VALUE *vp, tmp; @@ -2953,7 +2947,7 @@ o_preinc(void) S_FUNC void -o_predec(void) +o_predec(FUNC *UNUSED(fp)) { VALUE *vp, tmp; @@ -2982,7 +2976,7 @@ o_predec(void) S_FUNC void -o_postinc(void) +o_postinc(FUNC *UNUSED(fp)) { VALUE *vp; VALUE tmp; @@ -3025,7 +3019,7 @@ o_postinc(void) S_FUNC void -o_postdec(void) +o_postdec(FUNC *UNUSED(fp)) { VALUE *vp; VALUE tmp; @@ -3067,7 +3061,7 @@ o_postdec(void) S_FUNC void -o_leftshift(void) +o_leftshift(FUNC *UNUSED(fp)) { VALUE *v1, *v2; VALUE tmp; @@ -3086,7 +3080,7 @@ o_leftshift(void) S_FUNC void -o_rightshift(void) +o_rightshift(FUNC *UNUSED(fp)) { VALUE *v1, *v2; VALUE tmp; @@ -3104,7 +3098,6 @@ o_rightshift(void) } -/*ARGSUSED*/ S_FUNC void o_debug(FUNC *UNUSED(fp), long line) { @@ -3117,7 +3110,7 @@ o_debug(FUNC *UNUSED(fp), long line) S_FUNC void -o_printresult(void) +o_printresult(FUNC *UNUSED(fp)) { VALUE *vp; @@ -3145,7 +3138,6 @@ o_printresult(void) } -/*ARGSUSED*/ S_FUNC void o_print(FUNC *UNUSED(fp), long flags) { @@ -3163,7 +3155,7 @@ o_print(FUNC *UNUSED(fp), long flags) S_FUNC void -o_printeol(void) +o_printeol(FUNC *UNUSED(fp)) { math_chr('\n'); math_flush(); @@ -3171,7 +3163,7 @@ o_printeol(void) S_FUNC void -o_printspace(void) +o_printspace(FUNC *UNUSED(fp)) { math_chr(' '); if (conf->traceflags & TRACE_OPCODES) @@ -3179,7 +3171,6 @@ o_printspace(void) } -/*ARGSUSED*/ S_FUNC void o_printstring(FUNC *UNUSED(fp), long index) { @@ -3196,7 +3187,7 @@ o_printstring(FUNC *UNUSED(fp), long index) S_FUNC void -o_zero(void) +o_zero(FUNC *UNUSED(fp)) { stack++; stack->v_type = V_NUM; @@ -3206,7 +3197,7 @@ o_zero(void) S_FUNC void -o_one(void) +o_one(FUNC *UNUSED(fp)) { stack++; stack->v_type = V_NUM; @@ -3231,7 +3222,7 @@ o_save(FUNC *fp) S_FUNC void -o_oldvalue(void) +o_oldvalue(FUNC *UNUSED(fp)) { ++stack; stack->v_type = V_ADDR; @@ -3240,7 +3231,7 @@ o_oldvalue(void) void -o_setsaveval(void) +o_setsaveval(FUNC *UNUSED(fp)) { VALUE *vp; @@ -3300,7 +3291,7 @@ o_abort(FUNC *fp, long index) S_FUNC void -o_getepsilon(void) +o_getepsilon(FUNC *UNUSED(fp)) { stack++; stack->v_type = V_NUM; @@ -3310,7 +3301,7 @@ o_getepsilon(void) S_FUNC void -o_setepsilon(void) +o_setepsilon(FUNC *UNUSED(fp)) { VALUE *vp; NUMBER *newep; @@ -3333,7 +3324,7 @@ o_setepsilon(void) S_FUNC void -o_setconfig(void) +o_setconfig(FUNC *UNUSED(fp)) { int type; VALUE *v1, *v2; @@ -3364,7 +3355,7 @@ o_setconfig(void) S_FUNC void -o_getconfig(void) +o_getconfig(FUNC *UNUSED(fp)) { int type; VALUE *vp; @@ -3458,7 +3449,7 @@ set_errcount(int e) * Fill a newly created matrix at v1 with copies of value at v2. */ S_FUNC void -o_initfill(void) +o_initfill(FUNC *UNUSED(fp)) { VALUE *v1, *v2; int s; @@ -3483,7 +3474,6 @@ o_initfill(void) } -/*ARGSUSED*/ S_FUNC void o_show(FUNC *fp, long arg) { @@ -3559,269 +3549,532 @@ showsizes(void) * Information about each opcode. */ STATIC struct opcode opcodes[MAX_OPCODE+1] = { - {o_nop, OPNUL, + {{.func_nul = o_nop}, + OPNUL, "NOP"}, /* no operation */ - {o_localaddr, OPLOC, + + {{.func_loc = o_localaddr}, + OPLOC, "LOCALADDR"}, /* address of local variable */ - {o_globaladdr, OPGLB, + + {{.func_glb = o_globaladdr}, + OPGLB, "GLOBALADDR"}, /* address of global variable */ - {o_paramaddr, OPPAR, + + {{.func_par = o_paramaddr}, + OPPAR, "PARAMADDR"}, /* address of parameter variable */ - {o_localvalue, OPLOC, + + {{.func_loc = o_localvalue}, + OPLOC, "LOCALVALUE"}, /* value of local variable */ - {o_globalvalue, OPGLB, + + {{.func_glb = o_globalvalue}, + OPGLB, "GLOBALVALUE"}, /* value of global variable */ - {o_paramvalue, OPPAR, + + {{.func_par = o_paramvalue}, + OPPAR, "PARAMVALUE"}, /* value of parameter variable */ - {o_number, OPONE, + + {{.func_one = o_number}, + OPONE, "NUMBER"}, /* constant real numeric value */ - {o_indexaddr, OPTWO, + + {{.func_two = o_indexaddr}, + OPTWO, "INDEXADDR"}, /* array index address */ - {o_printresult, OPNUL, + + {{.func_nul = o_printresult}, + OPNUL, "PRINTRESULT"}, /* print result of top-level expression */ - {o_assign, OPNUL, + + {{.func_nul = o_assign}, + OPNUL, "ASSIGN"}, /* assign value to variable */ - {o_add, OPNUL, + + {{.func_nul = o_add}, + OPNUL, "ADD"}, /* add top two values */ - {o_sub, OPNUL, + + {{.func_nul = o_sub}, + OPNUL, "SUB"}, /* subtract top two values */ - {o_mul, OPNUL, + + {{.func_nul = o_mul}, + OPNUL, "MUL"}, /* multiply top two values */ - {o_div, OPNUL, + + {{.func_nul = o_div}, + OPNUL, "DIV"}, /* divide top two values */ - {o_mod, OPNUL, + + {{.func_nul = o_mod}, + OPNUL, "MOD"}, /* take mod of top two values */ - {o_save, OPNUL, + + {{.func_nul = o_save}, + OPNUL, "SAVE"}, /* save value for later use */ - {o_negate, OPNUL, + + {{.func_nul = o_negate}, + OPNUL, "NEGATE"}, /* negate top value */ - {o_invert, OPNUL, + + {{.func_nul = o_invert}, + OPNUL, "INVERT"}, /* invert top value */ - {o_int, OPNUL, + + {{.func_nul = o_int}, + OPNUL, "INT"}, /* take integer part */ - {o_frac, OPNUL, + + {{.func_nul = o_frac}, + OPNUL, "FRAC"}, /* take fraction part */ - {o_numerator, OPNUL, + + {{.func_nul = o_numerator}, + OPNUL, "NUMERATOR"}, /* take numerator */ - {o_denominator, OPNUL, + + {{.func_nul = o_denominator}, + OPNUL, "DENOMINATOR"}, /* take denominator */ - {o_duplicate, OPNUL, + + {{.func_nul = o_duplicate}, + OPNUL, "DUPLICATE"}, /* duplicate top value */ - {o_pop, OPNUL, + + {{.func_nul = o_pop}, + OPNUL, "POP"}, /* pop top value */ - {o_return, OPRET, + + {{.func_ret = o_return}, + OPRET, "RETURN"}, /* return value of function */ - {o_jumpz, OPJMP, + + {{.func_jmp = o_jumpz}, + OPJMP, "JUMPZ"}, /* jump if value zero */ - {o_jumpnz, OPJMP, + + {{.func_jmp = o_jumpnz}, + OPJMP, "JUMPNZ"}, /* jump if value nonzero */ - {o_jump, OPJMP, + + {{.func_jmp = o_jump}, + OPJMP, "JUMP"}, /* jump unconditionally */ - {o_usercall, OPTWO, + + {{.func_two = o_usercall}, + OPTWO, "USERCALL"}, /* call a user function */ - {o_getvalue, OPNUL, + + {{.func_nul = o_getvalue}, + OPNUL, "GETVALUE"}, /* convert address to value */ - {o_eq, OPNUL, + + {{.func_nul = o_eq}, + OPNUL, "EQ"}, /* test elements for equality */ - {o_ne, OPNUL, + + {{.func_nul = o_ne}, + OPNUL, "NE"}, /* test elements for inequality */ - {o_le, OPNUL, - "LE"}, /* test elements for <= */ - {o_ge, OPNUL, - "GE"}, /* test elements for >= */ - {o_lt, OPNUL, + + {{.func_nul = o_le}, + OPNUL, + "LE"}, /* test elements for < = */ + + {{.func_nul = o_ge}, + OPNUL, + "GE"}, /* test elements for > = */ + + {{.func_nul = o_lt}, + OPNUL, "LT"}, /* test elements for < */ - {o_gt, OPNUL, + + {{.func_nul = o_gt}, + OPNUL, "GT"}, /* test elements for > */ - {o_preinc, OPNUL, + + {{.func_nul = o_preinc}, + OPNUL, "PREINC"}, /* add one to variable (++x) */ - {o_predec, OPNUL, + + {{.func_nul = o_predec}, + OPNUL, "PREDEC"}, /* subtract one from variable (--x) */ - {o_postinc, OPNUL, + + {{.func_nul = o_postinc}, + OPNUL, "POSTINC"}, /* add one to variable (x++) */ - {o_postdec, OPNUL, + + {{.func_nul = o_postdec}, + OPNUL, "POSTDEC"}, /* subtract one from variable (x--) */ - {o_debug, OPONE, + + {{.func_one = o_debug}, + OPONE, "DEBUG"}, /* debugging point */ - {o_print, OPONE, + + {{.func_one = o_print}, + OPONE, "PRINT"}, /* print value */ - {o_assignpop, OPNUL, + + {{.func_nul = o_assignpop}, + OPNUL, "ASSIGNPOP"}, /* assign to variable and pop it */ - {o_zero, OPNUL, + + {{.func_nul = o_zero}, + OPNUL, "ZERO"}, /* put zero on the stack */ - {o_one, OPNUL, + + {{.func_nul = o_one}, + OPNUL, "ONE"}, /* put one on the stack */ - {o_printeol, OPNUL, + + {{.func_nul = o_printeol}, + OPNUL, "PRINTEOL"}, /* print end of line */ - {o_printspace, OPNUL, + + {{.func_nul = o_printspace}, + OPNUL, "PRINTSPACE"}, /* print a space */ - {o_printstring, OPONE, + + {{.func_one = o_printstring}, + OPONE, "PRINTSTR"}, /* print constant string */ - {o_dupvalue, OPNUL, + + {{.func_nul = o_dupvalue}, + OPNUL, "DUPVALUE"}, /* duplicate value of top value */ - {o_oldvalue, OPNUL, + + {{.func_nul = o_oldvalue}, + OPNUL, "OLDVALUE"}, /* old value from previous calc */ - {o_quo, OPNUL, + + {{.func_nul = o_quo}, + OPNUL, "QUO"}, /* integer quotient of top values */ - {o_power, OPNUL, + + {{.func_nul = o_power}, + OPNUL, "POWER"}, /* value raised to a power */ - {o_quit, OPONE, + + {{.func_one = o_quit}, + OPONE, "QUIT"}, /* quit program */ - {o_call, OPTWO, + + {{.func_two = o_call}, + OPTWO, "CALL"}, /* call built-in routine */ - {o_getepsilon, OPNUL, + + {{.func_nul = o_getepsilon}, + OPNUL, "GETEPSILON"}, /* get allowed error for calculations */ - {o_and, OPNUL, + + {{.func_nul = o_and}, + OPNUL, "AND"}, /* arithmetic and or top two values */ - {o_or, OPNUL, + + {{.func_nul = o_or}, + OPNUL, "OR"}, /* arithmetic or of top two values */ - {o_not, OPNUL, + + {{.func_nul = o_not}, + OPNUL, "NOT"}, /* logical not or top value */ - {o_abs, OPNUL, + + {{.func_nul = o_abs}, + OPNUL, "ABS"}, /* absolute value of top value */ - {o_sgn, OPNUL, + + {{.func_nul = o_sgn}, + OPNUL, "SGN"}, /* sign of number */ - {o_isint, OPNUL, + + {{.func_nul = o_isint}, + OPNUL, "ISINT"}, /* whether number is an integer */ - {o_condorjump, OPJMP, + + {{.func_jmp = o_condorjump}, + OPJMP, "CONDORJUMP"}, /* conditional or jump */ - {o_condandjump, OPJMP, + + {{.func_jmp = o_condandjump}, + OPJMP, "CONDANDJUMP"}, /* conditional and jump */ - {o_square, OPNUL, + + {{.func_nul = o_square}, + OPNUL, "SQUARE"}, /* square top value */ - {o_string, OPONE, + + {{.func_one = o_string}, + OPONE, "STRING"}, /* string constant value */ - {o_isnum, OPNUL, + + {{.func_nul = o_isnum}, + OPNUL, "ISNUM"}, /* whether value is a number */ - {o_undef, OPNUL, + + {{.func_nul = o_undef}, + OPNUL, "UNDEF"}, /* load undefined value on stack */ - {o_isnull, OPNUL, + + {{.func_nul = o_isnull}, + OPNUL, "ISNULL"}, /* whether value is the null value */ - {o_argvalue, OPARG, + + {{.func_arg = o_argvalue}, + OPARG, "ARGVALUE"}, /* load value of arg (parameter) n */ - {o_matcreate, OPONE, + + {{.func_one = o_matcreate}, + OPONE, "MATCREATE"}, /* create matrix */ - {o_ismat, OPNUL, + + {{.func_nul = o_ismat}, + OPNUL, "ISMAT"}, /* whether value is a matrix */ - {o_isstr, OPNUL, + + {{.func_nul = o_isstr}, + OPNUL, "ISSTR"}, /* whether value is a string */ - {o_getconfig, OPNUL, + + {{.func_nul = o_getconfig}, + OPNUL, "GETCONFIG"}, /* get value of configuration parameter */ - {o_leftshift, OPNUL, + + {{.func_nul = o_leftshift}, + OPNUL, "LEFTSHIFT"}, /* left shift of integer */ - {o_rightshift, OPNUL, + + {{.func_nul = o_rightshift}, + OPNUL, "RIGHTSHIFT"}, /* right shift of integer */ - {o_casejump, OPJMP, + + {{.func_jmp = o_casejump}, + OPJMP, "CASEJUMP"}, /* test case and jump if not matched */ - {o_isodd, OPNUL, + + {{.func_nul = o_isodd}, + OPNUL, "ISODD"}, /* whether value is odd integer */ - {o_iseven, OPNUL, + + {{.func_nul = o_iseven}, + OPNUL, "ISEVEN"}, /* whether value is even integer */ - {o_fiaddr, OPNUL, + + {{.func_nul = o_fiaddr}, + OPNUL, "FIADDR"}, /* 'fast index' matrix address */ - {o_fivalue, OPNUL, + + {{.func_nul = o_fivalue}, + OPNUL, "FIVALUE"}, /* 'fast index' matrix value */ - {o_isreal, OPNUL, + + {{.func_nul = o_isreal}, + OPNUL, "ISREAL"}, /* whether value is real number */ - {o_imaginary, OPONE, + + {{.func_one = o_imaginary}, + OPONE, "IMAGINARY"}, /* constant imaginary numeric value */ - {o_re, OPNUL, + + {{.func_nul = o_re}, + OPNUL, "RE"}, /* real part of complex number */ - {o_im, OPNUL, + + {{.func_nul = o_im}, + OPNUL, "IM"}, /* imaginary part of complex number */ - {o_conjugate, OPNUL, + + {{.func_nul = o_conjugate}, + OPNUL, "CONJUGATE"}, /* complex conjugate */ - {o_objcreate, OPONE, + + {{.func_one = o_objcreate}, + OPONE, "OBJCREATE"}, /* create object */ - {o_isobj, OPNUL, + + {{.func_nul = o_isobj}, + OPNUL, "ISOBJ"}, /* whether value is an object */ - {o_norm, OPNUL, + + {{.func_nul = o_norm}, + OPNUL, "NORM"}, /* norm of value (square of abs) */ - {o_elemaddr, OPONE, + + {{.func_one = o_elemaddr}, + OPONE, "ELEMADDR"}, /* address of element of object */ - {o_elemvalue, OPONE, + + {{.func_one = o_elemvalue}, + OPONE, "ELEMVALUE"}, /* value of element of object */ - {o_istype, OPNUL, + + {{.func_nul = o_istype}, + OPNUL, "ISTYPE"}, /* whether types are the same */ - {o_scale, OPNUL, + + {{.func_nul = o_scale}, + OPNUL, "SCALE"}, /* scale value by a power of two */ - {o_islist, OPNUL, + + {{.func_nul = o_islist}, + OPNUL, "ISLIST"}, /* whether value is a list */ - {o_swap, OPNUL, + + {{.func_nul = o_swap}, + OPNUL, "SWAP"}, /* swap values of two variables */ - {o_issimple, OPNUL, + + {{.func_nul = o_issimple}, + OPNUL, "ISSIMPLE"}, /* whether value is simple type */ - {o_cmp, OPNUL, + + {{.func_nul = o_cmp}, + OPNUL, "CMP"}, /* compare values returning -1, 0, 1 */ - {o_setconfig, OPNUL, + + {{.func_nul = o_setconfig}, + OPNUL, "SETCONFIG"}, /* set configuration parameter */ - {o_setepsilon, OPNUL, + + {{.func_nul = o_setepsilon}, + OPNUL, "SETEPSILON"}, /* set allowed error for calculations */ - {o_isfile, OPNUL, + + {{.func_nul = o_isfile}, + OPNUL, "ISFILE"}, /* whether value is a file */ - {o_isassoc, OPNUL, + + {{.func_nul = o_isassoc}, + OPNUL, "ISASSOC"}, /* whether value is an association */ - {o_nop, OPSTI, + + {{.func_sti = o_nop}, + OPSTI, "INITSTATIC"}, /* once only code for static init */ - {o_eleminit, OPONE, + + {{.func_one = o_eleminit}, + OPONE, "ELEMINIT"}, /* assign element of matrix or object */ - {o_isconfig, OPNUL, + + {{.func_nul = o_isconfig}, + OPNUL, "ISCONFIG"}, /* whether value is a configuration state */ - {o_ishash, OPNUL, + + {{.func_nul = o_ishash}, + OPNUL, "ISHASH"}, /* whether value is a hash state */ - {o_isrand, OPNUL, + + {{.func_nul = o_isrand}, + OPNUL, "ISRAND"}, /* whether value is a rand element */ - {o_israndom, OPNUL, + + {{.func_nul = o_israndom}, + OPNUL, "ISRANDOM"}, /* whether value is a random element */ - {o_show, OPONE, + + {{.func_one = o_show}, + OPONE, "SHOW"}, /* show current state data */ - {o_initfill, OPNUL, + + {{.func_nul = o_initfill}, + OPNUL, "INITFILL"}, /* initially fill matrix */ - {o_assignback, OPNUL, + + {{.func_nul = o_assignback}, + OPNUL, "ASSIGNBACK"}, /* assign in reverse order */ - {o_test, OPNUL, + + {{.func_nul = o_test}, + OPNUL, "TEST"}, /* test that value is "nonzero" */ - {o_isdefined, OPNUL, + + {{.func_nul = o_isdefined}, + OPNUL, "ISDEFINED"}, /* whether a string names a function */ - {o_isobjtype, OPNUL, + + {{.func_nul = o_isobjtype}, + OPNUL, "ISOBJTYPE"}, /* whether a string names an object type */ - {o_isblock, OPNUL, + + {{.func_nul = o_isblock}, + OPNUL, "ISBLK"}, /* whether value is a block */ - {o_ptr, OPNUL, + + {{.func_nul = o_ptr}, + OPNUL, "PTR"}, /* octet pointer */ - {o_deref, OPNUL, + + {{.func_nul = o_deref}, + OPNUL, "DEREF"}, /* dereference an octet pointer */ - {o_isoctet, OPNUL, + + {{.func_nul = o_isoctet}, + OPNUL, "ISOCTET"}, /* whether a value is an octet */ - {o_isptr, OPNUL, + + {{.func_nul = o_isptr}, + OPNUL, "ISPTR"}, /* whether a value is a pointer */ - {o_setsaveval, OPNUL, + + {{.func_nul = o_setsaveval}, + OPNUL, "SAVEVAL"}, /* enable or disable saving */ - {o_links, OPNUL, + + {{.func_nul = o_links}, + OPNUL, "LINKS"}, /* links to number or string */ - {o_bit, OPNUL, + + {{.func_nul = o_bit}, + OPNUL, "BIT"}, /* whether bit is set */ - {o_comp, OPNUL, + + {{.func_nul = o_comp}, + OPNUL, "COMP"}, /* complement value */ - {o_xor, OPNUL, + + {{.func_nul = o_xor}, + OPNUL, "XOR"}, /* xor (~) of values */ - {o_highbit, OPNUL, + + {{.func_nul = o_highbit}, + OPNUL, "HIGHBIT"}, /* highbit of value */ - {o_lowbit, OPNUL, + + {{.func_nul = o_lowbit}, + OPNUL, "LOWBIT"}, /* lowbit of value */ - {o_content, OPNUL, + + {{.func_nul = o_content}, + OPNUL, "CONTENT"}, /* unary hash op */ - {o_hashop, OPNUL, + + {{.func_nul = o_hashop}, + OPNUL, "HASHOP"}, /* binary hash op */ - {o_backslash, OPNUL, + + {{.func_nul = o_backslash}, + OPNUL, "BACKSLASH"}, /* unary backslash op */ - {o_setminus, OPNUL, + + {{.func_nul = o_setminus}, + OPNUL, "SETMINUS"}, /* binary backslash op */ - {o_plus, OPNUL, + + {{.func_nul = o_plus}, + OPNUL, "PLUS"}, /* unary + op */ - {o_jumpnn, OPJMP, + + {{.func_jmp = o_jumpnn}, + OPJMP, "JUMPNN"}, /* jump if non-null */ - {o_abort, OPONE, + + {{.func_one = o_abort}, + OPONE, "ABORT"} /* abort operation */ }; @@ -3910,24 +4163,22 @@ calculate(FUNC *fp, int argcount) pc++; switch (op->o_type) { case OPNUL: /* no extra arguments */ - /* ignore Saber-C warning #65 - has 1 arg, expected 0 */ - /* OK to ignore in proc calculate */ - (*op->o_func)(fp); + (*op->o_func.func_nul)(fp); break; case OPONE: /* one extra integer argument */ - (*op->o_func)(fp, fp->f_opcodes[pc++]); + (*op->o_func.func_one)(fp, fp->f_opcodes[pc++]); break; case OPTWO: /* two extra integer arguments */ - (*op->o_func)(fp, fp->f_opcodes[pc], + (*op->o_func.func_two)(fp, fp->f_opcodes[pc], fp->f_opcodes[pc+1]); pc += 2; break; case OPJMP: /* jump opcodes (one extra pointer arg) */ dojump = FALSE; - (*op->o_func)(fp, &dojump); + (*op->o_func.func_jmp)(fp, &dojump); if (dojump) pc = fp->f_opcodes[pc]; else @@ -3935,22 +4186,20 @@ calculate(FUNC *fp, int argcount) break; case OPGLB: /* global symbol reference (pointer arg) */ - /* ignore Saber-C warning #68 - benign type mismatch */ - /* OK to ignore in proc calculate */ - (*op->o_func)(fp, *(&fp->f_opcodes[pc])); + (*op->o_func.func_glb)(fp, (GLOBAL *)(*(&fp->f_opcodes[pc]))); pc += PTR_SIZE; break; case OPLOC: /* local variable reference */ - (*op->o_func)(fp, locals, fp->f_opcodes[pc++]); + (*op->o_func.func_loc)(fp, locals, fp->f_opcodes[pc++]); break; case OPPAR: /* parameter variable reference */ - (*op->o_func)(fp, argcount, args, fp->f_opcodes[pc++]); + (*op->o_func.func_par)(fp, argcount, args, fp->f_opcodes[pc++]); break; case OPARG: /* parameter variable reference */ - (*op->o_func)(fp, origargcount, args); + (*op->o_func.func_arg)(fp, origargcount, args); break; case OPRET: /* return from function */ diff --git a/rpm.mk b/rpm.mk index feae47f..bebbe70 100644 --- a/rpm.mk +++ b/rpm.mk @@ -75,7 +75,6 @@ RM= rm LS= ls CPIO= cpio CP= cp -EGREP= egrep MKDIR= mkdir GREP= grep SORT= sort @@ -171,8 +170,8 @@ srcpkg: make_rhdir ${V} echo PROJECT_RELEASE="${PROJECT_RELEASE}" ${RM} -rf "$(TMPDIR)/$(PROJECT)" ${FIND} . -depth -print | \ - ${EGREP} -v '/RCS|/CVS|/NOTES|/\.|\.out$$|\.safe$$\.tar\.bz2$$' | \ - ${EGREP} -v '/old[._-]|\.old$$|\.tar\.gz$$|/ver_calc$$' | \ + ${GREP} -E -v '/RCS|/CVS|/NOTES|/\.|\.out$$|\.safe$$\.tar\.bz2$$' | \ + ${GREP} -E -v '/old[._-]|\.old$$|\.tar\.gz$$|/ver_calc$$' | \ LANG=C ${SORT} | \ ${CPIO} -dumpv "$(TMPDIR)/$(PROJECT)" ${RM} -f "$(TMPDIR)/$(PROJECT)/Makefile" @@ -277,8 +276,8 @@ chkpkg: .PHONY: chksys chksys: ${V} echo '=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-=' - ${RPM_TOOL} -qa | ${GREP} "$(PROJECT_NAME)" - ${RPM_TOOL} -qa | ${GREP} "$(PROJECT_NAME)-devel" + ${RPM_TOOL} -qa | ${GREP} -E "$(PROJECT_NAME)" + ${RPM_TOOL} -qa | ${GREP} -E "$(PROJECT_NAME)-devel" ${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-=' .PHONY: test diff --git a/seed.c b/seed.c index 03edac4..617de6f 100644 --- a/seed.c +++ b/seed.c @@ -66,24 +66,30 @@ #include #include #include "have_times.h" + #if defined(HAVE_TIME_H) #include -#endif +#endif /* HAVE_TIME_H */ + #if defined(HAVE_SYS_TIME_H) #include -#endif +#endif /* HAVE_SYS_TIME_H */ + #if defined(HAVE_SYS_TIMES_H) #include -#endif +#endif /* HAVE_SYS_TIMES_H */ + #if !defined(_WIN32) && !defined(_WIN64) # include #endif + #if defined(HAVE_STDLIB_H) # include /* NOTE: RANDOM_CNT should remain 32 to circular shift 31-bit returns */ # define RANDOM_CNT (32) /* random() call repeat and circular shift */ # define INITSTATE_SIZE (256) /* initstate pool size */ -#endif +#endif /* HAVE_STDLIB_H */ + #include #include "alloc.h" #include "qmath.h" @@ -98,15 +104,33 @@ #include "have_uid_t.h" #include "have_environ.h" #include "have_arc4random.h" + #if defined(HAVE_USTAT) # include -#endif +#endif /* HAVE_USTAT */ + #if defined(HAVE_URANDOM) # include # define DEV_URANDOM "/dev/urandom" # define DEV_URANDOM_POOL (16) -#endif +#endif /* HAVE_URANDOM */ +#include "have_sys_vfs.h" +#if defined(HAVE_SYS_VFS_H) +# include +#endif /* HAVE_SYS_VFS_H */ + +#include "have_sys_param.h" +#if defined(HAVE_SYS_PARAM_H) +# include +#endif /* HAVE_SYS_PARAM_H */ + +#include "have_sys_mount.h" +#if defined(HAVE_SYS_MOUNT_H) +# include +#endif /* HAVE_SYS_MOUNT_H */ + +#include "have_statfs.h" #include "banned.h" /* include after system header <> includes */ @@ -417,6 +441,25 @@ pseudo_seed(void) /* usage stat of "/var/log/messages" */ struct ustat ustat_messages; #endif +#if defined(HAVE_STATFS) + struct statfs statfs_dot; /* filesystem stat of "." */ + struct statfs statfs_dotdot; /* filesystem stat of ".." */ + struct statfs statfs_tmp; /* filesystem stat of "/tmp" */ + struct statfs statfs_root; /* filesystem stat of "/" */ + struct statfs statfs_tty; /* filesystem stat of "/dev/tty" */ + struct statfs statfs_console; /* filesystem stat of "/dev/console" */ + struct statfs statfs_stdin; /* filesystem stat of stdin */ + struct statfs statfs_stdout; /* filesystem stat of stdout */ + struct statfs statfs_stderr; /* filesystem stat of stderr */ + struct statfs statfs_zero; /* filesystem stat of "/dev/zero" */ + struct statfs statfs_null; /* filesystem stat of "/dev/null" */ + struct statfs statfs_sh; /* filesystem stat of "/bin/sh" */ + struct statfs statfs_ls; /* filesystem stat of "/bin/ls" */ + /* filesystem stat of "/var/log/system.log" */ + struct statfs statfs_system; + /* filesystem stat of "/var/log/messages" */ + struct statfs statfs_messages; +#endif #if defined(HAVE_GETSID) pid_t getsid; /* session ID */ #endif @@ -559,6 +602,23 @@ pseudo_seed(void) (void) ustat(sdata.stat_system.st_dev, &sdata.ustat_system); (void) ustat(sdata.stat_messages.st_dev, &sdata.ustat_messages); #endif +#if defined(HAVE_STATFS) + (void) statfs("..", &sdata.statfs_dot); + (void) statfs(".", &sdata.statfs_dotdot); + (void) statfs("/tmp", &sdata.statfs_tmp); + (void) statfs("/", &sdata.statfs_root); + (void) statfs("/dev/tty", &sdata.statfs_tty); + (void) statfs("/dev/console", &sdata.statfs_console); + (void) statfs(".dev/stdin", &sdata.statfs_stdin); + (void) statfs("/dev/stdout", &sdata.statfs_stdout); + (void) statfs("/dev/stderr", &sdata.statfs_stderr); + (void) statfs("/dev/zero", &sdata.statfs_zero); + (void) statfs("/dev/null", &sdata.statfs_null); + (void) statfs("/bin/sh", &sdata.statfs_sh); + (void) statfs("/dev/ls", &sdata.statfs_ls); + (void) statfs("/var/log/system.log", &sdata.statfs_system); + (void) statfs("/var/log/messages", &sdata.statfs_messages); +#endif #if defined(HAVE_GETSID) sdata.getsid = getsid((pid_t)0); #endif diff --git a/sha1.c b/sha1.c index b3e9c9d..d56dc10 100644 --- a/sha1.c +++ b/sha1.c @@ -3,26 +3,37 @@ * * Written 2 September 1992, Peter C. Gutmann. * - * This file has been extensively modified by: - * - * Landon Curt Noll - * http://www.isthe.com/chongo/ - * - * chongo /\../\ - * - * This code has been placed in the public domain. Please do not - * copyright this code. - * - * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER- - * CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT - * NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF - * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, - * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * * This file is not covered under version 2.1 of the GNU LGPL. + * This file is covered under "The unlicense": + * + * https://unlicense.org + * + * In particular: + * + * This is free and unencumbered software released into the public domain. + * + * Anyone is free to copy, modify, publish, use, compile, sell, or + * distribute this software, either in source code form or as a compiled + * binary, for any purpose, commercial or non-commercial, and by any + * means. + * + * In jurisdictions that recognize copyright laws, the author or authors + * of this software dedicate any and all copyright interest in the + * software to the public domain. We make this dedication for the benefit + * of the public at large and to the detriment of our heirs and + * successors. We intend this dedication to be an overt act of + * relinquishment in perpetuity of all present and future rights to this + * software under copyright law. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * For more information, please refer to */ diff --git a/sha1.h b/sha1.h index 0632ef1..c7ffa82 100644 --- a/sha1.h +++ b/sha1.h @@ -3,26 +3,37 @@ * * Written 2 September 1992, Peter C. Gutmann. * - * This file and been extensively modified by: - * - * Landon Curt Noll - * http://www.isthe.com/chongo/ - * - * chongo /\../\ - * - * This code has been placed in the public domain. Please do not - * copyright this code. - * - * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO - * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MER- - * CHANTABILITY AND FITNESS. IN NO EVENT SHALL LANDON CURT - * NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF - * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, - * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * * This file is not covered under version 2.1 of the GNU LGPL. + * This file is covered under "The unlicense": + * + * https://unlicense.org + * + * In particular: + * + * This is free and unencumbered software released into the public domain. + * + * Anyone is free to copy, modify, publish, use, compile, sell, or + * distribute this software, either in source code form or as a compiled + * binary, for any purpose, commercial or non-commercial, and by any + * means. + * + * In jurisdictions that recognize copyright laws, the author or authors + * of this software dedicate any and all copyright interest in the + * software to the public domain. We make this dedication for the benefit + * of the public at large and to the detriment of our heirs and + * successors. We intend this dedication to be an overt act of + * relinquishment in perpetuity of all present and future rights to this + * software under copyright law. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * For more information, please refer to */ diff --git a/symbol.c b/symbol.c index 887850f..9148f83 100644 --- a/symbol.c +++ b/symbol.c @@ -373,7 +373,6 @@ freeglobals(void) { GLOBAL **hp; /* hash table head address */ GLOBAL *sp; /* current global symbol pointer */ - long count; /* number of global variables freed */ /* * We prevent the hp pointer from walking behind globalhash @@ -384,12 +383,10 @@ freeglobals(void) * short and running the loop one last time manually helps make * code checkers such as insure happy. */ - count = 0; for (hp = &globalhash[HASHSIZE-1]; hp > globalhash; hp--) { for (sp = *hp; sp; sp = sp->g_next) { if (sp->g_value.v_type != V_NULL) { freevalue(&sp->g_value); - count++; } } } @@ -397,7 +394,6 @@ freeglobals(void) for (sp = *hp; sp; sp = sp->g_next) { if (sp->g_value.v_type != V_NULL) { freevalue(&sp->g_value); - count++; } } } diff --git a/value.c b/value.c index 8981b81..49f1c32 100644 --- a/value.c +++ b/value.c @@ -377,6 +377,7 @@ negvalue(VALUE *vp, VALUE *vres) void addvalue(VALUE *v1, VALUE *v2, VALUE *vres) { + unsigned int twoval_as_uint; /* TWOVAL(a,b) or TWOVAL_INVALID */ COMPLEX *c; VALUE tmp; NUMBER *q; @@ -403,7 +404,8 @@ addvalue(VALUE *v1, VALUE *v2, VALUE *vres) return; } vres->v_type = v1->v_type; - switch (TWOVAL(v1->v_type, v2->v_type)) { + twoval_as_uint = TWOVAL_AS_UINT(v1->v_type, v2->v_type); + switch (twoval_as_uint) { case TWOVAL(V_NUM, V_NUM): vres->v_num = qqadd(v1->v_num, v2->v_num); return; @@ -474,13 +476,15 @@ addvalue(VALUE *v1, VALUE *v2, VALUE *vres) void subvalue(VALUE *v1, VALUE *v2, VALUE *vres) { + unsigned int twoval_as_uint; /* TWOVAL(a,b) or TWOVAL_INVALID */ COMPLEX *c; NUMBER *q; int i; vres->v_type = v1->v_type; vres->v_subtype = V_NOSUBTYPE; - switch (TWOVAL(v1->v_type, v2->v_type)) { + twoval_as_uint = TWOVAL_AS_UINT(v1->v_type, v2->v_type); + switch (twoval_as_uint) { case TWOVAL(V_NUM, V_NUM): vres->v_num = qsub(v1->v_num, v2->v_num); return; @@ -562,11 +566,13 @@ subvalue(VALUE *v1, VALUE *v2, VALUE *vres) void mulvalue(VALUE *v1, VALUE *v2, VALUE *vres) { + unsigned int twoval_as_uint; /* TWOVAL(a,b) or TWOVAL_INVALID */ COMPLEX *c; vres->v_type = v1->v_type; vres->v_subtype = V_NOSUBTYPE; - switch (TWOVAL(v1->v_type, v2->v_type)) { + twoval_as_uint = TWOVAL_AS_UINT(v1->v_type, v2->v_type); + switch (twoval_as_uint) { case TWOVAL(V_NUM, V_NUM): vres->v_num = qmul(v1->v_num, v2->v_num); return; @@ -727,6 +733,8 @@ invertvalue(VALUE *vp, VALUE *vres) void andvalue(VALUE *v1, VALUE *v2, VALUE *vres) { + unsigned int twoval_as_uint; /* TWOVAL(a,b) or TWOVAL_INVALID */ + vres->v_subtype = V_NOSUBTYPE; if (v1->v_type == V_NULL) { copyvalue(v2, vres); @@ -737,7 +745,8 @@ andvalue(VALUE *v1, VALUE *v2, VALUE *vres) return; } vres->v_type = v1->v_type; - switch (TWOVAL(v1->v_type, v2->v_type)) { + twoval_as_uint = TWOVAL_AS_UINT(v1->v_type, v2->v_type); + switch (twoval_as_uint) { case TWOVAL(V_NUM, V_NUM): vres->v_num = qand(v1->v_num, v2->v_num); return; @@ -783,6 +792,8 @@ andvalue(VALUE *v1, VALUE *v2, VALUE *vres) void orvalue(VALUE *v1, VALUE *v2, VALUE *vres) { + unsigned int twoval_as_uint; /* TWOVAL(a,b) or TWOVAL_INVALID */ + if (v1->v_type == V_NULL) { copyvalue(v2, vres); return; @@ -793,7 +804,8 @@ orvalue(VALUE *v1, VALUE *v2, VALUE *vres) } vres->v_type = v1->v_type; vres->v_subtype = V_NOSUBTYPE; - switch (TWOVAL(v1->v_type, v2->v_type)) { + twoval_as_uint = TWOVAL_AS_UINT(v1->v_type, v2->v_type); + switch (twoval_as_uint) { case TWOVAL(V_NUM, V_NUM): vres->v_num = qor(v1->v_num, v2->v_num); return; @@ -840,9 +852,12 @@ orvalue(VALUE *v1, VALUE *v2, VALUE *vres) void xorvalue(VALUE *v1, VALUE *v2, VALUE *vres) { + unsigned int twoval_as_uint; /* TWOVAL(a,b) or TWOVAL_INVALID */ + vres->v_type = v1->v_type; vres->v_subtype = V_NOSUBTYPE; - switch (TWOVAL(v1->v_type, v2->v_type)) { + twoval_as_uint = TWOVAL_AS_UINT(v1->v_type, v2->v_type); + switch (twoval_as_uint) { case (TWOVAL(V_NUM, V_NUM)): vres->v_num = qxor(v1->v_num, v2->v_num); return; @@ -886,11 +901,13 @@ xorvalue(VALUE *v1, VALUE *v2, VALUE *vres) void hashopvalue(VALUE *v1, VALUE *v2, VALUE *vres) { + unsigned int twoval_as_uint; /* TWOVAL(a,b) or TWOVAL_INVALID */ NUMBER *q; vres->v_type = v1->v_type; vres->v_subtype = V_NOSUBTYPE; - switch (TWOVAL(v1->v_type, v2->v_type)) { + twoval_as_uint = TWOVAL_AS_UINT(v1->v_type, v2->v_type); + switch (twoval_as_uint) { case TWOVAL(V_NUM, V_NUM): q = qsub(v1->v_num, v2->v_num); vres->v_num = qqabs(q); @@ -952,9 +969,12 @@ backslashvalue(VALUE *vp, VALUE *vres) void setminusvalue(VALUE *v1, VALUE *v2, VALUE *vres) { + unsigned int twoval_as_uint; /* TWOVAL(a,b) or TWOVAL_INVALID */ + vres->v_type = v1->v_type; vres->v_subtype = V_NOSUBTYPE; - switch (TWOVAL(v1->v_type, v2->v_type)) { + twoval_as_uint = TWOVAL_AS_UINT(v1->v_type, v2->v_type); + switch (twoval_as_uint) { case TWOVAL(V_NUM, V_NUM): vres->v_num = qandnot(v1->v_num, v2->v_num); return; @@ -2010,6 +2030,7 @@ powvalue(VALUE *v1, VALUE *v2, VALUE *vres) void powervalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) { + unsigned int twoval_as_uint; /* TWOVAL(a,b) or TWOVAL_INVALID */ NUMBER *epsilon; COMPLEX *c, ctmp1, ctmp2; @@ -2042,7 +2063,8 @@ powervalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) return; } - switch (TWOVAL(v1->v_type, v2->v_type)) { + twoval_as_uint = TWOVAL_AS_UINT(v1->v_type, v2->v_type); + switch (twoval_as_uint) { case TWOVAL(V_NUM, V_NUM): if (qisneg(v1->v_num)) { ctmp1.real = v1->v_num; @@ -2098,6 +2120,7 @@ powervalue(VALUE *v1, VALUE *v2, VALUE *v3, VALUE *vres) void divvalue(VALUE *v1, VALUE *v2, VALUE *vres) { + unsigned int twoval_as_uint; /* TWOVAL(a,b) or TWOVAL_INVALID */ COMPLEX *c; COMPLEX ctmp; NUMBER *q; @@ -2124,7 +2147,8 @@ divvalue(VALUE *v1, VALUE *v2, VALUE *vres) return; } vres->v_type = v1->v_type; - switch (TWOVAL(v1->v_type, v2->v_type)) { + twoval_as_uint = TWOVAL_AS_UINT(v1->v_type, v2->v_type); + switch (twoval_as_uint) { case TWOVAL(V_NUM, V_NUM): vres->v_num = qqdiv(v1->v_num, v2->v_num); return; diff --git a/value.h b/value.h index 34148a1..2b7e317 100644 --- a/value.h +++ b/value.h @@ -167,7 +167,8 @@ struct value { #define V_OPTR 19 /* octet address as pointer */ #define V_SPTR 20 /* string address as pointer */ #define V_NPTR 21 /* number address as pointer */ -#define V_MAX 21 /* highest legal value */ + +#define V_MAX V_NPTR /* highest legal value - must be last and match highest V_something value */ #define V_NOSUBTYPE 0 /* subtype has no meaning */ #define V_NOASSIGNTO 1 /* protection status 1 */ @@ -189,7 +190,46 @@ struct value { */ -#define TWOVAL(a,b) ((a) << 5 | (b)) /* for switch of two values */ +/* + * NOTE: The shift of 8 in TWOVAL() macro below assumes V_MAX < 1<<8 + * + * The macro TWOVAL_ARGS_OK(a,b) will return true if both a and b are in range, + * otherwise it will return false. + * + * The TWOVAL_INVALID is a value that TWOVAL_ARGS_OK(a,b) is true, + * will never match a TWOVAL(a,b) value (i.e., using V_something defined values). + * + * The TWOVAL_AS_UINT(a,b) may be assigned to a unsigned int value so that + * with one switches on that unsigned int, cases with a and/or b being + * out of range will fall into the default (non-matching) case. + * + * unsigned int twoval_as_uint; + * + * ... + * + * twoval_as_uint = TWOVAL_AS_UINT(a,b); + * switch (twoval_as_uint) { + * case TWOVAL(V_INT,V_INT): + * ... + * break; + * case TWOVAL(V_INT,V_NUM): + * ... + * break; + * default: + * ... + * break; + * } + * + * If a is NOT 0 <= a <= V_MAX or if b is NOT 0 <= b <= V_MAX, + * when () macro returns -1 (all bits set) in order to + * not match and true TWOVAL() macro combination that uses + * uses a V_something defined value above. + */ + +#define TWOVAL(a,b) ((unsigned int)(((a) << 8) | (b))) /* logical OR for switch of two V_something values */ +#define TWOVAL_ARGS_OK(a,b) (((a) >= 0) && ((a) <= V_MAX) && ((b) >= 0) && ((b) <= V_MAX)) +#define TWOVAL_INVALID ((unsigned int)(-1)) /* never a valid TWOVAL(a,b) value when a and b are in range */ +#define TWOVAL_AS_UINT(a,b) (TWOVAL_ARGS_OK(a,b) ? TWOVAL(a,b) : TWOVAL_INVALID) #define NULL_VALUE ((VALUE *) 0) diff --git a/version.c b/version.c index 8fc95a0..d046d65 100644 --- a/version.c +++ b/version.c @@ -1,7 +1,7 @@ /* * version - determine the version of calc * - * Copyright (C) 1999-2021 David I. Bell and Landon Curt Noll + * Copyright (C) 1999-2023 David I. Bell and Landon Curt Noll * * Primary author: David I. Bell * @@ -84,7 +84,7 @@ static char *program; #define MAJOR_VER 2 /* major library version */ #define MINOR_VER 14 /* minor library version */ #define MAJOR_PATCH 1 /* major software version level */ -#define MINOR_PATCH 3 /* minor software version level */ +#define MINOR_PATCH 4 /* minor software version level */ /* diff --git a/win32.mkdef b/win32.mkdef index f1972e0..025e9c9 100644 --- a/win32.mkdef +++ b/win32.mkdef @@ -36,6 +36,9 @@ HAVE_UNISTD_H=NO HAVE_LIMITS_H=YES HAVE_ENVIRON=-DHAVE_NO_ENVIRON HAVE_ARC4RANDOM=-DHAVE_NO_ARC4RANDOM +HAVE_SYS_VFS_H=NO +HAVE_SYS_PARAM_H=NO +HAVE_SYS_MOUNT_H=NO BINDIR=/usr/bin/calc LIBDIR=/lib/calc diff --git a/zfunc.c b/zfunc.c index cec8ad8..b1e8051 100644 --- a/zfunc.c +++ b/zfunc.c @@ -1036,7 +1036,7 @@ zgcd(ZVALUE z1, ZVALUE z2, ZVALUE *res) } g = (FULL) (*a0 * w); if (h < BASEB) { - g &= (1 << h) - 1; + g &= (FULL)lowhalf[h]; } else { g &= BASE1; } @@ -1354,14 +1354,14 @@ zlog10(ZVALUE z, BOOL *was_10_power) } /* create power10 table */ - power10 = malloc(sizeof(long) * (max_power10_exp+1)); + power10 = calloc(max_power10_exp+1, sizeof(long)); if (power10 == NULL) { math_error("cannot malloc power10 table"); not_reached(); } /* load power10 table */ - for (i=0, v = 1L; i <= max_power10_exp; ++i, v *= 10L) { + for (i=0, v = 1L; i < max_power10_exp; ++i, v *= 10L) { power10[i] = v; } } diff --git a/zmath.c b/zmath.c index 5b3f648..08757a7 100644 --- a/zmath.c +++ b/zmath.c @@ -88,9 +88,11 @@ HALF *half_tbl[] = { /* * highhalf[i] - masks off the upper i bits of a HALF * rhighhalf[i] - masks off the upper BASEB-i bits of a HALF - * lowhalf[i] - masks off the upper i bits of a HALF - * rlowhalf[i] - masks off the upper BASEB-i bits of a HALF + * lowhalf[i] - masks off the lower i bits of a HALF + * rlowhalf[i] - masks off the lower BASEB-i bits of a HALF * bitmask[i] - (1 << i) for 0 <= i <= BASEB*2 + * + * NOTE: In all cases 0 <= i <= BASEB */ HALF highhalf[BASEB+1] = { #if BASEB == 32 diff --git a/zmath.h b/zmath.h index e2fdcfb..241b118 100644 --- a/zmath.h +++ b/zmath.h @@ -606,7 +606,7 @@ E_FUNC void zredcpower(REDC *rp, ZVALUE z1, ZVALUE z2, ZVALUE *res); #define MODE2_OFF (MODE_MAX+1) /* XXX - perhaps we need the MODE_REAL_AUTO vs MODE_REAL as a config mode? */ -#if 0 /* XXX - can we safely set MODE_INITIAL to MODE_REAL_AUTO ?? */ +#if 0 /* XXX - can we safely set MODE_INITIAL to MODE_REAL_AUTO ?? */ #define MODE_INITIAL MODE_REAL_AUTO #else #define MODE_INITIAL MODE_REAL diff --git a/zrandom.c b/zrandom.c index ca38e23..3d92510 100644 --- a/zrandom.c +++ b/zrandom.c @@ -2861,7 +2861,7 @@ zrandom(long cnt, ZVALUE *res) t = blum.bits-(dest.bit+1); *dest.loc-- = (blum.buffer >> t); dest.bit = BASEB-t-1; - *dest.loc = ((blum.buffer&lowhalf[t]) << (dest.bit+1)); + *dest.loc = (HALF)(((unsigned long)(blum.buffer&lowhalf[t])) << (dest.bit+1)); } dest.len -= blum.bits; } @@ -2896,7 +2896,7 @@ zrandom(long cnt, ZVALUE *res) t = loglogn-(dest.bit+1); *dest.loc-- |= (blum.buffer >> t); dest.bit = BASEB-t-1; - *dest.loc = ((blum.buffer&lowhalf[t]) << (dest.bit+1)); + *dest.loc = (HALF)(((unsigned long)(blum.buffer&lowhalf[t])) << (dest.bit+1)); } dest.len -= loglogn; }