Hi,
goto FoldStringA_exit; ^^^^^^^^^^^^^^^^^^^^^^
No allocation has been done yet, just "return 0;" would be enough!
Indeed, although the above is functionally identical. Feel free to submit a patch if you feel strongly about it...
Interesting idea, but I wonder how you can distinguish between equal 0 and FALSE without some real magic! Same applies to lstrcmpi
No magic required. Use GetLastError(), just like it says.
Cheers, Jon
===== "Don't wait for the seas to part, or messiahs to come; Don't you sit around and waste this chance..." - Live
jon_p_griffiths@yahoo.com
__________________________________ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com
Jon Griffiths [mailto:jon_p_griffiths@yahoo.com] wrote:
goto FoldStringA_exit; ^^^^^^^^^^^^^^^^^^^^^^
No allocation has been done yet, just "return 0;" would be enough!
Indeed, although the above is functionally identical. Feel free to submit a patch if you feel strongly about it...
Interesting idea, but I wonder how you can distinguish between equal 0 and FALSE without some real magic! Same applies to lstrcmpi
No magic required. Use GetLastError(), just like it says.
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
Hi,
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.
Of course it 'works':
SetLastError(0); SomeCall(); if (GetLastError()) { ... }
This is common, albeit braindead, Windows programming practice.
So I think that documentation is just simply wrong, also MSDN doesn't say anything about this function returning any error indication.
The documentation is _correct_ for the _implementation_ of these functions. Please read the code.
I didn't implement these functions, I simply documented how they behave under Wine. If you think their implementation differs in an important way from native Windows, please submit a bug and/or test case and/or a code patch to remove the difference. If you believe they behave differently for good reason, please submit a documentation patch describing the difference for developers using these functions.
The fact that MSDN doesn't describe an error return does not mean there isn't one. Of course it doesn't mean there is, either. Perhaps lstrcmp crashes on invalid input under native, I don't know. The only way to know for sure is to write and run a test. Feel free!
Cheers, Jon
===== "Don't wait for the seas to part, or messiahs to come; Don't you sit around and waste this chance..." - Live
jon_p_griffiths@yahoo.com
__________________________________ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com
Rolf Kalbermatter wrote:
Jon Griffiths [mailto:jon_p_griffiths@yahoo.com] wrote:
goto FoldStringA_exit; ^^^^^^^^^^^^^^^^^^^^^^
No allocation has been done yet, just "return 0;" would be enough!
Indeed, although the above is functionally identical. Feel free to submit a patch if you feel strongly about it...
Interesting idea, but I wonder how you can distinguish between equal 0 and FALSE without some real magic! Same applies to lstrcmpi
No magic required. Use GetLastError(), just like it says.
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.
Shachar
Shachar Shemesh [mailto:wine-devel@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