http://bugs.winehq.org/show_bug.cgi?id=13091
Summary: Input error compiling c++ sources with mingw Product: Wine Version: 1.0-rc1 Platform: PC OS/Version: Linux Status: UNCONFIRMED Severity: major Priority: P2 Component: -unknown AssignedTo: wine-bugs@winehq.org ReportedBy: onido89@gmail.com
Hi,
i've searched for this bug but i don't know if it just exist, anyway i wanted to tell you that i've found a bug while i was compiling a source code in c++ language, that was made like this: -------------------------------------- #include <stdio.h>
int main() { int i=1; char s[40],c; while(i!=0) { printf("Number-->"); scanf("%d%c",&i,&c); printf("String->"); gets(s); } } -------------------------------------- When i try to use it in winecmd it doesn't get exactly the inputs method (it overlay the string method, it seems to ignore it...). Anyway try it for yourself if you want and i hope it will be fixed for 1.0.
Great work anyway, this is the best emulator that i've ever used ;)
Have a nice day, and keep rollin! GTOnizuka
http://bugs.winehq.org/show_bug.cgi?id=13091
Jeff Zaroyko jeffzaroyko@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |jeffzaroyko@gmail.com
--- Comment #1 from Jeff Zaroyko jeffzaroyko@gmail.com 2008-05-10 02:42:16 --- If we look purely at your program, the first error I see is that you have failed to check the return value of scanf.
If you read the documentation on scanf, you'll see something similar to what my manpage says:
These functions return the number of input items successfully matched and assigned, which can be fewer than provided for, or even zero in the event of an early matching failure.
If you do check the return value then you can have a real understanding the input that the program receives.
http://bugs.winehq.org/show_bug.cgi?id=13091
--- Comment #2 from onido onido89@gmail.com 2008-05-10 08:38:50 --- I don't think so because if we compile the same source into windows and we run the exe into there it function, but if we put the same exe that (if i'm not wrong) function into wine (in linux) it gives me the same error. I've never used the return of inputs because i don't need to know how many inputs there are (because i know that they're, in this case, 2).
Sincerly yours, GTOnizuka
http://bugs.winehq.org/show_bug.cgi?id=13091
Vitaliy Margolen vitaliy@kievinfo.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Severity|major |normal
--- Comment #3 from Vitaliy Margolen vitaliy@kievinfo.com 2008-05-10 16:35:54 --- Did you used this in wineconsole? Or just run 'cmd.exe your_program.exe'?
Use of "gets" is strongly discouraged in all it's applications. You should NEVER use it in your programs. Can you describe again what are you inputting, and how it should work? And what results you get on Wine? What are you expecting to be in "i", "c", "s"? With what input?
Not checking return from functions that get user input is really really bad practice. One should always validate all inputs, especially if it's from user/other program. This is about your comment not checking output from scanf.
http://bugs.winehq.org/show_bug.cgi?id=13091
--- Comment #4 from onido onido89@gmail.com 2008-05-11 04:22:06 --- Hi,
i've used winecmd obivously, not cmd (sincerly i didn't know of that into wine).
I've used multiple functions of gettings data to see if wine function correctly with them. So my program is only a test of the I/O system of winecmd. My source try to get a number (and carriage return) then try to get 'i' strings as much as i value. For ex. Number --> 3 String --> a //1 String --> b //2 String --> c //3
Anyway i've not checked the value of scanf only to try the I/O not to made a program with that source code (because also personally i think that is so stupid :p i like to use cin and cout method personally).
Greets, GTOnizuka
http://bugs.winehq.org/show_bug.cgi?id=13091
--- Comment #5 from onido onido89@gmail.com 2008-05-11 04:23:26 --- Ah, forget to point out that i've used mingw 2.8 (not tryied if the error persist also in 3.x and 4.x).
http://bugs.winehq.org/show_bug.cgi?id=13091
--- Comment #6 from Austin English austinenglish@gmail.com 2008-11-12 14:25:52 --- Is this still an issue in current (1.1.8 or newer) wine?
http://bugs.winehq.org/show_bug.cgi?id=13091
Jeff Zaroyko jeffz@jeffz.name changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |INVALID
--- Comment #7 from Jeff Zaroyko jeffz@jeffz.name 2008-11-12 17:40:11 --- (In reply to comment #6)
Is this still an issue in current (1.1.8 or newer) wine?
It's largely invalid because the reporter does not check return values in his program. Any serious program dealing with user input will always check the return value from scanf.
Quoting K&R.
"scanf stops when it exhausts its format string, or when some input fails to match the control specification. It returns as its value the number of successfully matched and assigned input items. This can be used to decide how many items were found."
http://bugs.winehq.org/show_bug.cgi?id=13091
Jeff Zaroyko jeffz@jeffz.name changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #8 from Jeff Zaroyko jeffz@jeffz.name 2008-11-12 17:51:58 --- functions have return values for a reason, check them. closing.
http://bugs.winehq.org/show_bug.cgi?id=13091
--- Comment #9 from Austin English austinenglish@gmail.com 2008-11-12 18:57:12 --- Reporter, does this work in windows?
http://bugs.winehq.org/show_bug.cgi?id=13091
--- Comment #10 from Jeff Zaroyko jeffz@jeffz.name 2008-11-12 20:03:22 --- (In reply to comment #9)
Reporter, does this work in windows?
http://c-faq.com/stdio/scanfinterlace.html
http://bugs.winehq.org/show_bug.cgi?id=13091
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|CLOSED |UNCONFIRMED Resolution|INVALID |
--- Comment #11 from Alexandre Julliard julliard@winehq.org 2008-11-13 04:03:45 --- He said that it works in Windows, so it's a valid bug. Probably a LF/CR+LF issue.
http://bugs.winehq.org/show_bug.cgi?id=13091
Chris chris.kcat@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |chris.kcat@gmail.com
--- Comment #12 from Chris chris.kcat@gmail.com 2008-11-13 04:55:51 --- This sounds suspiciously like a problem I encountered with conio functions. The problem was when it's run from a host shell with wine (even 'wine cmd' where you get a win32 prompt in a host shell), then wine would treat stdin as a file pipe and behave differently than it would with normal stdin (usually by not blocking and not reading input even when given it). However if it's run from a "proper" win32 console (eg. 'wine start cmd' as opposed to 'wine cmd'), it would work as expected.
IIRC, AJ said this was fixable, but not trivial to do.
http://bugs.winehq.org/show_bug.cgi?id=13091
--- Comment #13 from Jeff Zaroyko jeffz@jeffz.name 2008-11-13 05:26:05 --- Created an attachment (id=17257) --> (http://bugs.winehq.org/attachment.cgi?id=17257) related problem
ok -- ignoring the silly practice of mixing scanf and gets in the original report, at a glance there does appear to be a related issue with the %d format specifier
It consumes a trailing whitespace character incorrectly, so given the following related testcase[1], input the number 1 followed by enter, on windows it converts the 1 and stores it at &i then converts the newline and stores it at &c.
Under Wine, %d eats both a 1 and the newline and continues reading input attempting the %c conversion. Attached is my suggested fix.
[1]: #include <stdio.h> int main(void) { int i,ret; char c; printf("press the number 1 then hit enter\n"); ret = scanf("%d%c",&i,&c); if(ret == 2) { printf("expecting 1 10: got :%d %d\n"); } return 0; }
http://bugs.winehq.org/show_bug.cgi?id=13091
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch
http://bugs.winehq.org/show_bug.cgi?id=13091
--- Comment #14 from Austin English austinenglish@gmail.com 2009-05-18 10:48:33 --- Is this still an issue in current (1.1.21 or newer) wine?
http://bugs.winehq.org/show_bug.cgi?id=13091
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download
http://bugs.winehq.org/show_bug.cgi?id=13091
--- Comment #15 from Austin English austinenglish@gmail.com 2009-11-19 12:52:32 --- This is your friendly reminder that there has been no bug activity for 6 months. Is this still an issue in current (1.1.33 or newer) wine?
http://bugs.winehq.org/show_bug.cgi?id=13091
André H. nerv@dawncrow.de changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |nerv@dawncrow.de
--- Comment #16 from André H. nerv@dawncrow.de 2010-06-01 12:33:01 --- please retest, there were some mingw fixes some month ago.
http://bugs.winehq.org/show_bug.cgi?id=13091
Frédéric Delanoy frederic.delanoy@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED CC| |frederic.delanoy@gmail.com Resolution| |ABANDONED
--- Comment #17 from Frédéric Delanoy frederic.delanoy@gmail.com 2012-05-03 04:10:15 CDT --- Abandoned. Feel free to reopen if the bug still persists with latest wine.
http://bugs.winehq.org/show_bug.cgi?id=13091
Jerome Leclanche adys.wh@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #18 from Jerome Leclanche adys.wh@gmail.com 2012-05-06 07:06:56 CDT --- Closing