Compare commits

...

9 Commits

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

    Fixed version numbers in two cases in CHANGES that referred
    to the 2.14.2.x instead of 2.14.1.x.

    Rename MINGW Makefile variable (a holdover from MINGW32_NT-5.0)
    to OSNAME.

    Fixed FUNCPTR typedef in hist.c to fix deprecated compiler warnings.

    Fixed when USE_READLINE, READLINE_LIB, READLINE_EXTRAS, and
    READLINE_INCLUDE are set to empty (disable use of the GNU-readline
    facility).

    Fix cases of spaces before tabs in Makefile and Makefile.simple.

    Fixed obsolete references to the atoz() in LIBRARY to use the
    correct internal function name of str2z().

    Fixed obsolete references to the atoq() in LIBRARY to use the
    correct internal function name of str2q().

    Document in help/unexpected that * operator has has a higher
    precedence than << in calc, which differs from C.  Thanks
    goes to GitHub user @inguin for pointing put this difference.
2023-05-31 18:55:56 -07:00
Landon Curt Noll
e2b2976d18 document that * operator has has a higher precedence than << 2023-05-31 18:30:26 -07:00
Landon Curt Noll
3ea51ea937 Corrected LIBRARY to refer to str2z() and str2()
Fixed obsolete references to the atoz() in LIBRARY to use the
correct internal function name of str2z().

Fixed obsolete references to the atoq() in LIBRARY to use the
correct internal function name of str2q().
2023-05-31 18:22:09 -07:00
Landon Curt Noll
5fa732b869 Release v2.14.1.5
The following are the changes in this release:

    Fixed version numbers in two cases in CHANGES that referred
    to the 2.14.2.x instead of 2.14.1.x.

    Rename MINGW Makefile variable (a holdover from MINGW32_NT-5.0)
    to OSNAME.

    Fixed FUNCPTR typedef in hist.c to fix deprecated compiler warnings.

    Fixed when USE_READLINE, READLINE_LIB, READLINE_EXTRAS, and
    READLINE_INCLUDE are set to empty (disable use of the GNU-readline
    facility).

    Fix cases of spaces before tabs in Makefile and Makefile.simple.
2023-03-12 20:52:45 -07:00
Landon Curt Noll
6a54caf1c2 Fixed when disabling use of the GNU-readline facility
Fixed FUNCPTR typedef in hist.c to fix deprecated compiler warnings.

Fixed when USE_READLINE, READLINE_LIB, READLINE_EXTRAS, and
READLINE_INCLUDE are set to empty (disable use of the GNU-readline
facility).

Fix cases of spaces before tabs in Makefile and Makefile.simple.
2023-03-12 19:27:11 -07:00
Landon Curt Noll
cce930987b improve hist.c FUNCPTR type to use in arg 2023-03-12 18:16:36 -07:00
Landon Curt Noll
7c806f13ea Fixed FUNCPTR typedef in hist.c to fix deprecated compiler warnings 2023-03-12 18:10:38 -07:00
Landon Curt Noll
616bcd8d46 rename MINGW to OSNAME in Makefile
Rename MINGW Makefile variable (a holdover from MINGW32_NT-5.0)
to OSNAME.

Fixed some incorrect version number comments in CHANGES.
2023-03-11 01:05:01 -08:00
Landon Curt Noll
36a1a042f3 fix warnings while forming builtin list 2023-03-06 04:17:31 -08:00
10 changed files with 168 additions and 108 deletions

31
CHANGES
View File

@@ -1,4 +1,31 @@
The following are the changes from calc version 2.14.2.3 to date:
The following are the changes from calc version 2.14.1.5 to date:
Fixed version numbers in two cases in CHANGES that referred
to the 2.14.2.x instead of 2.14.1.x.
Rename MINGW Makefile variable (a holdover from MINGW32_NT-5.0)
to OSNAME.
Fixed FUNCPTR typedef in hist.c to fix deprecated compiler warnings.
Fixed when USE_READLINE, READLINE_LIB, READLINE_EXTRAS, and
READLINE_INCLUDE are set to empty (disable use of the GNU-readline
facility).
Fix cases of spaces before tabs in Makefile and Makefile.simple.
Fixed obsolete references to the atoz() in LIBRARY to use the
correct internal function name of str2z().
Fixed obsolete references to the atoq() in LIBRARY to use the
correct internal function name of str2q().
Document in help/unexpected that * operator has has a higher
precedence than << in calc, which differs from C. Thanks
goes to GitHub user @inguin for pointing put this difference.
The following are the changes from calc version 2.14.1.3 to 2.14.1.4:
Fixed missing <string.h include in have_fpos_pos.c.
@@ -78,7 +105,7 @@ The following are the changes from calc version 2.14.2.3 to date:
the Makefile dependency list via "make depend".
The following are the changes from calc version 2.14.2.0 to 2.14.1.2:
The following are the changes from calc version 2.14.1.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

16
LIBRARY
View File

@@ -344,7 +344,7 @@ values of 0 and 1 are so common that special checks are made for them.
For initial values besides 0 or 1, you need to call itoz to convert a long
value into a ZVALUE, as shown in the above example. Or alternatively,
for larger numbers you can use the atoz routine to convert a string which
for larger numbers you can use the str2z routine to convert a string which
represents a number into a ZVALUE. The string can be in decimal, octal,
hex, or binary according to the leading digits.
@@ -357,7 +357,7 @@ over a long sequence of operations.
ZVALUE z1, z2, z3;
z1 = _one_;
atoz("12345678987654321", &z2);
str2z("12345678987654321", &z2);
zadd(z1, z2, &z3);
zfree(z1);
zfree(z2);
@@ -446,10 +446,10 @@ to free them first. The following illustrates this:
itoz(55L, &q->num);
A better way to create NUMBERs with particular values is to use the itoq,
iitoq, or atoq functions. Using itoq makes a long value into a NUMBER,
iitoq, or str2q functions. Using itoq makes a long value into a NUMBER,
using iitoq makes a pair of longs into the numerator and denominator of a
NUMBER (reducing them first if needed), and atoq converts a string representing
a number into the corresponding NUMBER. The atoq function accepts input in
NUMBER (reducing them first if needed), and str2q converts a string representing
a number into the corresponding NUMBER. The str2q function accepts input in
integral, fractional, real, or exponential formats. Examples of allocating
numbers are:
@@ -457,7 +457,7 @@ numbers are:
q1 = itoq(66L);
q2 = iitoq(2L, 3L);
q3 = atoq("456.78");
q3 = str2q("456.78");
Also unlike ZVALUEs, NUMBERs are quickly copied. This is because they contain
a link count, which is the number of pointers there are to the NUMBER. The
@@ -504,8 +504,8 @@ For example, to calculate sin(0.5) to 100 decimal places, you could do:
NUMBER *q, *ans, *epsilon;
q = atoq("0.5");
epsilon = atoq("1e-100");
q = str2q("0.5");
epsilon = str2q("1e-100");
ans = qsin(q, epsilon);
There are many convenience macros similar to the ones for ZVALUEs which can

View File

@@ -79,8 +79,8 @@ endif
ifeq ($(hardware),)
hardware=$(shell uname -m 2>/dev/null)
endif
ifeq ($(MINGW),)
MINGW=$(shell uname -o 2>/dev/null)
ifeq ($(OSNAME),)
OSNAME=$(shell uname -o 2>/dev/null)
endif
#endif /* end of skip for non-Gnu makefiles */
@@ -113,7 +113,7 @@ endif
# then we will also need to use the Cygwin runtime enviroment
# and the calc Cygwin make target.
##
ifeq ($(MINGW),Cygwin)
ifeq ($(OSNAME),Cygwin)
target:= Cygwin
endif
#
@@ -1202,11 +1202,25 @@ CALCRC= ./.calcinit:~/.calcrc:${CALC_SHAREDIR}/startup
# READLINE_INCLUDE Where the readline include files reside
# (leave blank if they are /usr/include/readline)
#
# NOTE: If you select the 'USE_READLINE=' mode, then we recommend you set:
#
# READLINE_EXTRAS=
# READLINE_INCLUDE=
# READLINE_LIB=
#
# NOTE: The GNU-readline code is not shipped with calc. You must have
# the appropriate headers and link libs installed on your system in
# order to use it.
#
# If in doubt, set USE_READLINE, READLINE_LIB and READLINE_INCLUDE to nothing.
# To disable the use of the GNU-readline facility (as well as ncurses), set:
#
# USE_READLINE=
# READLINE_EXTRAS=
# READLINE_INCLUDE=
# READLINE_LIB=
#
# If in doubt, set USE_READLINE, READLINE_EXTRAS, READLINE_INCLUDE, and
# READLINE_LIB to nothing.
#
#USE_READLINE=
USE_READLINE= -DUSE_READLINE
@@ -1367,7 +1381,7 @@ EXT=
# The default calc versions
#
VERSION= 2.14.1.4
VERSION= 2.14.1.6
# Names of shared libraries with versions
#
@@ -5688,7 +5702,7 @@ endif
continue; \
fi; \
${RM} -f tmp; \
${SED} -e 's/^\(#[ ]*include[ ][ ]*\)"/\1"calc\//' \
${SED} -e 's/^\(#[ ]*include[ ][ ]*\)"/\1"calc\//' \
$$i > tmp; \
if ${CMP} -s tmp ${T}${CALC_INCDIR}/$$i; then \
${TRUE}; \

View File

@@ -1072,11 +1072,25 @@ CALCRC= ./.calcinit:~/.calcrc:${CALC_SHAREDIR}/startup
# READLINE_INCLUDE Where the readline include files reside
# (leave blank if they are /usr/include/readline)
#
# NOTE: If you select the 'USE_READLINE=' mode, then we recommend you set:
#
# READLINE_EXTRAS=
# READLINE_INCLUDE=
# READLINE_LIB=
#
# NOTE: The GNU-readline code is not shipped with calc. You must have
# the appropriate headers and link libs installed on your system in
# order to use it.
#
# If in doubt, set USE_READLINE, READLINE_LIB and READLINE_INCLUDE to nothing.
# To disable the use of the GNU-readline facility (as well as ncurses), set:
#
# USE_READLINE=
# READLINE_EXTRAS=
# READLINE_INCLUDE=
# READLINE_LIB=
#
# If in doubt, set USE_READLINE, READLINE_EXTRAS, READLINE_INCLUDE, and
# READLINE_LIB to nothing.
#
#USE_READLINE=
USE_READLINE= -DUSE_READLINE
@@ -1225,7 +1239,7 @@ EXT=
# The default calc versions
#
VERSION= 2.14.1.4
VERSION= 2.14.1.6
# Names of shared libraries with versions
#
@@ -4972,7 +4986,7 @@ install: ${LIB_H_SRC} ${BUILD_H_SRC} calc.1 all custom/Makefile
continue; \
fi; \
${RM} -f tmp; \
${SED} -e 's/^\(#[ ]*include[ ][ ]*\)"/\1"calc\//' \
${SED} -e 's/^\(#[ ]*include[ ][ ]*\)"/\1"calc\//' \
$$i > tmp; \
if ${CMP} -s tmp ${T}${CALC_INCDIR}/$$i; then \
${TRUE}; \

View File

@@ -475,7 +475,7 @@ EXT=
# The default calc versions
#
VERSION= 2.14.1.4
VERSION= 2.14.1.6
# Names of shared libraries with versions
#

View File

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

View File

@@ -2,11 +2,11 @@ s/VALUE/int/
s/NUMBER[ ]*\*/int /
s/NUMBER/int/
s/STRINGHEAD/int/
s/\(".*",.*,.*\),.*,.*,.*,.*,/\1, 0, 0, 0, 0,/
s/\(".*",.*,.*\),.*,.*,.*,.*,/\1, 0, 0, {.null = NULL}, {.null = NULL},/
s/[ ][ ]*$//
p
## Copyright (C) 1999 Landon Curt Noll
## Copyright (C) 1999,2023 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License

View File

@@ -556,8 +556,14 @@ Unexpected
; print sin(d2r(30))
0.5
* operator has has a higher precedence than <<
==============================================
## Copyright (C) 1999-2007,2014,2017,2021 Landon Curt Noll
The * operator has has a higher precedence than <<, which differs from the C language.
So 3 << 2*5 evaluates to 3072 in C, whereas 3 << 2*5 evaluates to 60 in calc.
## Copyright (C) 1999-2007,2014,2017,2021,2023 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License

165
hist.c
View File

@@ -98,7 +98,7 @@ STATIC struct {
} HS;
typedef void (*FUNCPTR)();
typedef void (*FUNCPTR)(int);
typedef struct {
char *name;
@@ -106,38 +106,38 @@ typedef struct {
} FUNC;
/* declare binding functions */
S_FUNC void flush_input(void);
S_FUNC void start_of_line(void);
S_FUNC void end_of_line(void);
S_FUNC void forward_char(void);
S_FUNC void backward_char(void);
S_FUNC void forward_word(void);
S_FUNC void backward_word(void);
S_FUNC void delete_char(void);
S_FUNC void forward_kill_char(void);
S_FUNC void backward_kill_char(void);
S_FUNC void forward_kill_word(void);
S_FUNC void kill_line(void);
S_FUNC void new_line(void);
S_FUNC void save_line(void);
S_FUNC void forward_history(void);
S_FUNC void backward_history(void);
S_FUNC void flush_input(int key);
S_FUNC void start_of_line(int key);
S_FUNC void end_of_line(int key);
S_FUNC void forward_char(int key);
S_FUNC void backward_char(int key);
S_FUNC void forward_word(int key);
S_FUNC void backward_word(int key);
S_FUNC void delete_char(int key);
S_FUNC void forward_kill_char(int key);
S_FUNC void backward_kill_char(int key);
S_FUNC void forward_kill_word(int key);
S_FUNC void kill_line(int key);
S_FUNC void new_line(int key);
S_FUNC void save_line(int key);
S_FUNC void forward_history(int key);
S_FUNC void backward_history(int key);
S_FUNC void insert_char(int key);
S_FUNC void goto_line(void);
S_FUNC void list_history(void);
S_FUNC void refresh_line(void);
S_FUNC void swap_chars(void);
S_FUNC void set_mark(void);
S_FUNC void yank(void);
S_FUNC void save_region(void);
S_FUNC void kill_region(void);
S_FUNC void reverse_search(void);
S_FUNC void quote_char(void);
S_FUNC void uppercase_word(void);
S_FUNC void lowercase_word(void);
S_FUNC void ignore_char(void);
S_FUNC void arrow_key(void);
S_FUNC void quit_calc(void) __attribute__((noreturn));
S_FUNC void goto_line(int key);
S_FUNC void list_history(int key);
S_FUNC void refresh_line(int key);
S_FUNC void swap_chars(int key);
S_FUNC void set_mark(int key);
S_FUNC void yank(int key);
S_FUNC void save_region(int key);
S_FUNC void kill_region(int key);
S_FUNC void reverse_search(int key);
S_FUNC void quote_char(int key);
S_FUNC void uppercase_word(int key);
S_FUNC void lowercase_word(int key);
S_FUNC void ignore_char(int key);
S_FUNC void arrow_key(int key);
S_FUNC void quit_calc(int key) __attribute__((noreturn));
STATIC FUNC funcs[] =
@@ -217,8 +217,8 @@ STATIC int save_len;
STATIC KEY_MAP *cur_map;
STATIC KEY_MAP *base_map;
STATIC KEY_ENT key_table[MAX_KEYS];
STATIC HIST* hist_first = NULL;
STATIC HIST* hist_last = NULL;
STATIC HIST* hist_first = NULL;
STATIC HIST* hist_last = NULL;
STATIC char save_buffer[SAVE_SIZE];
/* declare other static functions */
@@ -650,12 +650,11 @@ read_key(void)
ent = &cur_map->default_ent;
if (ent->next)
cur_map = ent->next;
if (ent->func)
/* ignore Saber-C warning #65 - has 1 arg, expecting 0 */
/* OK to ignore in proc read_key */
if (ent->func != NULL) {
(*ent->func)(key);
else
} else {
insert_char(key);
}
}
@@ -797,20 +796,20 @@ find_func(char *name)
S_FUNC void
arrow_key(void)
arrow_key(int UNUSED(key))
{
switch (fgetc(stdin)) {
case 'A':
backward_history();
backward_history(0);
break;
case 'B':
forward_history();
forward_history(0);
break;
case 'C':
forward_char();
forward_char(0);
break;
case 'D':
backward_char();
backward_char(0);
break;
}
}
@@ -867,13 +866,13 @@ decrement_end(int n)
S_FUNC void
ignore_char(void)
ignore_char(int UNUSED(key))
{
}
S_FUNC void
flush_input(void)
flush_input(int UNUSED(key))
{
echo_rest_of_line();
while (HS.end > HS.buf)
@@ -884,21 +883,21 @@ flush_input(void)
S_FUNC void
start_of_line(void)
start_of_line(int UNUSED(key))
{
goto_start_of_line();
}
S_FUNC void
end_of_line(void)
end_of_line(int UNUSED(key))
{
goto_end_of_line();
}
S_FUNC void
forward_char(void)
forward_char(int UNUSED(key))
{
if (HS.pos < HS.end)
echo_char(*HS.pos++);
@@ -906,7 +905,7 @@ forward_char(void)
S_FUNC void
backward_char(void)
backward_char(int UNUSED(key))
{
if (HS.pos > HS.buf)
back_over_char((int)(*--HS.pos));
@@ -914,7 +913,7 @@ backward_char(void)
S_FUNC void
uppercase_word(void)
uppercase_word(int UNUSED(key))
{
while ((HS.pos < HS.end) && !in_word((int)(*HS.pos)))
echo_char(*HS.pos++);
@@ -927,7 +926,7 @@ uppercase_word(void)
S_FUNC void
lowercase_word(void)
lowercase_word(int UNUSED(key))
{
while ((HS.pos < HS.end) && !in_word((int)(*HS.pos)))
echo_char(*HS.pos++);
@@ -940,7 +939,7 @@ lowercase_word(void)
S_FUNC void
forward_word(void)
forward_word(int UNUSED(key))
{
while ((HS.pos < HS.end) && !in_word((int)(*HS.pos)))
echo_char(*HS.pos++);
@@ -950,7 +949,7 @@ forward_word(void)
S_FUNC void
backward_word(void)
backward_word(int UNUSED(key))
{
if ((HS.pos > HS.buf) && in_word((int)(*HS.pos)))
back_over_char((int)(*--HS.pos));
@@ -964,7 +963,7 @@ backward_word(void)
S_FUNC void
forward_kill_char(void)
forward_kill_char(int UNUSED(key))
{
int rest;
char ch;
@@ -986,7 +985,7 @@ forward_kill_char(void)
S_FUNC void
delete_char(void)
delete_char(int UNUSED(key))
{
/*
* quit delete_char (usually ^D) is at start of line and we are allowed
@@ -997,30 +996,30 @@ delete_char(void)
if ((HS.end == HS.buf) &&
(conf->ctrl_d == CTRL_D_EMPTY_EOF ||
(conf->ctrl_d == CTRL_D_VIRGIN_EOF && HS.virgin_line == TRUE))) {
quit_calc();
quit_calc(0);
}
/*
* normal case: just forward_kill_char
*/
if (HS.end > HS.buf)
forward_kill_char();
forward_kill_char(0);
}
S_FUNC void
backward_kill_char(void)
backward_kill_char(int UNUSED(key))
{
if (HS.pos > HS.buf) {
HS.pos--;
back_over_char((int)(*HS.pos));
forward_kill_char();
forward_kill_char(0);
}
}
S_FUNC void
forward_kill_word(void)
forward_kill_word(int UNUSED(key))
{
char *cp;
@@ -1044,7 +1043,7 @@ forward_kill_word(void)
S_FUNC void
kill_line(void)
kill_line(int UNUSED(key))
{
if (HS.end <= HS.pos)
return;
@@ -1063,7 +1062,7 @@ kill_line(void)
* decide whether or not this should be done.
*/
S_FUNC void
new_line(void)
new_line(int UNUSED(key))
{
int len;
@@ -1087,21 +1086,21 @@ new_line(void)
S_FUNC void
save_line(void)
save_line(int UNUSED(key))
{
int len;
len = HS.end - HS.buf;
if (len > 0) {
hist_saveline(HS.buf, len);
flush_input();
flush_input(0);
}
HS.curhist = HS.histcount;
}
S_FUNC void
goto_line(void)
goto_line(int UNUSED(key))
{
int num;
char *cp;
@@ -1115,7 +1114,7 @@ goto_line(void)
beep();
return;
}
flush_input();
flush_input(0);
HS.curhist = HS.histcount - num;
hp = get_event(HS.curhist);
memcpy(HS.buf, hp->data, hp->len);
@@ -1125,11 +1124,11 @@ goto_line(void)
S_FUNC void
forward_history(void)
forward_history(int UNUSED(key))
{
HIST *hp;
flush_input();
flush_input(0);
if (++HS.curhist >= HS.histcount)
HS.curhist = 0;
hp = get_event(HS.curhist);
@@ -1142,11 +1141,11 @@ forward_history(void)
S_FUNC void
backward_history(void)
backward_history(int UNUSED(key))
{
HIST *hp;
flush_input();
flush_input(0);
if (--HS.curhist < 0)
HS.curhist = HS.histcount - 1;
hp = get_event(HS.curhist);
@@ -1208,7 +1207,7 @@ insert_string(char *str, int len)
S_FUNC void
list_history(void)
list_history(int UNUSED(key))
{
HIST *hp;
int hnum;
@@ -1218,12 +1217,12 @@ list_history(void)
printf("\n%3d: ", HS.histcount - hnum);
echo_string(hp->data, hp->len);
}
refresh_line();
refresh_line(0);
}
S_FUNC void
refresh_line(void)
refresh_line(int UNUSED(key))
{
char *cp;
@@ -1239,7 +1238,7 @@ refresh_line(void)
S_FUNC void
swap_chars(void)
swap_chars(int UNUSED(key))
{
char ch1;
char ch2;
@@ -1258,14 +1257,14 @@ swap_chars(void)
S_FUNC void
set_mark(void)
set_mark(int UNUSED(key))
{
HS.mark = HS.pos;
}
S_FUNC void
save_region(void)
save_region(int UNUSED(key))
{
int len;
@@ -1280,7 +1279,7 @@ save_region(void)
S_FUNC void
kill_region(void)
kill_region(int UNUSED(key))
{
char *cp;
char *left;
@@ -1312,14 +1311,14 @@ kill_region(void)
S_FUNC void
yank(void)
yank(int UNUSED(key))
{
insert_string(save_buffer, save_len);
}
S_FUNC void
reverse_search(void)
reverse_search(int UNUSED(key))
{
int len;
int count;
@@ -1345,7 +1344,7 @@ reverse_search(void)
HS.curhist = testhist;
save_pos = HS.pos;
flush_input();
flush_input(0);
memcpy(HS.buf, hp->data, hp->len);
HS.end = &HS.buf[hp->len];
goto_end_of_line();
@@ -1355,7 +1354,7 @@ reverse_search(void)
S_FUNC void
quote_char(void)
quote_char(int UNUSED(key))
{
int ch;
@@ -1451,7 +1450,7 @@ memrcpy(char *dest, char *src, int len)
#endif /* !USE_READLINE */
S_FUNC void
quit_calc(void)
quit_calc(int UNUSED(ch))
{
hist_term();
putchar('\n');
@@ -1493,7 +1492,7 @@ hist_getline(char *prompt, char *buf, size_t len)
case CTRL_D_VIRGIN_EOF:
case CTRL_D_EMPTY_EOF:
default:
quit_calc();
quit_calc(0);
not_reached();
}
}

View File

@@ -84,7 +84,7 @@ static char *program;
#define MAJOR_VER 2 /* major library version */
#define MINOR_VER 14 /* minor library version */
#define MAJOR_PATCH 1 /* major software version level */
#define MINOR_PATCH 4 /* minor software version level */
#define MINOR_PATCH 6 /* minor software version level */
/*