string: always call strcmp() in nstrcmp()
Some people seem to depend on the unstandardized behavior of some (notably glibc) implementations of strcmp() where the arithemtic difference between s1 and s2 is returned, not just any positive or negative number. This is explicitly undocumented in libneo as well, but still doing it won't hurt either.
This commit is contained in:
parent
7d64438f70
commit
8c591796fb
1 changed files with 5 additions and 5 deletions
|
@ -22,13 +22,13 @@ int nstrcmp(const string *s1, const string *s2, error *err)
|
|||
|
||||
int ret;
|
||||
|
||||
if (nlen(s1) > nlen(s2))
|
||||
ret = 1;
|
||||
else if (nlen(s1) < nlen(s2))
|
||||
ret = -1;
|
||||
usize maxbytes;
|
||||
if (s1->_capacity > s2->_capacity)
|
||||
maxbytes = s2->_capacity;
|
||||
else
|
||||
ret = strcmp(s1->_data, s2->_data);
|
||||
maxbytes = s1->_capacity;
|
||||
|
||||
ret = strncmp(s1->_data, s2->_data, maxbytes);
|
||||
neat(err);
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue