mirror of
git://git.gnupg.org/gnupg.git
synced 2025-03-28 22:49:59 +01:00
Move some ascii_foo functions to libcompat
This commit is contained in:
parent
ebdcac8089
commit
20af3fea15
@ -1,3 +1,8 @@
|
|||||||
|
2007-04-16 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
|
* util.h (ascii_toupper, ascii_tolower, ascii_strcasecmp,
|
||||||
|
ascii_strncasecmp): Move functions to compat.h.
|
||||||
|
|
||||||
2006-12-11 Werner Koch <wk@g10code.com>
|
2006-12-11 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
* mpi.h (mpi_is_neg, mpi_get_nlimbs): Replaced macros by function
|
* mpi.h (mpi_is_neg, mpi_get_nlimbs): Replaced macros by function
|
||||||
|
@ -6,6 +6,10 @@
|
|||||||
#define ascii_isspace(a) ((a)==' ' || (a)=='\n' || (a)=='\r' || (a)=='\t')
|
#define ascii_isspace(a) ((a)==' ' || (a)=='\n' || (a)=='\r' || (a)=='\t')
|
||||||
|
|
||||||
int hextobyte( const char *s );
|
int hextobyte( const char *s );
|
||||||
|
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);
|
||||||
|
|
||||||
#ifndef HAVE_STRSEP
|
#ifndef HAVE_STRSEP
|
||||||
char *strsep (char **stringp, const char *delim);
|
char *strsep (char **stringp, const char *delim);
|
||||||
|
@ -194,10 +194,6 @@ int check_utf8_string( const char *string );
|
|||||||
|
|
||||||
int ascii_isupper (int c);
|
int ascii_isupper (int c);
|
||||||
int ascii_islower (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);
|
int ascii_memcasecmp( const char *a, const char *b, size_t n);
|
||||||
|
|
||||||
#ifndef HAVE_STPCPY
|
#ifndef HAVE_STPCPY
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
2007-04-16 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
|
* strgutil.c (ascii_toupper, ascii_tolower, ascii_strcasecmp,
|
||||||
|
ascii_strncasecmp): Move functions to compat.c.
|
||||||
|
|
||||||
2007-04-16 Werner Koch <wk@g10code.com>
|
2007-04-16 Werner Koch <wk@g10code.com>
|
||||||
|
|
||||||
* secmem.c (init_pool): Avoid assigning a negative value to a
|
* secmem.c (init_pool): Avoid assigning a negative value to a
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
hextobyte (const char *s)
|
hextobyte (const char *s)
|
||||||
{
|
{
|
||||||
@ -22,3 +24,71 @@ hextobyte (const char *s)
|
|||||||
return -1;
|
return -1;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ascii_toupper (int c)
|
||||||
|
{
|
||||||
|
if (c >= 'a' && c <= 'z')
|
||||||
|
c &= ~0x20;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ascii_tolower (int c)
|
||||||
|
{
|
||||||
|
if (c >= 'A' && c <= 'Z')
|
||||||
|
c |= 0x20;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ascii_strcasecmp (const char *a, const char *b)
|
||||||
|
{
|
||||||
|
const unsigned char *p1 = (const unsigned char *)a;
|
||||||
|
const unsigned char *p2 = (const unsigned char *)b;
|
||||||
|
unsigned char c1, c2;
|
||||||
|
|
||||||
|
if (p1 == p2)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
c1 = ascii_tolower (*p1);
|
||||||
|
c2 = ascii_tolower (*p2);
|
||||||
|
|
||||||
|
if (c1 == '\0')
|
||||||
|
break;
|
||||||
|
|
||||||
|
++p1;
|
||||||
|
++p2;
|
||||||
|
}
|
||||||
|
while (c1 == c2);
|
||||||
|
|
||||||
|
return c1 - c2;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ascii_strncasecmp (const char *a, const char *b, size_t n)
|
||||||
|
{
|
||||||
|
const unsigned char *p1 = (const unsigned char *)a;
|
||||||
|
const unsigned char *p2 = (const unsigned char *)b;
|
||||||
|
unsigned char c1, c2;
|
||||||
|
|
||||||
|
if (p1 == p2 || !n )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
c1 = ascii_tolower (*p1);
|
||||||
|
c2 = ascii_tolower (*p2);
|
||||||
|
|
||||||
|
if ( !--n || c1 == '\0')
|
||||||
|
break;
|
||||||
|
|
||||||
|
++p1;
|
||||||
|
++p2;
|
||||||
|
}
|
||||||
|
while (c1 == c2);
|
||||||
|
|
||||||
|
return c1 - c2;
|
||||||
|
}
|
||||||
|
@ -1058,76 +1058,6 @@ ascii_islower (int c)
|
|||||||
return c >= 'a' && c <= 'z';
|
return c >= 'a' && c <= 'z';
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
ascii_toupper (int c)
|
|
||||||
{
|
|
||||||
if (c >= 'a' && c <= 'z')
|
|
||||||
c &= ~0x20;
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
ascii_tolower (int c)
|
|
||||||
{
|
|
||||||
if (c >= 'A' && c <= 'Z')
|
|
||||||
c |= 0x20;
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int
|
|
||||||
ascii_strcasecmp (const char *a, const char *b)
|
|
||||||
{
|
|
||||||
const unsigned char *p1 = (const unsigned char *)a;
|
|
||||||
const unsigned char *p2 = (const unsigned char *)b;
|
|
||||||
unsigned char c1, c2;
|
|
||||||
|
|
||||||
if (p1 == p2)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c1 = ascii_tolower (*p1);
|
|
||||||
c2 = ascii_tolower (*p2);
|
|
||||||
|
|
||||||
if (c1 == '\0')
|
|
||||||
break;
|
|
||||||
|
|
||||||
++p1;
|
|
||||||
++p2;
|
|
||||||
}
|
|
||||||
while (c1 == c2);
|
|
||||||
|
|
||||||
return c1 - c2;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
ascii_strncasecmp (const char *a, const char *b, size_t n)
|
|
||||||
{
|
|
||||||
const unsigned char *p1 = (const unsigned char *)a;
|
|
||||||
const unsigned char *p2 = (const unsigned char *)b;
|
|
||||||
unsigned char c1, c2;
|
|
||||||
|
|
||||||
if (p1 == p2 || !n )
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
c1 = ascii_tolower (*p1);
|
|
||||||
c2 = ascii_tolower (*p2);
|
|
||||||
|
|
||||||
if ( !--n || c1 == '\0')
|
|
||||||
break;
|
|
||||||
|
|
||||||
++p1;
|
|
||||||
++p2;
|
|
||||||
}
|
|
||||||
while (c1 == c2);
|
|
||||||
|
|
||||||
return c1 - c2;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
ascii_memcasecmp( const char *a, const char *b, size_t n )
|
ascii_memcasecmp( const char *a, const char *b, size_t n )
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user