From: Adam Dickmeiss Date: Tue, 21 Oct 2008 14:39:13 +0000 (+0200) Subject: Ensure we're using unsigned char's ptrs for ctype functions. X-Git-Tag: v1.1.0~81^2~3 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;h=49088b6680bed3c069be10ff0cb7cc16f3733729;p=pazpar2-moved-to-github.git Ensure we're using unsigned char's ptrs for ctype functions. Ensure we're using unsigned char's ptrs for ctype functions. If not, Pazpar2 will crash on Windows. This commit also removes ctype.h includes from source where it's not needed. --- diff --git a/src/charsets.c b/src/charsets.c index b2470bd..35dd611 100644 --- a/src/charsets.c +++ b/src/charsets.c @@ -182,7 +182,7 @@ static const char *pp2_relevance_token_a_to_z(pp2_relevance_token_t prt) int c; /* skip white space */ - while (*cp && (c = raw_char(tolower(*cp))) < 0) + while (*cp && (c = raw_char(tolower(*(const unsigned char *)cp))) < 0) cp++; if (*cp == '\0') { diff --git a/src/client.c b/src/client.c index edb5156..0a8860d 100644 --- a/src/client.c +++ b/src/client.c @@ -35,7 +35,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #endif #include -#include #include #include diff --git a/src/connection.c b/src/connection.c index c93e182..fac727b 100644 --- a/src/connection.c +++ b/src/connection.c @@ -36,7 +36,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #endif #include -#include #include #include diff --git a/src/dirent.c b/src/dirent.c index 6daba7e..a543bf9 100644 --- a/src/dirent.c +++ b/src/dirent.c @@ -24,7 +24,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #endif -#include #include #ifdef WIN32 #include diff --git a/src/http.c b/src/http.c index 2ad82ce..474401d 100644 --- a/src/http.c +++ b/src/http.c @@ -351,7 +351,7 @@ static int package_check(const char *buf, int sz) while (*cp == ' ') cp++; content_len = 0; - while (*cp && isdigit(*cp)) + while (*cp && isdigit(*(const unsigned char *)cp)) content_len = content_len*10 + (*cp++ - '0'); if (content_len < 0) /* prevent negative offsets */ content_len = 0; @@ -404,7 +404,7 @@ struct http_response *http_parse_response_buf(struct http_channel *c, const char return 0; *(value++) = '\0'; h->name = nmem_strdup(c->nmem, p); - while (isspace(*value)) + while (isspace(*(const unsigned char *) value)) value++; if (value >= p2) // Empty header; { diff --git a/src/http_command.c b/src/http_command.c index 2670b26..0cc172b 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -27,7 +27,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #endif #include #include -#include #if HAVE_SYS_TIME_H #include #endif diff --git a/src/normalize7bit.c b/src/normalize7bit.c index e4efb47..6e1562a 100644 --- a/src/normalize7bit.c +++ b/src/normalize7bit.c @@ -35,8 +35,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA /** \brief removes leading whitespace.. Removes suffix cahrs in rm_chars */ char * normalize7bit_generic(char * str, const char * rm_chars) { - unsigned char *p, *pe; - for (p = str; *p && isspace(*p); p++) + char *p, *pe; + for (p = str; *p && isspace(*(unsigned char *)p); p++) ; for (pe = p + strlen(p) - 1; pe > p && strchr(rm_chars, *pe); pe--) @@ -48,18 +48,18 @@ char * normalize7bit_generic(char * str, const char * rm_chars) char * normalize7bit_mergekey(char *buf, int skiparticle) { - unsigned char *p = buf, *pout = buf; + char *p = buf, *pout = buf; if (skiparticle) { char firstword[64]; char articles[] = "the den der die des an a "; // must end in space - while (*p && !isalnum(*p)) + while (*p && !isalnum(*(unsigned char *)p)) p++; pout = firstword; while (*p && *p != ' ' && pout - firstword < 62) - *(pout++) = tolower(*(p++)); + *(pout++) = tolower(*(unsigned char *)(p++)); *(pout++) = ' '; *(pout++) = '\0'; if (!strstr(articles, firstword)) @@ -69,13 +69,13 @@ char * normalize7bit_mergekey(char *buf, int skiparticle) while (*p) { - while (*p && !isalnum(*p)) + while (*p && !isalnum(*(unsigned char *)p)) p++; - while (isalnum(*p)) - *(pout++) = tolower(*(p++)); + while (isalnum(*(unsigned char *)p)) + *(pout++) = tolower(*(unsigned char *)(p++)); if (*p) *(pout++) = ' '; - while (*p && !isalnum(*p)) + while (*p && !isalnum(*(unsigned char *)p)) p++; } if (buf != pout) diff --git a/src/relevance.c b/src/relevance.c index 86ba9ec..bb08103 100644 --- a/src/relevance.c +++ b/src/relevance.c @@ -21,7 +21,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #endif -#include #include #include diff --git a/src/termlists.c b/src/termlists.c index 00247f2..3af94df 100644 --- a/src/termlists.c +++ b/src/termlists.c @@ -23,7 +23,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include #include #include "termlists.h"