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.
This commit is contained in:
Landon Curt Noll
2023-03-12 19:27:11 -07:00
parent cce930987b
commit 6a54caf1c2
4 changed files with 115 additions and 81 deletions

View File

@@ -8,6 +8,12 @@ The following are the changes from calc version 2.14.1.5 to date:
Fixed FUNCPTR typedef in hist.c to fix deprecated compiler warnings. 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.
The following are the changes from calc version 2.14.1.3 to 2.14.1.4: The following are the changes from calc version 2.14.1.3 to 2.14.1.4:

View File

@@ -1202,11 +1202,25 @@ CALCRC= ./.calcinit:~/.calcrc:${CALC_SHAREDIR}/startup
# READLINE_INCLUDE Where the readline include files reside # READLINE_INCLUDE Where the readline include files reside
# (leave blank if they are /usr/include/readline) # (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 # NOTE: The GNU-readline code is not shipped with calc. You must have
# the appropriate headers and link libs installed on your system in # the appropriate headers and link libs installed on your system in
# order to use it. # 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=
USE_READLINE= -DUSE_READLINE USE_READLINE= -DUSE_READLINE

View File

@@ -1072,11 +1072,25 @@ CALCRC= ./.calcinit:~/.calcrc:${CALC_SHAREDIR}/startup
# READLINE_INCLUDE Where the readline include files reside # READLINE_INCLUDE Where the readline include files reside
# (leave blank if they are /usr/include/readline) # (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 # NOTE: The GNU-readline code is not shipped with calc. You must have
# the appropriate headers and link libs installed on your system in # the appropriate headers and link libs installed on your system in
# order to use it. # 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=
USE_READLINE= -DUSE_READLINE USE_READLINE= -DUSE_READLINE

154
hist.c
View File

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