too many versions of nsCRT::strncmp

RESOLVED DUPLICATE of bug 124536

Status

()

Core
XPCOM
RESOLVED DUPLICATE of bug 124536
16 years ago
13 years ago

People

(Reporter: bbaetz, Assigned: dougt)

Tracking

({helpwanted})

Trunk
Future
helpwanted
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

16 years ago
We have both:

static PRInt32 strncmp(const char* s1, const char* s2,
                         PRUint32 aMaxLen)

and

static PRInt32 strncmp(const char* s1, const char* s2, PRInt32 aMaxLen)
The latter does some wierd 'optimisation' to compare the first character. Other
than that, they are identical, except that the 'optimisation' doesn't handle
aMaxLen==0.

I broke the mac yesterday when one of my calls called this with a paramater of
sizeof(foo)-1, when it complained that the call was ambiguous. I have no idea
whether it was right or not, but its silly to have two versions of this. Can we
get rid of the signed one?
(Assignee)

Comment 1

16 years ago
not sure what the rationale was.  The same was done to the strncmp that takes
PRUnichars.
Keywords: helpwanted
Target Milestone: --- → Future

Comment 2

16 years ago
for |const char*| let's use the native strncmp.  for |const PRUnichar*| we
should also use the native version (e.g. wcsncmp) when provided natively (win32,
linux, etc).
(Reporter)

Comment 3

16 years ago
We can only use native functions on platforms where the native functions accept
two byte encodings. (ie not linux)

Comment 4

16 years ago
so i'm on my redhat 7.2 box, and i look in /usr/include and i see a file called
wchar.h.  i open it and i find wcsncmp and friends.  now i suppose this is
probably a new addition or something, but shouldn't we check for it (via
autoconf) and use it when available?
(Reporter)

Comment 5

16 years ago
No, you can't use those. Those routines are compiled into libc, which uses a 4
byte wchar_T, which is the linux abi. We use two byte wchar_t, and so all the
libc functions wouldn't read the string correctly.

On windows, which does have a 2 byte wchar_t abi, you probably could use those.
There are still encoding issues, possibly, though.

Comment 6

16 years ago
ah interesting... ok, well we should try to at least use the win32 ones if they
prove to be compatible.
(Assignee)

Comment 7

16 years ago
cathleen is this something that you are cleaning up?

Comment 8

13 years ago
The double strncmp issue is fixed with Bug 124536, attachment:
https://bugzilla.mozilla.org/attachment.cgi?id=135660
Which is not yet checked in.

The wchar discussion is not for this bug.

So dupping this bug 124536.

*** This bug has been marked as a duplicate of 124536 ***
Status: NEW → RESOLVED
Last Resolved: 13 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.