changeset 34608:9286b7ab7104

(ISALNUM, ISALPHA, ISDIGIT, ISLOWER): New macros. Use them throughout instead of ctype functions/macros. (lowcase): Cast to unsigned char. (UPCASE): New macro. (canonicalize_filename): Use UPCASE instead toupper.
author Gerd Moellmann <gerd@gnu.org>
date Fri, 15 Dec 2000 14:32:55 +0000
parents 4d0a388c5e67
children cb2667416fa5
files lib-src/etags.c
diffstat 1 files changed, 25 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/lib-src/etags.c	Fri Dec 15 14:18:53 2000 +0000
+++ b/lib-src/etags.c	Fri Dec 15 14:32:55 2000 +0000
@@ -160,7 +160,8 @@
 #define strneq(s,t,n)	((DEBUG && (s) == NULL && (t) == NULL	\
 			  && (abort (), 1)) || !strncmp (s, t, n))
 
-#define lowcase(c)	tolower ((char)c)
+#define lowcase(c)	tolower ((unsigned char)(c))
+#define UPCASE(c)	toupper ((unsigned char)(c))
 
 #define CHARS 256		/* 2^sizeof(char) */
 #define CHAR(x)		((unsigned int)x & (CHARS - 1))
@@ -170,6 +171,11 @@
 #define	intoken(c)	(_itk[CHAR(c)]) /* c can be in token */
 #define	endtoken(c)	(_etk[CHAR(c)]) /* c ends tokens */
 
+#define ISALNUM(c)	isalnum ((unsigned char) (c))
+#define ISALPHA(c)	isalpha ((unsigned char) (c))
+#define ISDIGIT(c)	isdigit ((unsigned char) (c))
+#define ISLOWER(c)	islower ((unsigned char) (c))
+
 
 /*
  *	xnew, xrnew -- allocate, reallocate storage
@@ -3403,14 +3409,14 @@
       dbp += 3;
       return;
     }
-  if (!isdigit (*dbp))
+  if (!ISDIGIT (*dbp))
     {
       --dbp;			/* force failure */
       return;
     }
   do
     dbp++;
-  while (isdigit (*dbp));
+  while (ISDIGIT (*dbp));
 }
 
 static void
@@ -3431,7 +3437,7 @@
       dbp += 6;
       dbp = skip_spaces (dbp);
     }
-  if (!isalpha (*dbp) && *dbp != '_' && *dbp != '$')
+  if (!ISALPHA (*dbp) && *dbp != '_' && *dbp != '$')
     return;
   for (cp = dbp + 1; *cp != '\0' && intoken (*cp); cp++)
     continue;
@@ -3572,7 +3578,7 @@
 	  dbp = skip_spaces (dbp);
 	  for (cp = dbp;
 	       (*cp != '\0'
-		&& (isalpha (*cp) || isdigit (*cp) || *cp == '_' || *cp == '.'));
+		&& (ISALPHA (*cp) || ISDIGIT (*cp) || *cp == '_' || *cp == '.'));
 	       cp++)
 	    continue;
 	  if (cp == dbp)
@@ -3696,11 +3702,11 @@
     {
       /* If first char is alphabetic or one of [_.$], test for colon
 	 following identifier. */
-      if (isalpha (*cp) || *cp == '_' || *cp == '.' || *cp == '$')
+      if (ISALPHA (*cp) || *cp == '_' || *cp == '.' || *cp == '$')
  	{
  	  /* Read past label. */
 	  cp++;
- 	  while (isalnum (*cp) || *cp == '_' || *cp == '.' || *cp == '$')
+ 	  while (ISALNUM (*cp) || *cp == '_' || *cp == '.' || *cp == '$')
  	    cp++;
  	  if (*cp == ':' || iswhite (*cp))
  	    {
@@ -3760,7 +3766,7 @@
  	  if (*cp == '$' || *cp == '@' || *cp == '%')
  	    {
  	      char* varstart = ++cp;
- 	      while (isalnum (*cp) || *cp == '_')
+ 	      while (ISALNUM (*cp) || *cp == '_')
  		cp++;
  	      varname = savenstr (varstart, cp-varstart);
  	    }
@@ -3837,10 +3843,10 @@
       bp += 8;
 
       /* If eoln, compiler option or comment ignore whole line. */
-      if (bp[-1] != ' ' || !isalnum (bp[0]))
+      if (bp[-1] != ' ' || !ISALNUM (bp[0]))
         continue;
 
-      for (ep = bp; isalnum (*ep) || *ep == '-'; ep++)
+      for (ep = bp; ISALNUM (*ep) || *ep == '-'; ep++)
 	continue;
       if (*ep++ == '.')
 	pfnote (savenstr (bp, ep-bp), TRUE,
@@ -4529,11 +4535,11 @@
 
   origpos = pos;
 
-  if (islower(s[pos]) || (s[pos] == '_'))
+  if (ISLOWER(s[pos]) || (s[pos] == '_'))
     {
       /* The atom is unquoted. */
       pos++;
-      while (isalnum(s[pos]) || (s[pos] == '_'))
+      while (ISALNUM(s[pos]) || (s[pos] == '_'))
 	{
 	  pos++;
 	}
@@ -4710,11 +4716,11 @@
 
   origpos = pos;
 
-  if (isalpha (s[pos]) || s[pos] == '_')
+  if (ISALPHA (s[pos]) || s[pos] == '_')
     {
       /* The atom is unquoted. */
       pos++;
-      while (isalnum (s[pos]) || s[pos] == '_')
+      while (ISALNUM (s[pos]) || s[pos] == '_')
 	pos++;
       return pos - origpos;
     }
@@ -4939,7 +4945,7 @@
   for (t = etags_strchr (out, '\\');
        t != NULL;
        t = etags_strchr (t + 2, '\\'))
-    if (isdigit (t[1]))
+    if (ISDIGIT (t[1]))
       {
 	dig = t[1] - '0';
 	diglen = regs->end[dig] - regs->start[dig];
@@ -4952,7 +4958,7 @@
   result = xnew (size + 1, char);
 
   for (t = result; *out != '\0'; out++)
-    if (*out == '\\' && isdigit (*++out))
+    if (*out == '\\' && ISDIGIT (*++out))
       {
 	/* Using "dig2" satisfies my debugger.  Bleah. */
 	dig = *out - '0';
@@ -5472,7 +5478,7 @@
 {
   return (fn[0] == '/'
 #ifdef DOS_NT
-	  || (isalpha(fn[0]) && fn[1] == ':' && fn[2] == '/')
+	  || (ISALPHA(fn[0]) && fn[1] == ':' && fn[2] == '/')
 #endif
 	  );
 }
@@ -5484,8 +5490,8 @@
 {
 #ifdef DOS_NT
   /* Canonicalize drive letter case.  */
-  if (fn[0] && fn[1] == ':' && islower (fn[0]))
-    fn[0] = toupper (fn[0]);
+  if (fn[0] && fn[1] == ':' && ISLOWER (fn[0]))
+    fn[0] = upcase (fn[0]);
   /* Convert backslashes to slashes.  */
   for (; *fn != '\0'; fn++)
     if (*fn == '\\')