https://bugs.winehq.org/show_bug.cgi?id=42736
Bug ID: 42736 Summary: scanf doesn't work as expected when using format string contains non-ascii chars Product: Wine Version: unspecified Hardware: x86 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: msvcrt Assignee: wine-bugs@winehq.org Reporter: zhangboyang.id@gmail.com Distribution: ---
Created attachment 57728 --> https://bugs.winehq.org/attachment.cgi?id=57728 working example, should link msvcrt.dll (e.g. use mingw to compile)
(1) assume test.txt has this content
hexdump -C test.txt 00000000 ef bb bf 68 65 6c 6c 6f |...hello| 00000008
// the content is UTF8 BOM + "hello"
(2) fscanf(fp, "\xef\xbb\xbf") doesn't work as expected (using crossover 16.2.0)
char s[1000]; fscanf(fp, "\xef\xbb\xbf"); ///// won't read utf-8 bom as expected fscanf(fp, "%s", s);
/opt/cxoffice/bin/wine test.exe | hexdump -C 00000000 73 3d ef bb bf 68 65 6c 6c 6f 0d 0a |s=...hello..| 0000000c
(3) expected behavior is (under windows) E:\winebug>test2 s=hello
https://bugs.winehq.org/show_bug.cgi?id=42736
Zhang Boyang zhangboyang.id@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |zhangboyang.id@gmail.com
https://bugs.winehq.org/show_bug.cgi?id=42736
Zhang Boyang zhangboyang.id@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC|zhangboyang.id@gmail.com |
https://bugs.winehq.org/show_bug.cgi?id=42736
Zhang Boyang zhangboyang.id@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |zhangboyang.id@gmail.com
https://bugs.winehq.org/show_bug.cgi?id=42736
Gijs Vermeulen acescopezz@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |acescopezz@gmail.com
--- Comment #1 from Gijs Vermeulen acescopezz@gmail.com --- Did this commit fix it: https://source.winehq.org/git/wine.git/commit/32bb8d9068ae5282b6b10734579aaa...
https://bugs.winehq.org/show_bug.cgi?id=42736
Piotr Caban piotr.caban@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED CC| |piotr.caban@gmail.com Resolution|--- |FIXED Fixed by SHA1| |32bb8d9068ae5282b6b10734579 | |aaa2d5195a5af
--- Comment #2 from Piotr Caban piotr.caban@gmail.com --- The patch fixes attached application. Marking as fixed.
https://bugs.winehq.org/show_bug.cgi?id=42736
--- Comment #3 from Zhang Boyang zhangboyang.id@gmail.com --- Hello, I'm not sure whether directly casting '*format' to 'unsigned char' is appropriate. It seems that the wide-scanf and plain-scanf shares same code. If the code is compiled for wide-scanf, directly casting to 'unsigned char' may introduce new bug, e.g. ((unsigned char) L'\xabcd' == L'\xcd') is true.
https://bugs.winehq.org/show_bug.cgi?id=42736
Piotr Caban piotr.caban@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Resolution|FIXED |--- Status|RESOLVED |REOPENED
--- Comment #4 from Piotr Caban piotr.caban@gmail.com --- You're right. Sorry for that. I'll send a fix.
https://bugs.winehq.org/show_bug.cgi?id=42736
--- Comment #5 from Gijs Vermeulen acescopezz@gmail.com --- (In reply to Zhang Boyang from comment #3)
Hello, I'm not sure whether directly casting '*format' to 'unsigned char' is appropriate. It seems that the wide-scanf and plain-scanf shares same code. If the code is compiled for wide-scanf, directly casting to 'unsigned char' may introduce new bug, e.g. ((unsigned char) L'\xabcd' == L'\xcd') is true.
Should be fixed with: https://source.winehq.org/git/wine.git/commitdiff/e7f9b562b9da5aa1fbe369f9e5... Can you confirm?
https://bugs.winehq.org/show_bug.cgi?id=42736
--- Comment #6 from Zhang Boyang zhangboyang.id@gmail.com --- Yes, I wrote another testcase, and the test is passed when using latest wine. I can confirm the bug is fixed. Thank you!
https://bugs.winehq.org/show_bug.cgi?id=42736
--- Comment #7 from Zhang Boyang zhangboyang.id@gmail.com --- Created attachment 57790 --> https://bugs.winehq.org/attachment.cgi?id=57790 another testcase, test both sscanf and swscanf.
latest wine passed this testcase
https://bugs.winehq.org/show_bug.cgi?id=42736
Piotr Caban piotr.caban@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED Resolution|--- |FIXED Fixed by SHA1|32bb8d9068ae5282b6b10734579 |e7f9b562b9da5aa1fbe369f9e57 |aaa2d5195a5af |fe63d08cbb743
--- Comment #8 from Piotr Caban piotr.caban@gmail.com --- Marking as fixed.
https://bugs.winehq.org/show_bug.cgi?id=42736
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #9 from Alexandre Julliard julliard@winehq.org --- Closing bugs fixed in 2.6.
https://bugs.winehq.org/show_bug.cgi?id=42736
Michael Stefaniuc mstefani@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |2.0.x
https://bugs.winehq.org/show_bug.cgi?id=42736
Michael Stefaniuc mstefani@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|2.0.x |---
--- Comment #10 from Michael Stefaniuc mstefani@winehq.org --- Removing the 2.0.x milestone from bugs included in 2.0.2.