bug-gnulib
[Top][All Lists]
Advanced

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

Re: memmem issues


From: Ben Pfaff
Subject: Re: memmem issues
Date: Wed, 26 Dec 2007 11:36:38 -0800
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

>> > +  unsigned char b = (unsigned char) needle[i - 1];
>> > ...
>> > +      if (b == (unsigned char) needle[j])
>>
>> Would it be cleaner to declare 'b' to be of type 'char' and avoid the
>> casts?
>
> No; ISO C 99 section 7.21.4 says that when byte strings are compared the
> elements are considered as 'unsigned char' values.

The first cast to unsigned char quoted above seems to be
unnecessary: assigning a value to an object of type unsigned char
will implicitly convert it to unsigned char.
-- 
Ben Pfaff 
http://benpfaff.org





reply via email to

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