| Summary: | gtuxnes cannot read a .gtuxnesrc that contains spaces -- diff included | ||
|---|---|---|---|
| Product: | Gentoo Linux | Reporter: | Myk Taylor <myk002> |
| Component: | New packages | Assignee: | Gentoo Games <games> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | High | ||
| Version: | unspecified | ||
| Hardware: | All | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Package list: | Runtime testing required: | --- | |
| Attachments: | diff to fix .gtuxnesrc reading error | ||
Created attachment 51758 [details, diff]
diff to fix .gtuxnesrc reading error
Comment on attachment 51758 [details, diff]
diff to fix .gtuxnesrc reading error
this patch was also sent to Scott Weber, the author of gtuxnes. However he
replied that he was too busy to update the source, and suggested that I submit
the patch to the Gentoo team directly to integrate into the ebuild.
added to portage. thanks for the patch and bug report. |
gtuxnes loads the ROM name properly (the first line in .gtuxnesrc), but chokes on any parameter value that contained a space. Reproducible: Always Steps to Reproduce: 1. Select '8-bit Signed' for the audio 2. Select other options (like 'Ignore Unknown Instructions') 3. Exit, cat ~/.gtuxnesrc to see the order in which the settings were saved 4. Reload, observe all settings after the 'SNDFORMAT0=8-bit Signed' line are not loaded properly Actual Results: All settings after the 'SNDFORMAT0=8-bit Signed' line are not loaded properly Expected Results: Load all settings that were saved I tracked the bug down to the fscanf line in config.c (see diff below). According to the fscanf man page, any whitespace specified in the format string matches any sequence of whitespace characters (so "\n" == " " == "\t" == the regex "[ \n\t]+"). Reading the string '8-bit Signed' would copy '8-bit' into raw_data, and the next "parameter name" would be 'Signed'. This screwed up the parsing logic. The fix below uses the '%[...]' conversion syntax to properly read until a literal newline (or EOF) is hit. --- config.c 2001-04-16 21:16:44.000000000 -0700 +++ config.c.new 2005-02-12 23:07:46.246921944 -0800 @@ -56,7 +56,7 @@ while (!feof(config_file)) { raw_data[0] = '\0'; - fscanf(config_file, "%s\n", raw_data); + fscanf(config_file, "%[^\n]\n", raw_data); if (strlen(raw_data) < 10) break; strncpy(str_opname, raw_data, 10);