FoldStringA (using W version)

Rolf Kalbermatter rolf.kalbermatter at citeng.com
Fri Oct 24 14:42:50 CDT 2003


Shachar Shemesh [mailto:wine-devel at shemesh.biz]

> >Well so you want to say, if I want to test strings for equality
> >I do first have to call GetLastError() to check if it was an error
> >or if they are really equal?
> >
> >This won't work as by definition a WinAPI function is usually not
> >supposed to reset the last error if no error has occurred, so
> >GetLastError() may return an error even though the strings were
> >just simply equal.
> >
> >So I think that documentation is just simply wrong, also MSDN
> >doesn't say anything about this function returning any error
> >indication.
> >
> >Rolf Kalbermatter 
> >
> You can also do "SetLastError(ERROR_SUCCESS)" first yourself. That's 
> also there in the docs.

Yes of course, but it seems rather stupid to me to do something like
that and just because MS might maybe have designed some APIs like that,
doesn't mean they do that normally.

Usually the functions returns some indication that you should call
GetLastError() and in that case you shouldn't need to interpret its
return value to be not ERROR_SUCCESS to be sure that the return value
of the original function meant something else.

Well I checked those two functions on my W2K system and they do certainly
not return 0 as an error indication but just simply don't return an error
at all.

Passing NULL pointers for instance gives following result:

lstrcmpA(NULL, NULL) returns 0
lstrcmpA(NULL, "")   returns -1
lstrcmpA("", NULL)   returns 1

And most interestingly 

lstrcmpA("A", "a") returns 1 whereas our current implementation returns -1
as upper case is lower in the ASCII table than lower case.

I made a fix to lstrcmp(i)A/W to correctly handle that (except the last one
as that needs to be handled properly in CompareStringA/W which also compares
uppercase as being higher than lower case on W2K. I also extended the tests.

Patch is coming!

Rolf Kalbermatter






More information about the wine-devel mailing list