mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +03:00
Compare commits
6 Commits
prod-2.15.
...
prod-2.15.
Author | SHA1 | Date | |
---|---|---|---|
|
bb3b861090 | ||
|
0a3469125e | ||
|
9b37e79f21 | ||
|
18cd1f9067 | ||
|
43fc022dc8 | ||
|
29695028cd |
18
CHANGES
18
CHANGES
@@ -1,3 +1,21 @@
|
||||
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
|
||||
|
2
Makefile
2
Makefile
@@ -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
|
||||
|
@@ -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.5
|
||||
|
||||
# The calc major version in the form of x.y.z
|
||||
#
|
||||
|
@@ -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
|
||||
#
|
||||
|
56
hist.c
56
hist.c
@@ -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);
|
||||
@@ -1474,18 +1476,24 @@ quit_calc(int UNUSED(ch))
|
||||
* 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()
|
||||
* 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;
|
||||
|
||||
if (!rlbuf) {
|
||||
rlbuf = rlcur = readline(prompt);
|
||||
if (!rlbuf) {
|
||||
buf[0] = '\0';
|
||||
line = readline(prompt);
|
||||
if (!line) {
|
||||
switch (conf->ctrl_d) {
|
||||
case CTRL_D_NEVER_EOF:
|
||||
return 0;
|
||||
@@ -1496,13 +1504,39 @@ hist_getline(char *prompt, char *buf, size_t len)
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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 5 /* level 4: minor software version level */
|
||||
|
||||
|
||||
#endif /* !INCLUDE_VERSION_H*/
|
||||
|
Reference in New Issue
Block a user