mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-29 16:01:38 +00:00
fix bug spotted by fred
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34094 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a59695c097
commit
d8f925828c
2 changed files with 23 additions and 2 deletions
|
@ -2352,6 +2352,14 @@ isEqual_c(GSStr self, id anObject)
|
|||
{
|
||||
NXConstantString *other = (NXConstantString*)anObject;
|
||||
|
||||
if (self->_count > other->nxcslen)
|
||||
{
|
||||
/* Since UTF-8 is a multibyte character set, it must have at least
|
||||
* as many bytes as another string of the same length. So if the
|
||||
* UTF-8 string is shorter, the two cannot be equal.
|
||||
*/
|
||||
return NO;
|
||||
}
|
||||
if (internalEncoding == NSASCIIStringEncoding)
|
||||
{
|
||||
if (self->_count == other->nxcslen
|
||||
|
@ -2452,6 +2460,14 @@ isEqual_u(GSStr self, id anObject)
|
|||
unsigned i = 0;
|
||||
unichar u;
|
||||
|
||||
if (self->_count > other->nxcslen)
|
||||
{
|
||||
/* Since UTF-8 is a multibyte character set, it must have at least
|
||||
* as many bytes as another string of the same character length.
|
||||
* So if the UTF-8 string is shorter, the two cannot be equal.
|
||||
*/
|
||||
return NO;
|
||||
}
|
||||
while (i < other->nxcslen || n > 0)
|
||||
{
|
||||
u = nextUTF8((const uint8_t *)other->nxcsptr, other->nxcslen, &i, &n);
|
||||
|
@ -5046,11 +5062,11 @@ literalIsEqual(NXConstantString *self, id anObject)
|
|||
unsigned i = 0;
|
||||
unichar u;
|
||||
|
||||
if (len < self->nxcslen)
|
||||
if (len > self->nxcslen)
|
||||
{
|
||||
/* Since UTF-8 is a multibyte character set, it must have at least
|
||||
* as many bytes as another string of the same length. So if the
|
||||
* other is shorter, the two cannot be equal.
|
||||
* UTF-8 string is shorter, the two cannot be equal.
|
||||
*/
|
||||
return NO;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue