mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Release calc 2.12.6.8
The following are the changes in this release: For historical purposes, in lucas.cal, gen_v1(1, n) always returns 4. Fixed some compiler warnings, thanks to a report by Mike <michael dot d dot ince at gmail dot com>. Added work around for a gcc warning bug, thanks to a report by Mike <michael dot d dot ince at gmail dot com>. Fixed errors in various help files such as: mat randbit seed srandom types Removed the MAXSTRING symbol because it was no longer used by calc. Increased HIST_SIZE (depth of the history stack) from 10k to 32k. Increased TTYSIZE (reallocation size for terminal buffers) from 100 to 8191. Increased MAXDEPTH (maximum depth of input stack) from 10 to 255. Increased interactive input buffer size from 1024 to 256k. This has the effect of increasing the maximum length of an input line from a tty. This helps with an interactive bug that was reported by Ruslan Kabatsayev (b7 dot 10110111 at gmail dot com). The calc man page indicates that -d also disables the printing of the leading tilde. Added information to "help command" about how to silence messages while reading calc resource files. Fixed an error message buffer overflow thanks to a report by Frank Peters <nlp at northernlightsphoto dot biz>. Replaced all use of the C funcion sprintf() with snprintf(). Replaced all use of the C funcion vsprintf() with vsnprintf(). Replaced all DONT_HAVE_VSPRINTF with DONT_HAVE_VSNPRINTF. Replaced all Makefile var ${HAVE_VSPRINTF} with ${HAVE_VSNPRINTF}.
This commit is contained in:
93
have_varvs.c
93
have_varvs.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* have_varvs - try <varargs.h> to see if it really works with vsprintf()
|
||||
* have_varvs - try <varargs.h> to see if it really works with vsnprintf()
|
||||
*
|
||||
* Copyright (C) 1999 Landon Curt Noll
|
||||
* Copyright (C) 1999,2018 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
|
||||
@@ -26,12 +26,12 @@
|
||||
|
||||
/*
|
||||
* Some systems have bugs in the <varargs.h> implementation that show up in
|
||||
* vsprintf(), so we may have to try to use sprintf() as if it were vsprintf()
|
||||
* and hope for the best.
|
||||
* vsnprintf(), so we may have to try to use snprintf() as if it were
|
||||
* vsnprintf() and hope for the best.
|
||||
*
|
||||
* This program will output #defines and exits 0 if vsprintf() (or sprintf())
|
||||
* produces the results that we expect. This program exits 1 if vsprintf()
|
||||
* (or sprintf()) produces unexpected results while using the <stdarg.h>
|
||||
* This program will output #defines and exits 0 if vsnprintf() (or snprintf())
|
||||
* produces the results that we expect. This program exits 1 if vsnprintf()
|
||||
* (or snprintf()) produces unexpected results while using the <stdarg.h>
|
||||
* include file.
|
||||
*/
|
||||
|
||||
@@ -48,43 +48,27 @@
|
||||
# include <string.h>
|
||||
#endif
|
||||
|
||||
#undef VSPRINTF_SIZE_T
|
||||
#undef VSNPRINTF_SIZE_T
|
||||
#if defined(FORCE_STDC) || (defined(__STDC__) && __STDC__ != 0) || \
|
||||
defined(__cplusplus)
|
||||
# define VSPRINTF_SIZE_T size_t
|
||||
# define VSNPRINTF_SIZE_T size_t
|
||||
#else
|
||||
# define VSPRINTF_SIZE_T long
|
||||
# define VSNPRINTF_SIZE_T long
|
||||
#endif
|
||||
|
||||
char buf[BUFSIZ];
|
||||
char buf[BUFSIZ+1];
|
||||
|
||||
#if !defined(STDARG) && !defined(SIMULATE_STDARG)
|
||||
#include <varargs.h>
|
||||
|
||||
void
|
||||
try_this(char *fmt, ...)
|
||||
try_nthis(char *fmt, VSNPRINTF_SIZE_T size, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap);
|
||||
|
||||
#if !defined(DONT_HAVE_VSPRINTF)
|
||||
vsprintf(buf, fmt, ap);
|
||||
#else
|
||||
sprintf(buf, fmt, ap);
|
||||
#endif
|
||||
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
try_nthis(char *fmt, VSPRINTF_SIZE_T size, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap);
|
||||
|
||||
#if !defined(DONT_HAVE_VSPRINTF)
|
||||
#if !defined(DONT_HAVE_VSNPRINTF)
|
||||
vsnprintf(buf, size, fmt, ap);
|
||||
#else
|
||||
snprintf(buf, size, fmt, ap);
|
||||
@@ -96,13 +80,7 @@ try_nthis(char *fmt, VSPRINTF_SIZE_T size, ...)
|
||||
#else
|
||||
|
||||
void
|
||||
try_this(char *a, int b, char *c, int d)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
try_nthis(char *a, VSPRINTF_SIZE_T size, int b, char *c, int d)
|
||||
try_nthis(char *a, VSNPRINTF_SIZE_T size, int b, char *c, int d)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -118,36 +96,12 @@ main(void)
|
||||
*/
|
||||
buf[0] = '\0';
|
||||
|
||||
/*
|
||||
* test variable args and vsprintf/sprintf
|
||||
*/
|
||||
try_this("@%d:%s:%d@", 1, "hi", 2);
|
||||
if (strcmp(buf, "@1:hi:2@") != 0) {
|
||||
#if !defined(DONT_HAVE_VSPRINTF)
|
||||
/* <varargs.h> with vsprintf() didn't work */
|
||||
#else
|
||||
/* <varargs.h> with sprintf() simulating vsprintf() didn't work */
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
try_this("%s %d%s%d%d %s",
|
||||
"Landon Noll 1st proved that", 2, "^", 23209, -1, "was prime");
|
||||
if (strcmp(buf,
|
||||
"Landon Noll 1st proved that 2^23209-1 was prime") != 0) {
|
||||
#if !defined(DONT_HAVE_VSPRINTF)
|
||||
/* <varargs.h> with vsprintf() didn't work */
|
||||
#else
|
||||
/* <varargs.h> with sprintf() simulating vsprintf() didn't work */
|
||||
#endif
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* test variable args and vsnprintf/snprintf
|
||||
*/
|
||||
try_nthis("@%d:%s:%d@", sizeof(buf)-1, 1, "hello", 5);
|
||||
if (strcmp(buf, "@1:hello:5@") != 0) {
|
||||
#if !defined(DONT_HAVE_VSPRINTF)
|
||||
#if !defined(DONT_HAVE_VSNPRINTF)
|
||||
/* <varargs.h> with vsnprintf() didn't work */
|
||||
#else
|
||||
/* <varargs.h> with snprintf() simulating vsnprintf() didn't work */
|
||||
@@ -158,7 +112,7 @@ main(void)
|
||||
"Landon Noll 1st proved that", 2, "^", 23209, -1, "was prime");
|
||||
if (strcmp(buf,
|
||||
"Landon Noll 1st proved that 2^23209-1 was prime") != 0) {
|
||||
#if !defined(DONT_HAVE_VSPRINTF)
|
||||
#if !defined(DONT_HAVE_VSNPRINTF)
|
||||
/* <varargs.h> with vsnprintf() didn't work */
|
||||
#else
|
||||
/* <varargs.h> with snprintf() simulating vsnprintf() didn't work */
|
||||
@@ -172,22 +126,21 @@ main(void)
|
||||
puts("/* what type of variable args do we have? */");
|
||||
puts("#define VARARGS /* use <varargs.h> */");
|
||||
puts("#include <varargs.h>");
|
||||
puts("\n/* should we use vsprintf() and vsnprintf()? */");
|
||||
#if !defined(DONT_HAVE_VSPRINTF)
|
||||
puts("#define HAVE_VSPRINTF /* yes */");
|
||||
puts("\n/* should we use vsnprintf() and vsnprintf()? */");
|
||||
#if !defined(DONT_HAVE_VSNPRINTF)
|
||||
puts("#define HAVE_VSNPRINTF /* yes */");
|
||||
#else
|
||||
puts("/*");
|
||||
puts(" * Hack aleart!!!");
|
||||
puts(" *");
|
||||
puts(" * Systems that do not have vsprintf() need something. In some");
|
||||
puts(" * cases the sprintf function will deal correctly with the");
|
||||
puts(" * va_alist 3rd arg. Same gors for a lack of an vsnprintf()");
|
||||
puts(" * Systems that do not have vsnprintf() need something. In some");
|
||||
puts(" * cases the snprintf() function will deal correctly with the");
|
||||
puts(" * va_alist 4th arg. Same gors for a lack of an vsnprintf()");
|
||||
puts(" * function. In either case we use the #defines below and");
|
||||
puts(" * hope for the best!");
|
||||
puts(" */");
|
||||
puts("#define vsprintf sprintf");
|
||||
puts("#define vsnprintf snprintf");
|
||||
puts("#undef HAVE_VSPRINTF");
|
||||
puts("#undef HAVE_VSNPRINTF");
|
||||
#endif
|
||||
/* exit(0); */
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user