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: Bob Friesenhahn
Subject: Re: Correct arguments to isspace/isalnum
Date: Mon, 27 Sep 2004 14:18:08 -0500 (CDT)

On Mon, 27 Sep 2004, Ralf Wildenhues wrote:

* 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.

I don't think that libltdl needs to compile using C++ (I don't know of any such requirement). What I meant was that C++ is much more concise/correct than C regarding characters passed to/from functions. The C '89 language uses `int' while C++ uses `char'.

So my system uses the prototypes:

  int isalnum(int c);
  int isspace(int c);

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?

I didn't mean to imply that there were new warnings. Libltdl already produces gobs of warnings. It was just that the cast was to a type other than what the function prototypes specify.

Your latest patch looks ok to me.

Bob
======================================
Bob Friesenhahn
address@hidden
http://www.simplesystems.org/users/bfriesen




reply via email to

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