mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
gcc-4 defaults forced me to edit many many files to get rid of the
char * vs. unsigned char * warnings. The GNU coding standards used to say that these mismatches are okay and better than a bunch of casts. Obviously this has changed now.
This commit is contained in:
parent
3370164182
commit
deeba405a9
69 changed files with 558 additions and 348 deletions
|
@ -1,3 +1,16 @@
|
|||
2005-06-15 Werner Koch <wk@g10code.com>
|
||||
|
||||
* stringhelp.c (sanitize_buffer): Make P a void*.
|
||||
(ascii_memistr, memistr): Ditto.
|
||||
(ascii_memcasecmp): Ditto.
|
||||
* logging.c (writen): Use void * for arg BUFFER.
|
||||
* stringhelp.c (memistr): Fixed unsigned/signed pointer conflict.
|
||||
(ascii_memistr): Ditto.
|
||||
(ascii_memcasemem): Ditto.
|
||||
* utf8conv.c (utf8_to_native): Ditto.
|
||||
(utf8_to_native): Ditto.
|
||||
* argparse.c (show_version): Removed non-required cast.
|
||||
|
||||
2005-01-19 Werner Koch <wk@g10code.com>
|
||||
|
||||
* logging.c (fun_writer): Don't fallback to stderr. Print to
|
||||
|
|
|
@ -852,7 +852,7 @@ show_version()
|
|||
/* additional program info */
|
||||
for(i=30; i < 40; i++ )
|
||||
if( (s=strusage(i)) )
|
||||
fputs( (const byte*)s, stdout);
|
||||
fputs (s, stdout);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
|
|
@ -87,10 +87,11 @@ struct fun_cookie_s {
|
|||
char name[1];
|
||||
};
|
||||
|
||||
/* Write NBYTES of BUF to file descriptor FD. */
|
||||
/* Write NBYTES of BUFFER to file descriptor FD. */
|
||||
static int
|
||||
writen (int fd, const unsigned char *buf, size_t nbytes)
|
||||
writen (int fd, const void *buffer, size_t nbytes)
|
||||
{
|
||||
const char *buf = buffer;
|
||||
size_t nleft = nbytes;
|
||||
int nwritten;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* stringhelp.c - standard string helper functions
|
||||
* Copyright (C) 1998, 1999, 2000, 2001, 2003,
|
||||
* 2004 Free Software Foundation, Inc.
|
||||
* 2004, 2005 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GnuPG.
|
||||
*
|
||||
|
@ -35,45 +35,57 @@
|
|||
|
||||
/*
|
||||
* Look for the substring SUB in buffer and return a pointer to that
|
||||
* substring in BUF or NULL if not found.
|
||||
* substring in BUFFER or NULL if not found.
|
||||
* Comparison is case-insensitive.
|
||||
*/
|
||||
const char *
|
||||
memistr( const char *buf, size_t buflen, const char *sub )
|
||||
memistr (const void *buffer, size_t buflen, const char *sub)
|
||||
{
|
||||
const byte *t, *s ;
|
||||
size_t n;
|
||||
const unsigned char *buf = buffer;
|
||||
const unsigned char *t = (const unsigned char *)buffer;
|
||||
const unsigned char *s = (const unsigned char *)sub;
|
||||
size_t n = buflen;
|
||||
|
||||
for( t=buf, n=buflen, s=sub ; n ; t++, n-- )
|
||||
if( toupper(*t) == toupper(*s) ) {
|
||||
for( buf=t++, buflen = n--, s++;
|
||||
n && toupper(*t) == toupper(*s); t++, s++, n-- )
|
||||
;
|
||||
if( !*s )
|
||||
return buf;
|
||||
t = buf; n = buflen; s = sub ;
|
||||
for ( ; n ; t++, n-- )
|
||||
{
|
||||
if ( toupper (*t) == toupper (*s) )
|
||||
{
|
||||
for ( buf=t++, buflen = n--, s++;
|
||||
n && toupper (*t) == toupper (*s); t++, s++, n-- )
|
||||
;
|
||||
if (!*s)
|
||||
return (const char*)buf;
|
||||
t = buf;
|
||||
s = (const unsigned char *)sub ;
|
||||
n = buflen;
|
||||
}
|
||||
|
||||
return NULL ;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *
|
||||
ascii_memistr( const char *buf, size_t buflen, const char *sub )
|
||||
ascii_memistr ( const void *buffer, size_t buflen, const char *sub )
|
||||
{
|
||||
const byte *t, *s ;
|
||||
size_t n;
|
||||
const unsigned char *buf = buffer;
|
||||
const unsigned char *t = (const unsigned char *)buf;
|
||||
const unsigned char *s = (const unsigned char *)sub;
|
||||
size_t n = buflen;
|
||||
|
||||
for( t=buf, n=buflen, s=sub ; n ; t++, n-- )
|
||||
if( ascii_toupper(*t) == ascii_toupper(*s) ) {
|
||||
for( buf=t++, buflen = n--, s++;
|
||||
n && ascii_toupper(*t) == ascii_toupper(*s); t++, s++, n-- )
|
||||
;
|
||||
if( !*s )
|
||||
return buf;
|
||||
t = buf; n = buflen; s = sub ;
|
||||
for ( ; n ; t++, n-- )
|
||||
{
|
||||
if (ascii_toupper (*t) == ascii_toupper (*s) )
|
||||
{
|
||||
for ( buf=t++, buflen = n--, s++;
|
||||
n && ascii_toupper (*t) == ascii_toupper (*s); t++, s++, n-- )
|
||||
;
|
||||
if (!*s)
|
||||
return (const char*)buf;
|
||||
t = (const unsigned char *)buf;
|
||||
s = (const unsigned char *)sub ;
|
||||
n = buflen;
|
||||
}
|
||||
|
||||
return NULL ;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* This function is similar to strncpy(). However it won't copy more
|
||||
|
@ -402,13 +414,14 @@ print_sanitized_utf8_string (FILE *fp, const char *string, int delim)
|
|||
delim) : 0;
|
||||
}
|
||||
|
||||
/* Create a string from the buffer P of length N which is suitable for
|
||||
/* Create a string from the buffer P_ARG of length N which is suitable for
|
||||
printing. Caller must release the created string using xfree. */
|
||||
char *
|
||||
sanitize_buffer (const unsigned char *p, size_t n, int delim)
|
||||
sanitize_buffer (const void *p_arg, size_t n, int delim)
|
||||
{
|
||||
const unsigned char *p = p_arg;
|
||||
size_t save_n, buflen;
|
||||
const byte *save_p;
|
||||
const unsigned char *save_p;
|
||||
char *buffer, *d;
|
||||
|
||||
/* first count length */
|
||||
|
@ -552,15 +565,19 @@ ascii_strncasecmp (const char *a, const char *b, size_t n)
|
|||
|
||||
|
||||
int
|
||||
ascii_memcasecmp( const char *a, const char *b, size_t n )
|
||||
ascii_memcasecmp (const void *a_arg, const void *b_arg, size_t n )
|
||||
{
|
||||
if (a == b)
|
||||
return 0;
|
||||
for ( ; n; n--, a++, b++ ) {
|
||||
if( *a != *b && ascii_toupper (*a) != ascii_toupper (*b) )
|
||||
return *a == *b? 0 : (ascii_toupper (*a) - ascii_toupper (*b));
|
||||
}
|
||||
const char *a = a_arg;
|
||||
const char *b = b_arg;
|
||||
|
||||
if (a == b)
|
||||
return 0;
|
||||
for ( ; n; n--, a++, b++ )
|
||||
{
|
||||
if( *a != *b && ascii_toupper (*a) != ascii_toupper (*b) )
|
||||
return *a == *b? 0 : (ascii_toupper (*a) - ascii_toupper (*b));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -586,8 +603,8 @@ ascii_memcasemem (const void *haystack, size_t nhaystack,
|
|||
return (void*)haystack; /* finding an empty needle is really easy */
|
||||
if (nneedle <= nhaystack)
|
||||
{
|
||||
const unsigned char *a = haystack;
|
||||
const unsigned char *b = a + nhaystack - nneedle;
|
||||
const char *a = haystack;
|
||||
const char *b = a + nhaystack - nneedle;
|
||||
|
||||
for (; a <= b; a++)
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "types.h"
|
||||
|
||||
const char *memistr( const char *buf, size_t buflen, const char *sub );
|
||||
const char *memistr (const void *buf, size_t buflen, const char *sub);
|
||||
char *mem2str( char *, const void *, size_t);
|
||||
char *trim_spaces( char *string );
|
||||
char *trim_trailing_spaces( char *string );
|
||||
|
@ -46,7 +46,7 @@ size_t print_sanitized_utf8_buffer (FILE *fp, const void *buffer,
|
|||
size_t length, int delim);
|
||||
size_t print_sanitized_string (FILE *fp, const char *string, int delim);
|
||||
size_t print_sanitized_utf8_string (FILE *fp, const char *string, int delim);
|
||||
char *sanitize_buffer (const unsigned char *p, size_t n, int delim);
|
||||
char *sanitize_buffer (const void *p, size_t n, int delim);
|
||||
|
||||
|
||||
#ifdef HAVE_W32_SYSTEM
|
||||
|
@ -54,15 +54,14 @@ const char *w32_strerror (int ec);
|
|||
#endif
|
||||
|
||||
|
||||
const char *ascii_memistr( const char *buf, size_t buflen, const char *sub );
|
||||
int ascii_isupper (int c);
|
||||
int ascii_islower (int c);
|
||||
int ascii_toupper (int c);
|
||||
int ascii_tolower (int c);
|
||||
int ascii_strcasecmp( const char *a, const char *b );
|
||||
int ascii_strncasecmp (const char *a, const char *b, size_t n);
|
||||
int ascii_memcasecmp( const char *a, const char *b, size_t n );
|
||||
const char *ascii_memistr ( const char *buf, size_t buflen, const char *sub);
|
||||
int ascii_memcasecmp( const void *a, const void *b, size_t n );
|
||||
const char *ascii_memistr ( const void *buf, size_t buflen, const char *sub);
|
||||
void *ascii_memcasemem (const void *haystack, size_t nhaystack,
|
||||
const void *needle, size_t nneedle);
|
||||
|
||||
|
|
|
@ -136,16 +136,17 @@ get_native_charset ()
|
|||
* new allocated UTF8 string.
|
||||
*/
|
||||
char *
|
||||
native_to_utf8 (const char *string)
|
||||
native_to_utf8 (const char *orig_string)
|
||||
{
|
||||
const byte *s;
|
||||
const unsigned char *string = (const unsigned char *)orig_string;
|
||||
const unsigned char *s;
|
||||
char *buffer;
|
||||
byte *p;
|
||||
unsigned char *p;
|
||||
size_t length = 0;
|
||||
|
||||
if (no_translation)
|
||||
{
|
||||
buffer = jnlib_xstrdup (string);
|
||||
buffer = jnlib_xstrdup (orig_string);
|
||||
}
|
||||
else if (active_charset)
|
||||
{
|
||||
|
@ -156,7 +157,7 @@ native_to_utf8 (const char *string)
|
|||
length += 2; /* we may need 3 bytes */
|
||||
}
|
||||
buffer = jnlib_xmalloc (length + 1);
|
||||
for (p = buffer, s = string; *s; s++)
|
||||
for (p = (unsigned char *)buffer, s = string; *s; s++)
|
||||
{
|
||||
if ((*s & 0x80))
|
||||
{
|
||||
|
@ -187,7 +188,7 @@ native_to_utf8 (const char *string)
|
|||
length++;
|
||||
}
|
||||
buffer = jnlib_xmalloc (length + 1);
|
||||
for (p = buffer, s = string; *s; s++)
|
||||
for (p = (unsigned char *)buffer, s = string; *s; s++)
|
||||
{
|
||||
if (*s & 0x80)
|
||||
{
|
||||
|
@ -212,11 +213,12 @@ utf8_to_native (const char *string, size_t length, int delim)
|
|||
{
|
||||
int nleft;
|
||||
int i;
|
||||
byte encbuf[8];
|
||||
unsigned char encbuf[8];
|
||||
int encidx;
|
||||
const byte *s;
|
||||
size_t n;
|
||||
byte *buffer = NULL, *p = NULL;
|
||||
char *buffer = NULL;
|
||||
char *p = NULL;
|
||||
unsigned long val = 0;
|
||||
size_t slen;
|
||||
int resync = 0;
|
||||
|
@ -225,7 +227,8 @@ utf8_to_native (const char *string, size_t length, int delim)
|
|||
/* 2. pass (p!=NULL): create string */
|
||||
for (;;)
|
||||
{
|
||||
for (slen = length, nleft = encidx = 0, n = 0, s = string; slen;
|
||||
for (slen = length, nleft = encidx = 0, n = 0,
|
||||
s = (const unsigned char *)string; slen;
|
||||
s++, slen--)
|
||||
{
|
||||
if (resync)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue