diff options
-rw-r--r-- | ChangeLog | 15 | ||||
-rw-r--r-- | etc.c | 50 | ||||
-rw-r--r-- | indep.c | 46 | ||||
-rw-r--r-- | indep.h | 9 |
4 files changed, 68 insertions, 52 deletions
@@ -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 @@ -3469,4 +3482,4 @@ * release-0-2-1 * import w3m-0.2.1 -$Id: ChangeLog,v 1.385 2002/06/05 15:42:10 ukai Exp $ +$Id: ChangeLog,v 1.386 2002/06/07 15:46:44 ukai Exp $ @@ -1,4 +1,4 @@ -/* $Id: etc.c,v 1.21 2002/03/07 16:10:22 ukai Exp $ */ +/* $Id: etc.c,v 1.22 2002/06/07 15:46:44 ukai Exp $ */ #include "fm.h" #include <pwd.h> #include "myctype.h" @@ -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) { @@ -1,4 +1,4 @@ -/* $Id: indep.c,v 1.21 2001/12/26 17:57:57 ukai Exp $ */ +/* $Id: indep.c,v 1.22 2002/06/07 15:46:44 ukai Exp $ */ #include "fm.h" #include <stdio.h> #include <pwd.h> @@ -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 * @@ -1,4 +1,4 @@ -/* $Id: indep.h,v 1.7 2001/11/27 18:29:24 ukai Exp $ */ +/* $Id: indep.h,v 1.8 2002/06/07 15:46:44 ukai Exp $ */ #ifndef INDEP_H #define INDEP_H #include "gc.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 |