mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
Use gcc pragmas to suppress some warnings.
* configure.ac (AH_BOTTOM): Add GNUPG_GCC_VERSION macro. * util/estream-printf.c (pr_float): Use new gcc pragma to ignore a warning about a non-literal format. * util/miscutil.c (asctimestamp): Ditto. * cipher/md.c (md_stop_debug): Use new gcc pragme to ignore a warning * about a set but unused variable.
This commit is contained in:
parent
b5b6cb57db
commit
667ba59ec5
26
cipher/md.c
26
cipher/md.c
@ -65,7 +65,7 @@ new_list_item (int algo,
|
||||
r->name = (*get_info)( algo, &r->contextsize,
|
||||
&r->asnoid, &r->asnlen, &r->mdlen,
|
||||
&r->init, &r->write, &r->final, &r->read );
|
||||
if (!r->name )
|
||||
if (!r->name )
|
||||
{
|
||||
xfree(r);
|
||||
r = NULL;
|
||||
@ -82,7 +82,7 @@ new_list_item (int algo,
|
||||
|
||||
/*
|
||||
Load all available hash algorithms and return true. Subsequent
|
||||
calls will return 0.
|
||||
calls will return 0.
|
||||
*/
|
||||
static int
|
||||
load_digest_module (void)
|
||||
@ -96,26 +96,26 @@ load_digest_module (void)
|
||||
/* We load them in reverse order so that the most
|
||||
frequently used are the first in the list. */
|
||||
#ifdef USE_SHA512
|
||||
if (!new_list_item (DIGEST_ALGO_SHA512, sha512_get_info))
|
||||
if (!new_list_item (DIGEST_ALGO_SHA512, sha512_get_info))
|
||||
BUG ();
|
||||
if (!new_list_item (DIGEST_ALGO_SHA384, sha384_get_info))
|
||||
if (!new_list_item (DIGEST_ALGO_SHA384, sha384_get_info))
|
||||
BUG ();
|
||||
#endif
|
||||
#ifdef USE_SHA256
|
||||
if (!new_list_item (DIGEST_ALGO_SHA256, sha256_get_info))
|
||||
if (!new_list_item (DIGEST_ALGO_SHA256, sha256_get_info))
|
||||
BUG ();
|
||||
if (!new_list_item (DIGEST_ALGO_SHA224, sha224_get_info))
|
||||
if (!new_list_item (DIGEST_ALGO_SHA224, sha224_get_info))
|
||||
BUG ();
|
||||
#endif
|
||||
if (!new_list_item (DIGEST_ALGO_MD5, md5_get_info))
|
||||
if (!new_list_item (DIGEST_ALGO_MD5, md5_get_info))
|
||||
BUG ();
|
||||
if (!new_list_item (DIGEST_ALGO_RMD160, rmd160_get_info))
|
||||
if (!new_list_item (DIGEST_ALGO_RMD160, rmd160_get_info))
|
||||
BUG ();
|
||||
if (!new_list_item (DIGEST_ALGO_SHA1, sha1_get_info))
|
||||
if (!new_list_item (DIGEST_ALGO_SHA1, sha1_get_info))
|
||||
BUG ();
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************
|
||||
@ -317,7 +317,7 @@ md_write( MD_HANDLE a, const byte *inbuf, size_t inlen)
|
||||
}
|
||||
for(r=a->list; r; r = r->next ) {
|
||||
(*r->write)( &r->context.c, a->buffer, a->bufcount );
|
||||
/* Fixme: all ->write fnc should take a const byte* */
|
||||
/* Fixme: all ->write fnc should take a const byte* */
|
||||
(*r->write)( &r->context.c, (byte*)inbuf, inlen );
|
||||
}
|
||||
a->bufcount = 0;
|
||||
@ -508,6 +508,7 @@ md_start_debug( MD_HANDLE md, const char *suffix )
|
||||
log_debug("md debug: can't open %s\n", buf );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
md_stop_debug( MD_HANDLE md )
|
||||
{
|
||||
@ -519,6 +520,9 @@ md_stop_debug( MD_HANDLE md )
|
||||
}
|
||||
#ifdef HAVE_U64_TYPEDEF
|
||||
{ /* a kludge to pull in the __muldi3 for Solaris */
|
||||
#if GNUPG_GCC_VERSION >= 40600
|
||||
# pragma GCC diagnostic ignored "-Wunused-but-set-variable"
|
||||
#endif
|
||||
volatile u32 a = (u32)(ulong)md;
|
||||
volatile u64 b = 42;
|
||||
volatile u64 c;
|
||||
|
@ -446,6 +446,13 @@ is intended for making fat binary builds on OS X. */
|
||||
# define EXEC_TEMPFILE_ONLY
|
||||
#endif
|
||||
|
||||
/* A macro to help checking the GCC version. */
|
||||
#ifdef __GNUC__
|
||||
# define GNUPG_GCC_VERSION (__GNUC__ * 10000 \
|
||||
+ __GNUC_MINOR__ * 100 \
|
||||
+ __GNUC_PATCHLEVEL__)
|
||||
#endif /*__GNUC__*/
|
||||
|
||||
/* Please note that the string version must not contain more
|
||||
than one character because the using code assumes strlen()==1 */
|
||||
#ifdef HAVE_DOSISH_SYSTEM
|
||||
|
@ -52,7 +52,7 @@
|
||||
#if defined(HAVE_INTMAX_T) || defined(HAVE_UINTMAX_T)
|
||||
# ifdef HAVE_STDINT_H
|
||||
# include <stdint.h>
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#ifdef HAVE_LANGINFO_THOUSANDS_SEP
|
||||
#include <langinfo.h>
|
||||
@ -67,12 +67,12 @@
|
||||
|
||||
/* Allow redefinition of asprintf used malloc functions. */
|
||||
#if defined(_ESTREAM_PRINTF_MALLOC)
|
||||
#define my_printf_malloc(a) _ESTREAM_PRINTF_MALLOC((a))
|
||||
#define my_printf_malloc(a) _ESTREAM_PRINTF_MALLOC((a))
|
||||
#else
|
||||
#define my_printf_malloc(a) malloc((a))
|
||||
#endif
|
||||
#if defined(_ESTREAM_PRINTF_FREE)
|
||||
#define my_printf_free(a) _ESTREAM_PRINTF_FREE((a))
|
||||
#define my_printf_free(a) _ESTREAM_PRINTF_FREE((a))
|
||||
#else
|
||||
#define my_printf_free(a) free((a))
|
||||
#endif
|
||||
@ -182,7 +182,7 @@ typedef enum
|
||||
|
||||
|
||||
/* A union used to store the actual values. */
|
||||
typedef union
|
||||
typedef union
|
||||
{
|
||||
char a_char;
|
||||
signed char a_schar;
|
||||
@ -266,7 +266,7 @@ dump_argspecs (argspec_t arg, size_t argcount)
|
||||
int idx;
|
||||
|
||||
for (idx=0; argcount; argcount--, arg++, idx++)
|
||||
fprintf (stderr,
|
||||
fprintf (stderr,
|
||||
"%2d: len=%u flags=%u width=%d prec=%d mod=%d "
|
||||
"con=%d vt=%d pos=%d-%d-%d\n",
|
||||
idx,
|
||||
@ -290,8 +290,8 @@ compute_type (argspec_t arg)
|
||||
{
|
||||
switch (arg->conspec)
|
||||
{
|
||||
case CONSPEC_UNKNOWN:
|
||||
arg->vt = VALTYPE_UNSUPPORTED;
|
||||
case CONSPEC_UNKNOWN:
|
||||
arg->vt = VALTYPE_UNSUPPORTED;
|
||||
break;
|
||||
|
||||
case CONSPEC_DECIMAL:
|
||||
@ -302,7 +302,7 @@ compute_type (argspec_t arg)
|
||||
case LENMOD_LONG: arg->vt = VALTYPE_LONG; break;
|
||||
case LENMOD_LONGLONG: arg->vt = VALTYPE_LONGLONG; break;
|
||||
case LENMOD_INTMAX: arg->vt = VALTYPE_INTMAX; break;
|
||||
case LENMOD_SIZET: arg->vt = VALTYPE_SIZE; break;
|
||||
case LENMOD_SIZET: arg->vt = VALTYPE_SIZE; break;
|
||||
case LENMOD_PTRDIFF: arg->vt = VALTYPE_PTRDIFF; break;
|
||||
default: arg->vt = VALTYPE_INT; break;
|
||||
}
|
||||
@ -319,12 +319,12 @@ compute_type (argspec_t arg)
|
||||
case LENMOD_LONG: arg->vt = VALTYPE_ULONG; break;
|
||||
case LENMOD_LONGLONG: arg->vt = VALTYPE_ULONGLONG; break;
|
||||
case LENMOD_INTMAX: arg->vt = VALTYPE_UINTMAX; break;
|
||||
case LENMOD_SIZET: arg->vt = VALTYPE_SIZE; break;
|
||||
case LENMOD_SIZET: arg->vt = VALTYPE_SIZE; break;
|
||||
case LENMOD_PTRDIFF: arg->vt = VALTYPE_PTRDIFF; break;
|
||||
default: arg->vt = VALTYPE_UINT; break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case CONSPEC_FLOAT:
|
||||
case CONSPEC_FLOAT_UP:
|
||||
case CONSPEC_EXP:
|
||||
@ -340,9 +340,9 @@ compute_type (argspec_t arg)
|
||||
default: arg->vt = VALTYPE_DOUBLE; break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case CONSPEC_CHAR:
|
||||
arg->vt = VALTYPE_INT;
|
||||
arg->vt = VALTYPE_INT;
|
||||
break;
|
||||
|
||||
case CONSPEC_STRING:
|
||||
@ -365,12 +365,12 @@ compute_type (argspec_t arg)
|
||||
case LENMOD_LONG: arg->vt = VALTYPE_LONG_PTR; break;
|
||||
case LENMOD_LONGLONG: arg->vt = VALTYPE_LONGLONG_PTR; break;
|
||||
case LENMOD_INTMAX: arg->vt = VALTYPE_INTMAX_PTR; break;
|
||||
case LENMOD_SIZET: arg->vt = VALTYPE_SIZE_PTR; break;
|
||||
case LENMOD_SIZET: arg->vt = VALTYPE_SIZE_PTR; break;
|
||||
case LENMOD_PTRDIFF: arg->vt = VALTYPE_PTRDIFF_PTR; break;
|
||||
default: arg->vt = VALTYPE_INT_PTR; break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -395,7 +395,7 @@ parse_format (const char *format,
|
||||
|
||||
if (!format)
|
||||
goto leave_einval;
|
||||
|
||||
|
||||
for (; *format; format++)
|
||||
{
|
||||
unsigned int flags;
|
||||
@ -403,7 +403,7 @@ parse_format (const char *format,
|
||||
lenmod_t lenmod;
|
||||
conspec_t conspec;
|
||||
int arg_pos, width_pos, precision_pos;
|
||||
|
||||
|
||||
if (*format != '%')
|
||||
continue;
|
||||
s = ++format;
|
||||
@ -417,7 +417,7 @@ parse_format (const char *format,
|
||||
if (*s >= '1' && *s <= '9')
|
||||
{
|
||||
const char *save_s = s;
|
||||
|
||||
|
||||
arg_pos = (*s++ - '0');
|
||||
for (; *s >= '0' && *s <= '9'; s++)
|
||||
arg_pos = 10*arg_pos + (*s - '0');
|
||||
@ -431,7 +431,7 @@ parse_format (const char *format,
|
||||
s = save_s;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Parse the flags. */
|
||||
flags = 0;
|
||||
for ( ; *s; s++)
|
||||
@ -449,7 +449,7 @@ parse_format (const char *format,
|
||||
}
|
||||
}
|
||||
flags_parsed:
|
||||
|
||||
|
||||
/* Parse the field width. */
|
||||
width_pos = 0;
|
||||
if (*s == '*')
|
||||
@ -532,11 +532,11 @@ parse_format (const char *format,
|
||||
if (ignore_value)
|
||||
precision = NO_FIELD_VALUE;
|
||||
}
|
||||
|
||||
|
||||
/* Parse the length modifiers. */
|
||||
switch (*s)
|
||||
{
|
||||
case 'h':
|
||||
case 'h':
|
||||
if (s[1] == 'h')
|
||||
{
|
||||
lenmod = LENMOD_CHAR;
|
||||
@ -562,7 +562,7 @@ parse_format (const char *format,
|
||||
case 'L': lenmod = LENMOD_LONGDBL; s++; break;
|
||||
default: lenmod = LENMOD_NONE; break;
|
||||
}
|
||||
|
||||
|
||||
/* Parse the conversion specifier. */
|
||||
switch (*s)
|
||||
{
|
||||
@ -632,7 +632,7 @@ parse_format (const char *format,
|
||||
*argspecs_addr = argspecs;
|
||||
*r_argspecs_count = argcount;
|
||||
return 0; /* Success. */
|
||||
|
||||
|
||||
leave_einval:
|
||||
errno = EINVAL;
|
||||
leave:
|
||||
@ -663,14 +663,14 @@ read_values (valueitem_t valuetable, size_t valuetable_len, va_list vaargs)
|
||||
value->a_char_ptr = va_arg (vaargs, char *);
|
||||
break;
|
||||
case VALTYPE_SCHAR: value->a_schar = va_arg (vaargs, int); break;
|
||||
case VALTYPE_SCHAR_PTR:
|
||||
value->a_schar_ptr = va_arg (vaargs, signed char *);
|
||||
case VALTYPE_SCHAR_PTR:
|
||||
value->a_schar_ptr = va_arg (vaargs, signed char *);
|
||||
break;
|
||||
case VALTYPE_UCHAR: value->a_uchar = va_arg (vaargs, int); break;
|
||||
case VALTYPE_SHORT: value->a_short = va_arg (vaargs, int); break;
|
||||
case VALTYPE_USHORT: value->a_ushort = va_arg (vaargs, int); break;
|
||||
case VALTYPE_SHORT_PTR:
|
||||
value->a_short_ptr = va_arg (vaargs, short *);
|
||||
case VALTYPE_SHORT_PTR:
|
||||
value->a_short_ptr = va_arg (vaargs, short *);
|
||||
break;
|
||||
case VALTYPE_INT:
|
||||
value->a_int = va_arg (vaargs, int);
|
||||
@ -684,20 +684,20 @@ read_values (valueitem_t valuetable, size_t valuetable_len, va_list vaargs)
|
||||
case VALTYPE_LONG:
|
||||
value->a_long = va_arg (vaargs, long);
|
||||
break;
|
||||
case VALTYPE_ULONG:
|
||||
case VALTYPE_ULONG:
|
||||
value->a_ulong = va_arg (vaargs, unsigned long);
|
||||
break;
|
||||
case VALTYPE_LONG_PTR:
|
||||
value->a_long_ptr = va_arg (vaargs, long *);
|
||||
case VALTYPE_LONG_PTR:
|
||||
value->a_long_ptr = va_arg (vaargs, long *);
|
||||
break;
|
||||
#ifdef HAVE_LONG_LONG_INT
|
||||
case VALTYPE_LONGLONG:
|
||||
value->a_longlong = va_arg (vaargs, long long int);
|
||||
break;
|
||||
case VALTYPE_ULONGLONG:
|
||||
value->a_ulonglong = va_arg (vaargs, unsigned long long int);
|
||||
case VALTYPE_ULONGLONG:
|
||||
value->a_ulonglong = va_arg (vaargs, unsigned long long int);
|
||||
break;
|
||||
case VALTYPE_LONGLONG_PTR:
|
||||
case VALTYPE_LONGLONG_PTR:
|
||||
value->a_longlong_ptr = va_arg (vaargs, long long *);
|
||||
break;
|
||||
#endif
|
||||
@ -712,31 +712,31 @@ read_values (valueitem_t valuetable, size_t valuetable_len, va_list vaargs)
|
||||
case VALTYPE_STRING:
|
||||
value->a_string = va_arg (vaargs, const char *);
|
||||
break;
|
||||
case VALTYPE_POINTER:
|
||||
case VALTYPE_POINTER:
|
||||
value->a_void_ptr = va_arg (vaargs, void *);
|
||||
break;
|
||||
#ifdef HAVE_INTMAX_T
|
||||
case VALTYPE_INTMAX:
|
||||
value->a_intmax = va_arg (vaargs, intmax_t);
|
||||
break;
|
||||
case VALTYPE_INTMAX_PTR:
|
||||
value->a_intmax_ptr = va_arg (vaargs, intmax_t *);
|
||||
case VALTYPE_INTMAX_PTR:
|
||||
value->a_intmax_ptr = va_arg (vaargs, intmax_t *);
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAVE_UINTMAX_T
|
||||
case VALTYPE_UINTMAX:
|
||||
value->a_uintmax = va_arg (vaargs, uintmax_t);
|
||||
case VALTYPE_UINTMAX:
|
||||
value->a_uintmax = va_arg (vaargs, uintmax_t);
|
||||
break;
|
||||
#endif
|
||||
case VALTYPE_SIZE:
|
||||
value->a_size = va_arg (vaargs, size_t);
|
||||
break;
|
||||
case VALTYPE_SIZE_PTR:
|
||||
value->a_size_ptr = va_arg (vaargs, size_t *);
|
||||
case VALTYPE_SIZE_PTR:
|
||||
value->a_size_ptr = va_arg (vaargs, size_t *);
|
||||
break;
|
||||
#ifdef HAVE_PTRDIFF_T
|
||||
case VALTYPE_PTRDIFF:
|
||||
value->a_ptrdiff = va_arg (vaargs, ptrdiff_t);
|
||||
value->a_ptrdiff = va_arg (vaargs, ptrdiff_t);
|
||||
break;
|
||||
case VALTYPE_PTRDIFF_PTR:
|
||||
value->a_ptrdiff_ptr = va_arg (vaargs, ptrdiff_t *);
|
||||
@ -771,7 +771,7 @@ pad_out (estream_printf_out_t outfnc, void *outfncarg,
|
||||
*nbytes += n;
|
||||
count -= n;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -808,18 +808,18 @@ pr_integer (estream_printf_out_t outfnc, void *outfncarg,
|
||||
{
|
||||
case VALTYPE_SHORT: along = value.a_short; break;
|
||||
case VALTYPE_INT: along = value.a_int; break;
|
||||
case VALTYPE_LONG: along = value.a_long; break;
|
||||
case VALTYPE_LONG: along = value.a_long; break;
|
||||
#ifdef HAVE_LONG_LONG_INT
|
||||
case VALTYPE_LONGLONG: along = value.a_longlong; break;
|
||||
case VALTYPE_SIZE: along = value.a_size; break;
|
||||
case VALTYPE_LONGLONG: along = value.a_longlong; break;
|
||||
case VALTYPE_SIZE: along = value.a_size; break;
|
||||
# ifdef HAVE_INTMAX_T
|
||||
case VALTYPE_INTMAX: along = value.a_intmax; break;
|
||||
case VALTYPE_INTMAX: along = value.a_intmax; break;
|
||||
# endif
|
||||
# ifdef HAVE_PTRDIFF_T
|
||||
case VALTYPE_PTRDIFF: along = value.a_ptrdiff; break;
|
||||
case VALTYPE_PTRDIFF: along = value.a_ptrdiff; break;
|
||||
# endif
|
||||
#endif /*HAVE_LONG_LONG_INT*/
|
||||
default:
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
if (along < 0)
|
||||
@ -836,18 +836,18 @@ pr_integer (estream_printf_out_t outfnc, void *outfncarg,
|
||||
{
|
||||
case VALTYPE_USHORT: aulong = value.a_ushort; break;
|
||||
case VALTYPE_UINT: aulong = value.a_uint; break;
|
||||
case VALTYPE_ULONG: aulong = value.a_ulong; break;
|
||||
case VALTYPE_ULONG: aulong = value.a_ulong; break;
|
||||
#ifdef HAVE_LONG_LONG_INT
|
||||
case VALTYPE_ULONGLONG: aulong = value.a_ulonglong; break;
|
||||
case VALTYPE_SIZE: aulong = value.a_size; break;
|
||||
case VALTYPE_ULONGLONG: aulong = value.a_ulonglong; break;
|
||||
case VALTYPE_SIZE: aulong = value.a_size; break;
|
||||
# ifdef HAVE_UINTMAX_T
|
||||
case VALTYPE_UINTMAX: aulong = value.a_uintmax; break;
|
||||
case VALTYPE_UINTMAX: aulong = value.a_uintmax; break;
|
||||
# endif
|
||||
# ifdef HAVE_PTRDIFF_T
|
||||
case VALTYPE_PTRDIFF: aulong = value.a_ptrdiff; break;
|
||||
case VALTYPE_PTRDIFF: aulong = value.a_ptrdiff; break;
|
||||
# endif
|
||||
#endif /*HAVE_LONG_LONG_INT*/
|
||||
default:
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -878,7 +878,7 @@ pr_integer (estream_printf_out_t outfnc, void *outfncarg,
|
||||
|
||||
do
|
||||
{
|
||||
if ((arg->flags & FLAG_GROUPING)
|
||||
if ((arg->flags & FLAG_GROUPING)
|
||||
&& (++grouping == 3) && *grouping_string)
|
||||
{
|
||||
*--p = *grouping_string;
|
||||
@ -913,7 +913,7 @@ pr_integer (estream_printf_out_t outfnc, void *outfncarg,
|
||||
if ((arg->flags & FLAG_ALT_CONV))
|
||||
n_extra += 2;
|
||||
}
|
||||
|
||||
|
||||
n = pend - p;
|
||||
|
||||
if ((arg->flags & FLAG_ZERO_PAD)
|
||||
@ -958,7 +958,7 @@ pr_integer (estream_printf_out_t outfnc, void *outfncarg,
|
||||
if (rc)
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
rc = outfnc (outfncarg, p, pend - p);
|
||||
if (rc)
|
||||
return rc;
|
||||
@ -1011,7 +1011,7 @@ pr_float (estream_printf_out_t outfnc, void *outfncarg,
|
||||
adblfloat = value.a_longdouble;
|
||||
use_dbl=1; break;
|
||||
#endif
|
||||
default:
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1051,12 +1051,23 @@ pr_float (estream_printf_out_t outfnc, void *outfncarg,
|
||||
if ((arg->flags & FLAG_ALT_CONV))
|
||||
*--p = '#';
|
||||
*--p = '%';
|
||||
|
||||
#if GNUPG_GCC_VERSION >= 40600
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LONG_DOUBLE
|
||||
if (use_dbl)
|
||||
sprintf (numbuf, p, adblfloat);
|
||||
else
|
||||
#endif /*HAVE_LONG_DOUBLE*/
|
||||
sprintf (numbuf, p, afloat);
|
||||
|
||||
#if GNUPG_GCC_VERSION >= 40600
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
p = numbuf;
|
||||
n = strlen (numbuf);
|
||||
pend = p + n;
|
||||
@ -1122,7 +1133,7 @@ pr_char (estream_printf_out_t outfnc, void *outfncarg,
|
||||
if(rc)
|
||||
return rc;
|
||||
*nbytes += 1;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1143,7 +1154,7 @@ pr_string (estream_printf_out_t outfnc, void *outfncarg,
|
||||
string = "(null)";
|
||||
if (arg->precision >= 0)
|
||||
{
|
||||
for (n=0,s=string; *s && n < arg->precision; s++)
|
||||
for (n=0,s=string; *s && n < arg->precision; s++)
|
||||
n++;
|
||||
}
|
||||
else
|
||||
@ -1169,7 +1180,7 @@ pr_string (estream_printf_out_t outfnc, void *outfncarg,
|
||||
if (rc)
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1210,7 +1221,7 @@ pr_pointer (estream_printf_out_t outfnc, void *outfncarg,
|
||||
*--p = '0';
|
||||
*--p = 'x';
|
||||
*--p = '0';
|
||||
|
||||
|
||||
rc = outfnc (outfncarg, p, pend - p);
|
||||
if (rc)
|
||||
return rc;
|
||||
@ -1229,14 +1240,14 @@ pr_bytes_so_far (estream_printf_out_t outfnc, void *outfncarg,
|
||||
|
||||
switch (arg->vt)
|
||||
{
|
||||
case VALTYPE_SCHAR_PTR:
|
||||
*value.a_schar_ptr = (signed char)(unsigned int)(*nbytes);
|
||||
case VALTYPE_SCHAR_PTR:
|
||||
*value.a_schar_ptr = (signed char)(unsigned int)(*nbytes);
|
||||
break;
|
||||
case VALTYPE_SHORT_PTR:
|
||||
case VALTYPE_SHORT_PTR:
|
||||
*value.a_short_ptr = (short)(unsigned int)(*nbytes);
|
||||
break;
|
||||
case VALTYPE_LONG_PTR:
|
||||
*value.a_long_ptr = (long)(*nbytes);
|
||||
case VALTYPE_LONG_PTR:
|
||||
*value.a_long_ptr = (long)(*nbytes);
|
||||
break;
|
||||
#ifdef HAVE_LONG_LONG_INT
|
||||
case VALTYPE_LONGLONG_PTR:
|
||||
@ -1244,12 +1255,12 @@ pr_bytes_so_far (estream_printf_out_t outfnc, void *outfncarg,
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAVE_INTMAX_T
|
||||
case VALTYPE_INTMAX_PTR:
|
||||
case VALTYPE_INTMAX_PTR:
|
||||
*value.a_intmax_ptr = (intmax_t)(*nbytes);
|
||||
break;
|
||||
#endif
|
||||
case VALTYPE_SIZE_PTR:
|
||||
*value.a_size_ptr = (*nbytes);
|
||||
*value.a_size_ptr = (*nbytes);
|
||||
break;
|
||||
#ifdef HAVE_PTRDIFF_T
|
||||
case VALTYPE_PTRDIFF_PTR:
|
||||
@ -1274,8 +1285,8 @@ pr_bytes_so_far (estream_printf_out_t outfnc, void *outfncarg,
|
||||
holds the values and may be directly addressed using the position
|
||||
arguments given by ARGSPECS. MYERRNO is used for the "%m"
|
||||
conversion. NBYTES well be updated to reflect the number of bytes
|
||||
send to the output function. */
|
||||
static int
|
||||
send to the output function. */
|
||||
static int
|
||||
do_format (estream_printf_out_t outfnc, void *outfncarg,
|
||||
const char *format, argspec_t argspecs, size_t argspecs_len,
|
||||
valueitem_t valuetable, int myerrno, size_t *nbytes)
|
||||
@ -1319,7 +1330,7 @@ do_format (estream_printf_out_t outfnc, void *outfncarg,
|
||||
/* Save the next start. */
|
||||
s += arg->length;
|
||||
format = s;
|
||||
|
||||
|
||||
assert (argidx < argspecs_len);
|
||||
argidx++;
|
||||
|
||||
@ -1387,9 +1398,9 @@ do_format (estream_printf_out_t outfnc, void *outfncarg,
|
||||
}
|
||||
if (rc)
|
||||
return rc;
|
||||
arg++;
|
||||
arg++;
|
||||
}
|
||||
|
||||
|
||||
/* Print out any trailing stuff. */
|
||||
n = s - format;
|
||||
rc = n? outfnc (outfncarg, format, n) : 0;
|
||||
@ -1407,7 +1418,7 @@ do_format (estream_printf_out_t outfnc, void *outfncarg,
|
||||
output of the formatted stuff. FORMAT is the format specification
|
||||
and VAARGS a variable argumemt list matching the arguments of
|
||||
FORMAT. */
|
||||
int
|
||||
int
|
||||
estream_format (estream_printf_out_t outfnc,
|
||||
void *outfncarg,
|
||||
const char *format, va_list vaargs)
|
||||
@ -1442,7 +1453,7 @@ estream_format (estream_printf_out_t outfnc,
|
||||
/* Check that all ARG_POS fields are set. */
|
||||
for (argidx=0,max_pos=0; argidx < argspecs_len; argidx++)
|
||||
{
|
||||
if (argspecs[argidx].arg_pos != -1
|
||||
if (argspecs[argidx].arg_pos != -1
|
||||
&& argspecs[argidx].arg_pos > max_pos)
|
||||
max_pos = argspecs[argidx].arg_pos;
|
||||
if (argspecs[argidx].width_pos > max_pos)
|
||||
@ -1523,13 +1534,13 @@ estream_format (estream_printf_out_t outfnc,
|
||||
valuetable[validx].vt = VALTYPE_INT;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Read all the arguments. This will error out for unsupported
|
||||
types and for not given positional arguments. */
|
||||
rc = read_values (valuetable, max_pos, vaargs);
|
||||
if (rc)
|
||||
goto leave_einval;
|
||||
|
||||
goto leave_einval;
|
||||
|
||||
/* for (validx=0; validx < max_pos; validx++) */
|
||||
/* fprintf (stderr, "%2d: vt=%d\n", validx, valuetable[validx].vt); */
|
||||
|
||||
@ -1538,7 +1549,7 @@ estream_format (estream_printf_out_t outfnc,
|
||||
argspecs, argspecs_len, valuetable, myerrno, &nbytes);
|
||||
|
||||
goto leave;
|
||||
|
||||
|
||||
leave_einval:
|
||||
errno = EINVAL;
|
||||
leave_error:
|
||||
@ -1572,11 +1583,11 @@ estream_printf (const char *format, ...)
|
||||
{
|
||||
int rc;
|
||||
va_list arg_ptr;
|
||||
|
||||
|
||||
va_start (arg_ptr, format);
|
||||
rc = estream_format (plain_stdio_out, stderr, format, arg_ptr);
|
||||
va_end (arg_ptr);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -1586,16 +1597,16 @@ estream_fprintf (FILE *fp, const char *format, ...)
|
||||
{
|
||||
int rc;
|
||||
va_list arg_ptr;
|
||||
|
||||
|
||||
va_start (arg_ptr, format);
|
||||
rc = estream_format (plain_stdio_out, fp, format, arg_ptr);
|
||||
va_end (arg_ptr);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* A replacement for vfprintf. */
|
||||
int
|
||||
int
|
||||
estream_vfprintf (FILE *fp, const char *format, va_list arg_ptr)
|
||||
{
|
||||
return estream_format (plain_stdio_out, fp, format, arg_ptr);
|
||||
@ -1642,7 +1653,7 @@ fixed_buffer_out (void *outfncarg, const char *buf, size_t buflen)
|
||||
|
||||
|
||||
/* A replacement for vsnprintf. */
|
||||
int
|
||||
int
|
||||
estream_vsnprintf (char *buf, size_t bufsize,
|
||||
const char *format, va_list arg_ptr)
|
||||
{
|
||||
@ -1667,7 +1678,7 @@ estream_vsnprintf (char *buf, size_t bufsize,
|
||||
}
|
||||
|
||||
/* A replacement for snprintf. */
|
||||
int
|
||||
int
|
||||
estream_snprintf (char *buf, size_t bufsize, const char *format, ...)
|
||||
{
|
||||
int rc;
|
||||
@ -1676,7 +1687,7 @@ estream_snprintf (char *buf, size_t bufsize, const char *format, ...)
|
||||
va_start (arg_ptr, format);
|
||||
rc = estream_vsnprintf (buf, bufsize, format, arg_ptr);
|
||||
va_end (arg_ptr);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -1686,7 +1697,7 @@ estream_snprintf (char *buf, size_t bufsize, const char *format, ...)
|
||||
dynamic_buffer_out. */
|
||||
struct dynamic_buffer_parm_s
|
||||
{
|
||||
int error_flag; /* Internal helper. */
|
||||
int error_flag; /* Internal helper. */
|
||||
size_t alloced; /* Allocated size of the buffer. */
|
||||
size_t used; /* Used size of the buffer. */
|
||||
char *buffer; /* Malloced buffer. */
|
||||
@ -1709,7 +1720,7 @@ dynamic_buffer_out (void *outfncarg, const char *buf, size_t buflen)
|
||||
if (parm->used + buflen >= parm->alloced)
|
||||
{
|
||||
char *p;
|
||||
|
||||
|
||||
parm->alloced += buflen + 512;
|
||||
p = realloc (parm->buffer, parm->alloced);
|
||||
if (!p)
|
||||
@ -1732,7 +1743,7 @@ dynamic_buffer_out (void *outfncarg, const char *buf, size_t buflen)
|
||||
/* A replacement for vasprintf. As with the BSD of vasprintf version -1
|
||||
will be returned on error and NULL stored at BUFP. On success the
|
||||
number of bytes printed will be returned. */
|
||||
int
|
||||
int
|
||||
estream_vasprintf (char **bufp, const char *format, va_list arg_ptr)
|
||||
{
|
||||
struct dynamic_buffer_parm_s parm;
|
||||
@ -1747,7 +1758,7 @@ estream_vasprintf (char **bufp, const char *format, va_list arg_ptr)
|
||||
*bufp = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
rc = estream_format (dynamic_buffer_out, &parm, format, arg_ptr);
|
||||
if (!rc)
|
||||
rc = dynamic_buffer_out (&parm, "", 1); /* Print terminating Nul. */
|
||||
@ -1772,7 +1783,7 @@ estream_vasprintf (char **bufp, const char *format, va_list arg_ptr)
|
||||
/* A replacement for asprintf. As with the BSD of asprintf version -1
|
||||
will be returned on error and NULL stored at BUFP. On success the
|
||||
number of bytes printed will be returned. */
|
||||
int
|
||||
int
|
||||
estream_asprintf (char **bufp, const char *format, ...)
|
||||
{
|
||||
int rc;
|
||||
@ -1781,7 +1792,7 @@ estream_asprintf (char **bufp, const char *format, ...)
|
||||
va_start (arg_ptr, format);
|
||||
rc = estream_vasprintf (bufp, format, arg_ptr);
|
||||
va_end (arg_ptr);
|
||||
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
#ifdef HAVE_UNSIGNED_TIME_T
|
||||
# define INVALID_TIME_CHECK(a) ((a) == (time_t)(-1))
|
||||
#else
|
||||
#else
|
||||
/* Error or 32 bit time_t and value after 2038-01-19. */
|
||||
# define INVALID_TIME_CHECK(a) ((a) < 0)
|
||||
#endif
|
||||
@ -146,7 +146,7 @@ isotimestamp (u32 stamp)
|
||||
static char buffer[25+5];
|
||||
struct tm *tp;
|
||||
time_t atime = stamp;
|
||||
|
||||
|
||||
if (INVALID_TIME_CHECK (atime)) {
|
||||
strcpy (buffer, "????" "-??" "-??" " " "??" ":" "??" ":" "??");
|
||||
}
|
||||
@ -232,17 +232,24 @@ asctimestamp( u32 stamp )
|
||||
tp = localtime( &atime );
|
||||
#ifdef HAVE_STRFTIME
|
||||
#if defined(HAVE_NL_LANGINFO)
|
||||
# if GNUPG_GCC_VERSION >= 40600
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||||
# endif
|
||||
mem2str( fmt, nl_langinfo(D_T_FMT), DIM(fmt)-3 );
|
||||
if( strstr( fmt, "%Z" ) == NULL )
|
||||
strcat( fmt, " %Z");
|
||||
strftime( buffer, DIM(buffer)-1, fmt, tp );
|
||||
# if GNUPG_GCC_VERSION >= 40600
|
||||
# pragma GCC diagnostic pop
|
||||
# endif
|
||||
#else
|
||||
/* fixme: we should check whether the locale appends a " %Z"
|
||||
* These locales from glibc don't put the " %Z":
|
||||
* fi_FI hr_HR ja_JP lt_LT lv_LV POSIX ru_RU ru_SU sv_FI sv_SE zh_CN
|
||||
*/
|
||||
strftime( buffer, DIM(buffer)-1,
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
strftime( buffer, DIM(buffer)-1,
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
"%c"
|
||||
#else
|
||||
"%c %Z"
|
||||
@ -264,7 +271,7 @@ void
|
||||
print_string2( FILE *fp, const byte *p, size_t n, int delim, int delim2 )
|
||||
{
|
||||
for( ; n; n--, p++ )
|
||||
if (*p < 0x20
|
||||
if (*p < 0x20
|
||||
|| *p == 0x7f
|
||||
|| *p == delim || *p == delim2
|
||||
|| ((delim || delim2) && *p=='\\'))
|
||||
@ -456,7 +463,7 @@ answer_is_yes_no_quit( const char *s )
|
||||
}
|
||||
|
||||
/*
|
||||
Return 1 for okay, 0 for for cancel or DEF_ANSWER for default.
|
||||
Return 1 for okay, 0 for for cancel or DEF_ANSWER for default.
|
||||
*/
|
||||
int
|
||||
answer_is_okay_cancel (const char *s, int def_answer)
|
||||
@ -467,7 +474,7 @@ answer_is_okay_cancel (const char *s, int def_answer)
|
||||
const char *long_cancel = _("cancel|cancel");
|
||||
const char *short_okay = _("oO");
|
||||
const char *short_cancel = _("cC");
|
||||
|
||||
|
||||
/* Note: We have to use the locale dependent strcasecmp */
|
||||
if ( match_multistr(long_okay,s) )
|
||||
return 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user