Compare commits

..

22 Commits

Author SHA1 Message Date
Landon Curt Noll
d91ace6091 Release v2.14.1.2
The following are the changes in this release:

    Restored use of the #define FPOS_POS_LEN symbol.  This refers to
    the length of the __pos element (if the __pos element exists),
    the fpos_t type (if that type exists).

    Changed SWAP_HALF_IN_FILEPOS(dest, src) mato to use FILEPOS_LEN Little
    Endian when FILEPOS is a simple scalar type (i.e., HAVE_FILEPOS_SCALAR
    is defined).

    Changed #define HAVE_FPOS to HAVE_FGETSETPOS.

    Corrected comment in have_fpos_pos.h.  The HAVE_FPOS_POS symbol was
    NOT related to fgetpos & fsetpos but rather if we we have an __pos
    element in FILEPOS.

    Changed #define HAVE_NO_FPOS to HAVE_NO_FGETSETPOS.

    Improved comments in have_fpos_pos.h to show why and how
    HAVE_FPOS_POS, FPOS_POS_BITS, and FPOS_POS_LEN were defined or undefed.

    Changed showfiles builtin to print sizes cast to (long int) with
    the "%ld" printf format to avoid implementations that do not support
    the "%lld" printf format specifier.

    Renamed have_fpos.h to have_fgetsetpos.h.  Renamed CALC_HAVE_FPOS_H
    to CALC_HAVE_FGETSETPOS_H.  The make install and the olduninstall
    rules remove the any old have_fpos.h that was previously installed.

    Added swap_HALFs(dest, src, len) function to byteswap.c.

    Calc can now handle Big Engian file position sizes that are a
    multiple of BASEB bits in length.  Before handle Big Engian file
    positions could only be 32 and 64 bits in length.  This will allow,
    for example, a Big Engian file position size of 128 (assuming that
    128/BASEB is is an integer).

    Temporary workaround for musl libc systems such as gentoo Linux that
    allows them to compile calc and successfully run the regression test.
2022-11-29 13:10:33 -08:00
Landon Curt Noll
49c6a8218c Release calc v2.14.1.2
Restored use of the #define FPOS_POS_LEN symbol.  This refers to
the length of the __pos element (if the __pos element exists),
the fpos_t type (if that type exists).

Changed SWAP_HALF_IN_FILEPOS(dest, src) mato to use FILEPOS_LEN Little
Endian when FILEPOS is a simple scalar type (i.e., HAVE_FILEPOS_SCALAR
is defined).

Changed #define HAVE_FPOS to HAVE_FGETSETPOS.

Corrected comment in have_fpos_pos.h.  The HAVE_FPOS_POS symbol was
NOT related to fgetpos & fsetpos but rather if we we have an __pos
element in FILEPOS.

Changed #define HAVE_NO_FPOS to HAVE_NO_FGETSETPOS.

Improved comments in have_fpos_pos.h to show why and how
HAVE_FPOS_POS, FPOS_POS_BITS, and FPOS_POS_LEN were defined or
undefed.

Changed showfiles builtin to print sizes cast to (long int) with
the "%ld" printf format to avoid implementations that do not support
the "%lld" printf format specifier.

Renamed have_fpos.h to have_fgetsetpos.h.  Renamed CALC_HAVE_FPOS_H
to CALC_HAVE_FGETSETPOS_H.  The make install and the olduninstall
rules remove the any old have_fpos.h that was previously installed.

Added swap_HALFs(dest, src, len) function to byteswap.c.

Calc can now handle Big Engian file position sizes that are a
multiple of BASEB bits in length.  Before handle Big Engian file
positions could only be 32 and 64 bits in length.  This will allow,
for example, a Big Engian file position size of 128 (assuming that
128/BASEB is is an integer).

Temporary workaround for musl libc systems such as gentoo Linux that
allows them to compile calc and successfully run the regression
test.
2022-11-29 13:04:00 -08:00
Landon Curt Noll
def203f273 Release calc v2.14.1.2 2022-11-29 12:59:36 -08:00
Landon Curt Noll
5b2983f421 Improve format of SWAP_HALF_IN_FILEPOS in fposval.h 2022-11-28 15:24:31 -08:00
Landon Curt Noll
e6fc1a92a9 Improve file position handling on Big Engian machines
Added swap_HALFs(dest, src, len) function to byteswap.c.

Calc can now handle Big Engian file position sizes that are a
multiple of BASEB bits in length.  Before handle Big Engian file
positions could only be 32 and 64 bits in length.  This will allow,
for example, a Big Engian file position size of 128 (assuming that
128/BASEB is is an integer).
2022-11-28 15:13:16 -08:00
Landon Curt Noll
3e084d9fb9 Rename have_fpos.h to have_fgetsetpos.h
Renamed have_fpos.h to have_fgetsetpos.h.

Renamed CALC_HAVE_FPOS_H to CALC_HAVE_FGETSETPOS_H.
2022-11-28 14:07:47 -08:00
Landon Curt Noll
340c1990ce Checkpoint on fixing compiling with musl gentoo
Restored use of the #define FPOS_POS_LEN symbol.  This refers to the
length of the __pos element (if the __pos element exists), the fpos_t type
(if that type exists).

Changed SWAP_HALF_IN_FILEPOS(dest, src) mato to use FILEPOS_LEN Little
Endian when FILEPOS is a simple scalar type (i.e., HAVE_FILEPOS_SCALAR
is defined).

Changed #define HAVE_FPOS to HAVE_FGETSETPOS.

Corrected comment in have_fpos_pos.h.  The HAVE_FPOS_POS symbol was NOT
related to fgetpos & fsetpos but rather if we we have an __pos element
in FILEPOS.

Changed #define HAVE_NO_FPOS to HAVE_NO_FGETSETPOS.

Improved comments in have_fpos_pos.h to show why and how HAVE_FPOS_POS,
FPOS_POS_BITS, and FPOS_POS_LEN were defined or undefed.

Changed showfiles builtin to print sizes cast to (long int) with the
"%ld" printf format to avoid implementations that do not support the
"%lld" printf format specifier.
2022-11-28 12:55:29 -08:00
Landon Curt Noll
5acd67c704 Updated calc bug report template version: 1.3 2022-11-27 2022-11-27 19:07:54 -08:00
Landon Curt Noll
083011c9e3 Changed full_debug rule to not stop on sub-task error 2022-11-27 19:01:15 -08:00
Landon Curt Noll
dce2c6f0ee Improve the make debug rule
Added full_debug rule to Makefile.  This does the work of the
old debug rule in a more verbose mode by using Q= H=@ S= E= V=@.

The debug rule in the Makefile now pre-removes debug.out and then
runs make full_debug sending stdout and stderr to debug.out.  It then
prints a few instructions about filing a GitHub issue bug report.
2022-11-27 18:45:58 -08:00
Landon Curt Noll
827988c553 Fixed FILEPOS_LEN symbol and macro problems 2022-11-27 17:05:49 -08:00
Landon Curt Noll
25dcd8cb80 Release v2.14.1.1
The following are the changes in this release:

    Added a few remarks on calc version numbers to version.c.

    Fixed how fposval.h is built.  On a number of systems, the fposval.c
    file failed to compile incorrectly.  This caused problems for systems in
    which fposval.h.def was not correct.

    Fixed how have_memmv.h is built.  On a number of systems, the have_memmv.c
    file failed to compile incorrectly, producing a potentially incorrect
    have_memmv.h file for such systems.

    Fixed how align32.h is built.  On a number of systems, the align32.c
    file failed to compile incorrectly, producing a potentially incorrect
    align32.h file for such systems.

    Fixed how have_newstr.h is built.  On a number of systems, the have_newstr.c
    failed to compile incorrectly, producing a potentially incorrect
    have_newstr.h file for such systems.

    Fixed how have_strdup.h is built.  On a number of systems, the have_strdup.c
    file failed to compile incorrectly, producing a potentially incorrect
    have_strdup.h file for such systems.

    Fixed how have_strlcat.h is built.  On a number of systems, the have_strlcat.c
    file failed to compile incorrectly, producing a potentially incorrect
    have_strlcat.h file for such systems.

    Fixed how have_strlcpy.h is built.  On a number of systems, the have_strlcpy.c
    file failed to compile incorrectly, producing a potentially incorrect
    have_strlcpy.h file for such systems.

    Fixed how have_uid_t.h is built.  On a number of systems, the have_uid_t.c
    file failed to compile incorrectly, producing a potentially incorrect
    have_uid_t.h file for such systems.

    Fixed how have_uid_t.h is built.  On a number of systems, the have_uid_t.c
    file failed to compile incorrectly, producing a potentially incorrect
    have_uid_t.h file for such systems.
2022-11-27 13:41:32 -08:00
Landon Curt Noll
3b3bfb3f74 Proposed changes for v2.14.1.1
Added a few remarks on calc version numbers to version.c.

Fixed how fposval.h is built.  On a number of systems, the fposval.c
file failed to compile incorrectly.  This caused problems for systems in
which fposval.h.def was not correct.

Fixed how have_memmv.h is built.  On a number of systems, the have_memmv.c
file failed to compile incorrectly, producing a potentially incorrect
have_memmv.h file for such systems.

Fixed how align32.h is built.  On a number of systems, the align32.c
file failed to compile incorrectly, producing a potentially incorrect
align32.h file for such systems.

Fixed how have_newstr.h is built.  On a number of systems, the have_newstr.c
failed to compile incorrectly, producing a potentially incorrect
have_newstr.h file for such systems.

Fixed how have_strdup.h is built.  On a number of systems, the have_strdup.c
file failed to compile incorrectly, producing a potentially incorrect
have_strdup.h file for such systems.

Fixed how have_strlcat.h is built.  On a number of systems, the have_strlcat.c
file failed to compile incorrectly, producing a potentially incorrect
have_strlcat.h file for such systems.

Fixed how have_strlcpy.h is built.  On a number of systems, the have_strlcpy.c
file failed to compile incorrectly, producing a potentially incorrect
have_strlcpy.h file for such systems.

Fixed how have_uid_t.h is built.  On a number of systems, the have_uid_t.c
file failed to compile incorrectly, producing a potentially incorrect
have_uid_t.h file for such systems.

Fixed how have_uid_t.h is built.  On a number of systems, the have_uid_t.c
file failed to compile incorrectly, producing a potentially incorrect
have_uid_t.h file for such systems.
2022-11-27 13:28:32 -08:00
Landon Curt Noll
3e4391e2af Fix another comment in comma.cal 2022-06-20 19:39:11 -07:00
Landon Curt Noll
cfc6a6669c Improve comments in comma.cal 2022-06-20 19:36:54 -07:00
Landon Curt Noll
fa457db3cd Fix more comments in cal/comma.cal 2022-06-20 19:30:45 -07:00
Landon Curt Noll
d08b958a15 Fix typo in comma.cal comment 2022-06-20 19:28:16 -07:00
Landon Curt Noll
5f28e5b851 Removed training newline from fprint_comma in comma.cal 2022-06-20 19:26:35 -07:00
Landon Curt Noll
8dc52a532a Fix comma.cal to avoid leading 0's and tilde's 2022-06-20 19:20:34 -07:00
Landon Curt Noll
6fc14730c0 Fix the forming of fraction part in comma.cal 2022-06-20 19:10:20 -07:00
Landon Curt Noll
b97093e58c Fix calc man page \-escape, add cal/comma.cal
Fixed a \-escape bug in calc(1) man page.

Added cal/comma.cal:

    Convert numbers into strings with 3-digit group and integer-fraction
    separators.

    If the value is an integer, the integer-fraction separator is not used.

    str_comma(x, [group, [decimal]])

	Convert x into a string.

	If group is given and is a string, group will be used as
	the 3-digit group separator, otherwise the default 3-digit
	group separator will be used.

	If decimal is given and is a string, group will be used as
	the integer-fraction separator, otherwise the default
	integer-fraction separator will be used.

	The decimal and group arguments are optional.

    set_default_group_separator(group)

	Change the default 3-digit group separator if group is a string,
	otherwise the default 3-digit group separator will not be
	changed.  Return the old 3-digit group separator.

    set_default_decimal_separator(decimal)

	Change the default 3-digit group separator if decimal is a
	string, otherwise the default integer-fraction separator
	will not be changed.  Return the old integer-fraction separator.

    print_comma(x, [group, [decimal]])

	Print the value produced by str_comma(x, [group, [decimal]])
	followed by a newline.

	If the str_comma() does not return a string, nothing is printed.

	The decimal and group arguments are optional.

	The value produced by str_comma() is returned.

    fprint_comma(fd, x, [group, [decimal]])

	Print the value produced by str_comma(x, [group, [decimal]]),
	without a trailing newline, on file fd.

	If the str_comma() does not return a string, nothing is printed.

	If fd is not an open file, nothing is printed.

	The decimal and group arguments are optional.

	The value produced by str_comma() is returned.
2022-06-20 18:25:12 -07:00
Landon Curt Noll
923c36e475 Remove excess whitespace under SECURITY.md 2022-04-08 00:24:42 -07:00
24 changed files with 990 additions and 189 deletions

View File

@@ -7,7 +7,7 @@ assignees: ''
---
Calc bug report template version: 1.2 2022-02-24
Calc bug report template version: 1.3 2022-11-27
**Describe the bug**
A clear and concise description of what the bug is.
@@ -19,7 +19,7 @@ Steps to reproduce the behavior:
I.e., provide the command line you used to launch calc
1. Calc commands and their output
Please provide any calc commands you entered on the the terminal.
Please provide any calc commands you entered on the terminal.
Please provide the calc command line output inline as well.
If the above is long, please attach a file.
@@ -33,11 +33,11 @@ Steps to reproduce the behavior:
**Expected behavior**
A clear and concise description of what you expected to happen.
**Attach make debug output**
IMPORTANT: Please attach the output from `make debug`.
**Attach debug.out**
IMPORTANT: Please run `make debug` and then attach the `debug.out` file.
**Screenshots**
If applicable, attach screenshots to help explain your problem.
**Screen shots**
If applicable, attach screen shots to help explain your problem.
**Execution environment (please complete the following information):**
- OS:
@@ -48,14 +48,14 @@ If applicable, attach screenshots to help explain your problem.
or if no uname command, a description of the OS version/release you are using
- OS distribution:
E.g., macOS Monterey, contents of /etc/redhat-releaseor /etc/os-release, etc.
E.g., macOS 13.0.1, contents of /etc/redhat-release, or /etc/os-release, etc.
- Calc Version
E.g., output of calc -v
or if you cannot compile calc, the version you downloaded and from where it came from
- Shell and shell version
E.g.., bash, zsh, power shell, etc.
E.g., bash, zsh, power shell, etc.
and the version of the shell you are using, if known
**Calc mods**

3
.gitignore vendored
View File

@@ -29,6 +29,7 @@ cscript/simple
cscript/square
custom/.all
custom/libcustcalc*
debug.out
endian
endian_calc.h
fposval.h
@@ -36,7 +37,7 @@ have_arc4random.h
have_ban_pragma.h
have_const.h
have_environ.h
have_fpos.h
have_fgetsetpos.h
have_fpos_pos.h
have_getpgid.h
have_getprid.h

153
CHANGES
View File

@@ -1,4 +1,96 @@
The following are the changes from calc version 2.14.1.0 to date:
The following are the changes from calc version 2.14.1.2 to date:
Restored use of the #define FPOS_POS_LEN symbol. This refers to
the length of the __pos element (if the __pos element exists),
the fpos_t type (if that type exists).
Changed SWAP_HALF_IN_FILEPOS(dest, src) mato to use FILEPOS_LEN Little
Endian when FILEPOS is a simple scalar type (i.e., HAVE_FILEPOS_SCALAR
is defined).
Changed #define HAVE_FPOS to HAVE_FGETSETPOS.
Corrected comment in have_fpos_pos.h. The HAVE_FPOS_POS symbol was
NOT related to fgetpos & fsetpos but rather if we we have an __pos
element in FILEPOS.
Changed #define HAVE_NO_FPOS to HAVE_NO_FGETSETPOS.
Improved comments in have_fpos_pos.h to show why and how
HAVE_FPOS_POS, FPOS_POS_BITS, and FPOS_POS_LEN were defined or undefed.
Changed showfiles builtin to print sizes cast to (long int) with
the "%ld" printf format to avoid implementations that do not support
the "%lld" printf format specifier.
Renamed have_fpos.h to have_fgetsetpos.h. Renamed CALC_HAVE_FPOS_H
to CALC_HAVE_FGETSETPOS_H. The make install and the olduninstall
rules remove the any old have_fpos.h that was previously installed.
Added swap_HALFs(dest, src, len) function to byteswap.c.
Calc can now handle Big Engian file position sizes that are a
multiple of BASEB bits in length. Before handle Big Engian file
positions could only be 32 and 64 bits in length. This will allow,
for example, a Big Engian file position size of 128 (assuming that
128/BASEB is is an integer).
Temporary workaround for musl libc systems such as gentoo Linux that
allows them to compile calc and successfully run the regression test.
The following are the changes from calc version 2.14.1.1 to 2.14.1.1:
Added a few remarks on calc version numbers to version.c.
Fixed how fposval.h is built. On a number of systems, the fposval.c
file failed to compile incorrectly. This caused problems for systems in
which fposval.h.def was not correct.
Fixed how have_memmv.h is built. On a number of systems, the have_memmv.c
file failed to compile incorrectly, producing a potentially incorrect
have_memmv.h file for such systems.
Fixed how align32.h is built. On a number of systems, the align32.c
file failed to compile incorrectly, producing a potentially incorrect
align32.h file for such systems.
Fixed how have_newstr.h is built. On a number of systems, the have_newstr.c
failed to compile incorrectly, producing a potentially incorrect
have_newstr.h file for such systems.
Fixed how have_strdup.h is built. On a number of systems, the have_strdup.c
file failed to compile incorrectly, producing a potentially incorrect
have_strdup.h file for such systems.
Fixed how have_strlcat.h is built. On a number of systems, the have_strlcat.c
file failed to compile incorrectly, producing a potentially incorrect
have_strlcat.h file for such systems.
Fixed how have_strlcpy.h is built. On a number of systems, the have_strlcpy.c
file failed to compile incorrectly, producing a potentially incorrect
have_strlcpy.h file for such systems.
Fixed how have_uid_t.h is built. On a number of systems, the have_uid_t.c
file failed to compile incorrectly, producing a potentially incorrect
have_uid_t.h file for such systems.
Fixed how have_uid_t.h is built. On a number of systems, the have_uid_t.c
file failed to compile incorrectly, producing a potentially incorrect
have_uid_t.h file for such systems.
Added full_debug rule to Makefile. This does the work of the
old debug rule in a more verbose mode by using Q= H=@ S= E= V=@.
The debug rule in the Makefile now pre-removes debug.out and then
runs make full_debug sending stdout and stderr to debug.out. It then
prints a few instructions about filing a GitHub issue bug report.
The full_debug rule will no longer stop when one of the sub-tasks
failed (exit non-zero).
The following are the changes from calc version 2.14.1.0 to 2.14.1.0:
Fixed alignment of show item section of help command.
@@ -6,6 +98,65 @@ The following are the changes from calc version 2.14.1.0 to date:
Adjusted cal/test8900.cal to reflect this bug fix.
Added tests to cal/regress.cal to help verify bug fix is fixed.
Fixed a \-escape bug in calc(1) man page.
Added cal/comma.cal:
Convert numbers into strings with 3-digit group and integer-fraction
separators.
If the value is an integer, the integer-fraction separator is not used.
str_comma(x, [group, [decimal]])
Convert x into a string.
If group is given and is a string, group will be used as
the 3-digit group separator, otherwise the default 3-digit
group separator will be used.
If decimal is given and is a string, group will be used as
the integer-fraction separator, otherwise the default
integer-fraction separator will be used.
The decimal and group arguments are optional.
set_default_group_separator(group)
Change the default 3-digit group separator if group is a string,
otherwise the default 3-digit group separator will not be
changed. Return the old 3-digit group separator.
set_default_decimal_separator(decimal)
Change the default 3-digit group separator if decimal is a
string, otherwise the default integer-fraction separator
will not be changed. Return the old integer-fraction separator.
print_comma(x, [group, [decimal]])
Print the value produced by str_comma(x, [group, [decimal]])
followed by a newline.
If the str_comma() does not return a string, nothing is printed.
The decimal and group arguments are optional.
The value produced by str_comma() is returned.
fprint_comma(fd, x, [group, [decimal]])
Print the value produced by str_comma(x, [group, [decimal]]),
without a trailing newline, on file fd.
If the str_comma() does not return a string, nothing is printed.
If fd is not an open file, nothing is printed.
The decimal and group arguments are optional.
The value produced by str_comma() is returned.
The following are the changes from calc version 2.14.0.15 to 2.14.0.15:

138
Makefile
View File

@@ -280,14 +280,14 @@ LONG_BITS=
# Determine if we have the ANSI C fgetpos and fsetpos alternate interface
# to the ftell() and fseek() (with whence set to SEEK_SET) functions.
#
# If HAVE_FPOS is empty, this Makefile will run the have_fpos program
# to determine if there is are fgetpos and fsetpos functions. If HAVE_FPOS
# is set to -DHAVE_NO_FPOS, then calc will use ftell() and fseek().
# If HAVE_FGETSETPOS is empty, this Makefile will run the have_fpos program
# to determine if there is are fgetpos and fsetpos functions. If HAVE_FGETSETPOS
# is set to -DHAVE_NO_FGETSETPOS, then calc will use ftell() and fseek().
#
# If in doubt, leave HAVE_FPOS empty and this Makefile will figure it out.
# If in doubt, leave HAVE_FGETSETPOS empty and this Makefile will figure it out.
#
HAVE_FPOS=
#HAVE_FPOS= -DHAVE_NO_FPOS
HAVE_FGETSETPOS=
#HAVE_FGETSETPOS= -DHAVE_NO_FGETSETPOS
# Determine if we have an __pos element of a file position (fpos_t) structure.
#
@@ -1309,7 +1309,7 @@ EXT=
# The default calc versions
#
VERSION= 2.14.1.0
VERSION= 2.14.1.2
# Names of shared libraries with versions
#
@@ -1993,7 +1993,7 @@ ifndef EXCLUDE_FROM_CUSTOM_MAKEFILE
# Q= echo internal Makefile actions (debug / verbose mode)
#
# H=@: do not report hsrc file formation progress
# H=@ do echo hsrc file formation progress
# H=@ echo hsrc file formation progress
#
# S= >/dev/null 2>&1 silence ${CC} output during hsrc file formation
# S= full ${CC} output during hsrc file formation
@@ -2002,7 +2002,7 @@ ifndef EXCLUDE_FROM_CUSTOM_MAKEFILE
# E= full command stderr during hsrc file formation
#
# V=@: do not echo debug statements (quiet mode)
# V=@ do echo debug statements (debug / verbose mode)
# V=@ echo debug statements (debug / verbose mode)
#
#Q=
Q=@
@@ -2069,7 +2069,7 @@ LIB_H_SRC= alloc.h banned.h blkcpy.h block.h byteswap.h calc.h cmath.h \
# we build these .h files during the make
#
BUILD_H_SRC= align32.h args.h calcerr.h conf.h endian_calc.h \
fposval.h have_ban_pragma.h have_const.h have_fpos.h \
fposval.h have_ban_pragma.h have_const.h have_fgetsetpos.h \
have_fpos_pos.h have_getpgid.h have_getprid.h have_getsid.h \
have_gettime.h have_memmv.h have_newstr.h have_offscl.h \
have_posscl.h have_rusage.h have_stdlib.h have_strdup.h \
@@ -2087,7 +2087,7 @@ BUILD_C_SRC= calcerr.c
# There MUST be a .c for every .o in UTIL_OBJS.
#
UTIL_C_SRC= align32.c endian.c longbits.c have_newstr.c have_uid_t.c \
have_const.c have_stdvs.c have_varvs.c fposval.c have_fpos.c \
have_const.c have_stdvs.c have_varvs.c fposval.c have_fgetsetpos.c \
have_fpos_pos.c have_offscl.c have_posscl.c have_memmv.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 \
@@ -2105,7 +2105,7 @@ UTIL_MISC_SRC= calcerr_h.sed calcerr_h.awk calcerr_c.sed calcerr_c.awk \
# There MUST be a .o for every .c in UTIL_C_SRC.
#
UTIL_OBJS= endian.o longbits.o have_newstr.o have_uid_t.o \
have_const.o fposval.o have_fpos.o have_fpos_pos.o \
have_const.o fposval.o have_fgetsetpos.o have_fpos_pos.o \
try_strarg.o have_stdvs.o have_varvs.o have_posscl.o have_memmv.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 \
@@ -3176,7 +3176,7 @@ terminal.h: ${MAKE_FILE} ${LOC_MKF}
${TRUE}; \
fi
have_fpos.h: have_fpos.c banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
have_fgetsetpos.h: have_fgetsetpos.c banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f fpos_tmp $@
${H} echo 'forming $@'
${Q} echo '/*' > $@
@@ -3184,29 +3184,29 @@ have_fpos.h: have_fpos.c banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
${Q} echo ' */' >> $@
${Q} echo '' >> $@
${Q} echo '' >> $@
${Q} echo '#if !defined(CALC_HAVE_FPOS_H)' >> $@
${Q} echo '#define CALC_HAVE_FPOS_H' >> $@
${Q} echo '#if !defined(CALC_HAVE_FGETSETPOS_H)' >> $@
${Q} echo '#define CALC_HAVE_FGETSETPOS_H' >> $@
${Q} echo '' >> $@
${Q} echo '' >> $@
${Q} echo '/* do we have fgetpos & fsetpos functions? */' >> $@
${Q} ${RM} -f have_fpos.o have_fpos${EXT}
-${Q} ${LCC} ${HAVE_FPOS} ${ICFLAGS} have_fpos.c -c ${S} \
${Q} ${RM} -f have_fgetsetpos.o have_fpos${EXT}
-${Q} ${LCC} ${HAVE_FGETSETPOS} ${ICFLAGS} have_fgetsetpos.c -c ${S} \
|| ${TRUE}
-${Q} ${LCC} ${ILDFLAGS} have_fpos.o -o have_fpos${EXT} ${S} \
-${Q} ${LCC} ${ILDFLAGS} have_fgetsetpos.o -o have_fpos${EXT} ${S} \
|| ${TRUE}
-${Q} ./have_fpos${EXT} > fpos_tmp ${E} \
|| ${TRUE}
-${Q} if [ -s fpos_tmp ]; then \
${CAT} fpos_tmp >> $@; \
else \
echo '#undef HAVE_FPOS /* no */' >> $@; \
echo '#undef HAVE_FGETSETPOS /* no */' >> $@; \
echo '' >> $@; \
echo 'typedef long FILEPOS;' >> $@; \
fi
${Q} echo '' >> $@
${Q} echo '' >> $@
${Q} echo '#endif /* !CALC_HAVE_FPOS_H */' >> $@
${Q} ${RM} -f have_fpos${EXT} have_fpos.o fpos_tmp
${Q} echo '#endif /* !CALC_HAVE_FGETSETPOS_H */' >> $@
${Q} ${RM} -f have_fpos${EXT} have_fgetsetpos.o fpos_tmp
${H} echo '$@ formed'
-@if [ -z "${Q}" ]; then \
echo ''; \
@@ -3218,7 +3218,7 @@ have_fpos.h: have_fpos.c banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
${TRUE}; \
fi
have_fpos_pos.h: have_fpos_pos.c have_fpos.h have_posscl.h \
have_fpos_pos.h: have_fpos_pos.c have_fgetsetpos.h have_posscl.h \
banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f fpos_tmp $@
${H} echo 'forming $@'
@@ -3231,9 +3231,9 @@ have_fpos_pos.h: have_fpos_pos.c have_fpos.h have_posscl.h \
${Q} echo '#define CALC_HAVE_FPOS_POS_H' >> $@
${Q} echo '' >> $@
${Q} echo '' >> $@
${Q} echo '/* do we have fgetpos & fsetpos functions? */' >> $@
${Q} echo '/* do we have an __pos element in FILEPOS? */' >> $@
${Q} ${RM} -f have_fpos_pos.o have_fpos_pos${EXT}
-${Q} ${LCC} ${HAVE_FPOS} ${HAVE_FPOS_POS} ${ICFLAGS} \
-${Q} ${LCC} ${HAVE_FGETSETPOS} ${HAVE_FPOS_POS} ${ICFLAGS} \
have_fpos_pos.c -c ${S} \
|| ${TRUE}
-${Q} ${LCC} ${ILDFLAGS} have_fpos_pos.o -o have_fpos_pos${EXT} ${S} \
@@ -3262,9 +3262,10 @@ have_fpos_pos.h: have_fpos_pos.c have_fpos.h have_posscl.h \
${TRUE}; \
fi
fposval.h: fposval.c have_fpos.h have_fpos_pos.h have_offscl.h have_posscl.h \
fposval.h: fposval.c have_fgetsetpos.h have_fpos_pos.h have_offscl.h have_posscl.h \
endian_calc.h banned.h have_ban_pragma.h fposval.h.def alloc.h \
have_newstr.h have_memmv.h ${MAKE_FILE} ${LOC_MKF}
have_newstr.h have_memmv.h have_string.h have_const.h have_string.h \
have_unused.h ${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f fposval_tmp $@
${H} echo 'forming $@'
${Q} echo '/*' > $@
@@ -3389,7 +3390,7 @@ have_offscl.h: have_offscl.c have_unistd.h \
${TRUE}; \
fi
have_posscl.h: have_posscl.c have_fpos.h have_unistd.h \
have_posscl.h: have_posscl.c have_fgetsetpos.h have_unistd.h \
banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f have_posscl have_posscl.o posscl_tmp $@
${H} echo 'forming $@'
@@ -3431,7 +3432,7 @@ have_posscl.h: have_posscl.c have_fpos.h have_unistd.h \
fi
align32.h: align32.c longbits.h have_unistd.h \
banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
banned.h have_ban_pragma.h have_unused.h ${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f align32 align32_tmp $@
${H} echo 'forming $@'
${Q} echo '/*' > $@
@@ -3609,7 +3610,7 @@ have_arc4random.h: have_arc4random.c have_stdlib.h \
${TRUE}; \
fi
have_newstr.h: have_newstr.c banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
have_newstr.h: have_newstr.c banned.h have_ban_pragma.h have_string.h ${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f newstr_tmp $@
${H} echo 'forming $@'
${Q} echo '/*' > $@
@@ -3649,7 +3650,7 @@ have_newstr.h: have_newstr.c banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
${TRUE}; \
fi
have_memmv.h: have_memmv.c banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
have_memmv.h: have_memmv.c banned.h have_ban_pragma.h have_string.h ${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f have_memmv have_memmv.o memmv_tmp $@
${H} echo 'forming $@'
${Q} echo '/*' > $@
@@ -3968,7 +3969,7 @@ have_rusage.h: have_rusage.c banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
${TRUE}; \
fi
have_strdup.h: have_strdup.c banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
have_strdup.h: have_strdup.c banned.h have_ban_pragma.h have_string.h ${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f strdup_tmp $@
${H} echo 'forming $@'
${Q} echo '/*' > $@
@@ -4206,7 +4207,7 @@ have_ban_pragma.h: have_ban_pragma.c banned.h ${MAKE_FILE} ${LOC_MKF}
${TRUE}; \
fi
have_strlcpy.h: have_strlcpy.c banned.h have_ban_pragma.h \
have_strlcpy.h: have_strlcpy.c banned.h have_ban_pragma.h have_string.h \
${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f unused_tmp $@
${H} echo 'forming $@'
@@ -4248,7 +4249,7 @@ have_strlcpy.h: have_strlcpy.c banned.h have_ban_pragma.h \
${TRUE}; \
fi
have_strlcat.h: have_strlcat.c banned.h have_ban_pragma.h \
have_strlcat.h: have_strlcat.c banned.h have_ban_pragma.h have_string.h \
${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f unused_tmp $@
${H} echo 'forming $@'
@@ -4700,11 +4701,14 @@ chk: ./cal/regress.cal
# * print major Makefile variables
# * build anything not yet built
#
# make debug:
# make full_debug:
# * remove everything that was previously built
# * print major Makefile variables
# * make everything
# * run the regression tests
#
# make debug:
# * run 'make full_debug' and write stdout and stderr to debug.out
###
calcinfo:
@@ -4821,7 +4825,7 @@ env:
@echo 'HAVE_ARC4RANDOM=${HAVE_ARC4RANDOM}'; echo ''
@echo 'HAVE_CONST=${HAVE_CONST}'; echo ''
@echo 'HAVE_ENVIRON=${HAVE_ENVIRON}'; echo ''
@echo 'HAVE_FPOS=${HAVE_FPOS}'; echo ''
@echo 'HAVE_FGETSETPOS=${HAVE_FGETSETPOS}'; echo ''
@echo 'HAVE_FPOS_POS=${HAVE_FPOS_POS}'; echo ''
@echo 'HAVE_GETPGID=${HAVE_GETPGID}'; echo ''
@echo 'HAVE_GETPRID=${HAVE_GETPRID}'; echo ''
@@ -4937,45 +4941,58 @@ env:
mkdebug: env version.c
@echo '=-=-=-=-= ${MAKE_FILE} start of $@ rule =-=-=-=-='
@echo '=-=-=-= Contents of ${LOC_MKF} follows =-=-=-='
@${CAT} ${LOC_MKF}
-@${CAT} ${LOC_MKF}
@echo '=-=-=-= End of contents of ${LOC_MKF} =-=-=-='
@echo '=-=-=-= Determining the source version =-=-=-='
@${MAKE} -f Makefile Q= V=@ ver_calc${EXT}
-@${MAKE} -f Makefile Q= V=@ ver_calc${EXT}
-@./ver_calc${EXT}
@echo '=-=-=-= Invoking ${MAKE} -f Makefile Q= V=@ all =-=-=-='
@${MAKE} -f Makefile Q= V=@ all
@${MAKE} -f Makefile Q= H=@ S= E= V=@ all
@echo '=-=-=-= Back to the main Makefile for $@ rule =-=-=-='
@echo '=-=-=-= Determining the binary version =-=-=-='
-@./calc${EXT} -e -q -v
@echo '=-=-=-= Back to the main Makefile for $@ rule =-=-=-='
@echo '=-=-=-=-= ${MAKE_FILE} end of $@ rule =-=-=-=-='
debug: calcinfo env
full_debug: calcinfo env
@echo '=-=-=-=-= ${MAKE_FILE} start of $@ rule =-=-=-=-='
@echo '=-=-=-= Contents of ${LOC_MKF} follows =-=-=-='
@${CAT} ${LOC_MKF}
-@${CAT} ${LOC_MKF}
@echo '=-=-=-= End of contents of ${LOC_MKF} =-=-=-='
@echo '=-=-=-= Invoking ${MAKE} -f Makefile Q= V=@ clobber =-=-=-='
@${MAKE} -f Makefile Q= V=@ clobber
-@${MAKE} -f Makefile Q= H=@ S= E= V=@ clobber
@echo '=-=-=-= Back to the main Makefile for $@ rule =-=-=-='
@echo '=-=-=-= Invoking ${MAKE} -f Makefile Q= V=@ all =-=-=-='
@echo '=-=-= this may take a bit of time =-=-='
@${MAKE} -f Makefile Q= V=@ all
-@${MAKE} -f Makefile Q= H=@ S= E= V=@ all
@echo '=-=-=-= Back to the main Makefile for $@ rule =-=-=-='
@echo '=-=-=-= Determining the source version =-=-=-='
@${MAKE} -f Makefile Q= V=@ ver_calc${EXT}
-@${MAKE} -f Makefile Q= H=@ S= E= V=@ ver_calc${EXT}
-@./ver_calc${EXT}
@echo '=-=-=-= Back to the main Makefile for $@ rule =-=-=-='
@${ECHON} '=-=-=-= Print #defile values if custom functions '
-@${ECHON} '=-=-=-= Print #defile values if custom functions '
@echo 'are allowed =-=-=-='
-@${CALC_ENV} ./calc${EXT} -e -q -C 'print custom("sysinfo", 2);'
@echo '=-=-=-= Back to the main Makefile for $@ rule =-=-=-='
@echo '=-=-=-= Invoking ${MAKE} -f Makefile Q= V=@ check =-=-=-='
@echo '=-=-= this may take a while =-=-='
@${MAKE} -f Makefile Q= V=@ check
-@${MAKE} -f Makefile Q= V=@ check
@echo '=-=-=-= Back to the main Makefile for $@ rule =-=-=-='
@echo '=-=-=-=-= ${MAKE_FILE} end of $@ rule =-=-=-=-='
debug:
-${RM} -f debug.out
-${MAKE} -f Makefile full_debug 2>&1 | ${TEE} debug.out
@echo
@echo 'To file a bug report / open a GitHub Issue, visit:'
@echo
@echo ' https://github.com/lcn2/calc/issues'
@echo
@echo 'Click the ((New issue)) button to file a bug report.'
@echo
@echo 'Please attch the debug.out file to the bug report.'
@echo
###
#
# testing rules
@@ -5126,6 +5143,7 @@ olduninstall:
-${RMDIR} /usr/local/bin/cscript
${RM} -f inst_files
${RM} -f ${CALC_INCDIR}/calcerr.c
${RM} -f ${CALC_INCDIR}/have_fgetsetpos.h
tags: ${CALCSRC} ${LIBSRC} ${H_SRC} ${BUILD_H_SRC} ${MAKE_FILE}
-${CTAGS} ${CALCSRC} ${LIBSRC} ${H_SRC} ${BUILD_H_SRC} 2>&1 | \
@@ -5512,6 +5530,9 @@ endif
fi
${V} # NOTE: misc install cleanup
${Q} ${RM} -f tmp
${V} # NOTE: have_fgetsetpos.h has been renamed to have_fgetsetpos.h so we
${V} # remove the old have_fgetsetpos.h include file.
${Q} ${RM} -f ${CALC_INCDIR}/have_fgetsetpos.h
${V} # NOTE: remove the calcerr.c that was installed by mistake
${V} # under ${INC_DIR} in calc v2.12.9.1
${Q} ${RM} -f ${T}${CALC_INCDIR}/calcerr.c
@@ -5802,7 +5823,9 @@ addop.o: zmath.h
align32.o: align32.c
align32.o: banned.h
align32.o: have_ban_pragma.h
align32.o: have_stdlib.h
align32.o: have_unistd.h
align32.o: have_unused.h
align32.o: longbits.h
assocfunc.o: alloc.h
assocfunc.o: assocfunc.c
@@ -5846,7 +5869,7 @@ blkcpy.o: file.h
blkcpy.o: hash.h
blkcpy.o: have_ban_pragma.h
blkcpy.o: have_const.h
blkcpy.o: have_fpos.h
blkcpy.o: have_fgetsetpos.h
blkcpy.o: have_memmv.h
blkcpy.o: have_newstr.h
blkcpy.o: have_stdlib.h
@@ -6134,7 +6157,7 @@ file.o: fposval.h
file.o: hash.h
file.o: have_ban_pragma.h
file.o: have_const.h
file.o: have_fpos.h
file.o: have_fgetsetpos.h
file.o: have_fpos_pos.h
file.o: have_memmv.h
file.o: have_newstr.h
@@ -6153,16 +6176,19 @@ file.o: value.h
file.o: zmath.h
fposval.o: alloc.h
fposval.o: banned.h
fposval.o: decl.h
fposval.o: endian_calc.h
fposval.o: fposval.c
fposval.o: have_ban_pragma.h
fposval.o: have_fpos.h
fposval.o: have_const.h
fposval.o: have_fgetsetpos.h
fposval.o: have_fpos_pos.h
fposval.o: have_memmv.h
fposval.o: have_newstr.h
fposval.o: have_offscl.h
fposval.o: have_posscl.h
fposval.o: have_string.h
fposval.o: have_unused.h
func.o: alloc.h
func.o: attribute.h
func.o: banned.h
@@ -6181,7 +6207,7 @@ func.o: func.h
func.o: hash.h
func.o: have_ban_pragma.h
func.o: have_const.h
func.o: have_fpos.h
func.o: have_fgetsetpos.h
func.o: have_memmv.h
func.o: have_newstr.h
func.o: have_rusage.h
@@ -6249,12 +6275,12 @@ have_const.o: have_const.c
have_environ.o: banned.h
have_environ.o: have_ban_pragma.h
have_environ.o: have_environ.c
have_fpos.o: banned.h
have_fpos.o: have_ban_pragma.h
have_fpos.o: have_fpos.c
have_fgetsetpos.o: banned.h
have_fgetsetpos.o: have_ban_pragma.h
have_fgetsetpos.o: have_fgetsetpos.c
have_fpos_pos.o: banned.h
have_fpos_pos.o: have_ban_pragma.h
have_fpos_pos.o: have_fpos.h
have_fpos_pos.o: have_fgetsetpos.h
have_fpos_pos.o: have_fpos_pos.c
have_fpos_pos.o: have_posscl.h
have_getpgid.o: banned.h
@@ -6286,7 +6312,7 @@ have_offscl.o: have_offscl.c
have_offscl.o: have_unistd.h
have_posscl.o: banned.h
have_posscl.o: have_ban_pragma.h
have_posscl.o: have_fpos.h
have_posscl.o: have_fgetsetpos.h
have_posscl.o: have_posscl.c
have_posscl.o: have_unistd.h
have_rusage.o: banned.h
@@ -6650,7 +6676,7 @@ opcodes.o: func.h
opcodes.o: hash.h
opcodes.o: have_ban_pragma.h
opcodes.o: have_const.h
opcodes.o: have_fpos.h
opcodes.o: have_fgetsetpos.h
opcodes.o: have_memmv.h
opcodes.o: have_newstr.h
opcodes.o: have_stdlib.h
@@ -7103,7 +7129,7 @@ value.o: func.h
value.o: hash.h
value.o: have_ban_pragma.h
value.o: have_const.h
value.o: have_fpos.h
value.o: have_fgetsetpos.h
value.o: have_memmv.h
value.o: have_newstr.h
value.o: have_stdlib.h

View File

@@ -220,14 +220,14 @@ LONG_BITS=
# Determine if we have the ANSI C fgetpos and fsetpos alternate interface
# to the ftell() and fseek() (with whence set to SEEK_SET) functions.
#
# If HAVE_FPOS is empty, this Makefile will run the have_fpos program
# to determine if there is are fgetpos and fsetpos functions. If HAVE_FPOS
# is set to -DHAVE_NO_FPOS, then calc will use ftell() and fseek().
# If HAVE_FGETSETPOS is empty, this Makefile will run the have_fpos program
# to determine if there is are fgetpos and fsetpos functions. If HAVE_FGETSETPOS
# is set to -DHAVE_NO_FGETSETPOS, then calc will use ftell() and fseek().
#
# If in doubt, leave HAVE_FPOS empty and this Makefile will figure it out.
# If in doubt, leave HAVE_FGETSETPOS empty and this Makefile will figure it out.
#
HAVE_FPOS=
#HAVE_FPOS= -DHAVE_NO_FPOS
HAVE_FGETSETPOS=
#HAVE_FGETSETPOS= -DHAVE_NO_FGETSETPOS
# Determine if we have an __pos element of a file position (fpos_t) structure.
#
@@ -1151,7 +1151,7 @@ EXT=
# The default calc versions
#
VERSION= 2.14.1.0
VERSION= 2.14.1.2
# Names of shared libraries with versions
#
@@ -1400,7 +1400,7 @@ LDFLAGS= ${LD_DEBUG} ${ILDFLAGS} ${LIBCALC_STATIC} ${LIBCUSTCALC_STATIC}
# Q= echo internal Makefile actions (debug / verbose mode)
#
# H=@: do not report hsrc file formation progress
# H=@ do echo hsrc file formation progress
# H=@ echo hsrc file formation progress
#
# S= >/dev/null 2>&1 silence ${CC} output during hsrc file formation
# S= full ${CC} output during hsrc file formation
@@ -1409,7 +1409,7 @@ LDFLAGS= ${LD_DEBUG} ${ILDFLAGS} ${LIBCALC_STATIC} ${LIBCUSTCALC_STATIC}
# E= full command stderr during hsrc file formation
#
# V=@: do not echo debug statements (quiet mode)
# V=@ do echo debug statements (debug / verbose mode)
# V=@ echo debug statements (debug / verbose mode)
#
#Q=
Q=@
@@ -1476,7 +1476,7 @@ LIB_H_SRC= alloc.h banned.h blkcpy.h block.h byteswap.h calc.h cmath.h \
# we build these .h files during the make
#
BUILD_H_SRC= align32.h args.h calcerr.h conf.h endian_calc.h \
fposval.h have_ban_pragma.h have_const.h have_fpos.h \
fposval.h have_ban_pragma.h have_const.h have_fgetsetpos.h \
have_fpos_pos.h have_getpgid.h have_getprid.h have_getsid.h \
have_gettime.h have_memmv.h have_newstr.h have_offscl.h \
have_posscl.h have_rusage.h have_stdlib.h have_strdup.h \
@@ -1494,7 +1494,7 @@ BUILD_C_SRC= calcerr.c
# There MUST be a .c for every .o in UTIL_OBJS.
#
UTIL_C_SRC= align32.c endian.c longbits.c have_newstr.c have_uid_t.c \
have_const.c have_stdvs.c have_varvs.c fposval.c have_fpos.c \
have_const.c have_stdvs.c have_varvs.c fposval.c have_fgetsetpos.c \
have_fpos_pos.c have_offscl.c have_posscl.c have_memmv.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 \
@@ -1512,7 +1512,7 @@ UTIL_MISC_SRC= calcerr_h.sed calcerr_h.awk calcerr_c.sed calcerr_c.awk \
# There MUST be a .o for every .c in UTIL_C_SRC.
#
UTIL_OBJS= endian.o longbits.o have_newstr.o have_uid_t.o \
have_const.o fposval.o have_fpos.o have_fpos_pos.o \
have_const.o fposval.o have_fgetsetpos.o have_fpos_pos.o \
try_strarg.o have_stdvs.o have_varvs.o have_posscl.o have_memmv.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 \
@@ -2490,7 +2490,7 @@ terminal.h: ${MAKE_FILE} ${LOC_MKF}
${TRUE}; \
fi
have_fpos.h: have_fpos.c banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
have_fgetsetpos.h: have_fgetsetpos.c banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f fpos_tmp $@
${H} echo 'forming $@'
${Q} echo '/*' > $@
@@ -2498,29 +2498,29 @@ have_fpos.h: have_fpos.c banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
${Q} echo ' */' >> $@
${Q} echo '' >> $@
${Q} echo '' >> $@
${Q} echo '#if !defined(CALC_HAVE_FPOS_H)' >> $@
${Q} echo '#define CALC_HAVE_FPOS_H' >> $@
${Q} echo '#if !defined(CALC_HAVE_FGETSETPOS_H)' >> $@
${Q} echo '#define CALC_HAVE_FGETSETPOS_H' >> $@
${Q} echo '' >> $@
${Q} echo '' >> $@
${Q} echo '/* do we have fgetpos & fsetpos functions? */' >> $@
${Q} ${RM} -f have_fpos.o have_fpos${EXT}
-${Q} ${LCC} ${HAVE_FPOS} ${ICFLAGS} have_fpos.c -c ${S} \
${Q} ${RM} -f have_fgetsetpos.o have_fpos${EXT}
-${Q} ${LCC} ${HAVE_FGETSETPOS} ${ICFLAGS} have_fgetsetpos.c -c ${S} \
|| ${TRUE}
-${Q} ${LCC} ${ILDFLAGS} have_fpos.o -o have_fpos${EXT} ${S} \
-${Q} ${LCC} ${ILDFLAGS} have_fgetsetpos.o -o have_fpos${EXT} ${S} \
|| ${TRUE}
-${Q} ./have_fpos${EXT} > fpos_tmp ${E} \
|| ${TRUE}
-${Q} if [ -s fpos_tmp ]; then \
${CAT} fpos_tmp >> $@; \
else \
echo '#undef HAVE_FPOS /* no */' >> $@; \
echo '#undef HAVE_FGETSETPOS /* no */' >> $@; \
echo '' >> $@; \
echo 'typedef long FILEPOS;' >> $@; \
fi
${Q} echo '' >> $@
${Q} echo '' >> $@
${Q} echo '#endif /* !CALC_HAVE_FPOS_H */' >> $@
${Q} ${RM} -f have_fpos${EXT} have_fpos.o fpos_tmp
${Q} echo '#endif /* !CALC_HAVE_FGETSETPOS_H */' >> $@
${Q} ${RM} -f have_fpos${EXT} have_fgetsetpos.o fpos_tmp
${H} echo '$@ formed'
-@if [ -z "${Q}" ]; then \
echo ''; \
@@ -2532,7 +2532,7 @@ have_fpos.h: have_fpos.c banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
${TRUE}; \
fi
have_fpos_pos.h: have_fpos_pos.c have_fpos.h have_posscl.h \
have_fpos_pos.h: have_fpos_pos.c have_fgetsetpos.h have_posscl.h \
banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f fpos_tmp $@
${H} echo 'forming $@'
@@ -2545,9 +2545,9 @@ have_fpos_pos.h: have_fpos_pos.c have_fpos.h have_posscl.h \
${Q} echo '#define CALC_HAVE_FPOS_POS_H' >> $@
${Q} echo '' >> $@
${Q} echo '' >> $@
${Q} echo '/* do we have fgetpos & fsetpos functions? */' >> $@
${Q} echo '/* do we have an __pos element in FILEPOS? */' >> $@
${Q} ${RM} -f have_fpos_pos.o have_fpos_pos${EXT}
-${Q} ${LCC} ${HAVE_FPOS} ${HAVE_FPOS_POS} ${ICFLAGS} \
-${Q} ${LCC} ${HAVE_FGETSETPOS} ${HAVE_FPOS_POS} ${ICFLAGS} \
have_fpos_pos.c -c ${S} \
|| ${TRUE}
-${Q} ${LCC} ${ILDFLAGS} have_fpos_pos.o -o have_fpos_pos${EXT} ${S} \
@@ -2576,9 +2576,10 @@ have_fpos_pos.h: have_fpos_pos.c have_fpos.h have_posscl.h \
${TRUE}; \
fi
fposval.h: fposval.c have_fpos.h have_fpos_pos.h have_offscl.h have_posscl.h \
fposval.h: fposval.c have_fgetsetpos.h have_fpos_pos.h have_offscl.h have_posscl.h \
endian_calc.h banned.h have_ban_pragma.h fposval.h.def alloc.h \
have_newstr.h have_memmv.h ${MAKE_FILE} ${LOC_MKF}
have_newstr.h have_memmv.h have_string.h have_const.h have_string.h \
have_unused.h ${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f fposval_tmp $@
${H} echo 'forming $@'
${Q} echo '/*' > $@
@@ -2703,7 +2704,7 @@ have_offscl.h: have_offscl.c have_unistd.h \
${TRUE}; \
fi
have_posscl.h: have_posscl.c have_fpos.h have_unistd.h \
have_posscl.h: have_posscl.c have_fgetsetpos.h have_unistd.h \
banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f have_posscl have_posscl.o posscl_tmp $@
${H} echo 'forming $@'
@@ -2745,7 +2746,7 @@ have_posscl.h: have_posscl.c have_fpos.h have_unistd.h \
fi
align32.h: align32.c longbits.h have_unistd.h \
banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
banned.h have_ban_pragma.h have_unused.h ${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f align32 align32_tmp $@
${H} echo 'forming $@'
${Q} echo '/*' > $@
@@ -2923,7 +2924,7 @@ have_arc4random.h: have_arc4random.c have_stdlib.h \
${TRUE}; \
fi
have_newstr.h: have_newstr.c banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
have_newstr.h: have_newstr.c banned.h have_ban_pragma.h have_string.h ${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f newstr_tmp $@
${H} echo 'forming $@'
${Q} echo '/*' > $@
@@ -2963,7 +2964,7 @@ have_newstr.h: have_newstr.c banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
${TRUE}; \
fi
have_memmv.h: have_memmv.c banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
have_memmv.h: have_memmv.c banned.h have_ban_pragma.h have_string.h ${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f have_memmv have_memmv.o memmv_tmp $@
${H} echo 'forming $@'
${Q} echo '/*' > $@
@@ -3282,7 +3283,7 @@ have_rusage.h: have_rusage.c banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
${TRUE}; \
fi
have_strdup.h: have_strdup.c banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
have_strdup.h: have_strdup.c banned.h have_ban_pragma.h have_string.h ${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f strdup_tmp $@
${H} echo 'forming $@'
${Q} echo '/*' > $@
@@ -3520,7 +3521,7 @@ have_ban_pragma.h: have_ban_pragma.c banned.h ${MAKE_FILE} ${LOC_MKF}
${TRUE}; \
fi
have_strlcpy.h: have_strlcpy.c banned.h have_ban_pragma.h \
have_strlcpy.h: have_strlcpy.c banned.h have_ban_pragma.h have_string.h \
${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f unused_tmp $@
${H} echo 'forming $@'
@@ -3562,7 +3563,7 @@ have_strlcpy.h: have_strlcpy.c banned.h have_ban_pragma.h \
${TRUE}; \
fi
have_strlcat.h: have_strlcat.c banned.h have_ban_pragma.h \
have_strlcat.h: have_strlcat.c banned.h have_ban_pragma.h have_string.h \
${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f unused_tmp $@
${H} echo 'forming $@'
@@ -3988,11 +3989,14 @@ chk: ./cal/regress.cal
# * print major Makefile variables
# * build anything not yet built
#
# make debug:
# make full_debug:
# * remove everything that was previously built
# * print major Makefile variables
# * make everything
# * run the regression tests
#
# make debug:
# * run 'make full_debug' and write stdout and stderr to debug.out
###
calcinfo:
@@ -4109,7 +4113,7 @@ env:
@echo 'HAVE_ARC4RANDOM=${HAVE_ARC4RANDOM}'; echo ''
@echo 'HAVE_CONST=${HAVE_CONST}'; echo ''
@echo 'HAVE_ENVIRON=${HAVE_ENVIRON}'; echo ''
@echo 'HAVE_FPOS=${HAVE_FPOS}'; echo ''
@echo 'HAVE_FGETSETPOS=${HAVE_FGETSETPOS}'; echo ''
@echo 'HAVE_FPOS_POS=${HAVE_FPOS_POS}'; echo ''
@echo 'HAVE_GETPGID=${HAVE_GETPGID}'; echo ''
@echo 'HAVE_GETPRID=${HAVE_GETPRID}'; echo ''
@@ -4225,45 +4229,58 @@ env:
mkdebug: env version.c
@echo '=-=-=-=-= ${MAKE_FILE} start of $@ rule =-=-=-=-='
@echo '=-=-=-= Contents of ${LOC_MKF} follows =-=-=-='
@${CAT} ${LOC_MKF}
-@${CAT} ${LOC_MKF}
@echo '=-=-=-= End of contents of ${LOC_MKF} =-=-=-='
@echo '=-=-=-= Determining the source version =-=-=-='
@${MAKE} -f Makefile Q= V=@ ver_calc${EXT}
-@${MAKE} -f Makefile Q= V=@ ver_calc${EXT}
-@./ver_calc${EXT}
@echo '=-=-=-= Invoking ${MAKE} -f Makefile Q= V=@ all =-=-=-='
@${MAKE} -f Makefile Q= V=@ all
@${MAKE} -f Makefile Q= H=@ S= E= V=@ all
@echo '=-=-=-= Back to the main Makefile for $@ rule =-=-=-='
@echo '=-=-=-= Determining the binary version =-=-=-='
-@./calc${EXT} -e -q -v
@echo '=-=-=-= Back to the main Makefile for $@ rule =-=-=-='
@echo '=-=-=-=-= ${MAKE_FILE} end of $@ rule =-=-=-=-='
debug: calcinfo env
full_debug: calcinfo env
@echo '=-=-=-=-= ${MAKE_FILE} start of $@ rule =-=-=-=-='
@echo '=-=-=-= Contents of ${LOC_MKF} follows =-=-=-='
@${CAT} ${LOC_MKF}
-@${CAT} ${LOC_MKF}
@echo '=-=-=-= End of contents of ${LOC_MKF} =-=-=-='
@echo '=-=-=-= Invoking ${MAKE} -f Makefile Q= V=@ clobber =-=-=-='
@${MAKE} -f Makefile Q= V=@ clobber
-@${MAKE} -f Makefile Q= H=@ S= E= V=@ clobber
@echo '=-=-=-= Back to the main Makefile for $@ rule =-=-=-='
@echo '=-=-=-= Invoking ${MAKE} -f Makefile Q= V=@ all =-=-=-='
@echo '=-=-= this may take a bit of time =-=-='
@${MAKE} -f Makefile Q= V=@ all
-@${MAKE} -f Makefile Q= H=@ S= E= V=@ all
@echo '=-=-=-= Back to the main Makefile for $@ rule =-=-=-='
@echo '=-=-=-= Determining the source version =-=-=-='
@${MAKE} -f Makefile Q= V=@ ver_calc${EXT}
-@${MAKE} -f Makefile Q= H=@ S= E= V=@ ver_calc${EXT}
-@./ver_calc${EXT}
@echo '=-=-=-= Back to the main Makefile for $@ rule =-=-=-='
@${ECHON} '=-=-=-= Print #defile values if custom functions '
-@${ECHON} '=-=-=-= Print #defile values if custom functions '
@echo 'are allowed =-=-=-='
-@${CALC_ENV} ./calc${EXT} -e -q -C 'print custom("sysinfo", 2);'
@echo '=-=-=-= Back to the main Makefile for $@ rule =-=-=-='
@echo '=-=-=-= Invoking ${MAKE} -f Makefile Q= V=@ check =-=-=-='
@echo '=-=-= this may take a while =-=-='
@${MAKE} -f Makefile Q= V=@ check
-@${MAKE} -f Makefile Q= V=@ check
@echo '=-=-=-= Back to the main Makefile for $@ rule =-=-=-='
@echo '=-=-=-=-= ${MAKE_FILE} end of $@ rule =-=-=-=-='
debug:
-${RM} -f debug.out
-${MAKE} -f Makefile full_debug 2>&1 | ${TEE} debug.out
@echo
@echo 'To file a bug report / open a GitHub Issue, visit:'
@echo
@echo ' https://github.com/lcn2/calc/issues'
@echo
@echo 'Click the ((New issue)) button to file a bug report.'
@echo
@echo 'Please attch the debug.out file to the bug report.'
@echo
###
#
# testing rules
@@ -4414,6 +4431,7 @@ olduninstall:
-${RMDIR} /usr/local/bin/cscript
${RM} -f inst_files
${RM} -f ${CALC_INCDIR}/calcerr.c
${RM} -f ${CALC_INCDIR}/have_fgetsetpos.h
tags: ${CALCSRC} ${LIBSRC} ${H_SRC} ${BUILD_H_SRC} ${MAKE_FILE}
-${CTAGS} ${CALCSRC} ${LIBSRC} ${H_SRC} ${BUILD_H_SRC} 2>&1 | \
@@ -4780,6 +4798,9 @@ install: ${LIB_H_SRC} ${BUILD_H_SRC} calc.1 all custom/Makefile
fi
${V} # NOTE: misc install cleanup
${Q} ${RM} -f tmp
${V} # NOTE: have_fgetsetpos.h has been renamed to have_fgetsetpos.h so we
${V} # remove the old have_fgetsetpos.h include file.
${Q} ${RM} -f ${CALC_INCDIR}/have_fgetsetpos.h
${V} # NOTE: remove the calcerr.c that was installed by mistake
${V} # under ${INC_DIR} in calc v2.12.9.1
${Q} ${RM} -f ${T}${CALC_INCDIR}/calcerr.c
@@ -5070,7 +5091,9 @@ addop.o: zmath.h
align32.o: align32.c
align32.o: banned.h
align32.o: have_ban_pragma.h
align32.o: have_stdlib.h
align32.o: have_unistd.h
align32.o: have_unused.h
align32.o: longbits.h
assocfunc.o: alloc.h
assocfunc.o: assocfunc.c
@@ -5114,7 +5137,7 @@ blkcpy.o: file.h
blkcpy.o: hash.h
blkcpy.o: have_ban_pragma.h
blkcpy.o: have_const.h
blkcpy.o: have_fpos.h
blkcpy.o: have_fgetsetpos.h
blkcpy.o: have_memmv.h
blkcpy.o: have_newstr.h
blkcpy.o: have_stdlib.h
@@ -5402,7 +5425,7 @@ file.o: fposval.h
file.o: hash.h
file.o: have_ban_pragma.h
file.o: have_const.h
file.o: have_fpos.h
file.o: have_fgetsetpos.h
file.o: have_fpos_pos.h
file.o: have_memmv.h
file.o: have_newstr.h
@@ -5421,16 +5444,19 @@ file.o: value.h
file.o: zmath.h
fposval.o: alloc.h
fposval.o: banned.h
fposval.o: decl.h
fposval.o: endian_calc.h
fposval.o: fposval.c
fposval.o: have_ban_pragma.h
fposval.o: have_fpos.h
fposval.o: have_const.h
fposval.o: have_fgetsetpos.h
fposval.o: have_fpos_pos.h
fposval.o: have_memmv.h
fposval.o: have_newstr.h
fposval.o: have_offscl.h
fposval.o: have_posscl.h
fposval.o: have_string.h
fposval.o: have_unused.h
func.o: alloc.h
func.o: attribute.h
func.o: banned.h
@@ -5449,7 +5475,7 @@ func.o: func.h
func.o: hash.h
func.o: have_ban_pragma.h
func.o: have_const.h
func.o: have_fpos.h
func.o: have_fgetsetpos.h
func.o: have_memmv.h
func.o: have_newstr.h
func.o: have_rusage.h
@@ -5517,12 +5543,12 @@ have_const.o: have_const.c
have_environ.o: banned.h
have_environ.o: have_ban_pragma.h
have_environ.o: have_environ.c
have_fpos.o: banned.h
have_fpos.o: have_ban_pragma.h
have_fpos.o: have_fpos.c
have_fgetsetpos.o: banned.h
have_fgetsetpos.o: have_ban_pragma.h
have_fgetsetpos.o: have_fgetsetpos.c
have_fpos_pos.o: banned.h
have_fpos_pos.o: have_ban_pragma.h
have_fpos_pos.o: have_fpos.h
have_fpos_pos.o: have_fgetsetpos.h
have_fpos_pos.o: have_fpos_pos.c
have_fpos_pos.o: have_posscl.h
have_getpgid.o: banned.h
@@ -5554,7 +5580,7 @@ have_offscl.o: have_offscl.c
have_offscl.o: have_unistd.h
have_posscl.o: banned.h
have_posscl.o: have_ban_pragma.h
have_posscl.o: have_fpos.h
have_posscl.o: have_fgetsetpos.h
have_posscl.o: have_posscl.c
have_posscl.o: have_unistd.h
have_rusage.o: banned.h
@@ -5918,7 +5944,7 @@ opcodes.o: func.h
opcodes.o: hash.h
opcodes.o: have_ban_pragma.h
opcodes.o: have_const.h
opcodes.o: have_fpos.h
opcodes.o: have_fgetsetpos.h
opcodes.o: have_memmv.h
opcodes.o: have_newstr.h
opcodes.o: have_stdlib.h
@@ -6371,7 +6397,7 @@ value.o: func.h
value.o: hash.h
value.o: have_ban_pragma.h
value.o: have_const.h
value.o: have_fpos.h
value.o: have_fgetsetpos.h
value.o: have_memmv.h
value.o: have_newstr.h
value.o: have_stdlib.h

View File

@@ -15,5 +15,5 @@ FYI: please review the BUGS file, or enter the calc command:
Please create a calc GitHub repo issue:
https://github.com/lcn2/calc/issues
Click on ((New issue)) and follow the issue template.

View File

@@ -27,6 +27,11 @@
#include <stdio.h>
#include <signal.h>
#include "have_stdlib.h"
#if defined(HAVE_STDLIB_H)
#include <stdlib.h>
#endif
#include "longbits.h"
#include "have_unistd.h"
@@ -34,11 +39,13 @@
#include <unistd.h>
#endif
#include "have_unused.h"
#include "banned.h" /* include after system header <> includes */
static void buserr(void); /* catch alignment errors */
static void buserr(int arg); /* catch alignment errors */
int
@@ -46,7 +53,7 @@ main(void)
{
char byte[2*sizeof(USB32)]; /* mis-alignment buffer */
USB32 *p; /* mis-alignment pointer */
int i;
unsigned long i;
#if defined(MUST_ALIGN32)
/* force alignment */
@@ -82,7 +89,7 @@ main(void)
*/
/*ARGSUSED*/
static void
buserr(int arg)
buserr(int UNUSED(arg))
{
/* alignment is required */
printf("#define MUST_ALIGN32\t%c* must align 32 bit values *%c\n",

View File

@@ -40,7 +40,7 @@
* dest - pointer to where the swapped src will be put or
* NULL to allocate the storage
* src - pointer to a HALF array to swap
* len - length of the src HALF array
* len - length of the src HALF array in HALFs
*
* returns:
* pointer to where the swapped src has been put
@@ -276,7 +276,7 @@ swap_b8_in_COMPLEX(COMPLEX *dest, COMPLEX *src, BOOL all)
* dest - pointer to where the swapped src will be put or
* NULL to allocate the storage
* src - pointer to a HALF array to swap
* len - length of the src HALF array
* len - length of the src HALF array in HALFs
*
* returns:
* pointer to where the swapped src has been put
@@ -309,6 +309,50 @@ swap_b16_in_HALFs(HALF *dest, HALF *src, LEN len)
}
/*
* swap_HALFs - swap HALFs in an array of HALFs
*
* given:
* dest - pointer to where the swapped src will be put or
* NULL to allocate the storage
* src - pointer to a HALF array to swap
* len - length of the src HALF array in HALFs
*
* returns:
* pointer to where the swapped src has been put
*/
HALF *
swap_HALFs(HALF *dest, HALF *src, LEN len)
{
HALF *s; /* src swap pointer */
HALF *d; /* dest swap pointer */
HALF *ret;
LEN i;
/*
* allocate storage if needed
*/
if (dest == NULL) {
dest = alloc(len);
}
ret = dest;
/*
* swap HALFs in the array
*/
s = src;
d = &dest[len-1];
for (i=0; i < len; ++i, --d, ++s) {
*d = *s;
}
/*
* return the result
*/
return ret;
}
/*
* swap_b16_in_ZVALUE - swap 16 bits in a ZVALUE
*

View File

@@ -267,9 +267,9 @@ TRUE= true
#
CALC_FILES= README alg_config.cal beer.cal bernoulli.cal \
bernpoly.cal bigprime.cal bindings brentsolve.cal chi.cal chrem.cal \
constants.cal deg.cal dms.cal dotest.cal ellip.cal factorial.cal \
factorial2.cal gvec.cal hello.cal hms.cal infinities.cal intfile.cal \
intnum.cal lambertw.cal linear.cal lnseries.cal lucas.cal \
comma.cal constants.cal deg.cal dms.cal dotest.cal ellip.cal \
factorial.cal factorial2.cal gvec.cal hello.cal hms.cal infinities.cal \
intfile.cal intnum.cal lambertw.cal linear.cal lnseries.cal lucas.cal \
lucas_chk.cal mersenne.cal mfactor.cal mod.cal natnumset.cal \
palindrome.cal pell.cal pi.cal pix.cal pollard.cal poly.cal prompt.cal \
psqrt.cal qtime.cal quat.cal randbitrun.cal randmprime.cal \

View File

@@ -263,6 +263,64 @@ chrem.cal
Chinese remainder theorem/problem solver.
comma.cal
Convert numbers into strings with 3-digit group and integer-fraction
separators.
If the value is an integer, the integer-fraction separator is not used.
str_comma(x, [group, [decimal]])
Convert x into a string.
If group is given and is a string, group will be used as
the 3-digit group separator, otherwise the default 3-digit
group separator will be used.
If decimal is given and is a string, group will be used as
the integer-fraction separator, otherwise the default
integer-fraction separator will be used.
The decimal and group arguments are optional.
set_default_group_separator(group)
Change the default 3-digit group separator if group is a string,
otherwise the default 3-digit group separator will not be
changed. Return the old 3-digit group separator.
set_default_decimal_separator(decimal)
Change the default 3-digit group separator if decimal is a
string, otherwise the default integer-fraction separator
will not be changed. Return the old integer-fraction separator.
print_comma(x, [group, [decimal]])
Print the value produced by str_comma(x, [group, [decimal]])
followed by a newline.
If the str_comma() does not return a string, nothing is printed.
The decimal and group arguments are optional.
The value produced by str_comma() is returned.
fprint_comma(fd, x, [group, [decimal]])
Print the value produced by str_comma(x, [group, [decimal]]),
without a trailing newline, on file fd.
If the str_comma() does not return a string, nothing is printed.
If fd is not an open file, nothing is printed.
The decimal and group arguments are optional.
The value produced by str_comma() is returned.
deg.cal
deg(deg, min, sec)

437
cal/comma.cal Normal file
View File

@@ -0,0 +1,437 @@
/*
* comma - convert numbers into strings with 3-digit group and integer-fraction separators
*
* Convert numbers into strings with 3-digit group and integer-fraction separators.
*
* If the value is an integer, the integer-fraction separator is not used.
*
* str_comma(x, [group, [decimal]])
*
* Convert x into a string.
*
* If group is given and is a string, group will be used as
* the 3-digit group separator, otherwise the default 3-digit
* group separator will be used.
*
* If decimal is given and is a string, group will be used as
* the integer-fraction separator, otherwise the default
* integer-fraction separator will be used.
*
* The decimal and group arguments are optional.
*
* set_default_group_separator(group)
*
* Change the default 3-digit group separator if group is a string,
* otherwise the default 3-digit group separator will not be
* changed. Return the old 3-digit group separator.
*
* set_default_decimal_separator(decimal)
*
* Change the default 3-digit group separator if decimal is a
* string, otherwise the default integer-fraction separator
* will not be changed. Return the old integer-fraction separator.
*
* print_comma(x, [group, [decimal]])
*
* Print the value produced by str_comma(x, [group, [decimal]])
* followed by a newline.
*
* If the str_comma() does not return a string, nothing is printed.
*
* The decimal and group arguments are optional.
*
* The value produced by str_comma() is returned.
*
* fprint_comma(fd, x, [group, [decimal]])
*
* Print the value produced by str_comma(x, [group, [decimal]]),
* without a trailing newline, on file fd.
*
* If the str_comma() does not return a string, nothing is printed.
*
* If fd is not an open file, nothing is printed.
*
* The decimal and group arguments are optional.
*
* The value produced by str_comma() is returned.
*
* Copyright (C) 2022 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: 2022/06/20 15:51:49
* File existed as early as: 2022
*
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*/
static default_group_separator = ","; /* default 3-digit group separator */
static default_decimal_separator = "."; /* default integer-fraction separator */
/*
* str_comma - convert number into base 10 string with 3-digit groups and integer-fraction separator
*
*
* This function converts a real number into a base 10 string, where
* groups of 3 digits are separated by a 3-digit group separator and
* a integer-fraction separator is printed between integer and decimal fraction.
*
* For example:
*
* string = str_comma(x);
* string = str_comma(x), " ", ".");
* string = str_comma(x), ".", ",");
*
* Internally the function calls:
*
* strprintf("%f", x);
*
* and thus the number of decimal fraction digits is subject to
* the display() or config("display") value. See:
*
* man display
*
* for details.
*
* given:
*
* x number to convert
*
* optional args:
*
* group use this 3-digit group separator
* decimal use this integer-fraction separator
*
* returns:
*
* string containing the base 10 digits with group and decimal separators, OR
* null() if x is not a number, OR
* null() if group is neither null() (not given) nor a string, OR
* null() if group is null() (not given) AND default_group_separator is not a string, OR
* null() if decimal is neither null() (not given) nor a string, OR
* null() if decimal is null() (not given) AND default_decimal_separator is not a string.
*/
define str_comma(x, group, decimal)
{
local group_separator; /* 3-digit group separator */
local decimal_separator; /* separator between decimal integer and decimal fraction */
local sign_str; /* leading - if x < 0 or empty if x >= 0 */
local integer; /* integer part of absolute value of x */
local int_str; /* integer as a string */
local int_len; /* number of digits in int_str */
local first_group_len; /* length of 1st group before the 1st 3-digit group separator */
local fraction; /* factional part of absolute value of x */
local frac_str; /* fraction as a string */
local frac_len; /* number of digits in frac_str including leading 0. */
local ret; /* string to return */
local config_leadzero; /* config("leadzero") to restore */
local config_tilde; /* config("tilde") to restore */
local i;
/*
* parse args - return null if args are bogus
*
* Return null() if args or conditions are bogus.
*/
if (!isreal(x)) {
return null();
}
group_separator = isnull(group) ? default_group_separator : group;
decimal_separator = isnull(decimal) ? default_decimal_separator : decimal;
if (!isstr(group_separator)) {
return null();
}
if (!isstr(decimal_separator)) {
return null();
}
/*
* split number
*/
if (x < 0) {
sign_str = "-";
integer = int(-x);
fraction = frac(-x);
} else {
sign_str = "";
integer = int(x);
fraction = frac(x);
}
ret = sign_str;
/*
* convert digits
*
* Avoid printing ~ and leading zeros for factional part.
*/
int_str = strprintf("%d", integer);
config_leadzero = config("leadzero", 0);
config_tilde = config("tilde", 0);
frac_str = strprintf("%d", fraction);
config("leadzero", config_leadzero),;
config("tilde", config_tilde),;
/*
* determine number of digits in the integer part
*/
int_len = strlen(int_str);
frac_len = strlen(frac_str);
/*
* form integer part with group separators as needed
*/
/*
* case: integer is 3 or fewer digits
*/
if (integer < 1000) {
ret += int_str;
/*
* case: integer is 4 or more digits
*/
} else {
/*
* form a decimal string using group separators
*/
/*
* form the initial leading digits before 1st group separator
*/
first_group_len = int_len % 3;
if (first_group_len == 0) {
first_group_len = 3;
}
ret += substr(int_str, 1, first_group_len);
/*
* until end of digits, print group separator followed by 3 more digits
*/
for (i = first_group_len+1; i < int_len; i += 3) {
ret += group_separator + substr(int_str, i, 3);
}
}
/*
* form fractional part using decimal separator as needed
*/
/*
* case: x is an integer
*/
if (fraction == 0) {
/* no fraction, nothing more to do */
/*
* case: x is not an integer
*/
} else {
/*
* add integer-fraction separator
*/
ret += decimal_separator;
/*
* add remaining digits
*
* Skip over the leading 0. in frac_str
*/
ret += substr(frac_str, 2, frac_len-1);
}
/*
* All Done!!! -- Jessica Noll, Age 2
*/
return ret;
}
/*
* set_default_group_separator - change the default 3-digit group separator
*
* If group is not a string, then the default 3-digit group separator
* is not changed. Thus, this will only return the default 3-digit group separator:
*
* set_default_group_separator(null());
*
* given:
*
* group 3-digit group separator
*
* returns:
*
* previous 3-digit group separator value
*/
define set_default_group_separator(group)
{
local old_default_group_separator; /* previous default 3-digit group separator to return */
/*
* save current 3-digit group separator
*/
old_default_group_separator = default_group_separator;
/*
* change 3-digit group separator if group is a string
*/
if (isstr(group)) {
default_group_separator = group;
}
return old_default_group_separator;
}
/*
* set_default_decimal_separator - change the default integer-fraction separator
*
* If decimal is not a string, then the default integer-fraction separator
* is not changed. Thus, this will only return the integer-fraction separator:
*
* set_default_decimal_separator(null());
*
* given:
*
* decimal separator between decimal integer and decimal fraction (def: ".")
*
* returns:
*
* previous integer-fraction separator value
*/
define set_default_decimal_separator(decimal)
{
local old_default_decimal_separator; /* previous default integer-fraction separator */
/*
* save current integer-fraction separator
*/
old_default_decimal_separator = default_decimal_separator;
/*
* change 3-digit decimal integer-fraction if decimal is a string
*/
if (isstr(decimal)) {
default_decimal_separator = decimal;
}
return old_default_decimal_separator;
}
/*
* print_comma - print base 10 string with 3-digit group separators & integer-fraction separator + newline
*
* This function prints the result of str_comma(x, group, decimal) followed by a newline.
* For example:
*
* print_comma(x);
* print_comma(x), " ", ".");
* print_comma(x), ".", ",");
*
* If str_comma() does not return a string, this function prints nothing.
*
* NOTE: To print without a newline, use fprint_comma(fd, x, group, decimal).
*
* given:
* x number to convert
*
* optional args:
*
* group use this 3-digit group separator
* decimal use this integer-fraction separator
*
* returns:
*
* string containing the base 10 digits with group and decimal separators, OR
* null() if x is not a number, OR
* null() if group is neither null() (not given) nor a string, OR
* null() if group is null() (not given) AND default_group_separator is not a string, OR
* null() if decimal is neither null() (not given) nor a string, OR
* null() if decimal is null() (not given) AND default_decimal_separator is not a string.
*/
define print_comma(x, group, decimal)
{
local ret; /* base 10 string with 3-digit group and integer-fraction separators */
/*
* convert to string
*/
ret = str_comma(x, group, decimal);
/*
* print converted string
*/
if (isstr(ret)) {
printf("%s\n", ret);
}
return ret;
}
/*
* fprint_comma - print base 10 string with 3-digit group separators & integer-fraction separator w/o newline
*
* This function prints the result of str_comma(x, group, decimal) on an open file, without a trailing newline.
* For example:
*
* fprint_comma(files(1), x);
* fprint_comma(fd, x), " ", ".");
* fprint_comma(files(2), x), ".", ",");
*
* If str_comma() does not return a string, this function prints nothing.
*
* This function flushes output to the open file before returning.
*
* NOTE: To print with a newline, use print_comma(x, group, decimal).
*
* given:
* fd open file
* x number to convert
*
* optional args:
*
* group use this 3-digit group separator
* decimal use this integer-fraction separator
*
* returns:
*
* string containing the base 10 digits with group and integer-fraction separators, OR
* null() if x is not a number, OR
* null() if group is neither null() (not given) nor a string, OR
* null() if group is null() (not given) AND default_group_separator is not a string, OR
* null() if decimal is neither null() (not given) nor a string, OR
* null() if decimal is null() (not given) AND default_decimal_separator is not a string.
*/
define fprint_comma(fd, x, group, decimal)
{
local ret; /* base 10 string with 3-digit group and integer-fraction separators */
/*
* convert to string
*/
ret = str_comma(x, group, decimal);
/*
* print converted string
*/
if (isstr(ret) && isfile(fd)) {
fprintf(fd, "%s", ret);
fflush(fd);
}
return ret;
}

View File

@@ -596,7 +596,7 @@ may have to be replaced by:
.sp 1
.in +5n
.nf
print 27! ^2 or print 27\!^2
print 27! ^2 or print 27\\!^2
.fi
.in -5n

View File

@@ -474,7 +474,7 @@ EXT=
# The default calc versions
#
VERSION= 2.14.1.0
VERSION= 2.14.1.2
# Names of shared libraries with versions
#

View File

@@ -445,7 +445,7 @@ EXT=
# The default calc versions
#
VERSION= 2.14.1.0
VERSION= 2.14.1.2
# Names of shared libraries with versions
#

6
file.c
View File

@@ -39,7 +39,7 @@
#include "calc.h"
#include "alloc.h"
#include "longbits.h"
#include "have_fpos.h"
#include "have_fgetsetpos.h"
#include "have_fpos_pos.h"
#include "fposval.h"
#include "file.h"
@@ -1459,7 +1459,7 @@ z2filepos(ZVALUE zpos)
if (zpos.len >= FILEPOS_BITS/BASEB) {
/* copy the lower FILEPOS_BITS of the ZVALUE */
memset(&tmp, 0, sizeof(tmp)); /* FILEPOS could be non-scalar */
memcpy(&tmp, zpos.v, MIN(sizeof(tmp), FILEPOS_LEN);
memcpy(&tmp, zpos.v, MIN(sizeof(tmp), FILEPOS_LEN));
} else {
/* copy what bits we can into the temp value */
memset(&tmp, 0, sizeof(tmp)); /* FILEPOS could be non-scalar */
@@ -2022,7 +2022,7 @@ showfiles(void)
math_chr('\n');
continue;
}
printf(" size = %lld\n", (long long int)sizes[i]);
printf(" size = %ld\n", (long int)sizes[i]);
for (j = i + 1; j < idnum; j++) {
if (listed[j] || sizes[j] == -1)
continue;

6
file.h
View File

@@ -32,9 +32,9 @@
#if defined(CALC_SRC) /* if we are building from the calc source tree */
# include "have_fpos.h"
# include "have_fgetsetpos.h"
#else
# include <calc/have_fpos.h>
# include <calc/have_fgetsetpos.h>
#endif
@@ -71,7 +71,7 @@ typedef struct {
* Some obscure systems without fgetpos/fsetpos may not have a simple
* scalar type. In these cases the f_tell macro below will fail.
*/
#if defined(HAVE_FPOS)
#if defined(HAVE_FGETSETPOS)
#define f_seek_set(stream, loc) fsetpos((FILE*)(stream), (FILEPOS*)(loc))
#define f_tell(stream, loc) fgetpos((FILE*)(stream), (FILEPOS*)(loc))

View File

@@ -59,12 +59,19 @@
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "have_fpos.h"
#include "have_string.h"
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#include "decl.h"
#include "have_fgetsetpos.h"
#include "endian_calc.h"
#include "have_offscl.h"
#include "have_posscl.h"
#include "have_fpos_pos.h"
#include "alloc.h"
#include "have_unused.h"
#include "have_memmv.h"
#include "banned.h" /* include after system header <> includes */
@@ -73,7 +80,7 @@
char *program; /* our name */
int
main(int argc, char **argv)
main(int UNUSED(argc), char **argv)
{
int stsizelen; /* bit length of st_size in buf */
int fileposlen; /* bit length of FILEPOS */
@@ -89,7 +96,7 @@ main(int argc, char **argv)
/*
* print the file position information
*/
#if defined(HAVE_FPOS_POS)
#if defined(HAVE_FPOS_POS) && defined(FPOS_POS_BITS)
fileposlen = FPOS_POS_BITS;
#else /* ! HAVE_FPOS_POS */
# if defined(FPOS_BITS)
@@ -107,13 +114,17 @@ main(int argc, char **argv)
* Big Endian
*/
if (fileposlen == 64) {
printf("#define SWAP_HALF_IN_FILEPOS(dest, src)\t\t%s\n",
"SWAP_HALF_IN_B64(dest, src)");
printf("#define SWAP_HALF_IN_FILEPOS(dest, src) \\\n"
"\tSWAP_HALF_IN_B64(dest, src)\n");
} else if (fileposlen == 32) {
printf("#define SWAP_HALF_IN_FILEPOS(dest, src)\t\t%s\n",
"SWAP_HALF_IN_B32(dest, src)");
printf("#define SWAP_HALF_IN_FILEPOS(dest, src) \\\n"
"\tSWAP_HALF_IN_B32(dest, src)\n");
} else if (fileposlen%BASEB == 0) {
printf("#define SWAP_HALF_IN_FILEPOS(dest, src) \\\n"
"\tswap_HALFs(dest, src, %d)\n",
fileposlen/BASEB);
} else {
fprintf(stderr, "%s: unexpected FILEPOS bit size: %d\n",
fprintf(stderr, "%s: unexpected BIG_ENDIAN FILEPOS bit size: %d\n",
program, fileposlen);
exit(1);
}
@@ -122,16 +133,15 @@ main(int argc, char **argv)
* Little Endian
*/
#if defined(HAVE_FILEPOS_SCALAR)
printf("#define SWAP_HALF_IN_FILEPOS(dest, src)\t\t%s\n",
"(*(dest) = *(src))");
printf("#define SWAP_HALF_IN_FILEPOS(dest, src) \\\n"
"\t(*(dest) = *(src))\n");
#else /* HAVE_FILEPOS_SCALAR */
/*
* Normally a "(*(dest) = *(src))" would do, but on some
* systems a FILEPOS is not a scalar hence we must memcpy.
*/
printf("#define SWAP_HALF_IN_FILEPOS(dest, src)\t%s\n",
"\\\n\tmemcpy((void *)(dest), (void *)(src), "
"sizeof(FPOS_POS_LEN))");
printf("#define SWAP_HALF_IN_FILEPOS(dest, src) \\\n"
"\tmemcpy((void *)(dest), (void *)(src), FILEPOS_LEN)\n");
#endif /* HAVE_FILEPOS_SCALAR */
#endif /* CALC_BYTE_ORDER == BIG_ENDIAN */
putchar('\n');

View File

@@ -1,7 +1,7 @@
/*
* have_fpos - Determine if have fgetpos and fsetpos functions
*
* Copyright (C) 1999,2021 Landon Curt Noll
* Copyright (C) 1999,2021,2022 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
@@ -25,10 +25,10 @@
*/
/*
* If the symbol HAVE_NO_FPOS is defined, we will output nothing.
* If the symbol HAVE_NO_FGETSETPOS is defined, we will output nothing.
* If we are able to compile this program, then we must have the
* fgetpos and fsetpos functions and we will output the
* appropriate have_fpos.h file body.
* appropriate have_fgetsetpos.h file body.
*/
#include <stdio.h>
@@ -40,7 +40,7 @@
int
main(void)
{
#if !defined(HAVE_NO_FPOS)
#if !defined(HAVE_NO_FGETSETPOS)
fpos_t pos; /* file position */
/* get the current position */
@@ -49,9 +49,9 @@ main(void)
/* set the current position */
(void) fsetpos(stdin, &pos);
/* print a have_fpos.h body that says we have the functions */
printf("#undef HAVE_FPOS\n");
printf("#define HAVE_FPOS 1 /* yes */\n\n");
/* print a have_fgetsetpos.h body that says we have the functions */
printf("#undef HAVE_FGETSETPOS\n");
printf("#define HAVE_FGETSETPOS 1 /* yes */\n\n");
printf("typedef fpos_t FILEPOS;\n");
#endif
/* exit(0); */

View File

@@ -24,15 +24,9 @@
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*/
/*
* If the symbol HAVE_NO_FPOS is defined, we will output nothing.
* If the HAVE_FILEPOS_SCALAR is defined, we will output nothing.
* If we are able to compile this program, then we must have the
* __pos element in a non-scalar FILEPOS.
*/
#include <stdio.h>
#include "have_fpos.h"
#include "have_fgetsetpos.h"
#include "have_posscl.h"
@@ -42,29 +36,43 @@
int
main(void)
{
#if !defined(HAVE_NO_FPOS) && !defined(HAVE_FILEPOS_SCALAR)
fpos_t pos; /* file position */
#if defined(HAVE_FILEPOS_SCALAR)
/* print a __pos element in fpos_t */
printf("#undef HAVE_FPOS_POS\n");
printf("#define HAVE_FPOS_POS 1 /* yes */\n\n");
/* determine __pos element size */
printf("#undef FPOS_POS_BITS\n");
printf("#undef FPOS_POS_LEN\n");
# if defined(FPOS_POS_BITS)
printf("#define FPOS_POS_BITS %d\n", FPOS_POS_BITS);
printf("#define FPOS_POS_LEN %d\n", int(FPOS_POS_BITS/8));
# else
printf("#define FPOS_POS_BITS %lu\n", sizeof(pos.__pos)*8);
printf("#define FPOS_POS_LEN %lu\n", sizeof(pos.__pos));
# endif
#else
/* we have no __pos element */
printf("/* HAVE_FILEPOS_SCALAR is defined, we assume FILEPOS is scalar */\n");
printf("/* we assume we have no __pos in FILEPOS */\n");
printf("#undef HAVE_FPOS_POS\t/* no */\n");
printf("#undef FPOS_POS_BITS\n");
printf("#undef FPOS_POS_LEN\n");
#else
printf("/* HAVE_FILEPOS_SCALAR is undefined, we assume FILEPOS is not scalar */\n");
# if defined(HAVE_NO_FPOS_POS)
printf("/* HAVE_NO_FPOS_POS defiled, we assume we have no __pos in FILEPOS */\n");
printf("#undef HAVE_FPOS_POS\t/* no */\n");
printf("#undef FPOS_POS_BITS\n");
printf("#undef FPOS_POS_LEN\n");
# elif defined(FPOS_POS_BITS)
printf("/* FPOS_POS_BITS defiled, assume we have __pos in FILEPOS */\n");
printf("#undef HAVE_FPOS_POS\n");
printf("#define HAVE_FPOS_POS 1 /* yes */\n");
printf("#undef FPOS_POS_BITS\n");
printf("#define FPOS_POS_BITS %d\n", FPOS_POS_BITS);
printf("#undef FPOS_POS_LEN\n");
printf("#define FPOS_POS_LEN %d\n", int(FPOS_POS_BITS/8));
# else
fpos_t pos; /* file position */
memset(&pos, 0, sizeof(pos)); /* zeroize pos to "set it" */
printf("/* we successfully compiled with a fpos_t type wit an __pos element */\n");
printf("#undef HAVE_FPOS_POS\n");
printf("#define HAVE_FPOS_POS 1 /* yes */\n");
printf("#undef FPOS_POS_BITS\n");
printf("#define FPOS_POS_BITS %lu\n", sizeof(pos.__pos)*8);
printf("#undef FPOS_POS_LEN\n");
printf("#define FPOS_POS_LEN %lu\n", sizeof(pos.__pos));
# endif
#endif
/* exit(0); */
return 0;

View File

@@ -48,7 +48,7 @@
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#endif
#include "have_fpos.h"
#include "have_fgetsetpos.h"
#include "banned.h" /* include after system header <> includes */

View File

@@ -65,6 +65,8 @@ main(void)
extern uid_t geteuid();
curds = geteuid();
/* force curds to be used, but do not print much info about our UID */
printf("/* geteuid() mod 2 == %ld */\n", ((long)curds) & 0x1);
printf("#define HAVE_UID_T /* yes */\n");

View File

@@ -38,7 +38,7 @@
#include "file.h"
#include "zrand.h"
#include "zrandom.h"
#include "have_fpos.h"
#include "have_fgetsetpos.h"
#include "custom.h"
#include "lib_calc.h"
#include "block.h"

View File

@@ -51,10 +51,40 @@ static char *program;
#include "banned.h" /* include after system header <> includes */
/*
* MAJOR_VER
*
* The MAJOR_VER remains at 2. That are concepts for version 3 calc,
* but that is a long way off. One of the main reasons why MAJOR_VER
* might incremented is if fundamental calc data objects (such as when ZVALUE
* or NUMBER or COMPLEX need to change) that would cause an incompatibility
* with existing hardware accelerators that are using fundamental calc data objects.
*
* MINOR_VER
*
* The MINOR_VER changes when there are incompatible changes to the calc library
* or calc custom library. The MINOR_VER might change if we need to make a major
* change to the math engine. For example, when the way 0^x was evaluated, we
* changed MINOR_VER from 13 to 14.
*
* MAJOR_PATCH
*
* The MAJOR_PATCH changes when there is an update to the calc library
* or calc custom library. For example, the MAJOR_PATCH might increment when there
* are new builtin functions available, or when there is a change to how existing
* builtin functions process arguments.
*
* MINOR_PATCH
*
* The MINOR_PATCH changes whenever there is any change in the calc release.
* For example, when the documentation changes, the MINOR_PATCH will increment.
* Moreover, when we are working towards a new production release,
* bug fix and improvement updates will cause MINOR_PATCH to increment.
*/
#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 0 /* minor software version level */
#define MINOR_PATCH 2 /* minor software version level */
/*

View File

@@ -643,6 +643,7 @@ E_FUNC void math_error(char *, ...) \
E_FUNC HALF *swap_b8_in_HALFs(HALF *dest, HALF *src, LEN len);
E_FUNC ZVALUE *swap_b8_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all);
E_FUNC HALF *swap_b16_in_HALFs(HALF *dest, HALF *src, LEN len);
E_FUNC HALF *swap_HALFs(HALF *dest, HALF *src, LEN len);
E_FUNC ZVALUE *swap_b16_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all);
E_FUNC ZVALUE *swap_HALF_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all);