Opened 14 years ago

Closed 14 years ago

Last modified 8 years ago

#414 closed defect (fixed)

wcscasecmp does not exist on OS X

Reported by: Philip Taylor Owned by:
Priority: Should Have Milestone:
Component: Core engine Keywords: simple
Cc: Patch:

Description

We use wcscasecmp but it does not exist on OS X, causing errors. We should either define that function ourselves on OS X (possibly a bad idea since it might conflict with a system version in the future, and we would not bother with the locale support that the standard expects), or define a similar function with a new name (probably in lib/wchar.cpp, just doing ASCII-case-insensitive comparisons) and use that on all platforms.

Attachments (2)

wcscasecmpOSX.patch (959 bytes ) - added by Andrew 14 years ago.
wcscasecmp
wcscasecmpOSX-2.patch (646 bytes ) - added by Andrew 14 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 by Philip Taylor, 14 years ago

Keywords: simple added

by Andrew, 14 years ago

Attachment: wcscasecmpOSX.patch added

wcscasecmp

comment:2 by Andrew, 14 years ago

Keywords: review added

comment:3 by Andrew, 14 years ago

should be noted this will only work in 10.4 and higher

comment:4 by Philip Taylor, 14 years ago

Thanks! I see a couple of problems:

wcscpy copies the string's null terminator, but wcslen returns the length without the terminator, so the allocated buffers are too small (it should be sizeof(wchar_t) * (wcslen(s1)+1) etc).

It would be better not to do any dynamic memory allocation at all (since that can be expensive) - rather than creating strings for wcscmp, I think it should just loop over both input strings at the same time, and return positive/negative values if the towlower()ed characters differ.

by Andrew, 14 years ago

Attachment: wcscasecmpOSX-2.patch added

comment:5 by Andrew, 14 years ago

okay I have made some changes :P

comment:6 by philip, 14 years ago

Resolution: fixed
Status: newclosed

(In [7217]) # Fix OS X build error Fixes #414 (wcscasecmp does not exist on OS X), based on patch from wacko

comment:7 by (none), 14 years ago

Milestone: Unclassified

Milestone Unclassified deleted

comment:8 by sanderd17, 8 years ago

Keywords: review removed
Note: See TracTickets for help on using tickets.