mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Release calc version 2.12.1.9
This commit is contained in:
26
CHANGES
26
CHANGES
@@ -1,4 +1,4 @@
|
|||||||
The following are the changes from calc version 2.12.2 to date:
|
The following are the changes from calc version 2.12.1.8 to date:
|
||||||
|
|
||||||
Fixed calc cscripts that contained comments that were not valid calc
|
Fixed calc cscripts that contained comments that were not valid calc
|
||||||
comments. Improved calc comment documentation in "help unexpected"
|
comments. Improved calc comment documentation in "help unexpected"
|
||||||
@@ -36,8 +36,26 @@ The following are the changes from calc version 2.12.2 to date:
|
|||||||
|
|
||||||
Fixed calc command line usage message.
|
Fixed calc command line usage message.
|
||||||
|
|
||||||
|
Fixed missing README.src file in RPM src and tgz src tarball.
|
||||||
|
|
||||||
The following are the changes from calc version 2.12.1.6 to 2.12.1.6:
|
Removed HAVE_SNPRINTF test in version.c. We now assume that
|
||||||
|
all systems come with the standard snprintf() library function.
|
||||||
|
|
||||||
|
Make does not assume that DONT_HAVE_VSPRINTF must be defined in
|
||||||
|
order to test for varargs (via have_varvs.c). Instead it uses the
|
||||||
|
${HAVE_VSPRINTF} to determine if the vsprintf() and vsnprintf()
|
||||||
|
should be tested to assumed to exist or not exist.
|
||||||
|
|
||||||
|
Tests for the existence of vsprintf() now also require the existence
|
||||||
|
of vsnprintf(). Test for the existence of vsnprintf() now also
|
||||||
|
require the existence of vsprintf().
|
||||||
|
|
||||||
|
The #define CALC_SIZE_T was never used except when memmove() was
|
||||||
|
not found. This symbol was renamed to MEMMOVE_SIZE_T. Calc
|
||||||
|
requires that size_t must be a known type.
|
||||||
|
|
||||||
|
|
||||||
|
The following are the changes from calc version 2.12.1.6 to 2.12.1.7:
|
||||||
|
|
||||||
Added the calc builtin function, usertime(), to return the amount of
|
Added the calc builtin function, usertime(), to return the amount of
|
||||||
user CPU time used by the current process. Unlike the old runtime()
|
user CPU time used by the current process. Unlike the old runtime()
|
||||||
@@ -6318,8 +6336,8 @@ Following is a list of visible changes to calc from version 1.24.7 to 1.26.1:
|
|||||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
##
|
##
|
||||||
## @(#) $Revision: 29.93 $
|
## @(#) $Revision: 29.95 $
|
||||||
## @(#) $Id: CHANGES,v 29.93 2007/02/07 00:41:06 chongo Exp $
|
## @(#) $Id: CHANGES,v 29.95 2007/02/07 21:28:20 chongo Exp $
|
||||||
## @(#) $Source: /usr/local/src/cmd/calc/RCS/CHANGES,v $
|
## @(#) $Source: /usr/local/src/cmd/calc/RCS/CHANGES,v $
|
||||||
##
|
##
|
||||||
## Under source code control: 1993/06/02 18:12:57
|
## Under source code control: 1993/06/02 18:12:57
|
||||||
|
13
Makefile
13
Makefile
@@ -32,8 +32,8 @@
|
|||||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#
|
#
|
||||||
MAKEFILE_REV= $$Revision: 29.84 $$
|
MAKEFILE_REV= $$Revision: 29.85 $$
|
||||||
# @(#) $Id: Makefile.ship,v 29.84 2007/02/07 00:34:23 chongo Exp $
|
# @(#) $Id: Makefile.ship,v 29.85 2007/02/07 20:35:58 chongo Exp $
|
||||||
# @(#) $Source: /usr/local/src/cmd/calc/RCS/Makefile.ship,v $
|
# @(#) $Source: /usr/local/src/cmd/calc/RCS/Makefile.ship,v $
|
||||||
#
|
#
|
||||||
# Under source code control: 1990/02/15 01:48:41
|
# Under source code control: 1990/02/15 01:48:41
|
||||||
@@ -71,13 +71,18 @@ TERMCONTROL=
|
|||||||
|
|
||||||
# If your system does not have a vsprintf() function, you could be in trouble.
|
# If your system does not have a vsprintf() function, you could be in trouble.
|
||||||
#
|
#
|
||||||
# vsprintf(stream, format, ap)
|
# vsprintf(string, format, ap)
|
||||||
#
|
#
|
||||||
# This function works like sprintf except that the 3rd arg is a va_list
|
# This function works like sprintf except that the 3rd arg is a va_list
|
||||||
# strarg (or varargs) list. Some old systems do not have vsprintf().
|
# strarg (or varargs) list. Some old systems do not have vsprintf().
|
||||||
# If you do not have vsprintf(), then calc will try sprintf() and hope
|
# If you do not have vsprintf(), then calc will try sprintf() and hope
|
||||||
# for the best.
|
# for the best.
|
||||||
#
|
#
|
||||||
|
# A simular problem occurs if your system does not have a vsnprintf()
|
||||||
|
# function. This function is like the vsprintf() function except that
|
||||||
|
# there is an extra second argument that controls the maximum size
|
||||||
|
# string that is produced.
|
||||||
|
#
|
||||||
# If HAVE_VSPRINTF is empty, this Makefile will run the have_stdvs.c and/or
|
# If HAVE_VSPRINTF is empty, this Makefile will run the have_stdvs.c and/or
|
||||||
# have_varvs.c program to determine if vsprintf() is supported. If
|
# have_varvs.c program to determine if vsprintf() is supported. If
|
||||||
# HAVE_VSPRINTF is set to -DDONT_HAVE_VSPRINTF then calc will hope that
|
# HAVE_VSPRINTF is set to -DDONT_HAVE_VSPRINTF then calc will hope that
|
||||||
@@ -2828,7 +2833,7 @@ args.h: have_stdvs.c have_varvs.c have_string.h have_unistd.h have_string.h
|
|||||||
fi
|
fi
|
||||||
-${Q} if [ ! -f have_args.sh ] && [ X"${HAVE_VSPRINTF}" = X ]; then \
|
-${Q} if [ ! -f have_args.sh ] && [ X"${HAVE_VSPRINTF}" = X ]; then \
|
||||||
${RM} -f have_stdvs.o have_stdvs${EXT} have_varvs.o have_varvs${EXT}; \
|
${RM} -f have_stdvs.o have_stdvs${EXT} have_varvs.o have_varvs${EXT}; \
|
||||||
${LCC} ${ICFLAGS} -DDONT_HAVE_VSPRINTF have_varvs.c -c \
|
${LCC} ${ICFLAGS} ${HAVE_VSPRINTF} have_varvs.c -c \
|
||||||
2>/dev/null; \
|
2>/dev/null; \
|
||||||
${LCC} ${ILDFLAGS} have_varvs.o -o have_varvs${EXT} 2>/dev/null; \
|
${LCC} ${ILDFLAGS} have_varvs.o -o have_varvs${EXT} 2>/dev/null; \
|
||||||
if ./have_varvs${EXT} >>args.h 2>/dev/null; then \
|
if ./have_varvs${EXT} >>args.h 2>/dev/null; then \
|
||||||
|
12
alloc.h
12
alloc.h
@@ -17,8 +17,8 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.4 $
|
* @(#) $Revision: 29.5 $
|
||||||
* @(#) $Id: alloc.h,v 29.4 2001/06/08 21:00:58 chongo Exp $
|
* @(#) $Id: alloc.h,v 29.5 2007/02/07 20:51:38 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/alloc.h,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/RCS/alloc.h,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1990/02/15 01:48:29
|
* Under source code control: 1990/02/15 01:48:29
|
||||||
@@ -94,13 +94,13 @@ extern int strcmp();
|
|||||||
#endif /* HAVE_NEWSTR */
|
#endif /* HAVE_NEWSTR */
|
||||||
|
|
||||||
#if !defined(HAVE_MEMMOVE)
|
#if !defined(HAVE_MEMMOVE)
|
||||||
# undef CALC_SIZE_T
|
# undef MEMMOVE_SIZE_T
|
||||||
#if defined(FORCE_STDC) || (defined(__STDC__) && __STDC__ != 0) || defined(__cplusplus)
|
#if defined(FORCE_STDC) || (defined(__STDC__) && __STDC__ != 0) || defined(__cplusplus)
|
||||||
# define CALC_SIZE_T size_t
|
# define MEMMOVE_SIZE_T size_t
|
||||||
# else
|
# else
|
||||||
# define CALC_SIZE_T long
|
# define MEMMOVE_SIZE_T long
|
||||||
# endif
|
# endif
|
||||||
extern void *memmove(void *s1, const void *s2, CALC_SIZE_T n);
|
extern void *memmove(void *s1, const void *s2, MEMMOVE_SIZE_T n);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* !__ALLOC_H__ */
|
#endif /* !__ALLOC_H__ */
|
||||||
|
6
blkcpy.c
6
blkcpy.c
@@ -19,8 +19,8 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.9 $
|
* @(#) $Revision: 29.10 $
|
||||||
* @(#) $Id: blkcpy.c,v 29.9 2006/05/20 08:43:55 chongo Exp $
|
* @(#) $Id: blkcpy.c,v 29.10 2007/02/07 20:51:38 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/blkcpy.c,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/RCS/blkcpy.c,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1997/04/18 20:41:26
|
* Under source code control: 1997/04/18 20:41:26
|
||||||
@@ -935,7 +935,7 @@ copyostr2blk(char *str,long ssi,long num,BLOCK *dblk,long dsi,BOOL noreloc)
|
|||||||
* s1
|
* s1
|
||||||
*/
|
*/
|
||||||
void *
|
void *
|
||||||
memmove(void *s1, const void *s2, CALC_SIZE_T n)
|
memmove(void *s1, const void *s2, MEMMOVE_SIZE_T n)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* firewall
|
* firewall
|
||||||
|
@@ -17,8 +17,8 @@
|
|||||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#
|
#
|
||||||
# @(#) $Revision: 29.29 $
|
# @(#) $Revision: 29.31 $
|
||||||
# @(#) $Id: Makefile,v 29.29 2007/02/07 00:31:59 chongo Exp $
|
# @(#) $Id: Makefile,v 29.31 2007/02/07 01:43:56 chongo Exp $
|
||||||
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/Makefile,v $
|
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/Makefile,v $
|
||||||
#
|
#
|
||||||
# Under source code control: 1999/11/29 11:10:26
|
# Under source code control: 1999/11/29 11:10:26
|
||||||
@@ -199,7 +199,7 @@ SCRIPT_SRC= 4dsphere.calc fproduct.calc mersenne.calc \
|
|||||||
|
|
||||||
# These files are found (but not built) in the distribution
|
# These files are found (but not built) in the distribution
|
||||||
#
|
#
|
||||||
DISTLIST= ${SCRIPT_SRC} ${MAKE_FILE} README
|
DISTLIST= ${SCRIPT_SRC} ${MAKE_FILE} README.src
|
||||||
|
|
||||||
# These files are used to make (but not build) a calc .a library
|
# These files are used to make (but not build) a calc .a library
|
||||||
#
|
#
|
||||||
|
@@ -7,7 +7,7 @@ be useful!
|
|||||||
|
|
||||||
Please note that calc shell scripts must start with the line:
|
Please note that calc shell scripts must start with the line:
|
||||||
|
|
||||||
#!/usr/bin/calc -q -f
|
#!/usr/local/src/cmd/calc/calc -q -f
|
||||||
|
|
||||||
The above line MUST start in column 1 of the first line. The first line
|
The above line MUST start in column 1 of the first line. The first line
|
||||||
must also end in -f. The -q is optional, but is recommended to disable
|
must also end in -f. The -q is optional, but is recommended to disable
|
||||||
@@ -18,7 +18,7 @@ Comments must be /* c-like comment */ or start with a double ## symbol.
|
|||||||
|
|
||||||
This is the correct way to form a calc shell script:
|
This is the correct way to form a calc shell script:
|
||||||
|
|
||||||
#!/usr/bin/calc -q -f
|
#!/usr/local/src/cmd/calc/calc -q -f
|
||||||
|
|
||||||
/* a correct comment */
|
/* a correct comment */
|
||||||
## another correct comment
|
## another correct comment
|
||||||
@@ -36,7 +36,7 @@ For more informaton about calc command lines, see "help usage".
|
|||||||
|
|
||||||
This next example WRONG:
|
This next example WRONG:
|
||||||
|
|
||||||
#!/usr/bin/calc -q
|
#!/usr/local/src/cmd/calc/calc -q
|
||||||
|
|
||||||
# This is not a calc calc comment because it has only a single #
|
# This is not a calc calc comment because it has only a single #
|
||||||
# You must to start comments with ## or /*
|
# You must to start comments with ## or /*
|
65
have_stdvs.c
65
have_stdvs.c
@@ -17,8 +17,8 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 29.3 $
|
||||||
* @(#) $Id: have_stdvs.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
* @(#) $Id: have_stdvs.c,v 29.3 2007/02/07 20:53:18 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/have_stdvs.c,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/RCS/have_stdvs.c,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1995/09/09 22:41:10
|
* Under source code control: 1995/09/09 22:41:10
|
||||||
@@ -56,6 +56,13 @@
|
|||||||
# include <string.h>
|
# include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#undef VSPRINTF_SIZE_T
|
||||||
|
#if defined(FORCE_STDC) || (defined(__STDC__) && __STDC__ != 0) || defined(__cplusplus)
|
||||||
|
# define VSPRINTF_SIZE_T size_t
|
||||||
|
#else
|
||||||
|
# define VSPRINTF_SIZE_T long
|
||||||
|
#endif
|
||||||
|
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
|
|
||||||
|
|
||||||
@@ -74,6 +81,21 @@ try_this(char *fmt, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
try_nthis(char *fmt, VSPRINTF_SIZE_T size, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
#if !defined(DONT_HAVE_VSPRINTF)
|
||||||
|
vsnprintf(buf, size, fmt, ap);
|
||||||
|
#else
|
||||||
|
snprintf(buf, size, fmt, ap);
|
||||||
|
#endif
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(void)
|
main(void)
|
||||||
{
|
{
|
||||||
@@ -95,9 +117,9 @@ main(void)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
try_this("%s %d%s%d%d %s",
|
try_this("%s %d%s%d%d %s",
|
||||||
"Landon Noll 1st proved that", 2, "^", 23209, -1, "was prime");
|
"Landon Noll 1st coproved that", 2, "^", 21701, -1, "was prime");
|
||||||
if (strcmp(buf,
|
if (strcmp(buf,
|
||||||
"Landon Noll 1st proved that 2^23209-1 was prime") != 0) {
|
"Landon Noll 1st coproved that 2^21701-1 was prime") != 0) {
|
||||||
#if !defined(DONT_HAVE_VSPRINTF)
|
#if !defined(DONT_HAVE_VSPRINTF)
|
||||||
/* <stdarg.h> with vsprintf() didn't work */
|
/* <stdarg.h> with vsprintf() didn't work */
|
||||||
#else
|
#else
|
||||||
@@ -106,6 +128,30 @@ main(void)
|
|||||||
exit(1);
|
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)
|
||||||
|
/* <stdarg.h> with vsnprintf() didn't work */
|
||||||
|
#else
|
||||||
|
/* <stdarg.h> with snprintf() simulating vsnprintf() didn't work */
|
||||||
|
#endif
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
try_nthis("%s %d%s%d%d %s", sizeof(buf)-1,
|
||||||
|
"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)
|
||||||
|
/* <stdarg.h> with vsnprintf() didn't work */
|
||||||
|
#else
|
||||||
|
/* <stdarg.h> with snprintf() simulating vsnprintf() didn't work */
|
||||||
|
#endif
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* report the result
|
* report the result
|
||||||
*/
|
*/
|
||||||
@@ -128,19 +174,22 @@ main(void)
|
|||||||
puts("#define STDARG /* use <stdarg.h> */");
|
puts("#define STDARG /* use <stdarg.h> */");
|
||||||
puts("#include <stdarg.h>");
|
puts("#include <stdarg.h>");
|
||||||
#endif
|
#endif
|
||||||
puts("\n/* should we use vsprintf()? */");
|
puts("\n/* should we use vsprintf() and vsnprintf()? */");
|
||||||
#if !defined(DONT_HAVE_VSPRINTF)
|
#if !defined(DONT_HAVE_VSPRINTF)
|
||||||
puts("#define HAVE_VS /* yes */");
|
puts("#define HAVE_VSPRINTF /* yes */");
|
||||||
#else
|
#else
|
||||||
puts("/*");
|
puts("/*");
|
||||||
puts(" * Hack aleart!!!");
|
puts(" * Hack aleart!!!");
|
||||||
puts(" *");
|
puts(" *");
|
||||||
puts(" * Systems that do not have vsprintf() need something. In some");
|
puts(" * Systems that do not have vsprintf() need something. In some");
|
||||||
puts(" * cases the sprintf function will deal correctly with the");
|
puts(" * cases the sprintf function will deal correctly with the");
|
||||||
puts(" * va_alist 3rd arg. Hope for the best!");
|
puts(" * va_alist 3rd 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(" */");
|
||||||
puts("#define vsprintf sprintf");
|
puts("#define vsprintf sprintf");
|
||||||
puts("#undef HAVE_VS");
|
puts("#define vsnprintf snprintf");
|
||||||
|
puts("#undef HAVE_VSPRINTF");
|
||||||
#endif
|
#endif
|
||||||
/* exit(0); */
|
/* exit(0); */
|
||||||
return 0;
|
return 0;
|
||||||
|
72
have_varvs.c
72
have_varvs.c
@@ -17,8 +17,8 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 29.3 $
|
||||||
* @(#) $Id: have_varvs.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
* @(#) $Id: have_varvs.c,v 29.3 2007/02/07 20:53:18 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/have_varvs.c,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/RCS/have_varvs.c,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1995/09/09 22:41:10
|
* Under source code control: 1995/09/09 22:41:10
|
||||||
@@ -52,6 +52,13 @@
|
|||||||
# include <string.h>
|
# include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#undef VSPRINTF_SIZE_T
|
||||||
|
#if defined(FORCE_STDC) || (defined(__STDC__) && __STDC__ != 0) || defined(__cplusplus)
|
||||||
|
# define VSPRINTF_SIZE_T size_t
|
||||||
|
#else
|
||||||
|
# define VSPRINTF_SIZE_T long
|
||||||
|
#endif
|
||||||
|
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
|
|
||||||
#if !defined(STDARG) && !defined(SIMULATE_STDARG)
|
#if !defined(STDARG) && !defined(SIMULATE_STDARG)
|
||||||
@@ -73,6 +80,22 @@ try_this(char *fmt, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
try_nthis(char *fmt, VSPRINTF_SIZE_T size, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap);
|
||||||
|
|
||||||
|
#if !defined(DONT_HAVE_VSPRINTF)
|
||||||
|
vsnprintf(buf, size, fmt, ap);
|
||||||
|
#else
|
||||||
|
snprintf(buf, size, fmt, ap);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -81,6 +104,12 @@ try_this(char *a, int b, char *c, int d)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
try_nthis(char *a, VSPRINTF_SIZE_T size, int b, char *c, int d)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -109,9 +138,33 @@ main(void)
|
|||||||
if (strcmp(buf,
|
if (strcmp(buf,
|
||||||
"Landon Noll 1st proved that 2^23209-1 was prime") != 0) {
|
"Landon Noll 1st proved that 2^23209-1 was prime") != 0) {
|
||||||
#if !defined(DONT_HAVE_VSPRINTF)
|
#if !defined(DONT_HAVE_VSPRINTF)
|
||||||
/* <stdarg.h> with vsprintf() didn't work */
|
/* <varargs.h> with vsprintf() didn't work */
|
||||||
#else
|
#else
|
||||||
/* <stdarg.h> with sprintf() simulating vsprintf() didn't work */
|
/* <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)
|
||||||
|
/* <varargs.h> with vsnprintf() didn't work */
|
||||||
|
#else
|
||||||
|
/* <varargs.h> with snprintf() simulating vsnprintf() didn't work */
|
||||||
|
#endif
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
try_nthis("%s %d%s%d%d %s", sizeof(buf)-1,
|
||||||
|
"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 vsnprintf() didn't work */
|
||||||
|
#else
|
||||||
|
/* <varargs.h> with snprintf() simulating vsnprintf() didn't work */
|
||||||
#endif
|
#endif
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -122,19 +175,22 @@ main(void)
|
|||||||
puts("/* what type of variable args do we have? */");
|
puts("/* what type of variable args do we have? */");
|
||||||
puts("#define VARARGS /* use <varargs.h> */");
|
puts("#define VARARGS /* use <varargs.h> */");
|
||||||
puts("#include <varargs.h>");
|
puts("#include <varargs.h>");
|
||||||
puts("\n/* should we use vsprintf()? */");
|
puts("\n/* should we use vsprintf() and vsnprintf()? */");
|
||||||
#if !defined(DONT_HAVE_VSPRINTF)
|
#if !defined(DONT_HAVE_VSPRINTF)
|
||||||
puts("#define HAVE_VS /* yes */");
|
puts("#define HAVE_VSPRINTF /* yes */");
|
||||||
#else
|
#else
|
||||||
puts("/*");
|
puts("/*");
|
||||||
puts(" * Hack aleart!!!");
|
puts(" * Hack aleart!!!");
|
||||||
puts(" *");
|
puts(" *");
|
||||||
puts(" * Systems that do not have vsprintf() need something. In some");
|
puts(" * Systems that do not have vsprintf() need something. In some");
|
||||||
puts(" * cases the sprintf function will deal correctly with the");
|
puts(" * cases the sprintf function will deal correctly with the");
|
||||||
puts(" * va_alist 3rd arg. Hope for the best!");
|
puts(" * va_alist 3rd 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(" */");
|
||||||
puts("#define vsprintf sprintf");
|
puts("#define vsprintf sprintf");
|
||||||
puts("#undef HAVE_VS");
|
puts("#define vsnprintf snprintf");
|
||||||
|
puts("#undef HAVE_VSPRINTF");
|
||||||
#endif
|
#endif
|
||||||
/* exit(0); */
|
/* exit(0); */
|
||||||
return 0;
|
return 0;
|
||||||
|
29
version.c
29
version.c
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* version - determine the version of calc
|
* version - determine the version of calc
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999-2006 David I. Bell and Landon Curt Noll
|
* Copyright (C) 1999-2007 David I. Bell and Landon Curt Noll
|
||||||
*
|
*
|
||||||
* Primary author: David I. Bell
|
* Primary author: David I. Bell
|
||||||
*
|
*
|
||||||
@@ -19,8 +19,8 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.73 $
|
* @(#) $Revision: 29.76 $
|
||||||
* @(#) $Id: version.c,v 29.73 2007/02/07 00:41:06 chongo Exp $
|
* @(#) $Id: version.c,v 29.76 2007/02/07 21:28:20 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/version.c,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/RCS/version.c,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1990/05/22 11:00:58
|
* Under source code control: 1990/05/22 11:00:58
|
||||||
@@ -48,7 +48,7 @@ static char *program;
|
|||||||
#define MAJOR_VER 2 /* major version */
|
#define MAJOR_VER 2 /* major version */
|
||||||
#define MINOR_VER 12 /* minor version */
|
#define MINOR_VER 12 /* minor version */
|
||||||
#define MAJOR_PATCH 1 /* patch level or 0 if no patch */
|
#define MAJOR_PATCH 1 /* patch level or 0 if no patch */
|
||||||
#define MINOR_PATCH 7 /* test number or 0 if no minor patch */
|
#define MINOR_PATCH 9 /* test number or 0 if no minor patch */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -72,9 +72,9 @@ static char *stored_version = NULL; /* version formed if != NULL */
|
|||||||
char *Copyright = "\n"
|
char *Copyright = "\n"
|
||||||
"calc - arbitrary precision calculator\n"
|
"calc - arbitrary precision calculator\n"
|
||||||
"\n"
|
"\n"
|
||||||
"@(#) Copyright (C) 2006 David I. Bell, Landon Curt Noll and Ernest Bowen\n"
|
"@(#) Copyright (C) 2007 David I. Bell, Landon Curt Noll and Ernest Bowen\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Primary author: David I. Bell\n"
|
"Initial author: David I. Bell\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Calc is open software; you can redistribute it and/or modify it under\n"
|
"Calc is open software; you can redistribute it and/or modify it under\n"
|
||||||
"the terms of the version 2.1 of the GNU Lesser General Public License\n"
|
"the terms of the version 2.1 of the GNU Lesser General Public License\n"
|
||||||
@@ -95,23 +95,6 @@ char *Copyright = "\n"
|
|||||||
"\n";
|
"\n";
|
||||||
|
|
||||||
|
|
||||||
#if !defined(HAVE_SNPRINTF)
|
|
||||||
/* Simulate snprintf with vsprintf, hoping that BUFSIZ is large enough. */
|
|
||||||
#include <stdarg.h>
|
|
||||||
/*ARGSUSED*/
|
|
||||||
int
|
|
||||||
snprintf (char *buf, size_t UNUSED n, const char *fmt, ...)
|
|
||||||
{
|
|
||||||
int retval;
|
|
||||||
va_list arg;
|
|
||||||
|
|
||||||
va_start (arg, fmt);
|
|
||||||
retval = vsprintf (buf, fmt, arg);
|
|
||||||
va_end (arg);
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* version - return version string
|
* version - return version string
|
||||||
*
|
*
|
||||||
|
@@ -11,8 +11,8 @@
|
|||||||
#define STDARG /* use <stdarg.h> */
|
#define STDARG /* use <stdarg.h> */
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
/* should we use vsprintf()? */
|
/* should we use vsprintf() and vsnprintf()? */
|
||||||
#define HAVE_VS /* yes */
|
#define HAVE_VSPRINTF /* yes */
|
||||||
|
|
||||||
|
|
||||||
#endif /* !__ARGS_H__ */
|
#endif /* !__ARGS_H__ */
|
||||||
|
Reference in New Issue
Block a user