libtool-patches
[Top][All Lists]
Advanced

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

Re: Correct arguments to isspace/isalnum


From: Ralf Wildenhues
Subject: Re: Correct arguments to isspace/isalnum
Date: Mon, 27 Sep 2004 21:00:14 +0200
User-agent: Mutt/1.4.1i

* Bob Friesenhahn wrote on Mon, Sep 27, 2004 at 08:32:31PM CEST:
> On Mon, 27 Sep 2004, Ralf Wildenhues wrote:
> 
> >Most systems accept this error, because it's so widespread.
> >No excuse stating that sign conversion is difficult in C ;)
> 
> It seems that the correct answer to this depends on which standard you 
> are conforming to and whether you are using C or C++.  In C '89 these 
> functions accept an 'int'.  Naturally C++ has made things more 
> correct.

No.  It's independent of the standard, except that I forgot C++
compatibility, sorry.  At least in C the cast to unsigned char is
required, because in C these functions accept ranges within unsigned
char only.  So for C++ we need to add another cast.  Sigh.

But then again, libltdl fails to compile in many places when run through
a C++ compiler, the slist implementation even uses `delete' as a
variable name.  Is C++ source compatibility necessary or desired?

> All compilers I have run libltdl through except for GCC produce oodles 
> of warning messages during compilation.  Is that how this issue was 
> discovered?  If so, what compiler was used?

No.  This issue was discovered by reading the code alone.  If you think
my change is wrong, I would like backing from some standard which tells
me so.  I know the original code can fail on some systems when given
characters with the 8th bit set, whereas the corrected does not.

OK, updated patch below.  Does this fix the warnings?

Regards,
Ralf

2004-09-27  Ralf Wildenhues <address@hidden>

        * libltdl/ltdl.c (load_deplibs, try_dlopen): Cast argument
        to isspace/isalnum to the correct range.  Also, cast to int to
        avoid compiler warnings.


Index: libltdl/ltdl.c
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/ltdl.c,v
retrieving revision 1.213
diff -u -r1.213 ltdl.c
--- libltdl/ltdl.c      2 Sep 2004 13:27:24 -0000       1.213
+++ libltdl/ltdl.c      27 Sep 2004 18:13:20 -0000
@@ -736,10 +736,10 @@
  p = deplibs;
  while (*p)
    {
-      if (!isspace ((int) *p))
+      if (!isspace ((int)(unsigned char) *p))
        {
          char *end = p+1;
-         while (*end && !isspace((int) *end))
+         while (*end && !isspace((int)(unsigned char) *end))
            {
              ++end;
            }
@@ -785,14 +790,14 @@
  p = deplibs;
  while (*p)
    {
-      if (isspace ((int) *p))
+      if (isspace ((int)(unsigned char) *p))
        {
          ++p;
        }
      else
        {
          char *end = p+1;
-         while (*end && !isspace ((int) *end))
+         while (*end && !isspace ((int)(unsigned char) *end))
            {
              ++end;
            }
@@ -999,7 +999,7 @@
    int i;
    for (i = 0; i < ext - base_name; ++i)
      {
-       if (isalnum ((int)(base_name[i])))
+       if (isalnum ((int)(unsigned char)(base_name[i])))
          {
            name[i] = base_name[i];
          }




reply via email to

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