From: Harlan Stenn Date: Fri, 28 Jul 2006 04:57:01 +0000 (-0400) Subject: libopts-27.4.2 X-Git-Tag: NTP_4_2_3P22~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a44d03a076460261164bc1a39c24dae2e83b818a;p=thirdparty%2Fntp.git libopts-27.4.2 bk: 44c9991dlJ1g6E76BR64S_H1LsvYeA --- diff --git a/libopts/compat/snprintf.c b/libopts/compat/snprintf.c index 021557859..78bda479b 100644 --- a/libopts/compat/snprintf.c +++ b/libopts/compat/snprintf.c @@ -3,6 +3,26 @@ #include "choke-me: no vprintf and no snprintf" #endif +#if defined(HAVE_STDARG_H) +# include +# ifndef VA_START +# define VA_START(a, f) va_start(a, f) +# define VA_END(a) va_end(a) +# endif /* VA_START */ +# define SNV_USING_STDARG_H + +#elif defined(HAVE_VARARGS_H) +# include +# ifndef VA_START +# define VA_START(a, f) va_start(a) +# define VA_END(a) va_end(a) +# endif /* VA_START */ +# undef SNV_USING_STDARG_H + +#else +# include "must-have-stdarg-or-varargs" +#endif + static int snprintf(char *str, size_t n, const char *fmt, ...) { @@ -11,17 +31,21 @@ snprintf(char *str, size_t n, const char *fmt, ...) #ifdef VSPRINTF_CHARSTAR char *rp; - va_start(ap, fmt); + VA_START(ap, fmt); rp = vsprintf(str, fmt, ap); - va_end(ap); + VA_END(ap); rval = strlen(rp); #else - va_start(ap, fmt); + VA_START(ap, fmt); rval = vsprintf(str, fmt, ap); - va_end(ap); + VA_END(ap); #endif + if (rval > n) { + fprintf(stderr, "snprintf buffer overrun %d > %d\n", rval, n); + abort(); + } return rval; } diff --git a/libopts/m4/libopts.m4 b/libopts/m4/libopts.m4 index fed65020d..d800dd95a 100644 --- a/libopts/m4/libopts.m4 +++ b/libopts/m4/libopts.m4 @@ -2,7 +2,7 @@ dnl -*- buffer-read-only: t -*- vi: set ro: dnl dnl DO NOT EDIT THIS FILE (libopts.m4) dnl -dnl It has been AutoGen-ed Saturday July 22, 2006 at 08:36:51 AM PDT +dnl It has been AutoGen-ed Thursday July 27, 2006 at 09:14:31 PM PDT dnl From the definitions libopts.def dnl and the template file conftest.tpl dnl diff --git a/libopts/makeshell.c b/libopts/makeshell.c index 0d7f39e95..dbb4ff590 100644 --- a/libopts/makeshell.c +++ b/libopts/makeshell.c @@ -1,7 +1,7 @@ /* - * $Id: makeshell.c,v 4.13 2006/07/15 22:10:21 bkorb Exp $ - * Time-stamp: "2006-07-15 08:18:01 bkorb" + * $Id: makeshell.c,v 4.14 2006/07/27 02:51:47 bkorb Exp $ + * Time-stamp: "2006-07-24 21:30:51 bkorb" * * This module will interpret the options set in the tOptions * structure and create a Bourne shell script capable of parsing them. @@ -499,6 +499,13 @@ optionParseShell( tOptions* pOpts ) static void textToVariable( tOptions* pOpts, teTextTo whichVar, tOptDesc* pOD ) { +# define _TT_(n) tSCC z ## n [] = #n; + TEXTTO_TABLE +# undef _TT_ +# define _TT_(n) z ## n , + static const char* apzTTNames[] = { TEXTTO_TABLE }; +# undef _TT_ + #if defined(__windows__) && !defined(__CYGWIN__) printf( "%1$s_%2$s_TEXT='no %2$s text'\n", pOpts->pzPROGNAME, apzTTNames[ whichVar ]); @@ -507,13 +514,6 @@ textToVariable( tOptions* pOpts, teTextTo whichVar, tOptDesc* pOD ) int pipeFd[2]; FILE* fp; -# define _TT_(n) tSCC z ## n [] = #n; - TEXTTO_TABLE -# undef _TT_ -# define _TT_(n) z ## n , - static const char* apzTTNames[] = { TEXTTO_TABLE }; -# undef _TT_ - printf( "%s_%s_TEXT='", pOpts->pzPROGNAME, apzTTNames[ whichVar ]); fflush( stdout ); diff --git a/libopts/proto.h b/libopts/proto.h index 574728e3e..fc0536637 100644 --- a/libopts/proto.h +++ b/libopts/proto.h @@ -1,7 +1,7 @@ /* -*- buffer-read-only: t -*- vi: set ro: * * Prototypes for autoopts - * Generated Sat Jul 22 08:37:30 PDT 2006 + * Generated Thu Jul 27 21:15:11 PDT 2006 */ #ifndef AUTOOPTS_PROTO_H_GUARD #define AUTOOPTS_PROTO_H_GUARD 1 diff --git a/libopts/streqvcmp.c b/libopts/streqvcmp.c index 28b255a36..42336dc97 100644 --- a/libopts/streqvcmp.c +++ b/libopts/streqvcmp.c @@ -1,7 +1,7 @@ /* - * $Id: streqvcmp.c,v 4.9 2006/03/25 19:23:28 bkorb Exp $ - * Time-stamp: "2005-10-29 14:05:07 bkorb" + * $Id: streqvcmp.c,v 4.10 2006/07/27 02:51:47 bkorb Exp $ + * Time-stamp: "2006-07-26 18:25:53 bkorb" * * String Equivalence Comparison * @@ -273,9 +273,7 @@ strequate( const char* s ) * err: none. =*/ void -strtransform( d, s ) - char* d; - const char* s; +strtransform( char* d, const char* s ) { do { *(d++) = (char)charmap[ (unsigned)*s ]; diff --git a/libopts/version.c b/libopts/version.c index 290ee0fe0..e01809a80 100644 --- a/libopts/version.c +++ b/libopts/version.c @@ -1,6 +1,6 @@ -/* $Id: version.c,v 4.8 2006/03/25 19:23:28 bkorb Exp $ - * Time-stamp: "2005-12-13 10:29:09 bkorb" +/* $Id: version.c,v 4.9 2006/07/27 02:51:47 bkorb Exp $ + * Time-stamp: "2006-07-26 18:38:16 bkorb" * * This module implements the default usage procedure for * Automated Options. It may be overridden, of course. @@ -146,9 +146,7 @@ printVersion( tOptions* pOpts, tOptDesc* pOD, FILE* fp ) * This routine will print the version to stdout. =*/ void -optionPrintVersion( pOpts, pOD ) - tOptions* pOpts; - tOptDesc* pOD; +optionPrintVersion( tOptions* pOpts, tOptDesc* pOD ) { printVersion( pOpts, pOD, stdout ); } @@ -164,9 +162,7 @@ optionPrintVersion( pOpts, pOD ) * This routine will print the version to stderr. =*/ void -optionVersionStderr( pOpts, pOD ) - tOptions* pOpts; - tOptDesc* pOD; +optionVersionStderr( tOptions* pOpts, tOptDesc* pOD ) { printVersion( pOpts, pOD, stderr ); } diff --git a/sntp/libopts/compat/snprintf.c b/sntp/libopts/compat/snprintf.c index 021557859..78bda479b 100644 --- a/sntp/libopts/compat/snprintf.c +++ b/sntp/libopts/compat/snprintf.c @@ -3,6 +3,26 @@ #include "choke-me: no vprintf and no snprintf" #endif +#if defined(HAVE_STDARG_H) +# include +# ifndef VA_START +# define VA_START(a, f) va_start(a, f) +# define VA_END(a) va_end(a) +# endif /* VA_START */ +# define SNV_USING_STDARG_H + +#elif defined(HAVE_VARARGS_H) +# include +# ifndef VA_START +# define VA_START(a, f) va_start(a) +# define VA_END(a) va_end(a) +# endif /* VA_START */ +# undef SNV_USING_STDARG_H + +#else +# include "must-have-stdarg-or-varargs" +#endif + static int snprintf(char *str, size_t n, const char *fmt, ...) { @@ -11,17 +31,21 @@ snprintf(char *str, size_t n, const char *fmt, ...) #ifdef VSPRINTF_CHARSTAR char *rp; - va_start(ap, fmt); + VA_START(ap, fmt); rp = vsprintf(str, fmt, ap); - va_end(ap); + VA_END(ap); rval = strlen(rp); #else - va_start(ap, fmt); + VA_START(ap, fmt); rval = vsprintf(str, fmt, ap); - va_end(ap); + VA_END(ap); #endif + if (rval > n) { + fprintf(stderr, "snprintf buffer overrun %d > %d\n", rval, n); + abort(); + } return rval; } diff --git a/sntp/libopts/m4/libopts.m4 b/sntp/libopts/m4/libopts.m4 index fed65020d..d800dd95a 100644 --- a/sntp/libopts/m4/libopts.m4 +++ b/sntp/libopts/m4/libopts.m4 @@ -2,7 +2,7 @@ dnl -*- buffer-read-only: t -*- vi: set ro: dnl dnl DO NOT EDIT THIS FILE (libopts.m4) dnl -dnl It has been AutoGen-ed Saturday July 22, 2006 at 08:36:51 AM PDT +dnl It has been AutoGen-ed Thursday July 27, 2006 at 09:14:31 PM PDT dnl From the definitions libopts.def dnl and the template file conftest.tpl dnl diff --git a/sntp/libopts/makeshell.c b/sntp/libopts/makeshell.c index 0d7f39e95..dbb4ff590 100644 --- a/sntp/libopts/makeshell.c +++ b/sntp/libopts/makeshell.c @@ -1,7 +1,7 @@ /* - * $Id: makeshell.c,v 4.13 2006/07/15 22:10:21 bkorb Exp $ - * Time-stamp: "2006-07-15 08:18:01 bkorb" + * $Id: makeshell.c,v 4.14 2006/07/27 02:51:47 bkorb Exp $ + * Time-stamp: "2006-07-24 21:30:51 bkorb" * * This module will interpret the options set in the tOptions * structure and create a Bourne shell script capable of parsing them. @@ -499,6 +499,13 @@ optionParseShell( tOptions* pOpts ) static void textToVariable( tOptions* pOpts, teTextTo whichVar, tOptDesc* pOD ) { +# define _TT_(n) tSCC z ## n [] = #n; + TEXTTO_TABLE +# undef _TT_ +# define _TT_(n) z ## n , + static const char* apzTTNames[] = { TEXTTO_TABLE }; +# undef _TT_ + #if defined(__windows__) && !defined(__CYGWIN__) printf( "%1$s_%2$s_TEXT='no %2$s text'\n", pOpts->pzPROGNAME, apzTTNames[ whichVar ]); @@ -507,13 +514,6 @@ textToVariable( tOptions* pOpts, teTextTo whichVar, tOptDesc* pOD ) int pipeFd[2]; FILE* fp; -# define _TT_(n) tSCC z ## n [] = #n; - TEXTTO_TABLE -# undef _TT_ -# define _TT_(n) z ## n , - static const char* apzTTNames[] = { TEXTTO_TABLE }; -# undef _TT_ - printf( "%s_%s_TEXT='", pOpts->pzPROGNAME, apzTTNames[ whichVar ]); fflush( stdout ); diff --git a/sntp/libopts/proto.h b/sntp/libopts/proto.h index 574728e3e..fc0536637 100644 --- a/sntp/libopts/proto.h +++ b/sntp/libopts/proto.h @@ -1,7 +1,7 @@ /* -*- buffer-read-only: t -*- vi: set ro: * * Prototypes for autoopts - * Generated Sat Jul 22 08:37:30 PDT 2006 + * Generated Thu Jul 27 21:15:11 PDT 2006 */ #ifndef AUTOOPTS_PROTO_H_GUARD #define AUTOOPTS_PROTO_H_GUARD 1 diff --git a/sntp/libopts/streqvcmp.c b/sntp/libopts/streqvcmp.c index 28b255a36..42336dc97 100644 --- a/sntp/libopts/streqvcmp.c +++ b/sntp/libopts/streqvcmp.c @@ -1,7 +1,7 @@ /* - * $Id: streqvcmp.c,v 4.9 2006/03/25 19:23:28 bkorb Exp $ - * Time-stamp: "2005-10-29 14:05:07 bkorb" + * $Id: streqvcmp.c,v 4.10 2006/07/27 02:51:47 bkorb Exp $ + * Time-stamp: "2006-07-26 18:25:53 bkorb" * * String Equivalence Comparison * @@ -273,9 +273,7 @@ strequate( const char* s ) * err: none. =*/ void -strtransform( d, s ) - char* d; - const char* s; +strtransform( char* d, const char* s ) { do { *(d++) = (char)charmap[ (unsigned)*s ]; diff --git a/sntp/libopts/version.c b/sntp/libopts/version.c index 290ee0fe0..e01809a80 100644 --- a/sntp/libopts/version.c +++ b/sntp/libopts/version.c @@ -1,6 +1,6 @@ -/* $Id: version.c,v 4.8 2006/03/25 19:23:28 bkorb Exp $ - * Time-stamp: "2005-12-13 10:29:09 bkorb" +/* $Id: version.c,v 4.9 2006/07/27 02:51:47 bkorb Exp $ + * Time-stamp: "2006-07-26 18:38:16 bkorb" * * This module implements the default usage procedure for * Automated Options. It may be overridden, of course. @@ -146,9 +146,7 @@ printVersion( tOptions* pOpts, tOptDesc* pOD, FILE* fp ) * This routine will print the version to stdout. =*/ void -optionPrintVersion( pOpts, pOD ) - tOptions* pOpts; - tOptDesc* pOD; +optionPrintVersion( tOptions* pOpts, tOptDesc* pOD ) { printVersion( pOpts, pOD, stdout ); } @@ -164,9 +162,7 @@ optionPrintVersion( pOpts, pOD ) * This routine will print the version to stderr. =*/ void -optionVersionStderr( pOpts, pOD ) - tOptions* pOpts; - tOptDesc* pOD; +optionVersionStderr( tOptions* pOpts, tOptDesc* pOD ) { printVersion( pOpts, pOD, stderr ); }