w3m

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/w3m.git/
Log | Files | Refs | README

commit 0c77e08525687d1418bb8e787f1b0b1cc0df28f6
parent c2bfd56c3b9ef32d247eb3e46afd442d5591c100
Author: ukai <ukai>
Date:   Fri,  7 Jun 2002 15:46:44 +0000

[w3m-dev 03207] strchr(), strcasecmp(), and strncasecmp()
* etc.c (strchr): removed
	(strcasecmp): removed
	(strncasecmp): removed
* indep.c (strchr): moved, cast
	(strcasecmp): moved, fix the case that s1 = ""
	(strncasecmp): moved, fix the case that s1 is shorter than s2
* indep.h (strchr): added
	(strcasecmp): added
	(strncasecmp): added
From: Kiyokazu SUTO <suto@ks-and-ks.ne.jp>

Diffstat:
MChangeLog | 13+++++++++++++
Metc.c | 48------------------------------------------------
Mindep.c | 44++++++++++++++++++++++++++++++++++++++++++++
Mindep.h | 7+++++++
4 files changed, 64 insertions(+), 48 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,16 @@ +2002-06-08 Kiyokazu SUTO <suto@ks-and-ks.ne.jp> + + * [w3m-dev 03207] strchr(), strcasecmp(), and strncasecmp() + * etc.c (strchr): removed + (strcasecmp): removed + (strncasecmp): removed + * indep.c (strchr): moved, cast + (strcasecmp): moved, fix the case that s1 = "" + (strncasecmp): moved, fix the case that s1 is shorter than s2 + * indep.h (strchr): added + (strcasecmp): added + (strncasecmp): added + 2002-06-06 Fumitoshi UKAI <ukai@debian.or.jp> * [w3m-dev 03206] Re: dict diff --git a/etc.c b/etc.c @@ -25,54 +25,6 @@ #endif /* __WATT32__ */ -#ifndef HAVE_STRCHR -char * -strchr(char *s, char c) -{ - while (*s) { - if (*s == c) - return s; - s++; - } - return NULL; -} -#endif /* not HAVE_STRCHR */ - -#ifndef HAVE_STRCASECMP -int -strcasecmp(char *s1, char *s2) -{ - int x; - while (*s1) { - x = tolower(*s1) - tolower(*s2); - if (x != 0) - break; - s1++; - s2++; - } - if (x != 0) - return x; - return -tolower(*s2); -} - -int -strncasecmp(char *s1, char *s2, int n) -{ - int x; - while (*s1 && n) { - x = tolower(*s1) - tolower(*s2); - if (x != 0) - break; - s1++; - s2++; - n--; - } - if (x != 0) - return x; - return 0; -} -#endif /* not HAVE_STRCASECMP */ - int columnSkip(Buffer *buf, int offset) { diff --git a/indep.c b/indep.c @@ -193,6 +193,50 @@ expandPath(char *name) return extpath->ptr; } +#ifndef HAVE_STRCHR +char * +strchr(const char *s, int c) +{ + while (*s) { + if ((unsigned char)*s == c) + return (char *)s; + s++; + } + return NULL; +} +#endif /* not HAVE_STRCHR */ + +#ifndef HAVE_STRCASECMP +int +strcasecmp(const char *s1, const char *s2) +{ + int x; + while (*s1) { + x = tolower(*s1) - tolower(*s2); + if (x != 0) + return x; + s1++; + s2++; + } + return -tolower(*s2); +} + +int +strncasecmp(const char *s1, const char *s2, size_t n) +{ + int x; + while (*s1 && n) { + x = tolower(*s1) - tolower(*s2); + if (x != 0) + return x; + s1++; + s2++; + n--; + } + return n ? -tolower(*s2) : 0; +} +#endif /* not HAVE_STRCASECMP */ + #ifndef HAVE_STRCASESTR /* string search using the simplest algorithm */ char * diff --git a/indep.h b/indep.h @@ -24,6 +24,13 @@ extern int strCmp(const void *s1, const void *s2); extern char *currentdir(void); extern char *cleanupName(char *name); extern char *expandPath(char *name); +#ifndef HAVE_STRCHR +extern char *strchr(const char *s, int c); +#endif /* not HAVE_STRCHR */ +#ifndef HAVE_STRCASECMP +extern int strcasecmp(const char *s1, const char *s2); +extern int strncasecmp(const char *s1, const char *s2, size_t n); +#endif /* not HAVE_STRCASECMP */ #ifndef HAVE_STRCASESTR extern char *strcasestr(const char *s1, const char *s2); #endif