2001-05-05 05:02:15 +08:00
|
|
|
/* string.h: Extra string defs
|
|
|
|
|
|
|
|
This file is part of Cygwin.
|
|
|
|
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
|
|
details. */
|
|
|
|
|
|
|
|
#ifndef _CYGWIN_STRING_H
|
|
|
|
#define _CYGWIN_STRING_H
|
|
|
|
|
|
|
|
#include_next <string.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2012-10-27 20:09:38 +08:00
|
|
|
#undef strchrnul
|
|
|
|
#define strchrnul cygwin_strchrnul
|
2003-01-27 08:16:01 +08:00
|
|
|
static inline __stdcall char *
|
2012-10-27 20:09:38 +08:00
|
|
|
strchrnul (const char *s, int c)
|
2003-01-27 08:16:01 +08:00
|
|
|
{
|
2012-10-27 04:00:12 +08:00
|
|
|
while (*s != (char) c && *s != 0)
|
|
|
|
++s;
|
|
|
|
return (char *) s;
|
2003-01-27 08:16:01 +08:00
|
|
|
}
|
|
|
|
|
2007-12-13 18:33:55 +08:00
|
|
|
#ifdef __INSIDE_CYGWIN__
|
|
|
|
|
2002-10-31 05:05:18 +08:00
|
|
|
extern const char isalpha_array[];
|
|
|
|
|
|
|
|
static inline int
|
2008-02-01 20:37:51 +08:00
|
|
|
ascii_strcasematch (const char *cs, const char *ct)
|
2002-10-31 05:05:18 +08:00
|
|
|
{
|
2021-08-27 04:14:11 +08:00
|
|
|
const unsigned char *us, *ut;
|
2012-10-27 04:00:12 +08:00
|
|
|
|
|
|
|
us = (const unsigned char *) cs;
|
|
|
|
ut = (const unsigned char *) ct;
|
|
|
|
|
|
|
|
while (us[0] == ut[0] || (us[0] ^ isalpha_array[us[0]]) == ut[0])
|
|
|
|
{
|
|
|
|
if (us[0] == 0)
|
|
|
|
return 1;
|
|
|
|
++us, ++ut;
|
|
|
|
}
|
|
|
|
return 0;
|
2002-10-31 05:05:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
2008-02-01 20:37:51 +08:00
|
|
|
ascii_strncasematch (const char *cs, const char *ct, size_t n)
|
2002-10-31 05:05:18 +08:00
|
|
|
{
|
2021-08-27 04:14:11 +08:00
|
|
|
const unsigned char *us, *ut;
|
2012-10-27 04:00:12 +08:00
|
|
|
|
|
|
|
if (!n)
|
|
|
|
return 1;
|
|
|
|
us = (const unsigned char *) cs;
|
|
|
|
ut = (const unsigned char *) ct;
|
|
|
|
|
|
|
|
while (us[0] == ut[0] || (us[0] ^ isalpha_array[us[0]]) == ut[0])
|
|
|
|
{
|
|
|
|
--n;
|
|
|
|
if (!n || us[0] == 0)
|
|
|
|
return 1;
|
|
|
|
++us, ++ut;
|
|
|
|
}
|
|
|
|
return 0;
|
2002-10-31 05:05:18 +08:00
|
|
|
}
|
2008-02-01 20:37:51 +08:00
|
|
|
|
2007-12-12 20:12:24 +08:00
|
|
|
#undef strcasecmp
|
|
|
|
#define strcasecmp cygwin_strcasecmp
|
|
|
|
int __stdcall cygwin_strcasecmp (const char *, const char *);
|
|
|
|
|
|
|
|
#undef strncasecmp
|
|
|
|
#define strncasecmp cygwin_strncasecmp
|
|
|
|
int __stdcall cygwin_strncasecmp (const char *, const char *, size_t);
|
|
|
|
|
|
|
|
#define strcasematch(s1,s2) (!cygwin_strcasecmp ((s1),(s2)))
|
|
|
|
#define strncasematch(s1,s2,n) (!cygwin_strncasecmp ((s1),(s2),(n)))
|
|
|
|
|
2014-08-19 02:24:06 +08:00
|
|
|
char *strlwr (char *);
|
|
|
|
char *strupr (char *);
|
2002-10-31 05:05:18 +08:00
|
|
|
|
2007-12-13 18:33:55 +08:00
|
|
|
#endif /* __INSIDE_CYGWIN__ */
|
|
|
|
|
2013-11-25 19:38:08 +08:00
|
|
|
char *__stdcall strccpy (char *__restrict s1, const char **__restrict s2,
|
|
|
|
char c);
|
2011-01-19 17:41:54 +08:00
|
|
|
|
2001-05-05 05:02:15 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2007-12-13 18:33:55 +08:00
|
|
|
|
2001-05-05 05:02:15 +08:00
|
|
|
#endif /* _CYGWIN_STRING_H */
|