Finally fixed space bug with labels on windows correctly

This commit is contained in:
dolphin6k 2022-02-12 10:20:18 +09:00
parent 599e616d13
commit f4cc875861

View file

@ -23898,26 +23898,15 @@ static void load_info_about_label_surface(FILE * lfi)
#endif
#ifdef WIN32
fgets(tmpstr, 1024, lfi);
nwchar = mbstowcs(wtmpstr, tmpstr, 1024) - 2;
/* FIXME: */
/*
According to the document, return value of MultiByteToWideChar() is the number of
characters written to the buffer.
https://docs.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-multibytetowidechar
However, it seems to return a value 2 larger here.
2022/02/11 Shin-ichi TOYAMA
*/
/* Using fancy "%[]" operator to scan until the end of a line */
tmp_fscanf_return = fscanf(lfi, "%[^\n]\n", tmpstr);
mbstowcs(wtmpstr, tmpstr, 1024);
for (l = 0; l < new_node->save_texttool_len; l++)
new_node->save_texttool_str[l] = wtmpstr[l];
new_node->save_texttool_str[l] = L'\0';
#else
/* Using fancy "%[]" operator to scan until the end of a line */
tmp_fscanf_return = fscanf(lfi, "%l[^\n]\n", new_node->save_texttool_str);
nwchar = wcslen(new_node->save_texttool_str);
#endif
#ifdef DEBUG
@ -23926,6 +23915,7 @@ static void load_info_about_label_surface(FILE * lfi)
/* If the string is shorter than what we expect (new_node->save_texttool_len),
then it must have been prefixed with spaces that we lost. */
nwchar = wcslen(new_node->save_texttool_str);
if (nwchar < new_node->save_texttool_len)
{
wchar_t *wtmpstr;