bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

trim: warnings


From: Bruno Haible
Subject: trim: warnings
Date: Wed, 16 Apr 2008 03:26:34 +0200
User-agent: KMail/1.5.4

The 'trim' function gives warnings on NetBSD 3.0:

trim.c:116: warning: subscript has type `char'
trim.c:124: warning: subscript has type `char'

It's actually a bug: 'char' values must be casted to 'unsigned char' before
being usable as argument to <ctype.h> functions.

This fixes it.

2008-04-15  Bruno Haible  <address@hidden>

        * lib/trim.c (trim2): Fix argument of isspace() macro.

--- lib/trim.c.orig     2008-04-16 03:25:52.000000000 +0200
+++ lib/trim.c  2008-04-16 03:21:05.000000000 +0200
@@ -113,7 +113,7 @@
       
       /* Trim leading whitespaces. */
       if (how != TRIM_TRAILING) {
-       for (p = d; *p && isspace (*p); p++)
+       for (p = d; *p && isspace ((unsigned char) *p); p++)
          ;                     
 
        memmove (d, p, strlen (p) + 1);
@@ -121,7 +121,7 @@
 
       /* Trim trailing whitespaces. */
       if (how != TRIM_LEADING) {
-       for (p = d + strlen (d) - 1; p >= d && isspace (*p); p--)
+       for (p = d + strlen (d) - 1; p >= d && isspace ((unsigned char) *p); 
p--)
          *p = '\0';
       }
     }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]