diff options
author | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-12-24 17:20:45 +0000 |
---|---|---|
committer | Fumitoshi UKAI <ukai@debian.or.jp> | 2002-12-24 17:20:45 +0000 |
commit | 4ca69fff36ed4c9013f8ba74eeb47fea71b7121b (patch) | |
tree | f20970c6c6c73feb448ebdcd663792a4e8d49f96 | |
parent | mimehead.c (decodeWord): don't use toupper() (requires ctype.h) (diff) | |
download | w3m-4ca69fff36ed4c9013f8ba74eeb47fea71b7121b.tar.gz w3m-4ca69fff36ed4c9013f8ba74eeb47fea71b7121b.zip |
[w3m-dev 03595] tolower, toupper
* Str.c (Strlower): TOLOWER
(Strupper): TOUPPER
* backend.c: delete ctype.h
* etc.c (gethtmlcmd): TOLOWER
* file.c (readHeader): TOLOWER
(checkOverWrite): TOLOWER
(guess_charset): TOLOWER
* ftp.c: delete ctype.h
* indep.c (strcasecmp): TOLOWER
(strncasecmp): TOLOWER
(strcasematch): TOLOWER
* istream.c: include myctype.h
(ssl_get_certificate): TOLOWER
* mailcap.c (mailcapMatch): TOLOWER
* main.c (_quitfm): TOLOWER
* menu.c (accesskey_menu): TOLOWER
* mimehead.c: include myctype.h
(decodeWord): TOUPPER
* mktable.c: delete ctype.h, include myctype.h
(main): IS_SPACE
* myctype.h: delete ctype.h
(TOLOWER): added
(TOUPPER): added
* parsetagx.c (parse_tag): TOLOWER
* rc.c (str_to_bool): TOLOWER
(str_to_color): TOLOWER
* regex.c: delete ctype.h, include myctype.h
(TOLOWER): added
(TOUPPER): added
(regmatch1): TOLOWER
(matchWhich): TOLOWER, TOUPPER
From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
Diffstat (limited to '')
-rw-r--r-- | ChangeLog | 37 | ||||
-rw-r--r-- | Str.c | 6 | ||||
-rw-r--r-- | backend.c | 3 | ||||
-rw-r--r-- | etc.c | 11 | ||||
-rw-r--r-- | file.c | 8 | ||||
-rw-r--r-- | ftp.c | 3 | ||||
-rw-r--r-- | indep.c | 12 | ||||
-rw-r--r-- | istream.c | 9 | ||||
-rw-r--r-- | mailcap.c | 6 | ||||
-rw-r--r-- | main.c | 4 | ||||
-rw-r--r-- | menu.c | 6 | ||||
-rw-r--r-- | mimehead.c | 7 | ||||
-rw-r--r-- | mktable.c | 8 | ||||
-rw-r--r-- | myctype.h | 7 | ||||
-rw-r--r-- | parsetagx.c | 8 | ||||
-rw-r--r-- | rc.c | 10 | ||||
-rw-r--r-- | regex.c | 25 |
17 files changed, 105 insertions, 65 deletions
@@ -1,3 +1,38 @@ +2002-12-25 Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> + + * [w3m-dev 03595] tolower, toupper + * Str.c (Strlower): TOLOWER + (Strupper): TOUPPER + * backend.c: delete ctype.h + * etc.c (gethtmlcmd): TOLOWER + * file.c (readHeader): TOLOWER + (checkOverWrite): TOLOWER + (guess_charset): TOLOWER + * ftp.c: delete ctype.h + * indep.c (strcasecmp): TOLOWER + (strncasecmp): TOLOWER + (strcasematch): TOLOWER + * istream.c: include myctype.h + (ssl_get_certificate): TOLOWER + * mailcap.c (mailcapMatch): TOLOWER + * main.c (_quitfm): TOLOWER + * menu.c (accesskey_menu): TOLOWER + * mimehead.c: include myctype.h + (decodeWord): TOUPPER + * mktable.c: delete ctype.h, include myctype.h + (main): IS_SPACE + * myctype.h: delete ctype.h + (TOLOWER): added + (TOUPPER): added + * parsetagx.c (parse_tag): TOLOWER + * rc.c (str_to_bool): TOLOWER + (str_to_color): TOLOWER + * regex.c: delete ctype.h, include myctype.h + (TOLOWER): added + (TOUPPER): added + (regmatch1): TOLOWER + (matchWhich): TOLOWER, TOUPPER + 2002-12-22 Fumitoshi UKAI <ukai@debian.or.jp> * mimehead.c (decodeWord): don't use toupper() (requires ctype.h) @@ -6009,4 +6044,4 @@ a * [w3m-dev 03276] compile error on EWS4800 * release-0-2-1 * import w3m-0.2.1 -$Id: ChangeLog,v 1.641 2002/12/22 14:26:34 ukai Exp $ +$Id: ChangeLog,v 1.642 2002/12/24 17:20:45 ukai Exp $ @@ -1,4 +1,4 @@ -/* $Id: Str.c,v 1.7 2001/12/21 21:37:12 ukai Exp $ */ +/* $Id: Str.c,v 1.8 2002/12/24 17:20:46 ukai Exp $ */ /* * String manipulation library for Boehm GC * @@ -262,7 +262,7 @@ Strlower(Str s) int i; STR_LENGTH_CHECK(s); for (i = 0; i < s->length; i++) - s->ptr[i] = tolower(s->ptr[i]); + s->ptr[i] = TOLOWER(s->ptr[i]); } void @@ -271,7 +271,7 @@ Strupper(Str s) int i; STR_LENGTH_CHECK(s); for (i = 0; i < s->length; i++) - s->ptr[i] = toupper(s->ptr[i]); + s->ptr[i] = TOUPPER(s->ptr[i]); } void @@ -1,8 +1,7 @@ -/* $Id: backend.c,v 1.9 2002/02/03 15:25:45 ukai Exp $ */ +/* $Id: backend.c,v 1.10 2002/12/24 17:20:46 ukai Exp $ */ #include <stdio.h> #include <string.h> #include <sys/types.h> -#include <ctype.h> #include "fm.h" #include "gc.h" #include "terms.h" @@ -1,4 +1,4 @@ -/* $Id: etc.c,v 1.43 2002/12/14 15:18:38 ukai Exp $ */ +/* $Id: etc.c,v 1.44 2002/12/24 17:20:46 ukai Exp $ */ #include "fm.h" #include <pwd.h> #include "myctype.h" @@ -134,14 +134,17 @@ gethtmlcmd(char **s) (*s)++; /* first character */ - if (IS_ALNUM(**s) || **s == '_' || **s == '/') - *(p++) = tolower(*((*s)++)); + if (IS_ALNUM(**s) || **s == '_' || **s == '/') { + *(p++) = TOLOWER(**s); + (*s)++; + } else return HTML_UNKNOWN; if (p[-1] == '/') SKIP_BLANKS(*s); while ((IS_ALNUM(**s) || **s == '_') && p - cmdstr < MAX_CMD_LEN) { - *(p++) = tolower(*((*s)++)); + *(p++) = TOLOWER(**s); + (*s)++; } if (p - cmdstr == MAX_CMD_LEN) { /* buffer overflow: perhaps caused by bad HTML source */ @@ -1,4 +1,4 @@ -/* $Id: file.c,v 1.168 2002/12/21 16:19:33 ukai Exp $ */ +/* $Id: file.c,v 1.169 2002/12/24 17:20:46 ukai Exp $ */ #include "fm.h" #include <sys/types.h> #include "myctype.h" @@ -826,7 +826,7 @@ readHeader(URLFile *uf, Buffer *newBuf, int thru, ParsedURL *pu) Strcat_charp(msg, " (y/n)"); ans = inputAnswer(msg->ptr); } - if (ans == NULL || tolower(*ans) != 'y' || + if (ans == NULL || TOLOWER(*ans) != 'y' || (err = add_cookie(pu, name, value, expires, domain, path, flag | COO_OVERRIDE, comment, version, @@ -7661,7 +7661,7 @@ checkOverWrite(char *path) if (stat(path, &st) < 0) return 0; ans = inputAnswer("File exists. Overwrite? (y/n)"); - if (ans && tolower(*ans) == 'y') + if (ans && TOLOWER(*ans) == 'y') return 0; else return -1; @@ -7871,7 +7871,7 @@ guess_charset(char *p) p += 2; while (*p != '\0') { if (*p != '-' && *p != '_') - Strcat_char(c, tolower(*p)); + Strcat_char(c, TOLOWER(*p)); p++; } if (strncmp(c->ptr, "euc", 3) == 0) @@ -1,8 +1,7 @@ -/* $Id: ftp.c,v 1.19 2002/12/19 15:29:05 ukai Exp $ */ +/* $Id: ftp.c,v 1.20 2002/12/24 17:20:47 ukai Exp $ */ #include <stdio.h> #include <pwd.h> #include <Str.h> -#include <ctype.h> #include <signal.h> #include <setjmp.h> #include <time.h> @@ -1,4 +1,4 @@ -/* $Id: indep.c,v 1.26 2002/12/09 15:24:04 ukai Exp $ */ +/* $Id: indep.c,v 1.27 2002/12/24 17:20:47 ukai Exp $ */ #include "fm.h" #include <stdio.h> #include <pwd.h> @@ -228,13 +228,13 @@ strcasecmp(const char *s1, const char *s2) { int x; while (*s1) { - x = tolower(*s1) - tolower(*s2); + x = TOLOWER(*s1) - TOLOWER(*s2); if (x != 0) return x; s1++; s2++; } - return -tolower(*s2); + return -TOLOWER(*s2); } int @@ -242,14 +242,14 @@ strncasecmp(const char *s1, const char *s2, size_t n) { int x; while (*s1 && n) { - x = tolower(*s1) - tolower(*s2); + x = TOLOWER(*s1) - TOLOWER(*s2); if (x != 0) return x; s1++; s2++; n--; } - return n ? -tolower(*s2) : 0; + return n ? -TOLOWER(*s2) : 0; } #endif /* not HAVE_STRCASECMP */ @@ -282,7 +282,7 @@ strcasematch(char *s1, char *s2) while (*s1) { if (*s2 == '\0') return 1; - x = tolower(*s1) - tolower(*s2); + x = TOLOWER(*s1) - TOLOWER(*s2); if (x != 0) break; s1++; @@ -1,5 +1,6 @@ -/* $Id: istream.c,v 1.15 2002/09/28 16:30:07 ukai Exp $ */ +/* $Id: istream.c,v 1.16 2002/12/24 17:20:47 ukai Exp $ */ #include "fm.h" +#include "myctype.h" #include "istream.h" #include <signal.h> #ifdef USE_SSL @@ -494,7 +495,7 @@ ssl_get_certificate(SSL * ssl, char *hostname) emsg = Strnew_charp("No SSL peer certificate: accept? (y/n)"); ans = inputAnswer(emsg->ptr); } - if (ans && tolower(*ans) == 'y') + if (ans && TOLOWER(*ans) == 'y') amsg = Strnew_charp ("Accept SSL session without any peer certificate"); else { @@ -527,7 +528,7 @@ ssl_get_certificate(SSL * ssl, char *hostname) emsg = Sprintf("%s: accept? (y/n)", em); ans = inputAnswer(emsg->ptr); } - if (ans && tolower(*ans) == 'y') { + if (ans && TOLOWER(*ans) == 'y') { amsg = Sprintf("Accept unsecure SSL session: " "unverified: %s", em); } @@ -553,7 +554,7 @@ ssl_get_certificate(SSL * ssl, char *hostname) Strcat_charp(ep, ": accept? (y/n)"); ans = inputAnswer(ep->ptr); } - if (ans && tolower(*ans) == 'y') { + if (ans && TOLOWER(*ans) == 'y') { amsg = Strnew_charp("Accept unsecure SSL session:"); Strcat(amsg, emsg); } @@ -1,4 +1,4 @@ -/* $Id: mailcap.c,v 1.10 2002/01/05 16:13:27 ukai Exp $ */ +/* $Id: mailcap.c,v 1.11 2002/12/24 17:20:47 ukai Exp $ */ #include "fm.h" #include "myctype.h" #include <stdio.h> @@ -21,7 +21,7 @@ mailcapMatch(struct mailcap *mcap, char *type) char *cap = mcap->type, *p; int level; for (p = cap; *p != '/'; p++) { - if (tolower(*p) != tolower(*type)) + if (TOLOWER(*p) != TOLOWER(*type)) return 0; type++; } @@ -36,7 +36,7 @@ mailcapMatch(struct mailcap *mcap, char *type) if (*p == '*') return 10 + level; while (*p) { - if (tolower(*p) != tolower(*type)) + if (TOLOWER(*p) != TOLOWER(*type)) return 0; p++; type++; @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.176 2002/12/18 16:42:31 ukai Exp $ */ +/* $Id: main.c,v 1.177 2002/12/24 17:20:47 ukai Exp $ */ #define MAINPROGRAM #include "fm.h" #include <signal.h> @@ -2259,7 +2259,7 @@ _quitfm(int confirm) "Do you want to exit w3m? (y/n)"); else if (confirm) ans = inputChar("Do you want to exit w3m? (y/n)"); - if (!(ans && tolower(*ans) == 'y')) { + if (!(ans && TOLOWER(*ans) == 'y')) { displayBuffer(Currentbuf, B_NORMAL); return; } @@ -1,4 +1,4 @@ -/* $Id: menu.c,v 1.29 2002/12/10 15:41:32 ukai Exp $ */ +/* $Id: menu.c,v 1.30 2002/12/24 17:20:47 ukai Exp $ */ /* * w3m menu.c */ @@ -1924,10 +1924,10 @@ accesskey_menu(Buffer *buf) c = ap[i]->accesskey; if (!IS_ALPHA(c) || menu.keyselect[n] >= 0) continue; - c = tolower(c); + c = TOLOWER(c); menu.keymap[(int)c] = mSelect; menu.keyselect[(int)c] = i; - c = toupper(c); + c = TOUPPER(c); menu.keymap[(int)c] = mSelect; menu.keyselect[(int)c] = i; } @@ -1,9 +1,10 @@ -/* $Id: mimehead.c,v 1.6 2002/12/22 14:26:34 ukai Exp $ */ +/* $Id: mimehead.c,v 1.7 2002/12/24 17:20:47 ukai Exp $ */ /* * MIME header support by Akinori ITO */ #include <sys/types.h> +#include "myctype.h" #include "Str.h" #define LINELEN 4096 @@ -217,13 +218,11 @@ decodeWord(char **ow) goto convert_fail; w++; p = w; - switch (method) { + switch (TOUPPER(method)) { case 'B': - case 'b': a = decodeB(&w); break; case 'Q': - case 'q': a = decodeQ(&w); break; default: @@ -1,7 +1,7 @@ -/* $Id: mktable.c,v 1.10 2002/11/12 12:41:58 ukai Exp $ */ +/* $Id: mktable.c,v 1.11 2002/12/24 17:20:47 ukai Exp $ */ #include <stdio.h> #include <stdlib.h> -#include <ctype.h> +#include "myctype.h" #include "config.h" #include "hash.h" #include "Str.h" @@ -74,11 +74,11 @@ main(int argc, char *argv[], char **envp) Strremovetrailingspaces(s); name = Strnew(); for (p = s->ptr; *p; p++) { - if (isspace(*p)) + if (IS_SPACE(*p)) break; Strcat_char(name, *p); } - while (*p && isspace(*p)) + while (*p && IS_SPACE(*p)) p++; putHash_ss(hash, name->ptr, p); n++; @@ -1,4 +1,4 @@ -/* $Id: myctype.h,v 1.4 2001/12/10 15:23:08 ukai Exp $ */ +/* $Id: myctype.h,v 1.5 2002/12/24 17:20:47 ukai Exp $ */ #ifndef _MYCTYPE_H #define _MYCTYPE_H @@ -44,8 +44,9 @@ extern unsigned char MYCTYPE_DIGITMAP[]; #define IS_KANJI(x) (GET_INTCTYPE(x) & INTCTYPE_KANJI) #define IS_LATIN1(x) (GET_INTCTYPE(x) & INTCTYPE_LATIN1) -extern unsigned char INTCTYPE_MAP[]; +#define TOLOWER(x) (IS_ALPHA(x) ? ((x)|0x20) : (x)) +#define TOUPPER(x) (IS_ALPHA(x) ? ((x)&~0x20) : (x)) -#include <ctype.h> +extern unsigned char INTCTYPE_MAP[]; #endif diff --git a/parsetagx.c b/parsetagx.c index eaaf1a9..de51801 100644 --- a/parsetagx.c +++ b/parsetagx.c @@ -1,4 +1,4 @@ -/* $Id: parsetagx.c,v 1.11 2002/12/14 15:37:56 ukai Exp $ */ +/* $Id: parsetagx.c,v 1.12 2002/12/24 17:20:48 ukai Exp $ */ #include "fm.h" #include "myctype.h" #include "indep.h" @@ -128,7 +128,8 @@ parse_tag(char **s, int internal) } while (*q && !IS_SPACE(*q) && !(tagname[0] != '/' && *q == '/') && *q != '>' && p - tagname < MAX_TAG_LEN - 1) { - *(p++) = tolower(*(q++)); + *(p++) = TOLOWER(*q); + q++; } *p = '\0'; @@ -161,7 +162,8 @@ parse_tag(char **s, int internal) p = attrname; while (*q && *q != '=' && !IS_SPACE(*q) && *q != '>' && p - attrname < MAX_TAG_LEN - 1) { - *(p++) = tolower(*(q++)); + *(p++) = TOLOWER(*q); + q++; } if (q == p) { q++; @@ -1,4 +1,4 @@ -/* $Id: rc.c,v 1.72 2002/12/18 16:42:31 ukai Exp $ */ +/* $Id: rc.c,v 1.73 2002/12/24 17:20:48 ukai Exp $ */ /* * Initialization file etc. */ @@ -991,18 +991,18 @@ str_to_bool(char *value, int old) { if (value == NULL) return 1; - switch (tolower(*value)) { + switch (TOLOWER(*value)) { case '0': case 'f': /* false */ case 'n': /* no */ case 'u': /* undef */ return 0; case 'o': - if (tolower(value[1]) == 'f') /* off */ + if (TOLOWER(value[1]) == 'f') /* off */ return 0; return 1; /* on */ case 't': - if (tolower(value[1]) == 'o') /* toggle */ + if (TOLOWER(value[1]) == 'o') /* toggle */ return !old; return 1; /* true */ case '!': @@ -1019,7 +1019,7 @@ str_to_color(char *value) { if (value == NULL) return 8; /* terminal */ - switch (tolower(*value)) { + switch (TOLOWER(*value)) { case '0': return 0; /* black */ case '1': @@ -1,4 +1,4 @@ -/* $Id: regex.c,v 1.19 2002/11/26 18:51:15 ukai Exp $ */ +/* $Id: regex.c,v 1.20 2002/12/24 17:20:48 ukai Exp $ */ /* * regex: Regular expression pattern match library * @@ -13,10 +13,10 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <ctype.h> #include <gc.h> #include "regex.h" #include "config.h" +#include "myctype.h" #ifndef NULL #define NULL 0 @@ -51,9 +51,11 @@ char *lc2c(longchar *, int); int verbose; #endif /* REGEX_DEBUG */ -#ifndef IS_ALPHA -#define IS_ALPHA(x) (!((x)&0x80) && isalpha(x)) +#ifndef IS_KANJI1 +#include <ctype.h> #define IS_KANJI1(x) ((x)&0x80) +#define TOLOWER(x) tolower(x) +#define TOUPPER(x) toupper(x) #endif #ifdef JP_CHARSET @@ -627,9 +629,8 @@ regmatch1(regexchar * re, longchar c) *re->p.pattern == c); #endif /* REGEX_DEBUG */ if (re->mode & RE_IGNCASE) { - if (*re->p.pattern < 127 && c < 127 && - IS_ALPHA(*re->p.pattern) && IS_ALPHA(c)) - return tolower(*re->p.pattern) == tolower(c); + if (*re->p.pattern < 127 && c < 127) + return TOLOWER(*re->p.pattern) == TOLOWER(c); else return *re->p.pattern == c; } @@ -659,9 +660,9 @@ matchWhich(longchar * pattern, longchar c, int igncase) ans = 1; break; } - else if (igncase && c < 127 && IS_ALPHA(c) && - ((*p <= tolower(c) && tolower(c) <= *(p + 2)) || - (*p <= toupper(c) && toupper(c) <= *(p + 2)))) { + else if (igncase && c < 127 && + ((*p <= TOLOWER(c) && TOLOWER(c) <= *(p + 2)) || + (*p <= TOUPPER(c) && TOUPPER(c) <= *(p + 2)))) { ans = 1; break; } @@ -672,8 +673,8 @@ matchWhich(longchar * pattern, longchar c, int igncase) ans = 1; break; } - else if (igncase && c < 127 && IS_ALPHA(c) && - (*p == tolower(c) || *p == toupper(c))) { + else if (igncase && c < 127 && + (*p == TOLOWER(c) || *p == TOUPPER(c))) { ans = 1; break; } |