From: Pietro Cerutti Date: Tue, 24 Jan 2017 11:35:58 +0000 (+0000) Subject: Remove most ascii_ functions X-Git-Tag: neomutt-20170128~5^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8e589618d85767e692fd93dc57dc1f221bdc3cf7;p=neomutt Remove most ascii_ functions Issue: #325 --- diff --git a/ascii.c b/ascii.c index 45f7e5d09..abc8f6c6c 100644 --- a/ascii.c +++ b/ascii.c @@ -34,32 +34,6 @@ #include #include "ascii.h" -inline int ascii_isupper (int c) -{ - return (c >= 'A') && (c <= 'Z'); -} - -inline int ascii_islower (int c) -{ - return (c >= 'a') && (c <= 'z'); -} - -inline int ascii_toupper (int c) -{ - if (ascii_islower (c)) - return c & ~32; - - return c; -} - -inline int ascii_tolower (int c) -{ - if (ascii_isupper (c)) - return c | 32; - - return c; -} - int ascii_strcasecmp (const char *a, const char *b) { int i; @@ -73,7 +47,7 @@ int ascii_strcasecmp (const char *a, const char *b) for (;; a++, b++) { - if ((i = ascii_tolower (*a) - ascii_tolower (*b))) + if ((i = tolower (*a) - tolower (*b))) return i; /* test for NUL here rather that in the for loop in order to detect unqual * length strings (see http://dev.mutt.org/trac/ticket/3601) @@ -98,7 +72,7 @@ int ascii_strncasecmp (const char *a, const char *b, int n) for (j = 0; (*a || *b) && j < n; a++, b++, j++) { - if ((i = ascii_tolower (*a) - ascii_tolower (*b))) + if ((i = tolower (*a) - tolower (*b))) return i; } diff --git a/ascii.h b/ascii.h index a4aad7484..35ee2b60f 100644 --- a/ascii.h +++ b/ascii.h @@ -29,10 +29,8 @@ #ifndef _ASCII_H # define _ASCII_H -int ascii_isupper (int c); -int ascii_islower (int c); -int ascii_toupper (int c); -int ascii_tolower (int c); +#include + int ascii_strcasecmp (const char *a, const char *b); int ascii_strncasecmp (const char *a, const char *b, int n); @@ -43,10 +41,9 @@ static inline char* ascii_strlower (char *s) { char *p = s; - while (*p) + for (; *p; ++p) { - *p = ascii_tolower ((unsigned int) *p); - p++; + *p = tolower (*p); } return s; diff --git a/charset.c b/charset.c index 2411f2cb4..2f2e9bfe2 100644 --- a/charset.c +++ b/charset.c @@ -281,7 +281,7 @@ void mutt_canonical_charset (char *dest, size_t dlen, const char *name) /* for cosmetics' sake, transform to lowercase. */ for (p = dest; *p; p++) - *p = ascii_tolower (*p); + *p = tolower (*p); out: if (ext && *ext) diff --git a/crypt-gpgme.c b/crypt-gpgme.c index 1c543a58d..c783cbb91 100644 --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -2774,7 +2774,7 @@ static const char *crypt_entry_fmt (char *dest, kflags = (key->flags /*| (pkey->flags & KEYFLAG_RESTRICTIONS) | uid->flags*/); - switch (ascii_tolower (op)) + switch (tolower (op)) { case '[': { diff --git a/edit.c b/edit.c index 823a0165d..df6ae460f 100644 --- a/edit.c +++ b/edit.c @@ -384,8 +384,8 @@ int mutt_builtin_editor (const char *path, HEADER *msg, HEADER *cur) cur->msgno + 1); } buf = be_include_messages (p, buf, &bufmax, &buflen, - (ascii_tolower (tmp[1]) == 'm'), - (ascii_isupper ((unsigned char) tmp[1]))); + (tolower (tmp[1]) == 'm'), + (isupper ((unsigned char) tmp[1]))); } else addstr (_("No mailbox.\n")); diff --git a/keymap.c b/keymap.c index 8daa970e6..1cc26e8f3 100644 --- a/keymap.c +++ b/keymap.c @@ -144,7 +144,7 @@ static int parse_fkey(char *s) char *t; int n = 0; - if(s[0] != '<' || ascii_tolower(s[1]) != 'f') + if(s[0] != '<' || tolower(s[1]) != 'f') return -1; for(t = s + 2; *t && isdigit((unsigned char) *t); t++) diff --git a/nntp.c b/nntp.c index 85d27b49c..7461b2e1e 100644 --- a/nntp.c +++ b/nntp.c @@ -338,7 +338,7 @@ static int nntp_auth (NNTP_SERVER *nserv) p = authenticators; while (*p) { - *p = ascii_toupper (*p); + *p = toupper (*p); p++; } diff --git a/parse.c b/parse.c index 2947c9a34..b9d0356f8 100644 --- a/parse.c +++ b/parse.c @@ -986,7 +986,7 @@ int mutt_parse_rfc822_line (ENVELOPE *e, HEADER *hdr, char *line, char *p, short if (lastp) last = *lastp; - switch (ascii_tolower (line[0])) + switch (tolower (line[0])) { case 'a': if (ascii_strcasecmp (line+1, "pparently-to") == 0) diff --git a/pgpkey.c b/pgpkey.c index 36a92ae2c..21d991cec 100644 --- a/pgpkey.c +++ b/pgpkey.c @@ -149,7 +149,7 @@ static const char *pgp_entry_fmt (char *dest, kflags = key->flags | (pkey->flags & KEYFLAG_RESTRICTIONS) | uid->flags; - switch (ascii_tolower (op)) + switch (tolower (op)) { case '[': diff --git a/url.c b/url.c index eff1b1e67..2e2ee10d6 100644 --- a/url.c +++ b/url.c @@ -92,7 +92,7 @@ url_scheme_t url_check_scheme (const char *s) strfcpy (sbuf, s, t - s + 1); for (t = sbuf; *t; t++) - *t = ascii_tolower (*t); + *t = tolower (*t); if ((i = mutt_getvaluebyname (sbuf, UrlMap)) == -1) return U_UNKNOWN;