| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 1 | |
Hi,
> But when I used data with zero character inside thats showed some
> interesting thing
>
> inline bool operator<(const QByteArray &a1, const QByteArray &a2)
> { return strcmp(a1, a2) < 0; }
>
> inline bool operator==(const QByteArray &a1, const QByteArray &a2)
> { return (a1.size () == a2.size()) && (memcmp(a1, a2, a1.size())==0); }
> [...]
> But this things causes:
>
> a == b = 0
> a > b = 0
> b > a = 0
You're right. This can be reproduced with the following test case:
#include <QByteArray>
#include <QDebug>
int main() {
const char ca[3] = { '@', '\0', 'A' };
QByteArray a(ca, 3);
const char cb[3] = { '@', '\0', 'B' };
QByteArray b(cb, 3);
qDebug() << (a == b);
qDebug() << (a < b);
qDebug() << (a > b);
}
I suggest you report this to Trolltech:
http://trolltech.com/bugreport-form
--
[ signature omitted ]
Dimitri wrote:
>Hi,
>
>> But when I used data with zero character inside thats showed some
>> interesting thing
>>
>> inline bool operator<(const QByteArray &a1, const QByteArray &a2)
>> { return strcmp(a1, a2) < 0; }
>>
>> inline bool operator==(const QByteArray &a1, const QByteArray &a2)
>> { return (a1.size () == a2.size()) && (memcmp(a1, a2, a1.size())==0);
>> } [...]
>> But this things causes:
>>
>> a == b = 0
>> a > b = 0
>> b > a = 0
>
>You're right. This can be reproduced with the following test case:
> #include <QByteArray>
> #include <QDebug>
> int main() {
> const char ca[3] = { '@', '\0', 'A' };
> QByteArray a(ca, 3);
> const char cb[3] = { '@', '\0', 'B' };
> QByteArray b(cb, 3);
> qDebug() << (a == b);
> qDebug() << (a < b);
> qDebug() << (a > b);
> }
>
>I suggest you report this to Trolltech:
> http://trolltech.com/bugreport-form
No need. I've already fixed the problem.
Be careful if you were depending on the broken behaviour.
--
[ signature omitted ]
Attachment:
signature.asc
Description: This is a digitally signed message part.