On Thu, Nov 29, 2018 at 12:02 PM Dmitry Timoshkov dmitry@baikal.ru wrote:
Nikolay Sivov nsivov@codeweavers.com wrote:
+DWORD WINAPI SHAnsiToAnsi(const char *src, char *dest, int dest_len) +{
- DWORD ret;
- TRACE("(%s, %p, %d)\n", debugstr_a(src), dest, dest_len);
- if (!src || !dest || dest_len <= 0)
return 0;
- lstrcpynA(dest, src, dest_len);
- ret = strlen(dest);
- return src[ret] ? 0 : ret + 1;
+}
lstrcpynA(dest, src, dest_len); ret = strlen(dest); if (ret) ret++; return ret;
It won't pass the tests.
... because of a typo.
Nikolay had a point here, though: this scans the string twice, but at this point it probably doesn't matter.
On a related note: I'm wondering if we should have a custom Wine strcpy helper (at least for wide version) for cases like these.
All it would do is return the string's end instead of the beginning (which is completely useless), or return the amount copied, whatever. Something useful.
Then we can easily do (ret - base) to get the length. strcpyW would be implemented on top of it then.
Just an idea.