Compare commits

..

11 Commits

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

     Thanks to GitHub user @ashamedbit, a long standing memory leak in
     zrandom.c has been fixed.
2024-02-09 08:28:56 -08:00
Landon Curt Noll
ae85846839 improve useful strings produced by update_ver 2024-02-09 08:27:02 -08:00
Landon Curt Noll
e096bd9ad8 credit @ashamedbit a memory leak fix in zrandom.c 2024-02-09 08:02:50 -08:00
Landon Curt Noll
884b1bc81b Merge pull request #142 from ashamedbit/fix-memory-leak
Fix memory leak in zrandom.c
2024-02-09 07:53:47 -08:00
ashamedbit
a30a518ba7 Fix memory leak in zrandom.c 2024-02-09 03:48:11 -05:00
Landon Curt Noll
bb3b861090 Release v2.15.0.5
The following are the changes in this release:

     make clobber now removes the legacy files: have_fpos.h, help/man,
     and help/usage.  The latter 2 are now managed as help aliases
     in help.c.

     make install now removes the legacy files: ${HELPDIR}/man
     and ${HELPDIR}/usage.

     Fixed a problem where, when calc was linked with and uses GNU
     readline then for any multi-line copy-and-paste, only the first
     line is executed.  Thanks to GitHub user @malfisya for reporting
     this problem, and thanks to GitHub user @gromit1811 for doing
     the research needed to overcome deficiencies in the GNU readline
     documentation, and for supplying the work-a-round to allow
     multi-line copy-and-paste to work as expected!
2024-02-01 20:45:42 -08:00
Landon Curt Noll
0a3469125e prep CHANGES for the next release of calc 2024-02-01 20:38:19 -08:00
Landon Curt Noll
9b37e79f21 update CHANGES, fix make clobber and make install
make clobber also removes the legacy files: help/man, and help/usage.

make install now removes the legacy files: ${HELPDIR}/man and
${HELPDIR}/usage.

Document the GNU readline then for any multi-line copy-and-paste
fix in CHANGES.
2024-01-05 10:21:26 -08:00
Landon Curt Noll
18cd1f9067 Merge pull request #139 from gromit1811/master
Properly handle multi-line strings and newline returned by readline()
2024-01-05 09:51:47 -08:00
Martin Buck
43fc022dc8 Properly handle multi-line strings and newline returned by readline()
Fix for #138

According to
https://lists.gnu.org/archive/html/bug-readline/2024-01/msg00000.html
it's OK for readline() to return multi-line strings and/or newlines in case
of bracketed paste (enabled by default since readline 8.1) and also in other
situations even though its documentation explicitly states the opposite. So
we need to handle this properly in calc instead of just using the first line
and dropping the rest: Split the string returned by readline() into lines
and return line by line with each invocation of hist_getline(), each
possbily adding a terminating newline.
2024-01-05 10:34:25 +01:00
Landon Curt Noll
29695028cd improve make clobber
make clobber now removes the legacy file: have_fpos.h
2023-12-26 12:41:29 -08:00
8 changed files with 120 additions and 29 deletions

24
CHANGES
View File

@@ -1,3 +1,27 @@
The following are the changes from calc version 2.15.0.5 to 2.15.0.6:
Thanks to GitHub user @ashamedbit, a long standing memory leak in
zrandom.c has been fixed.
The following are the changes from calc version 2.15.0.4 to 2.15.0.5:
make clobber now removes the legacy files: have_fpos.h, help/man,
and help/usage. The latter 2 are now managed as help aliases
in help.c.
make install now removes the legacy files: ${HELPDIR}/man
and ${HELPDIR}/usage.
Fixed a problem where, when calc was linked with and uses GNU
readline then for any multi-line copy-and-paste, only the first
line is executed. Thanks to GitHub user @malfisya for reporting
this problem, and thanks to GitHub user @gromit1811 for doing
the research needed to overcome deficiencies in the GNU readline
documentation, and for supplying the work-a-round to allow
multi-line copy-and-paste to work as expected!
The following are the changes from calc version 2.15.0.3 to 2.15.0.4:
Fixed bug that caused calc to fail to compile filepos2z() in file.c

View File

@@ -3478,7 +3478,7 @@ clobber: clean
${RM} -rf .DS_Store; \
fi
${RM} -f func.show func.sort
${RM} -f outfile
${RM} -f outfile have_fpos.h
${V} echo '=-=-=-=-= ${MAKE_FILE} end of $@ rule =-=-=-=-='
# install everything

View File

@@ -1243,7 +1243,7 @@ EXT=
# The calc version in the form of x.y.z.w
#
VERSION= 2.15.0.4
VERSION= 2.15.0.6
# The calc major version in the form of x.y.z
#

View File

@@ -675,7 +675,7 @@ clean:
${RM} -f COPYING COPYING-LGPL questions
clobber: clean
${RM} -f ${BLT_HELP_FILES} full .all calc
${RM} -f ${BLT_HELP_FILES} full .all calc man usage
${RM} -f ${SINGULAR_FILES} ${DETAIL_CLONE}
-${Q} if [ -e .DS_Store ]; then \
echo ${RM} -rf .DS_Store; \
@@ -743,6 +743,14 @@ install: all
${RM} -f ${T}${HELPDIR}/md5; \
echo "removed old ${T}${HELPDIR}/md5"; \
fi;
-${Q} if [ -f "${T}${HELPDIR}/man" ]; then \
${RM} -f ${T}${HELPDIR}/man; \
echo "removed old ${T}${HELPDIR}/man"; \
fi;
-${Q} if [ -f "${T}${HELPDIR}/usage" ]; then \
${RM} -f ${T}${HELPDIR}/usage; \
echo "removed old ${T}${HELPDIR}/usage"; \
fi;
# Try to remove everything that was installed
#

76
hist.c
View File

@@ -73,6 +73,8 @@
#include "banned.h" /* include after system header <> includes */
#define MIN(a,b) (((a) <= (b)) ? (a) : (b))
#if !defined(USE_READLINE)
E_FUNC FILE *curstream(void);
@@ -1472,37 +1474,69 @@ quit_calc(int UNUSED(ch))
* The readline/history libs do most of the dirty work for us, so we can
* replace hist_init() and hist_term() with dummies when using readline.
* For hist_getline() we have to add a newline that readline removed but
* calc expects. For hist_saveline(), we have to undo this. hist_getline()
* calc expects. For hist_saveline(), we have to undo this. hist_getline()
* also has to cope with the different memory management schemes of calc and
* readline.
* readline (pointer to target buffer passed to hist_getline() vs. returned
* malloc()ed buffer from readline()). While doing that, we also split
* multi-line strings potentially returned by readline() in case of
* bracketed paste mode even though its documentation promises to only return
* single lines. For details, see https://github.com/lcn2/calc/issues/138
* and https://lists.gnu.org/archive/html/bug-readline/2024-01/msg00000.html
*/
size_t
hist_getline(char *prompt, char *buf, size_t len)
{
char *line;
STATIC char *rlbuf, *rlcur;
buf[0] = '\0';
line = readline(prompt);
if (!line) {
switch (conf->ctrl_d) {
case CTRL_D_NEVER_EOF:
return 0;
case CTRL_D_VIRGIN_EOF:
case CTRL_D_EMPTY_EOF:
default:
quit_calc(0);
not_reached();
if (!rlbuf) {
rlbuf = rlcur = readline(prompt);
if (!rlbuf) {
buf[0] = '\0';
switch (conf->ctrl_d) {
case CTRL_D_NEVER_EOF:
return 0;
case CTRL_D_VIRGIN_EOF:
case CTRL_D_EMPTY_EOF:
default:
quit_calc(0);
not_reached();
}
}
}
strlcpy(buf, line, len);
buf[len - 2] = '\0';
len = strlen(buf);
buf[len] = '\n';
buf[len + 1] = '\0';
free(line);
return len + 1;
/* eol: pointer to trailing newline (if there is one) or \0 */
char *eol = strchr(rlcur, '\n');
if (!eol) {
eol = rlcur + strlen(rlcur);
}
/* len: length of line in target buffer including (possibly added)
* newline, truncated if buffer is too small. Note that we reduce
* the available buffer size by 1 so that we can safely add the
* newline below.
*/
len = MIN(len - 1, (size_t)(eol - rlcur + 1));
strlcpy(buf, rlcur, len);
/* make sure we have a newline and NUL */
buf[len - 1] = '\n';
buf[len] = '\0';
/* skip over newline in readline buffer */
if (*eol) {
eol++;
}
/* prepare for next invocation: point to next line or free readline
* buffer if we've reached EOL
*/
if (*eol) {
rlcur = eol;
} else {
free(rlbuf);
rlbuf = rlcur = NULL;
}
return len;
}

View File

@@ -169,6 +169,7 @@ for i in $MK_SET1; do
echo "$i: $VER_STRING"
fi
done
echo
if [[ -n $VER_ERR ]]; then
echo "$0: FATAL: error in finding calc major version string"
echo "$0: FATAL: exit 10"
@@ -177,15 +178,36 @@ fi
# print other useful calc strings
#
export VER_CALC_OUTPUT=$(./ver_calc)
echo 'Begin text strings used to produce this release:'
echo 'vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv'
echo
echo "calc $(./ver_calc) release"
echo
echo 'calc-*'$(./ver_calc)'*'
echo
echo "Release v$(./ver_calc)"
echo "$VER_CALC_OUTPUT"
echo
echo "v$VER_CALC_OUTPUT"
echo
echo "Release v$VER_CALC_OUTPUT"
echo
echo "calc $VER_CALC_OUTPUT release"
echo
echo 'For use with sourceforge.net:'
echo
echo 'cd /home/pfs/project/calc/calc'
echo "mkdir $VER_CALC_OUTPUT"
echo "cd $VER_CALC_OUTPUT"
echo 'mput calc-*'"$VER_CALC_OUTPUT"'*'
echo 'put /home/chongo/tmp/README.txt'
echo 'ls'
echo
echo
echo
echo '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'
echo 'End text strings used to produce this release:'
echo
# All Done!!! -- Jessica Noll, Age 2
#
echo
echo "VERSION in Makefile.config is up to date"
exit 0

View File

@@ -64,7 +64,7 @@
#define MAJOR_VER 2 /* level 1: major library version */
#define MINOR_VER 15 /* level 2: minor library version */
#define MAJOR_PATCH 0 /* level 3: major software version level */
#define MINOR_PATCH 4 /* level 4: minor software version level */
#define MINOR_PATCH 6 /* level 4: minor software version level */
#endif /* !INCLUDE_VERSION_H*/

View File

@@ -2679,6 +2679,9 @@ zsetrandom(CONST RANDOM *state)
*/
if (state != NULL) {
p_blum = randomcopy(state);
if (blum_initialized == true) {
randomfree(&blum);
}
blum = *p_blum;
free(p_blum);
}