diff --git a/CHANGES b/CHANGES index 72696b6..b285153 100644 --- a/CHANGES +++ b/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 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 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 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. ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. ## -## @(#) $Revision: 29.93 $ -## @(#) $Id: CHANGES,v 29.93 2007/02/07 00:41:06 chongo Exp $ +## @(#) $Revision: 29.95 $ +## @(#) $Id: CHANGES,v 29.95 2007/02/07 21:28:20 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/RCS/CHANGES,v $ ## ## Under source code control: 1993/06/02 18:12:57 diff --git a/Makefile b/Makefile index 91aca64..d4d5aae 100644 --- a/Makefile +++ b/Makefile @@ -32,8 +32,8 @@ # received a copy with calc; if not, write to Free Software Foundation, Inc. # 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. # -MAKEFILE_REV= $$Revision: 29.84 $$ -# @(#) $Id: Makefile.ship,v 29.84 2007/02/07 00:34:23 chongo Exp $ +MAKEFILE_REV= $$Revision: 29.85 $$ +# @(#) $Id: Makefile.ship,v 29.85 2007/02/07 20:35:58 chongo Exp $ # @(#) $Source: /usr/local/src/cmd/calc/RCS/Makefile.ship,v $ # # 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. # -# vsprintf(stream, format, ap) +# vsprintf(string, format, ap) # # 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(). # If you do not have vsprintf(), then calc will try sprintf() and hope # 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 # have_varvs.c program to determine if vsprintf() is supported. If # 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 -${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}; \ - ${LCC} ${ICFLAGS} -DDONT_HAVE_VSPRINTF have_varvs.c -c \ + ${LCC} ${ICFLAGS} ${HAVE_VSPRINTF} have_varvs.c -c \ 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 \ diff --git a/alloc.h b/alloc.h index 0b2b225..b94da57 100644 --- a/alloc.h +++ b/alloc.h @@ -17,8 +17,8 @@ * received a copy with calc; if not, write to Free Software Foundation, Inc. * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * - * @(#) $Revision: 29.4 $ - * @(#) $Id: alloc.h,v 29.4 2001/06/08 21:00:58 chongo Exp $ + * @(#) $Revision: 29.5 $ + * @(#) $Id: alloc.h,v 29.5 2007/02/07 20:51:38 chongo Exp $ * @(#) $Source: /usr/local/src/cmd/calc/RCS/alloc.h,v $ * * Under source code control: 1990/02/15 01:48:29 @@ -94,13 +94,13 @@ extern int strcmp(); #endif /* HAVE_NEWSTR */ #if !defined(HAVE_MEMMOVE) -# undef CALC_SIZE_T +# undef MEMMOVE_SIZE_T #if defined(FORCE_STDC) || (defined(__STDC__) && __STDC__ != 0) || defined(__cplusplus) -# define CALC_SIZE_T size_t +# define MEMMOVE_SIZE_T size_t # else -# define CALC_SIZE_T long +# define MEMMOVE_SIZE_T long # 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 /* !__ALLOC_H__ */ diff --git a/blkcpy.c b/blkcpy.c index c78a374..1665b91 100644 --- a/blkcpy.c +++ b/blkcpy.c @@ -19,8 +19,8 @@ * received a copy with calc; if not, write to Free Software Foundation, Inc. * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * - * @(#) $Revision: 29.9 $ - * @(#) $Id: blkcpy.c,v 29.9 2006/05/20 08:43:55 chongo Exp $ + * @(#) $Revision: 29.10 $ + * @(#) $Id: blkcpy.c,v 29.10 2007/02/07 20:51:38 chongo Exp $ * @(#) $Source: /usr/local/src/cmd/calc/RCS/blkcpy.c,v $ * * 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 */ void * -memmove(void *s1, const void *s2, CALC_SIZE_T n) +memmove(void *s1, const void *s2, MEMMOVE_SIZE_T n) { /* * firewall diff --git a/cscript/Makefile b/cscript/Makefile index fe43aa8..7620af7 100644 --- a/cscript/Makefile +++ b/cscript/Makefile @@ -17,8 +17,8 @@ # received a copy with calc; if not, write to Free Software Foundation, Inc. # 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. # -# @(#) $Revision: 29.29 $ -# @(#) $Id: Makefile,v 29.29 2007/02/07 00:31:59 chongo Exp $ +# @(#) $Revision: 29.31 $ +# @(#) $Id: Makefile,v 29.31 2007/02/07 01:43:56 chongo Exp $ # @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/Makefile,v $ # # 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 # -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 # diff --git a/cscript/README b/cscript/README.src similarity index 96% rename from cscript/README rename to cscript/README.src index 4e4de8f..5532426 100644 --- a/cscript/README +++ b/cscript/README.src @@ -7,7 +7,7 @@ be useful! 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 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: - #!/usr/bin/calc -q -f + #!/usr/local/src/cmd/calc/calc -q -f /* a correct comment */ ## another correct comment @@ -36,7 +36,7 @@ For more informaton about calc command lines, see "help usage". 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 # # You must to start comments with ## or /* diff --git a/have_stdvs.c b/have_stdvs.c index c385141..6c51a2d 100644 --- a/have_stdvs.c +++ b/have_stdvs.c @@ -17,8 +17,8 @@ * received a copy with calc; if not, write to Free Software Foundation, Inc. * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * - * @(#) $Revision: 29.2 $ - * @(#) $Id: have_stdvs.c,v 29.2 2000/06/07 14:02:13 chongo Exp $ + * @(#) $Revision: 29.3 $ + * @(#) $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 $ * * Under source code control: 1995/09/09 22:41:10 @@ -56,6 +56,13 @@ # include #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]; @@ -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 main(void) { @@ -95,9 +117,9 @@ main(void) exit(1); } 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, - "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) /* with vsprintf() didn't work */ #else @@ -106,6 +128,30 @@ main(void) 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) + /* with vsnprintf() didn't work */ +#else + /* 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) + /* with vsnprintf() didn't work */ +#else + /* with snprintf() simulating vsnprintf() didn't work */ +#endif + exit(1); + } + /* * report the result */ @@ -128,19 +174,22 @@ main(void) puts("#define STDARG /* use */"); puts("#include "); #endif - puts("\n/* should we use vsprintf()? */"); + puts("\n/* should we use vsprintf() and vsnprintf()? */"); #if !defined(DONT_HAVE_VSPRINTF) - puts("#define HAVE_VS /* yes */"); + puts("#define HAVE_VSPRINTF /* 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. 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("#define vsprintf sprintf"); - puts("#undef HAVE_VS"); + puts("#define vsnprintf snprintf"); + puts("#undef HAVE_VSPRINTF"); #endif /* exit(0); */ return 0; diff --git a/have_varvs.c b/have_varvs.c index 3fa4f8a..f2d7623 100644 --- a/have_varvs.c +++ b/have_varvs.c @@ -17,8 +17,8 @@ * received a copy with calc; if not, write to Free Software Foundation, Inc. * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * - * @(#) $Revision: 29.2 $ - * @(#) $Id: have_varvs.c,v 29.2 2000/06/07 14:02:13 chongo Exp $ + * @(#) $Revision: 29.3 $ + * @(#) $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 $ * * Under source code control: 1995/09/09 22:41:10 @@ -52,6 +52,13 @@ # include #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]; #if !defined(STDARG) && !defined(SIMULATE_STDARG) @@ -73,6 +80,22 @@ try_this(char *fmt, ...) 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 void @@ -81,6 +104,12 @@ 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) +{ + return; +} + #endif @@ -109,9 +138,33 @@ main(void) if (strcmp(buf, "Landon Noll 1st proved that 2^23209-1 was prime") != 0) { #if !defined(DONT_HAVE_VSPRINTF) - /* with vsprintf() didn't work */ + /* with vsprintf() didn't work */ #else - /* with sprintf() simulating vsprintf() didn't work */ + /* 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) + /* with vsnprintf() didn't work */ +#else + /* 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) + /* with vsnprintf() didn't work */ +#else + /* with snprintf() simulating vsnprintf() didn't work */ #endif exit(1); } @@ -122,19 +175,22 @@ main(void) puts("/* what type of variable args do we have? */"); puts("#define VARARGS /* use */"); puts("#include "); - puts("\n/* should we use vsprintf()? */"); + puts("\n/* should we use vsprintf() and vsnprintf()? */"); #if !defined(DONT_HAVE_VSPRINTF) - puts("#define HAVE_VS /* yes */"); + puts("#define HAVE_VSPRINTF /* 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. 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("#define vsprintf sprintf"); - puts("#undef HAVE_VS"); + puts("#define vsnprintf snprintf"); + puts("#undef HAVE_VSPRINTF"); #endif /* exit(0); */ return 0; diff --git a/version.c b/version.c index cfdbdce..f20662f 100644 --- a/version.c +++ b/version.c @@ -1,7 +1,7 @@ /* * 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 * @@ -19,8 +19,8 @@ * received a copy with calc; if not, write to Free Software Foundation, Inc. * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * - * @(#) $Revision: 29.73 $ - * @(#) $Id: version.c,v 29.73 2007/02/07 00:41:06 chongo Exp $ + * @(#) $Revision: 29.76 $ + * @(#) $Id: version.c,v 29.76 2007/02/07 21:28:20 chongo Exp $ * @(#) $Source: /usr/local/src/cmd/calc/RCS/version.c,v $ * * Under source code control: 1990/05/22 11:00:58 @@ -48,7 +48,7 @@ static char *program; #define MAJOR_VER 2 /* major version */ #define MINOR_VER 12 /* minor version */ #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" "calc - arbitrary precision calculator\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" - "Primary author: David I. Bell\n" + "Initial author: David I. Bell\n" "\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" @@ -95,23 +95,6 @@ char *Copyright = "\n" "\n"; -#if !defined(HAVE_SNPRINTF) -/* Simulate snprintf with vsprintf, hoping that BUFSIZ is large enough. */ -#include -/*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 * diff --git a/win32/args.h b/win32/args.h index 4f72462..80eb297 100644 --- a/win32/args.h +++ b/win32/args.h @@ -11,8 +11,8 @@ #define STDARG /* use */ #include -/* should we use vsprintf()? */ -#define HAVE_VS /* yes */ +/* should we use vsprintf() and vsnprintf()? */ +#define HAVE_VSPRINTF /* yes */ #endif /* !__ARGS_H__ */