Compare commits

...

47 Commits

Author SHA1 Message Date
Landon Curt Noll
11ddc30528 Release v2.14.1.3
The following are the changes in this release:

    Fixed missing <string.h include in have_fpos_pos.c.

    Change calc version from 2.14.1.2 to 2.14.2.3 as part of a test to
    build calc RPMs on a reference RHEL8.7 platform (formerly a RHEL7.9
    platform).
2023-02-14 15:49:05 -08:00
Landon Curt Noll
f5fc06fbd4 update make depend 2023-02-14 15:42:57 -08:00
Landon Curt Noll
8a4c12d2be add missing have_fpos_pos.c fix to CHANGES 2023-02-14 15:41:11 -08:00
Landon Curt Noll
d2139064cb Merge branch 'master' of github.com:lcn2/calc 2023-02-14 15:39:53 -08:00
Landon Curt Noll
774060944b prep for calc version 2.14.1.3
Change calc version from 2.14.1.2 to 2.14.2.3 as part of a test to
build calc RPMs on a reference RHEL8.7 platform (formerly a RHEL7.9
platform).
2023-02-14 15:39:11 -08:00
Landon Curt Noll
61c268f1c2 Merge pull request #68 from fweimer-rh/c99
Avoid implicit declaration memset in have_fpos_pos.c probe
2023-01-21 19:36:01 -08:00
Florian Weimer
dcf360d688 Avoid implicit declaration memset in have_fpos_pos.c probe
Otherwise, the probe result changes with compilers which do not
support implicit function declarations, a language feature that
was removed from C in 1999.
2023-01-18 10:54:55 +01:00
Landon Curt Noll
fddd24d6c6 Update CodeQL Action to v2
See: https://github.blog/changelog/2022-04-27-code-scanning-deprecation-of-codeql-action-v1/
2022-12-08 14:40:03 -08:00
Landon Curt Noll
bcae90959e Enable Dependabot version updateo
See also: https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabots
2022-12-08 14:36:15 -08:00
Landon Curt Noll
5b42c557b0 Add missing copyright example to COPYING 2022-12-08 14:29:01 -08:00
Landon Curt Noll
1b0e6c4462 Improve README.WINDOWS
Expand on the notes made by GitHub user @Leoongithub.

Re-order a few README.WINDOWS sections.

Add a number of 'NOTE:" notes to README.WINDOWS.
2022-12-08 14:11:04 -08:00
Landon Curt Noll
f0396fccde Merge pull request #67 from Leoongithub/patch-1
Update latest information about compile under Windows
2022-12-08 13:21:17 -08:00
Leoongithub
21be7adb82 Fix Cygwin compile error 2022-12-07 18:14:11 +08:00
Leoongithub
6317991f2b Update README.WINDOWS 2022-12-07 18:08:44 +08:00
Landon Curt Noll
f4f19f21dc Add config("complex_space") to control spaces around + or - in complex values
Added config("fraction_space", boolean) to help/config, along with
a few few minor text improvements.  Updated cal/regress to test
config("tilde_space").

Added config("complex_space", boolean).  The "complex_space" controls
whether or not a space (' ') is printed before and after the + or -
in complex values.

By default, config("complex_space") is false.

For example, with the default, config("complex_space", 0):

    ; asin(2)
	    1.57079632679489661923-1.31695789692481670863i

With config("complex_space", 1):

    ; asin(2)
	    1.57079632679489661923 - 1.31695789692481670863i

NOTE: Use of config("complex_space", 1) can break printing and scanning
      of fractional values via "%r".

NOTE: Use of config("complex_space", 1) can break printing and scanning
      of complex values via "%c".

Added config("complex_space", boolean) to help/config, along with
a few few minor text improvements.  Updated cal/regress to test
config("complex_space").
2022-12-04 00:53:15 -08:00
Landon Curt Noll
348f3ed427 Clarified -a and -f in calc man page
Clarify in the calc man page, the relationship between -q and
calc start scripts such as the ~/.calcrc file.

Fixed in the calc man page, the issue of -f not implying -q.
2022-12-03 16:36:46 -08:00
Landon Curt Noll
542a263de6 Improve show config and help config order 2022-12-03 16:09:03 -08:00
Landon Curt Noll
17702a4799 Add config("fraction_space") to control spaces around printing fractions
Added config("tilde_space", boolean) to help/config, along with
a few few minor text improvements.  Updated cal/regress to test
config("tilde_space").

Added config("fraction_space", boolean).  The "fraction_space" controls
whether or not a space (' ') is printed before and after fractions.
By default, config("fraction_space") is false.

For example, with the default, config("fraction_space", 0):

    ; base(1/3),
    ; 1/7
            1/7

With config("fraction_space", 1):

    ; base(1/3),
    ; 1/7
            1 / 7

NOTE: Use of config("fraction_space", 1) can break printing and scanning
      of fractional values via "%r".

NOTE: Use of config("fraction_space", 1) can break printing and scanning
      of complex values via "%c".

Added config("fraction_space", boolean) to help/config, along with
a few few minor text improvements.  Updated cal/regress to test
config("tilde_space").
2022-12-03 14:39:25 -08:00
Landon Curt Noll
7c6723db88 Change tilde_space to be 0 by default 2022-12-03 14:02:49 -08:00
Landon Curt Noll
0d99ba54d8 Change default to print space after the approximation tilde
Added config("tilde_space", boolean).  The "tilde_space" controls
whether or not a space (' ') is printed after leading tilde ('~').
By default, config("tilde_space") is true, which is a change
from past behavior.  For example, now:

    ; 1/3
	    ~ 0.33333333333333333333

With config("tilde_space", 0):

    ; 1/3
	    ~0.33333333333333333333

To disable "tilde_space", use config("tilde_space", 0) on the
command line and/or use config("tilde_space", 0),; in your ~/.calcrc.
Thanks goes to <GitHub use ljramalho> for this suggestion.

Added config("tilde_space", boolean) to help/config, along with
a few few minor text improvements.  Updated cal/regress to test
config("tilde_space") and to account for the new default.
2022-12-03 12:22:55 -08:00
Landon Curt Noll
83adfaa720 Removed compiler confusing setjmp() call
In pseudo_seed(), we removed a call to setjmp() that was only
there to add more information to mix into the seed.  For compilers
such as gcc that used -Wclobbered, the call to setjmp() gave the
impression that the hash_val might be clobbered by a longjmp().
Where there is no longjmp() that would use the previous setjmp(),
the gcc compiler has nil ways to notice that. So to avoid confusion
we removed the setjmp() call.  Thanks to <GitHub user mattdm> for
raising this potential concern.
2022-12-03 10:47:05 -08:00
Landon Curt Noll
ef6a30c9c9 Fixed how the original TTY state is preserved
In find_tty_state(), we changed how we expand fd_orig as an original
pre-modified copy of fd_setup.  We realloc the fd_orig array and copy
the fd_setup into it first, before touching the fd_setup array.
2022-12-03 10:25:43 -08:00
Landon Curt Noll
3aaad95443 Fixed a use after free bug
Fixed a -Wuse-after-free warning that identified a call to realloc() in
find_tty_state() could move the fd_setup array.  Thanks goes to <GitHub
user mattdm> for reporting this bug!
2022-12-03 10:10:21 -08:00
Landon Curt Noll
74b833977b Use calloc in swap_HALF_in_ZVALUE() to help with compiler paranoia 2022-12-03 09:34:32 -08:00
Landon Curt Noll
333f0c4332 Add a Makefile comment about how to turn on all messages 2022-12-03 09:33:15 -08:00
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
38 changed files with 1606 additions and 338 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**

View File

@@ -43,7 +43,7 @@ jobs:
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -54,7 +54,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
@@ -68,4 +68,4 @@ jobs:
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2

12
.github/workflows/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
# Set update schedule for GitHub Actions
#
# See https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"

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

284
CHANGES
View File

@@ -1,4 +1,227 @@
The following are the changes from calc version 2.14.1.0 to date:
The following are the changes from calc version 2.14.2.3 to date:
Fixed missing <string.h include in have_fpos_pos.c.
Change calc version from 2.14.1.2 to 2.14.2.3 as part of a test to
build calc RPMs on a reference RHEL8.7 platform (formerly a RHEL7.9
platform).
The following are the changes from calc version 2.14.2.0 to 2.14.1.2:
Attempted to address a paranoid compiler warning -Wmaybe-uninitialized
in swap_HALF_in_ZVALUE() where the gcc compiler seems to ignore the
fact that calling not_reached() above the call to zcopyval()
should prevent dest from being NULL to the 1st zcopyval() call.
Thanks to <GitHub user mattdm> for raising this potential concern.
Fixed a -Wuse-after-free warning that identified a call to realloc()
in find_tty_state() could move the fd_setup array. Thanks goes to
<GitHub user mattdm> for reporting this bug!
In find_tty_state(), we changed how we expand fd_orig as an original
pre-modified copy of fd_setup. We realloc the fd_orig array and copy
the fd_setup into it first, before touching the fd_setup array.
In pseudo_seed(), we removed a call to setjmp() that was only
there to add more information to mix into the seed. For compilers
such as gcc that used -Wclobbered, the call to setjmp() gave the
impression that the hash_val might be clobbered by a longjmp().
Where there is no longjmp() that would use the previous setjmp(),
the gcc compiler has nil ways to notice that. So to avoid confusion
we removed the setjmp() call. Thanks to <GitHub user mattdm> for
raising this potential concern.
Added config("tilde_space", boolean). The "tilde_space" controls
whether or not a space (' ') is printed after leading tilde ('~').
By default, config("tilde_space") is false.
For example, with the default, config("tilde_space", 0):
; 1/3
~0.33333333333333333333
; sqrt(7 + 5i,1e-100)
~2.79305614578749801863+~0.89507688693280053094i
With config("tilde_space", 1):
; 1/3
~ 0.33333333333333333333
; sqrt(7 + 5i,1e-100)
~ 2.79305614578749801863+~ 0.89507688693280053094i
NOTE: Use of config("tilde_space", 1) can break printing and scanning
of complex values via "%c".
To enable "tilde_space", use config("tilde_space", 1) on the
command line and/or use config("tilde_space", 1),; in your ~/.calcrc.
Thanks goes to <GitHub use ljramalho> for this suggestion.
Added config("tilde_space", boolean) to help/config, along with
a few few minor text improvements. Updated cal/regress to test
config("tilde_space").
For example, with the default, config("tilde_space", 0):
; pi(1e-50)
~3.14159265358979323846
With config("tilde_space", 1):
; pi(1e-50)
~ 3.14159265358979323846
Added config("fraction_space", boolean). The "fraction_space" controls
whether or not a space (' ') is printed before and after fractions.
By default, config("fraction_space") is false.
For example, with the default, config("fraction_space", 0):
; base(1/3),
; 1/7
1/7
With config("fraction_space", 1):
; base(1/3),
; 1/7
1 / 7
NOTE: Use of config("fraction_space", 1) can break printing and scanning
of fractional values via "%r".
NOTE: Use of config("fraction_space", 1) can break printing and scanning
of complex values via "%c".
Added config("fraction_space", boolean) to help/config, along with
a few few minor text improvements. Updated cal/regress to test
config("tilde_space").
Added config("complex_space", boolean). The "complex_space" controls
whether or not a space (' ') is printed before and after the + or -
in complex values.
By default, config("complex_space") is false.
For example, with the default, config("complex_space", 0):
; asin(2)
1.57079632679489661923-1.31695789692481670863i
With config("complex_space", 1):
; asin(2)
1.57079632679489661923 - 1.31695789692481670863i
NOTE: Use of config("complex_space", 1) can break printing and scanning
of fractional values via "%r".
NOTE: Use of config("complex_space", 1) can break printing and scanning
of complex values via "%c".
Added config("complex_space", boolean) to help/config, along with
a few few minor text improvements. Updated cal/regress to test
config("complex_space").
Clarify in the calc man page, the relationship between -q and
calc start scripts such as the ~/.calcrc file.
Fixed in the calc man page, the issue of -f not implying -q.
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 +229,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:

View File

@@ -6,7 +6,7 @@ This file is Copyrighted
This file is covered under the following Copyright:
Copyright (C) 1999-2021 Landon Curt Noll
Copyright (C) 1999-2022 Landon Curt Noll
All rights reserved.
Everyone is permitted to copy and distribute verbatim copies
@@ -120,6 +120,7 @@ Calc copyrights and exception files
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
These files are not covered under one of the Copyrights listed above:

149
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.3
# Names of shared libraries with versions
#
@@ -1811,7 +1811,7 @@ CCWERR=
CCOPT= ${DEBUG}
CCMISC=
#
LCC= x86_64-w64-mingw32-gcc
LCC= cc
CC= ${PURIFY} ${LCC} ${CCWERR}
#
endif
@@ -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,15 @@ 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)
#
# To turn all messages, use:
#
# Q=
# H=@
# S=
# E=
# V=@
#
#Q=
Q=@
@@ -2069,7 +2077,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 +2095,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 +2113,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 +3184,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 +3192,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 +3226,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 have_string.h \
banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f fpos_tmp $@
${H} echo 'forming $@'
@@ -3231,9 +3239,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 +3270,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 +3398,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 +3440,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 +3618,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 +3658,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 +3977,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 +4215,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 +4257,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 +4709,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 +4833,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 +4949,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 +5151,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 +5538,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 +5831,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 +5877,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 +6165,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 +6184,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 +6215,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,14 +6283,15 @@ 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_fpos_pos.o: have_string.h
have_getpgid.o: banned.h
have_getpgid.o: have_ban_pragma.h
have_getpgid.o: have_getpgid.c
@@ -6286,7 +6321,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 +6685,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 +7138,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.3
# 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,15 @@ 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)
#
# To turn all messages, use:
#
# Q=
# H=@
# S=
# E=
# V=@
#
#Q=
Q=@
@@ -1476,7 +1484,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 +1502,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 +1520,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 +2498,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 +2506,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 +2540,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 have_string.h \
banned.h have_ban_pragma.h ${MAKE_FILE} ${LOC_MKF}
${Q} ${RM} -f fpos_tmp $@
${H} echo 'forming $@'
@@ -2545,9 +2553,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 +2584,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 +2712,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 +2754,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 +2932,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 +2972,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 +3291,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 +3529,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 +3571,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 +3997,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 +4121,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 +4237,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 +4439,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 +4806,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 +5099,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 +5145,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 +5433,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 +5452,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 +5483,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,14 +5551,15 @@ 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_fpos_pos.o: have_string.h
have_getpgid.o: banned.h
have_getpgid.o: have_ban_pragma.h
have_getpgid.o: have_getpgid.c
@@ -5554,7 +5589,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 +5953,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 +6406,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

@@ -3,16 +3,8 @@ Dear calc user on a Windows based system,
See the HOWTO.INSTALL file for information on how to build and install calc.
See also the README file.
BTW: While we are unable to use Windows 11, we welcome
Windows 11 developers to try compiling calc natively
(instead of via a Linux virtual machine). If you are
able to compile Windows 11 natively, we would welcome
GitHub pull requests showing any needed modifications:
https://github.com/lcn2/calc/pulls
Please also add notes to the 'Compiling calc under Windows 11'
section in README.WINDOWS file.
and 'Compiling with Cygwin' section in README.WINDOWS file.
NOTE: The main developers do not have access to a Windows based platform.
While we will make an effort to not break calc Windows based system,
@@ -21,10 +13,18 @@ NOTE: The main developers do not have access to a Windows based platform.
Of course you are welcome to send us any patches that fix your
Windows build environment.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=-= Compiling calc under Windows 11 =-=
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
BTW: While we are unable to use Windows 11, we welcome Windows 11
developers to try compiling calc natively (instead of via a Linux
virtual machine). If you are able to compile Windows 11 natively,
we would welcome GitHub pull requests showing any needed modifications:
https://github.com/lcn2/calc/pulls
We were given this advice from a Windows 11 developer:
Windows 11 users could use Cygwin:
@@ -34,66 +34,78 @@ We were given this advice from a Windows 11 developer:
IMPORTANT: While installing Cygwin, and during Cygwin Setup, be sure to
select all the MinGW64 packages relating to gcc.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=-= Compiling calc via virtual machine under Windows 11 =-=
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
See the "Compiling with Cygwin" section below.
We would prefer a Windows 11 solution that does not require a Windows 11
developer to install a Linux virtual machine. Nevertheless, a Windows 11
user might want to use the Microsoft Windows Subsystem (WSL) for Linux:
NOTE: Compiling calc under Windows 11 is work in progress. If you run into
problems, consider the "Compiling with Cygwin" section below.
https://docs.microsoft.com/en-us/windows/wsl/
We have been told that you will need to turn on virtualization
to use this WSL subsystem.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=-= Compiling calc under Windows 10 via Windows Subsystem for Linux (WSL) =-=
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
It has been reported that calc version 2.12.6.4 has been successfully
compiled, installed and running on Windows 10 on 2018 Jan 21.
We were told:
"The Windows Subsystem for Linux (WSL) is a new Windows 10 feature that
enables you to run native Linux command-line tools directly on Windows"
https://docs.microsoft.com/cs-cz/windows/wsl/about
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=-= compiling with Cygwin =-=
=-= Compiling with Cygwin =-=
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
An effort is being made to allow windows users to compile calc using the
Cygwin project (http://sources.redhat.com/cygwin/) with the GCC compiler
and Un*x tools for Windows.
and Unix tools for Windows.
The major porting work for Cygwin was performed by Thomas Jones-Low
(tjoneslo at softstart dot com).
In March 2009, Michael Penk (mpenk at wuska dot com) reported success in
installs under Cygwin:
In December 2022, GitHub user @Leoongithub successfully compiled
calc-2.14.1.2 under cygwin 2.924 (64 bit). The following are the
compilation steps that GitHub user @Leoongithub recommends:
On my fairly complete Cygwin installs, everything compiles,
checks, and installs correctly. My Cygwin is configured
in a very standard way (out of the box, using all of Cygwin's
defaults). The install worked on 5 different machines with
Cygwin on them: one XP home, one XP professional, and three
Vista professionals.
0. Install the latest version of cygwin (https://cygwin.com/install.html).
Using the calc Makefile, he did the following:
NOTE: In addition to the default packages, you also need to check these
three packages: gcc-core, make, and libreadline-devel. The version
of these packages does not matter. Just choose the latest version.
make all target=Cygwin
make check
make install
NOTE: The addition of "target=Cygwin" to make commands below
is done just in case the target is not set properly by make.
He also reports:
1. Change (cd) into the top of the source code directory of calc.
Of course, one should be logged in as an Administrator when
one builds and installs calc.
NOTE: The make command assume you are at the top of the calc source directory.
2. make clobber target=Cygwin
NOTE: This helps ensure that you are starting from a so-called "clean slate",
and that you have nothing hanging around from previous attempts to compile.
3. make all target=Cygwin
NOTE: If successful, you should have a calc executable. However that executable
may not be working properly. Advance to step (4) to test.
4. make chk target=Cygwin
NOTE: If you want this command be be verbose, try:
make check target=Cygwin
NOTE: This will run calc with the regress.cal regression suite. This step could take
for a while to run, depending on the speed/performance of your machine.
If all is well (all regression tests pass), you will see at the end:
chk OK
Otherwise you may see calc exit non-zero after it prints some lines with '****'
error messages followed by a line including a final error count of the form:
**** 2 error(s) found \/++\/
If you see some errors that may relate to files and I/O, all may not be lost.
It could simply mean that your Windows environment is not conforming to standard
I/O and file operations. The calc mathematical engine may be just fine. On the
other hand if you see mathematical related regression test failures, this is
bad sign that your calc executable under Windows is not usable.
5. make install target=Cygwin
NOTE: This step is optional. While calc is usable at the top of the source code directory
of calc, installing calc may be of benefit so you can use calc elsewhere on your system.
He was compiling calc 2.12.4.0 with Cygwin version 1.5.25-15.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=-= If all else fails, for Cygwin =-=
@@ -118,6 +130,10 @@ In particular:
source directory, edit them (if needed) and build using the
Cygwin GCC compiler and Cygwin build environment.
NOTE: The use of win32_hsrc and this method has been deprecated.
It may go away once the Windows 11 methods are stable.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=-= compiling under DJGPP =-=
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@@ -178,8 +194,43 @@ Look for Makefile comments of the form:
Follow those recommendations. In cases where they conflict with
the above Makefile list, follow the recommendation in the Makefile.
NOTE: The use of DJGPP and this method has been deprecated.
It may go away once the Windows 11 methods are stable.
## Copyright (C) 2002-2009,2021 Landon Curt Noll and Thomas Jones-Low
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=-= Compiling calc via virtual machine under Windows 11 =-=
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
We would prefer a Windows 11 solution that does not require a Windows 11
developer to install a Linux virtual machine. Nevertheless, a Windows 11
user might want to use the Microsoft Windows Subsystem (WSL) for Linux:
https://docs.microsoft.com/en-us/windows/wsl/
We have been told that you will need to turn on virtualization
to use this WSL subsystem.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=-= Compiling calc under Windows 10 via Windows Subsystem for Linux (WSL) =-=
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
It has been reported that calc version 2.12.6.4 has been successfully
compiled, installed and running on Windows 10 on 2018 Jan 21.
We were told:
"The Windows Subsystem for Linux (WSL) is a new Windows 10 feature that
enables you to run native Linux command-line tools directly on Windows"
https://docs.microsoft.com/cs-cz/windows/wsl/about
NOTE: The use of calc under Windows 10 has been deprecated in favor of one
of the Windows 11 methods above.
## Copyright (C) 2002-2009,2021,2022 Landon Curt Noll and Thomas Jones-Low
##
## 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

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
*
@@ -531,7 +575,7 @@ swap_HALF_in_ZVALUE(ZVALUE *dest, ZVALUE *src, BOOL all)
/*
* allocate the storage
*/
dest = malloc(sizeof(ZVALUE));
dest = calloc(1, sizeof(ZVALUE));
if (dest == NULL) {
math_error("swap_HALF_in_ZVALUE: Not enough memory");
not_reached();

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

@@ -541,7 +541,16 @@ define test_config()
vrfy(issimple(config("dupvar_warn")),
'562: issimple(config("rdupvar_warn"))');
print '563: Ending test_config';
/* test new space modes */
vrfy(config("tilde_space") == 0,
'563: config("tilde_space") == 0');
vrfy(config("fraction_space") == 0,
'564: config("fraction_space") == 0');
vrfy(config("complex_space") == 0,
'565: config("complex_space") == 0');
print '566: Ending test_config';
}
print '010: parsed test_config()';
@@ -3924,7 +3933,7 @@ define test_fileops()
vrfy(!iserror(p=fopen("tmp4200","r")),
'4274: !iserror(p=fopen("tmp4200","r"))');
vrfy(!iserror(s=fgetline(p)), '4275: !iserror(s=fgetline(p))');
vrfy(strcmp(s,"chongo") == 0, '4276: strcmp(s,"chongo") == 0');
vrfy(strcmp(s,"chongo") == 0, '4276: strcmp(s,"chongo") == 0');
vrfy(!iserror(s=fgetfile(p)), '4277: !iserror(s=fgetfile(p))');
vrfy(strcmp(s,"w\0a\0s\nhere\n") == 0,
'4278: strcmp(s,"w\0a\0s\nhere\n") == 0');
@@ -4296,84 +4305,119 @@ define test_strprintf()
print '4804: c = config("display", 2)';
c = config("tilde", 0);
print '4805: c = config("tilde", 0)';
c = config("tilde_space", 1);
print '4806: c = config("tilde_space", 1)';
c = config("leadzero", 0);
print '4806: c = config("leadzero", 0)';
print '4807: c = config("leadzero", 0)';
c = config("fullzero", 0);
print '4807: c = config("fullzero", 0)';
print '4808: c = config("fullzero", 0)';
/* tests with tilde == 0 */
vrfy(strprintf("%d%d", 27, 29) == "2729",
'4808: strprintf("%d%d", 27, 29) == "2729"');
'4809: strprintf("%d%d", 27, 29) == "2729"');
vrfy(strprintf("%5d%3d", 27, 29) == " 27 29",
'4809: strprintf("%5d%3d", 27, 29) == " 27 29"; ');
'4810: strprintf("%5d%3d", 27, 29) == " 27 29"; ');
vrfy(strprintf("%-5d%-3d", 27, 29) == "27 29 ",
'4810: strprintf("%-5d%-3d", 27, 29) == "27 29 "');
'4811: strprintf("%-5d%-3d", 27, 29) == "27 29 "');
vrfy(strprintf("%f", 1.375) == "1.38",
'4811: strprintf("%f", 1.375) == "1.38"');
'4812: strprintf("%f", 1.375) == "1.38"');
vrfy(strprintf("%f", 1.385) == "1.38",
'4812: strprintf("%f", 1.385) == "1.38"');
'4813: strprintf("%f", 1.385) == "1.38"');
vrfy(strprintf("%f", .375) == ".38",
'4813: strprintf("%f", .375) == ".38"');
'4814: strprintf("%f", .375) == ".38"');
vrfy(strprintf("%f", .385) == ".38",
'4814: strprintf("%f", .385) == ".38"');
'4815: strprintf("%f", .385) == ".38"');
/* tests with tilde == 1 */
c = config("tilde", 1);
print '4815: c = config("tilde", 1)';
vrfy(strprintf("%f", 1.375) == "~1.38",
'4816: strprintf("%f", 1.375) == "~1.38"');
vrfy(strprintf("%f", 27/29) == "~.93",
'4817: strprintf("%f", 27/29) == "~.93"');
print '4816: c = config("tilde", 1)';
vrfy(strprintf("%f", 1.375) == "~ 1.38",
'4817: strprintf("%f", 1.375) == "~ 1.38"');
vrfy(strprintf("%f", 27/29) == "~ .93",
'4818: strprintf("%f", 27/29) == "~ .93"');
vrfy(strprintf("%r", 27/29) == "27/29",
'4818: strprintf("%r", 27/29) == "27/29"');
'4819: strprintf("%r", 27/29) == "27/29"');
vrfy(strprintf("%o", 27/29) == "033/035",
'4819: strprintf("%o", 27/29) == "033/035"');
'4820: strprintf("%o", 27/29) == "033/035"');
vrfy(strprintf("%x", 27/29) == "0x1b/0x1d",
'4820: strprintf("%x", 27/29) == "0x1b/0x1d"');
'4821: strprintf("%x", 27/29) == "0x1b/0x1d"');
vrfy(strprintf("%b", 27/29) == "0b11011/0b11101",
'4821: strprintf("%b", 27/29) == "0b11011/0b11101"');
'4822: strprintf("%b", 27/29) == "0b11011/0b11101"');
vrfy(strprintf("%e", 12345) == "~ 1.23e4",
'4823: strprintf("%e", 12345) == "~ 1.23e4"');
vrfy(strprintf("%g", .385) == "~ .38",
'4824: strprintf("%g", .385) == "~ .38"');
vrfy(strprintf("%g", 385) == "~ 3.8e2",
'4825: strprintf("%g", 385) == "~ 3.8e2"');
/* tests with tilde == 1 and tilde_space == 0 */
c = config("tilde_space", 0);
print '4826: c = config("tilde_space", 0)';
vrfy(strprintf("%f", 1.375) == "~1.38",
'4827: strprintf("%f", 1.375) == "~1.38"');
vrfy(strprintf("%f", 27/29) == "~.93",
'4828: strprintf("%f", 27/29) == "~.93"');
vrfy(strprintf("%e", 12345) == "~1.23e4",
'4822: strprintf("%e", 12345) == "~1.23e4"');
'4829: strprintf("%e", 12345) == "~1.23e4"');
vrfy(strprintf("%g", .385) == "~.38",
'4823: strprintf("%g", .385) == "~.38"');
'4830: strprintf("%g", .385) == "~.38"');
vrfy(strprintf("%g", 385) == "~3.8e2",
'4824: strprintf("%g", 385) == "~3.8e2"');
'4831: strprintf("%g", 385) == "~3.8e2"');
/* tests with tilde_space == 0 */
c = config("tilde_space", 1);
print '4832: c = config("tilde_space", 1)';
vrfy(strprintf("%f", 1.375) == "~ 1.38",
'4833: strprintf("%f", 1.375) == "~ 1.38"');
vrfy(strprintf("%f", 27/29) == "~ .93",
'4834: strprintf("%f", 27/29) == "~ .93"');
vrfy(strprintf("%e", 12345) == "~ 1.23e4",
'4835: strprintf("%e", 12345) == "~ 1.23e4"');
vrfy(strprintf("%g", .385) == "~ .38",
'4836: strprintf("%g", .385) == "~ .38"');
vrfy(strprintf("%g", 385) == "~ 3.8e2",
'4837: strprintf("%g", 385) == "~ 3.8e2"');
/* mode tests with tilde == 0 */
c = config("tilde", 0);
print '4825: c = config("tilde", 0)';
print '4838: c = config("tilde", 0)';
vrfy(strprintf("%e", 12345) == "1.23e4",
'4826: strprintf("%e", 12345) == "1.23e4"');
'4839: strprintf("%e", 12345) == "1.23e4"');
vrfy(strprintf("%.3e", 12345) == "1.234e4",
'4827: strprintf("%.3e", 12345) == "1.234e4"');
'4840: strprintf("%.3e", 12345) == "1.234e4"');
vrfy(strprintf("%e", .00012345) == "1.23e-4",
'4828: strprintf("%e", .00012345) == "1.23e-4"');
'4841: strprintf("%e", .00012345) == "1.23e-4"');
vrfy(strprintf("%d %d", 27) == "27 ",
'4829: strprintf("%d %d", 27) == "27 "');
'4842: strprintf("%d %d", 27) == "27 "');
vrfy(strprintf("%d", 27, 29) == "27",
'4830: strprintf("%d", 27, 29) == "27"');
'4843: strprintf("%d", 27, 29) == "27"');
vrfy(strprintf("%r = %f", 27/29, 27/29) == "27/29 = .93",
'4831: strprintf("%r = %f", 27/29, 27/29) == "27/29 = .93"');
'4844: strprintf("%r = %f", 27/29, 27/29) == "27/29 = .93"');
vrfy(strprintf("%s", "abc") == "abc",
'4832: strprintf("%s", "abc") == "abc"');
'4845: strprintf("%s", "abc") == "abc"');
vrfy(strprintf("%f", "abc") == "abc",
'4833: strprintf("%f", "abc") == "abc"');
'4846: strprintf("%f", "abc") == "abc"');
vrfy(strprintf("%e", "abc") == "abc",
'4834: strprintf("%e", "abc") == "abc"');
'4847: strprintf("%e", "abc") == "abc"');
vrfy(strprintf("%5s", "abc") == " abc",
'4835: strprintf("%5s", "abc") == " abc"');
'4848: strprintf("%5s", "abc") == " abc"');
vrfy(strprintf("%-5s", "abc") == "abc ",
'4836: strprintf("%-5s", "abc") == "abc "');
'4849: strprintf("%-5s", "abc") == "abc "');
vrfy(strprintf("%g", .385) == ".38",
'4837: strprintf("%g", .385) == ".38"');
'4850: strprintf("%g", .385) == ".38"');
vrfy(strprintf("%g", 385) == "3.8e2",
'4838: strprintf("%g", 385) == "3.8e2"');
'4851: strprintf("%g", 385) == "3.8e2"');
c = config("fraction_space", 1);
print '4852: c = config("fraction_space", 1)';
vrfy(strprintf("%r = %f", 27/29, 27/29) == "27 / 29 = .93",
'4853: strprintf("%r = %f", 27/29, 27/29) == "27 / 29 = .93"');
/* restore config */
c = config("all", callcfg);
print '4839: c = config("all", callcfg)';
print '4854: c = config("all", callcfg)';
print '4840: Ending test_strprintf';
print '4855: Ending test_strprintf';
}
print '088: parsed test_fileop()';
@@ -8129,7 +8173,7 @@ vrfy(config("redecl_warn",0), '8651: config("redecl_warn",0)');
vrfy(config("dupvar_warn",0), '8652: config("dupvar_warn",0)');
vrfy(u_glob == 6, '8653: u_glob == 6');
global u_glob = 555;
print '8654: declare u_glob';
print '8654: declare u_glob';
vrfy(u_glob == 555, '8655: u_glob == 555');
define func_8650(u_glob) { local u_glob; return u_glob; }
print '8656: u_glob as both local and parameter';

View File

@@ -251,9 +251,6 @@ For example:
\fI#!${BINDIR}/calc\fP \fB\-q\fP \fB\-f\fP
.fi
.in -5n
.sp 1
This allows the script to run independently of
startup scripts.
.sp 1
See
@@ -294,6 +291,24 @@ This will cause calc to process lines in
in
.BR "shell script mode" .
.sp 1
.B NOTE:
The use of
.BR \-f
does
.B NOT
imply
.BR \-q
and thus one would need to use
.sp 1
.in +5n
.nf
\fIcalc\fP\ [optional_other_flags\ \&...] \fB\-q\fP \fB\-f\fP filename
.fi
.in -5n
.sp 1
to disable the use of calc startup files as well.
.sp 1
The use of
.B \-f
@@ -458,6 +473,13 @@ flag overrides
.TP
.B \-q
Disable the reading of the startup scripts.
.sp 1
This allows the script to run independently of
startup scripts such those managed by the
.B $CALCRC
environment variable.
For example, this will disable the use of the common calcrc file
(usually ~/.calcrc).
.TP
.B \-s
@@ -596,7 +618,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
@@ -813,6 +835,23 @@ are automatically set if
.B \-i
is not given.
.sp 1
.B NOTE:
The use of
.BR \-f
does
.B NOT
imply
.BR \-q
and thus one would need to use
.sp 1
.in +5n
.nf
\fIcalc\fP\ [optional_other_flags\ \&...] \fB\-q\fP \fB\-f\fP filename
.fi
.in -5n
.sp 1
to disable the use of calc startup files as well.
.sp 1
For example, if
the file
.BR /tmp/mersenne :

View File

@@ -1191,12 +1191,18 @@ comprint(COMPLEX *c)
qtmp = c->imag[0];
if (qiszero(&qtmp))
return;
if (conf->complex_space) {
math_chr(' ');
}
if (!qiszero(c->real) && !qisneg(&qtmp))
math_chr('+');
if (qisneg(&qtmp)) {
math_chr('-');
qtmp.num.sign = 0;
}
if (conf->complex_space) {
math_chr(' ');
}
qprintnum(&qtmp, MODE_DEFAULT, conf->outdigits);
math_chr('i');
}
@@ -1223,7 +1229,13 @@ cprintfr(COMPLEX *c)
zprintval(i->num, 0L, 0L);
math_chr('i');
if (qisfrac(i)) {
if (conf->fraction_space) {
math_chr(' ');
}
math_chr('/');
if (conf->fraction_space) {
math_chr(' ');
}
zprintval(i->den, 0L, 0L);
}
}

117
config.c
View File

@@ -93,6 +93,9 @@ NAMETYPE configs[] = {
{"pow2", CONFIG_POW2},
{"redc2", CONFIG_REDC2},
{"tilde", CONFIG_TILDE},
{"tilde_space", CONFIG_TILDE_SPACE},
{"fraction_space", CONFIG_FRACTION_SPACE},
{"complex_space", CONFIG_COMPLEX_SPACE},
{"tab", CONFIG_TAB},
{"quomod", CONFIG_QUOMOD},
{"quo", CONFIG_QUO},
@@ -150,8 +153,11 @@ CONFIG oldstd = { /* backward compatible standard configuration */
SQ_ALG2, /* size of number to use square alg 2 */
POW_ALG2, /* size of modulus to use REDC for powers */
REDC_ALG2, /* size of modulus to use REDC algorithm 2 */
TRUE, /* OK to print a tilde on approximations */
TRUE, /* OK to print tab before numeric values */
TRUE, /* TRUE ==> print a tilde on approximations */
FALSE, /* TRUE ==> print a space after tilde on approximations */
FALSE, /* TRUE ==> print spaces around / in fractions */
FALSE, /* TRUE ==> print spaces around + or - in complex values */
TRUE, /* TRUE ==> print tab before numeric values */
0, /* quomod() default rounding mode */
2, /* quotient // default rounding mode */
0, /* mod % default rounding mode */
@@ -161,8 +167,8 @@ CONFIG oldstd = { /* backward compatible standard configuration */
8, /* cfsim() default rounding mode */
2, /* output default rounding mode */
24, /* round()/bround() default rounding mode */
FALSE, /* OK to print leading 0 before decimal pt */
0, /* OK to print trailing 0's */
FALSE, /* TRUE ==> print leading 0 before decimal pt */
0, /* TRUE ==> print trailing 0's */
MAXSCANCOUNT, /* max scan errors before abort */
PROMPT1, /* normal prompt */
PROMPT2, /* prompt when inside multi-line input */
@@ -173,30 +179,30 @@ CONFIG oldstd = { /* backward compatible standard configuration */
0, /* internal calc debug level */
3, /* calc resource file debug level */
0, /* user defined debug level */
FALSE, /* print Quit or abort executed messages */
FALSE, /* TRUE ==> print Quit or abort executed messages */
CTRL_D_VIRGIN_EOF, /* ^D only exits on virgin lines */
NULL, /* our name */
NULL, /* basename of our name */
#if defined(_WIN32) || defined(_WIN64)
TRUE, /* running under windows */
TRUE, /* TRUE ==> running under windows */
#else
FALSE, /* not using windows */
FALSE, /* FALSE ==> not using windows */
#endif
#if defined(__CYGWIN__)
TRUE, /* compiled under cygwin */
TRUE, /* TRUE ==> compiled under cygwin */
#else
FALSE, /* not compiled with cygwin */
FALSE, /* FALSE ==> not compiled with cygwin */
#endif
#if defined(CUSTOM)
TRUE, /* compiled with -DCUSTOM */
TRUE, /* TRUE ==> compiled with -DCUSTOM */
#else
FALSE, /* compiled without -DCUSTOM */
FALSE, /* FALSE ==> compiled without -DCUSTOM */
#endif
&allow_custom, /* *TRUE=> custom functions are enabled */
NULL, /* version */
BASEB, /* base for calculations */
TRUE, /* warn when redeclaring */
TRUE, /* warn when variable names collide */
TRUE, /* TRUE ==> warn when redeclaring */
TRUE, /* TRUE ==> warn when variable names collide */
};
CONFIG newstd = { /* new non-backward compatible configuration */
MODE_INITIAL, /* current output mode */
@@ -210,8 +216,11 @@ CONFIG newstd = { /* new non-backward compatible configuration */
SQ_ALG2, /* size of number to use square alg 2 */
POW_ALG2, /* size of modulus to use REDC for powers */
REDC_ALG2, /* size of modulus to use REDC algorithm 2 */
TRUE, /* OK to print a tilde on approximations */
TRUE, /* OK to print tab before numeric values */
TRUE, /* TRUE ==> print a tilde on approximations */
FALSE, /* TRUE ==> print spaces around / in fractions */
FALSE, /* TRUE ==> print a space after tilde on approximations */
FALSE, /* TRUE ==> print spaces around + or - in complex values */
TRUE, /* TRUE ==> print tab before numeric values */
0, /* quomod() default rounding mode */
2, /* quotient // default rounding mode */
0, /* mod % default rounding mode */
@@ -221,8 +230,8 @@ CONFIG newstd = { /* new non-backward compatible configuration */
8, /* cfsim() default rounding mode */
24, /* output default rounding mode */
24, /* round()/bround() default rounding mode */
TRUE, /* OK to print leading 0 before decimal pt */
0, /* OK to print trailing 0's */
TRUE, /* TRUE ==> print leading 0 before decimal pt */
0, /* TRUE ==> print trailing 0's */
MAXSCANCOUNT, /* max scan errors before abort */
"; ", /* normal prompt */
";; ", /* prompt when inside multi-line input */
@@ -233,30 +242,30 @@ CONFIG newstd = { /* new non-backward compatible configuration */
0, /* internal calc debug level */
3, /* calc resource file debug level */
0, /* user defined debug level */
FALSE, /* print Quit or abort executed messages */
FALSE, /* TRUE ==> print Quit or abort executed messages */
CTRL_D_VIRGIN_EOF, /* ^D only exits on virgin lines */
NULL, /* our name */
NULL, /* basename of our name */
#if defined(_WIN32) || defined(_WIN64)
TRUE, /* running under windows */
TRUE, /* TRUE ==> running under windows */
#else
FALSE, /* not using windows */
FALSE, /* FALSE ==> not using windows */
#endif
#if defined(__CYGWIN__)
TRUE, /* compiled under cygwin */
TRUE, /* TRUE ==> compiled under cygwin */
#else
FALSE, /* not compiled with cygwin */
FALSE, /* FALSE ==> not compiled with cygwin */
#endif
#if defined(CUSTOM)
TRUE, /* compiled with -DCUSTOM */
TRUE, /* TRUE ==> compiled with -DCUSTOM */
#else
FALSE, /* compiled without -DCUSTOM */
FALSE, /* FALSE ==> compiled without -DCUSTOM */
#endif
&allow_custom, /* *TRUE=> custom functions are enabled */
&allow_custom, /* *TRUE ==> custom functions are enabled */
NULL, /* version */
BASEB, /* base for calculations */
TRUE, /* warn when redeclaring */
TRUE, /* warn when variable names collide */
TRUE, /* TRUE ==> warn when redeclaring */
TRUE, /* TRUE ==> warn when variable names collide */
};
CONFIG *conf = NULL; /* loaded in at startup - current configuration */
@@ -624,6 +633,48 @@ setconfig(int type, VALUE *vp)
}
break;
case CONFIG_TILDE_SPACE:
if (vp->v_type == V_NUM) {
q = vp->v_num;
conf->tilde_space = !qiszero(q);
} else if (vp->v_type == V_STR) {
temp = lookup_long(truth, vp->v_str->s_str);
if (temp < 0) {
math_error("Illegal truth value for tilde_space");
not_reached();
}
conf->tilde_space = (int)temp;
}
break;
case CONFIG_FRACTION_SPACE:
if (vp->v_type == V_NUM) {
q = vp->v_num;
conf->fraction_space = !qiszero(q);
} else if (vp->v_type == V_STR) {
temp = lookup_long(truth, vp->v_str->s_str);
if (temp < 0) {
math_error("Illegal truth value for fraction_space");
not_reached();
}
conf->fraction_space = (int)temp;
}
break;
case CONFIG_COMPLEX_SPACE:
if (vp->v_type == V_NUM) {
q = vp->v_num;
conf->complex_space = !qiszero(q);
} else if (vp->v_type == V_STR) {
temp = lookup_long(truth, vp->v_str->s_str);
if (temp < 0) {
math_error("Illegal truth value for complex_space");
not_reached();
}
conf->complex_space = (int)temp;
}
break;
case CONFIG_TAB:
if (vp->v_type == V_NUM) {
q = vp->v_num;
@@ -1205,6 +1256,18 @@ config_value(CONFIG *cfg, int type, VALUE *vp)
i = (cfg->tilde_ok ? 1 : 0);
break;
case CONFIG_TILDE_SPACE:
i = (cfg->tilde_space ? 1 : 0);
break;
case CONFIG_FRACTION_SPACE:
i = (cfg->fraction_space ? 1 : 0);
break;
case CONFIG_COMPLEX_SPACE:
i = (cfg->complex_space ? 1 : 0);
break;
case CONFIG_TAB:
i = (cfg->tab_ok ? 1 : 0);
break;

View File

@@ -94,6 +94,9 @@
#define CONFIG_REDECL_WARN 44
#define CONFIG_DUPVAR_WARN 45
#define CONFIG_HZ 46
#define CONFIG_TILDE_SPACE 47
#define CONFIG_FRACTION_SPACE 48
#define CONFIG_COMPLEX_SPACE 49
/*
@@ -123,7 +126,7 @@ struct config {
int outmode2; /* current secondary output mode */
LEN outdigits; /* current output digits for float or exp */
NUMBER *epsilon; /* default error for real functions */
long epsilonprec; /* epsilon binary precision (tied to epsilon) */
long epsilonprec; /* epsilon binary precision (tied to epsilon) */
FLAG traceflags; /* tracing flags */
LEN maxprint; /* number of elements to print */
LEN mul2; /* size of number to use multiply algorithm 2 */
@@ -131,6 +134,9 @@ struct config {
LEN pow2; /* size of modulus to use REDC for powers */
LEN redc2; /* size of modulus to use REDC algorithm 2 */
BOOL tilde_ok; /* OK to print a tilde on approximations */
BOOL tilde_space; /* print space after tilde on approximations */
BOOL fraction_space; /* TRUE => print spaces around / in fractions */
BOOL complex_space; /* TRUE => print spaces around + or - in complex values */
BOOL tab_ok; /* OK to print tab before numeric values */
LEN quomod; /* quomod() default rounding mode */
LEN quo; /* quotient // default rounding mode */

View File

@@ -474,7 +474,7 @@ EXT=
# The default calc versions
#
VERSION= 2.14.1.0
VERSION= 2.14.1.3
# 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.3
# 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');

2
hash.c
View File

@@ -956,6 +956,7 @@ hash_value(int type, void *v, HASH *state)
state = hash_len(type, value->v_config->pow2, state);
state = hash_len(type, value->v_config->redc2, state);
state = hash_bool(type, value->v_config->tilde_ok, state);
state = hash_bool(type, value->v_config->tilde_space, state);
state = hash_bool(type, value->v_config->tab_ok, state);
state = hash_long(type, (long)value->v_config->quomod, state);
state = hash_long(type, (long)value->v_config->quo, state);
@@ -1001,6 +1002,7 @@ hash_value(int type, void *v, HASH *state)
state = hash_int(type, value->v_config->baseb, state);
state = hash_bool(type, value->v_config->redecl_warn, state);
state = hash_bool(type, value->v_config->dupvar_warn, state);
state = hash_bool(type, value->v_config->fraction_space, state);
break;
case V_HASH:

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,16 +24,14 @@
* 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"
#include "have_string.h"
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#include "banned.h" /* include after system header <> includes */
@@ -42,29 +40,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

@@ -34,6 +34,7 @@ DESCRIPTION
"pow2" sets size for alternate powering.
"redc2" sets size for alternate REDC.
"tilde" enable/disable printing of the roundoff '~'
"tilde_space" enable/disable printing space after roundoff tilde '~ '
"tab" enable/disable printing of leading tabs
"quomod" sets rounding mode for quomod
"quo" sets rounding mode for //, default for quo
@@ -134,6 +135,7 @@ DESCRIPTION
config("display", 50); 50 digits of output
epsilon(epsilon() / 8); 3 bits more accuracy
config("tilde", 0) disable roundoff tilde printing
config("tilde_space", 1) enable printing space after roundoff tilde
config("tab", "off") disable leading tab printing
=-=
@@ -264,7 +266,7 @@ DESCRIPTION
config("mul2", int)
config("sq2", int)
Mul2 and sq2 specify the sizes of numbers at which calc switches
Both "mul2" and "sq2" specify the sizes of numbers at which calc switches
from its first to its second algorithm for multiplying and squaring.
The first algorithm is the usual method of cross multiplying, which
runs in a time of O(N^2). The second method is a recursive and
@@ -305,7 +307,7 @@ DESCRIPTION
config("pow2", int)
Pow2 specifies the sizes of numbers at which calc switches from
The "pow2" specifies the sizes of numbers at which calc switches from
its first to its second algorithm for calculating powers modulo
another number. The first algorithm for calculating modular powers
is by repeated squaring and multiplying and dividing by the modulus.
@@ -334,7 +336,7 @@ DESCRIPTION
config("redc2", int)
Redc2 specifies the sizes of numbers at which calc switches from
The "redc2" specifies the sizes of numbers at which calc switches from
its first to its second algorithm when using the REDC algorithm.
The first algorithm performs a multiply and a modular reduction
together in one loop which runs in O(N^2). The second algorithm
@@ -363,16 +365,48 @@ DESCRIPTION
config("tilde", boolean)
Config("tilde") controls whether or not a leading tilde ('~') is
The "tilde" controls whether or not a leading tilde ('~') is
printed to indicate that a number has not been printed exactly
because the number of decimal digits required would exceed the
specified maximum number. The initial "tilde" value is 1.
specified maximum number.
If config("tilde") is false, then config("tilde_space") has no effect.
The initial "tilde" value is 1 (on).
=-=
config("tilde_space", boolean)
The "tilde_space" controls whether or not a space (' ') is
printed after leading tilde ('~'). See config("tilde") above.
If config("tilde") is false, then config("tilde_space") has no effect.
NOTE: Use of config("tilde_space", 1) can break printing and scanning
of complex values via "%c".
The initial "tilde_space" value is 0 (off)
=-=
config("fraction_space", boolean)
The "fraction_space" controls whether or not a space (' ') is
printed both before and after '/' when printing a fraction.
NOTE: Use of config("fraction_space", 1) can break printing and scanning
of fractional values via "%r".
NOTE: Use of config("fraction_space", 1) can break printing and scanning
of complex values via "%c".
The initial "fraction_space" value is 0 (off).
=-=
config("tab", boolean)
Config ("tab") controls the printing of a tab before results
config("tab") controls the printing of a tab before results
automatically displayed when working interactively. It does not
affect the printing by the functions print, printf, etc. The initial
"tab" value is 1.
@@ -908,6 +942,7 @@ EXAMPLE
pow2 40
redc2 50
tilde 1
tilde_space 0
tab 1
quomod 0
quo 2
@@ -944,6 +979,7 @@ EXAMPLE
redecl_warn 1
dupvar_warn 1
hz 100
fraction_space 0
; display()
20

View File

@@ -321,6 +321,7 @@ libcalc_call_me_first(void)
if (d_flag) {
conf->resource_debug = 0;
conf->tilde_ok = 0;
conf->tilde_space = 0;
}
/*
@@ -693,7 +694,7 @@ calc_strdup(CONST char *s1)
#else /* HAVE_STRDUP */
char *ret; /* return string */
size_t s1_len; /* length of string to duplicate */
size_t s1_len; /* length of string to duplicate */
/*
* firewall
@@ -737,7 +738,7 @@ S_FUNC int
find_tty_state(int fd)
{
int *new_fd_setup; /* new fd_setup array */
ttystruct *new_fd_orig; /* new fd_orig array */
ttystruct *new_fd_orig; /* new fd_orig array */
ttystruct *new_fd_cur; /* new fd_cur array */
int i;
@@ -764,7 +765,7 @@ find_tty_state(int fd)
if (fd_orig == NULL) {
return -1;
}
fd_cur = (ttystruct *)malloc(sizeof(fd_orig[0]));
fd_cur = (ttystruct *)malloc(sizeof(fd_cur[0]));
if (fd_cur == NULL) {
return -1;
}
@@ -796,26 +797,35 @@ find_tty_state(int fd)
/*
* no empty slots exist, realloc another slot
*/
/* expand fd_orig as an original pre-modified copy of fd_setup */
new_fd_orig = (ttystruct *)realloc(fd_orig, sizeof(fd_orig[0]) *
(fd_setup_len+1));
if (new_fd_orig == NULL) {
return -1;
}
fd_orig = new_fd_orig;
memcpy(fd_orig, fd_setup, sizeof(fd_orig[0]) * (fd_setup_len+1));
/* expand fd_setup */
new_fd_setup = (int *)realloc(fd_setup, sizeof(fd_setup[0]) *
(fd_setup_len+1));
if (new_fd_setup == NULL) {
return -1;
}
fd_setup = new_fd_setup;
new_fd_setup[fd_setup_len] = -1;
new_fd_orig = (ttystruct *)realloc(fd_setup, sizeof(fd_orig[0]) *
(fd_setup_len+1));
if (new_fd_orig == NULL) {
return -1;
}
/* expand fd_cur */
new_fd_cur = (ttystruct *)realloc(fd_cur, sizeof(fd_cur[0]) *
(fd_setup_len+1));
if (new_fd_cur == NULL) {
return -1;
}
fd_setup = new_fd_setup;
fd_orig = new_fd_orig;
fd_cur = new_fd_cur;
/* expand fd setup length */
++fd_setup_len;
/* return the new slot */
return fd_setup_len-1;
}

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"

42
qio.c
View File

@@ -201,16 +201,24 @@ qprintnum(NUMBER *q, int outmode, LEN outdigits)
}
switch (outmode) {
case MODE_INT:
if (conf->tilde_ok && qisfrac(q))
if (conf->tilde_ok && qisfrac(q)) {
PUTCHAR('~');
if (conf->tilde_space && qisfrac(q)) {
PUTCHAR(' ');
}
}
qprintfd(q, 0L);
break;
case MODE_REAL:
prec = qdecplaces(q);
if ((prec < 0) || (prec > outdigits)) {
if (conf->tilde_ok)
if (conf->tilde_ok) {
PUTCHAR('~');
if (conf->tilde_space) {
PUTCHAR(' ');
}
}
}
if (conf->fullzero || (prec < 0) ||
(prec > outdigits))
@@ -412,7 +420,13 @@ qprintfr(NUMBER *q, long width, BOOL force)
{
zprintval(q->num, 0L, width);
if (force || qisfrac(q)) {
if (conf->fraction_space) {
PUTCHAR(' ');
}
PUTCHAR('/');
if (conf->fraction_space) {
PUTCHAR(' ');
}
zprintval(q->den, 0L, width);
}
}
@@ -446,7 +460,13 @@ qprintfx(NUMBER *q, long width)
{
zprintx(q->num, width);
if (qisfrac(q)) {
if (conf->fraction_space) {
PUTCHAR(' ');
}
PUTCHAR('/');
if (conf->fraction_space) {
PUTCHAR(' ');
}
zprintx(q->den, 0L);
}
}
@@ -461,7 +481,13 @@ qprintfb(NUMBER *q, long width)
{
zprintb(q->num, width);
if (qisfrac(q)) {
if (conf->fraction_space) {
PUTCHAR(' ');
}
PUTCHAR('/');
if (conf->fraction_space) {
PUTCHAR(' ');
}
zprintb(q->den, 0L);
}
}
@@ -476,7 +502,13 @@ qprintfo(NUMBER *q, long width)
{
zprinto(q->num, width);
if (qisfrac(q)) {
if (conf->fraction_space) {
PUTCHAR(' ');
}
PUTCHAR('/');
if (conf->fraction_space) {
PUTCHAR(' ');
}
zprinto(q->den, 0L);
}
}
@@ -749,6 +781,12 @@ fitprint(NUMBER *q, long width)
width1 = width - width2;
}
fitzprint(q->num, numdigits, width1);
if (conf->fraction_space) {
PUTCHAR(' ');
}
PUTCHAR('/');
if (conf->fraction_space) {
PUTCHAR(' ');
}
fitzprint(q->den, dendigits, width2);
}

View File

@@ -439,6 +439,7 @@ config_hash(CONFIG *cfg, QCKHASH val)
value = (((value>>5) | (value<<27)) ^ (USB32)cfg->pow2);
value = (((value>>5) | (value<<27)) ^ (USB32)cfg->redc2);
value = (((value>>5) | (value<<27)) ^ (USB32)cfg->tilde_ok);
value = (((value>>5) | (value<<27)) ^ (USB32)cfg->tilde_space);
value = (((value>>5) | (value<<27)) ^ (USB32)cfg->tab_ok);
value = (((value>>5) | (value<<27)) ^ (USB32)cfg->quomod);
value = (((value>>5) | (value<<27)) ^ (USB32)cfg->quo);

1
seed.c
View File

@@ -592,7 +592,6 @@ pseudo_seed(void)
sdata.size = sizeof(sdata);
sdata.prev_hash64_copy = prev_hash64; /* load previous hash */
sdata.call_count_copy = ++call_count; /* update call count */
(void) setjmp(sdata.env);
#if defined(HAVE_ENVIRON)
sdata.environ_copy = environ;
#endif /* HAVE_ENVIRON */

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 3 /* minor software version level */
/*
@@ -78,7 +108,7 @@ STATIC char *stored_version = NULL; /* version formed if != NULL */
char *Copyright = "\n"
"calc - arbitrary precision calculator\n"
"\n"
"Copyright (C) 1999-2021 David I. Bell, Landon Curt Noll "
"Copyright (C) 1999-2023 David I. Bell, Landon Curt Noll "
"and Ernest Bowen\n"
"\n"
"Initial author: David I. Bell\n"

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);