changeset 1221:f34b803b8639

Handle signed chars. Aadded dIsspace() and dIsalnum() to dlib
author Jorge Arellano Cid <jcid@dillo.org>
date Sun, 12 Jul 2009 16:53:16 -0400
parents 15423e6f22f7
children deffd7fc6d52
files dlib/dlib.c dlib/dlib.h dpi/cookies.c dpi/file.c dpi/ftp.c src/auth.c src/colors.c src/cookies.c src/misc.c src/url.c
diffstat 10 files changed, 26 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/dlib/dlib.c	Sat Jul 11 17:19:05 2009 +0200
+++ b/dlib/dlib.c	Sun Jul 12 16:53:16 2009 -0400
@@ -124,8 +124,8 @@
    int len;
 
    if (s && *s) {
-      for (p = s; isspace(*p); ++p);
-      for (len = strlen(p); len && isspace(p[len-1]); --len);
+      for (p = s; dIsspace(*p); ++p);
+      for (len = strlen(p); len && dIsspace(p[len-1]); --len);
       if (p > s)
          memmove(s, p, len);
       s[len] = 0;
@@ -785,17 +785,17 @@
       ret = 1;
    } else if ((eq = strchr(*line, '='))) {
       /* get name */
-      for (p = *line; *p && *p != '=' && !isspace(*p); ++p);
+      for (p = *line; *p && *p != '=' && !dIsspace(*p); ++p);
       *p = 0;
       *name = *line;
 
       /* skip whitespace */
       if (p < eq)
-         for (++p; isspace(*p); ++p);
+         for (++p; dIsspace(*p); ++p);
 
       /* get value */
       if (p == eq) {
-         for (++p; isspace(*p); ++p);
+         for (++p; dIsspace(*p); ++p);
          len = strlen(p);
          if (len >= 2 && *p == '"' && p[len-1] == '"') {
             p[len-1] = 0;
--- a/dlib/dlib.h	Sat Jul 11 17:19:05 2009 +0200
+++ b/dlib/dlib.h	Sun Jul 12 16:53:16 2009 -0400
@@ -30,6 +30,10 @@
 #undef  MIN
 #define MIN(a, b)  (((a) < (b)) ? (a) : (b))
 
+/* Handle signed char */
+#define dIsspace(c) isspace((uchar_t)(c))
+#define dIsalnum(c) isalnum((uchar_t)(c))
+
 /*
  *-- Casts -------------------------------------------------------------------
  */
--- a/dpi/cookies.c	Sat Jul 11 17:19:05 2009 +0200
+++ b/dpi/cookies.c	Sun Jul 12 16:53:16 2009 -0400
@@ -838,7 +838,7 @@
          continue;
       }
       /* Skip whitespace */
-      while (isspace(*str))
+      while (dIsspace(*str))
          str++;
 
       /* Get attribute */
@@ -1262,17 +1262,17 @@
          j = 0;
 
          /* Get the domain */
-         while (line[i] != '\0' && !isspace(line[i]))
+         while (line[i] != '\0' && !dIsspace(line[i]))
             domain[j++] = line[i++];
          domain[j] = '\0';
 
          /* Skip past whitespaces */
-         while (isspace(line[i]))
+         while (dIsspace(line[i]))
             i++;
 
          /* Get the rule */
          j = 0;
-         while (line[i] != '\0' && !isspace(line[i]))
+         while (line[i] != '\0' && !dIsspace(line[i]))
             rule[j++] = line[i++];
          rule[j] = '\0';
 
--- a/dpi/file.c	Sat Jul 11 17:19:05 2009 +0200
+++ b/dpi/file.c	Sun Jul 12 16:53:16 2009 -0400
@@ -122,7 +122,7 @@
    _MSG("File_get_content_type_from_data:: Size = %d\n", Size);
 
    /* HTML try */
-   for (i = 0; i < Size && isspace(p[i]); ++i);
+   for (i = 0; i < Size && dIsspace(p[i]); ++i);
    if ((Size - i >= 5  && !dStrncasecmp(p+i, "<html", 5)) ||
        (Size - i >= 5  && !dStrncasecmp(p+i, "<head", 5)) ||
        (Size - i >= 6  && !dStrncasecmp(p+i, "<title", 6)) ||
--- a/dpi/ftp.c	Sat Jul 11 17:19:05 2009 +0200
+++ b/dpi/ftp.c	Sun Jul 12 16:53:16 2009 -0400
@@ -97,7 +97,7 @@
    size_t i, non_ascci;
 
    /* HTML try */
-   for (i = 0; i < Size && isspace(p[i]); ++i);
+   for (i = 0; i < Size && dIsspace(p[i]); ++i);
    if ((Size - i >= 5  && !dStrncasecmp(p+i, "<html", 5)) ||
        (Size - i >= 5  && !dStrncasecmp(p+i, "<head", 5)) ||
        (Size - i >= 6  && !dStrncasecmp(p+i, "<title", 6)) ||
@@ -129,7 +129,7 @@
       Size = MIN (Size, 256);
       for (i = 0; i < Size; i++) {
          ch = (uchar_t) p[i];
-         if ((ch < 32 || ch > 126) && !isspace(ch))
+         if ((ch < 32 || ch > 126) && !dIsspace(ch))
             ++non_ascci;
       }
       if (Size == 256) {
--- a/src/auth.c	Sat Jul 11 17:19:05 2009 +0200
+++ b/src/auth.c	Sun Jul 12 16:53:16 2009 -0400
@@ -91,7 +91,7 @@
 static int Auth_is_token_char(char c)
 {
    const char *invalid = "\"()<>@,;:\\[]?=/{} \t";
-   return (strchr(invalid, c) || iscntrl(c)) ? 0 : 1;
+   return (strchr(invalid, c) || iscntrl((uchar_t)c)) ? 0 : 1;
 }
 
 /*
--- a/src/colors.c	Sat Jul 11 17:19:05 2009 +0200
+++ b/src/colors.c	Sun Jul 12 16:53:16 2009 -0400
@@ -246,7 +246,7 @@
    int ret, low, mid, high, st = 1;
 
    /* skip leading spaces */
-   for (cp = subtag; isspace(*cp); cp++);
+   for (cp = subtag; dIsspace(*cp); cp++);
 
    ret_color = default_color;
    if (*cp == '#') {
--- a/src/cookies.c	Sat Jul 11 17:19:05 2009 +0200
+++ b/src/cookies.c	Sun Jul 12 16:53:16 2009 -0400
@@ -266,17 +266,17 @@
          j = 0;
 
          /* Get the domain */
-         while (line[i] != '\0' && !isspace(line[i]))
+         while (line[i] != '\0' && !dIsspace(line[i]))
             domain[j++] = line[i++];
          domain[j] = '\0';
 
          /* Skip past whitespaces */
-         while (isspace(line[i]))
+         while (dIsspace(line[i]))
             i++;
 
          /* Get the rule */
          j = 0;
-         while (line[i] != '\0' && !isspace(line[i]))
+         while (line[i] != '\0' && !dIsspace(line[i]))
             rule[j++] = line[i++];
          rule[j] = '\0';
 
--- a/src/misc.c	Sat Jul 11 17:19:05 2009 +0200
+++ b/src/misc.c	Sun Jul 12 16:53:16 2009 -0400
@@ -128,7 +128,7 @@
    DetectedContentType Type = DT_OCTET_STREAM; /* default to binary */
 
    /* HTML try */
-   for (i = 0; i < Size && isspace(p[i]); ++i);
+   for (i = 0; i < Size && dIsspace(p[i]); ++i);
    if ((Size - i >= 5  && !dStrncasecmp(p+i, "<html", 5)) ||
        (Size - i >= 5  && !dStrncasecmp(p+i, "<head", 5)) ||
        (Size - i >= 6  && !dStrncasecmp(p+i, "<title", 6)) ||
@@ -166,7 +166,7 @@
       Size = MIN (Size, 256);
       for (i = 0; i < Size; i++) {
          int ch = (uchar_t) p[i];
-         if (ch < 32 && !isspace(ch))
+         if (ch < 32 && !dIsspace(ch))
             ++bin_chars;
          if (ch > 126)
             ++non_ascci;
@@ -208,13 +208,13 @@
    if (!str)
       return;
 
-   for (s = str; isalnum(*s) || (*s == '-'); s++);
+   for (s = str; dIsalnum(*s) || (*s == '-'); s++);
    if (major)
       *major = dStrndup(str, s - str);
    is_text = (s - str == 4) && !dStrncasecmp(str, "text", 4);
 
    if (*s == '/') {
-      for (str = ++s; isalnum(*s) || (*s == '-'); s++);
+      for (str = ++s; dIsalnum(*s) || (*s == '-'); s++);
       if (minor)
          *minor = dStrndup(str, s - str);
    }
--- a/src/url.c	Sat Jul 11 17:19:05 2009 +0200
+++ b/src/url.c	Sun Jul 12 16:53:16 2009 -0400
@@ -585,7 +585,7 @@
    newstr = dNew(char, 6*strlen(str)+1);
 
    for (c = newstr; *str; str++)
-      if ((isalnum(*str) && !(*str & 0x80)) || strchr(verbatim, *str))
+      if ((dIsalnum(*str) && !(*str & 0x80)) || strchr(verbatim, *str))
       /* we really need isalnum for the "C" locale */
          *c++ = *str;
       else if (*str == ' ')