mirror of
https://github.com/openssl/openssl.git
synced 2025-03-19 19:50:42 +08:00
Remove internal functions OPENSSL_strcasecmp and OPENSSL_strncasecmp
Their only reason to exist was that they didn't exist in VMS before version 7.0. We do not support such old versions any more. However, for the benefit of systems that don't get strings.h included by string.h, we include the former in e_os.h. RT#4458 Reviewed-by: Viktor Dukhovni <viktor@openssl.org>
This commit is contained in:
parent
90edbfcce3
commit
7233bea263
@ -14,49 +14,6 @@
|
||||
#include "internal/cryptlib.h"
|
||||
#include "internal/o_str.h"
|
||||
|
||||
#if !defined(OPENSSL_IMPLEMENTS_strncasecmp) && \
|
||||
!defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_WINCE) && \
|
||||
!defined(NETWARE_CLIB)
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
int OPENSSL_strncasecmp(const char *str1, const char *str2, size_t n)
|
||||
{
|
||||
#if defined(OPENSSL_IMPLEMENTS_strncasecmp)
|
||||
while (*str1 && *str2 && n) {
|
||||
int res = toupper(*str1) - toupper(*str2);
|
||||
if (res)
|
||||
return res < 0 ? -1 : 1;
|
||||
str1++;
|
||||
str2++;
|
||||
n--;
|
||||
}
|
||||
if (n == 0)
|
||||
return 0;
|
||||
if (*str1)
|
||||
return 1;
|
||||
if (*str2)
|
||||
return -1;
|
||||
return 0;
|
||||
#else
|
||||
/*
|
||||
* Recursion hazard warning! Whenever strncasecmp is #defined as
|
||||
* OPENSSL_strncasecmp, OPENSSL_IMPLEMENTS_strncasecmp must be defined as
|
||||
* well.
|
||||
*/
|
||||
return strncasecmp(str1, str2, n);
|
||||
#endif
|
||||
}
|
||||
|
||||
int OPENSSL_strcasecmp(const char *str1, const char *str2)
|
||||
{
|
||||
#if defined(OPENSSL_IMPLEMENTS_strncasecmp)
|
||||
return OPENSSL_strncasecmp(str1, str2, (size_t)-1);
|
||||
#else
|
||||
return strcasecmp(str1, str2);
|
||||
#endif
|
||||
}
|
||||
|
||||
int OPENSSL_memcmp(const void *v1, const void *v2, size_t n)
|
||||
{
|
||||
const unsigned char *c1 = v1, *c2 = v2;
|
||||
|
8
e_os.h
8
e_os.h
@ -476,12 +476,8 @@ struct servent *PASCAL getservbyname(const char *, const char *);
|
||||
# define strdup _strdup
|
||||
# define unlink _unlink
|
||||
# endif
|
||||
# elif defined(OPENSSL_SYS_VMS)
|
||||
/* VMS below version 7.0 doesn't have strcasecmp() */
|
||||
# include "internal/o_str.h"
|
||||
# define strcasecmp OPENSSL_strcasecmp
|
||||
# define strncasecmp OPENSSL_strncasecmp
|
||||
# define OPENSSL_IMPLEMENTS_strncasecmp
|
||||
# else
|
||||
# include <strings.h>
|
||||
# endif
|
||||
|
||||
/* vxworks */
|
||||
|
@ -12,8 +12,6 @@
|
||||
|
||||
# include <stddef.h> /* to get size_t */
|
||||
|
||||
int OPENSSL_strcasecmp(const char *str1, const char *str2);
|
||||
int OPENSSL_strncasecmp(const char *str1, const char *str2, size_t n);
|
||||
int OPENSSL_memcmp(const void *p1, const void *p2, size_t n);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user