w3m

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

commit 51dba641d878aefb1a12a9ede707dddfd1544108
parent 1a9c4fb250d4f44d8283ce2a1c1004d348ae9f33
Author: ukai <ukai>
Date:   Tue, 24 Dec 2002 17:20:45 +0000

[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:
MChangeLog | 35+++++++++++++++++++++++++++++++++++
MStr.c | 4++--
Mbackend.c | 1-
Metc.c | 9++++++---
Mfile.c | 6+++---
Mftp.c | 1-
Mindep.c | 10+++++-----
Mistream.c | 7++++---
Mmailcap.c | 4++--
Mmain.c | 2+-
Mmenu.c | 4++--
Mmimehead.c | 5++---
Mmktable.c | 6+++---
Mmyctype.h | 5+++--
Mparsetagx.c | 6++++--
Mrc.c | 8++++----
Mregex.c | 23++++++++++++-----------
17 files changed, 88 insertions(+), 48 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -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) diff --git a/Str.c b/Str.c @@ -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 diff --git a/backend.c b/backend.c @@ -2,7 +2,6 @@ #include <stdio.h> #include <string.h> #include <sys/types.h> -#include <ctype.h> #include "fm.h" #include "gc.h" #include "terms.h" diff --git a/etc.c b/etc.c @@ -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 */ diff --git a/file.c b/file.c @@ -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) diff --git a/ftp.c b/ftp.c @@ -2,7 +2,6 @@ #include <stdio.h> #include <pwd.h> #include <Str.h> -#include <ctype.h> #include <signal.h> #include <setjmp.h> #include <time.h> diff --git a/indep.c b/indep.c @@ -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++; diff --git a/istream.c b/istream.c @@ -1,5 +1,6 @@ /* $Id$ */ #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); } diff --git a/mailcap.c b/mailcap.c @@ -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++; diff --git a/main.c b/main.c @@ -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; } diff --git a/menu.c b/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; } diff --git a/mimehead.c b/mimehead.c @@ -4,6 +4,7 @@ */ #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: diff --git a/mktable.c b/mktable.c @@ -1,7 +1,7 @@ /* $Id$ */ #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++; diff --git a/myctype.h b/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 @@ -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++; diff --git a/rc.c b/rc.c @@ -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': diff --git a/regex.c b/regex.c @@ -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; }