Re: More format string fixups (was: Re: [PATCH] Persuade yadex to work on amd64)

  • From: Darren Salt <linux@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
  • To: amajorel@xxxxxxxxx, yadex@xxxxxxxxxxxxx
  • Date: Sun, 02 Jul 2006 15:09:11 +0100

I demand that Andre Majorel may or may not have written...

> On 2006-06-19 01:22 +0100, Darren Salt wrote:
[snip]
>>       fatal_error (
>> -            "%s(d%): directive \"%s\" takes between 5 and 6 parameters",
>> +            "%s(%d): directive \"%s\" takes between 5 and 6 parameters",

> Ha ! This software has been tested. Tes-ted, I'm telling you.

Of course :-)

[snip]
>> --- yadex-1.7.900~/src/help2.cc      2006-06-19 00:53:01.000000000 +0100
>> +++ yadex-1.7.900/src/help2.cc       2006-06-19 00:53:03.095796000 +0100
>> @@ -106,9 +106,9 @@
>>                y0 + BOX_BORDER + FONTH / 2,
>>                "Yadex");
>>    set_colour (WINFG);
>> -  DrawScreenText (x0 + BOX_BORDER + 2 * FONTW, y0 + BOX_BORDER + FONTH, "");
>> +  DrawScreenString (x0 + BOX_BORDER + 2 * FONTW, y0 + BOX_BORDER + FONTH, 
>> "");
>>    for (const char **str = help_text; *str; str++)
>> -     DrawScreenText (-1, -1, *str);
>> +     DrawScreenString (-1, -1, *str);

> Not a good idea.

Combined with one fixup in help_text[] ("%%" -> "%"), this makes sense to me.
For a start, you lose a couple of format string warnings and gain a little in
that the text doesn't have to be run through sprintf().

(Hmm. ISTM that help_text could be made static const *const [], with an
appropriate fixup for the for loops in DisplayHelp().)

[snip]
>> -      warn ("%s: seek error\n", wad_level_lump[l]);
>> +      warn ("%s: seek error\n", wad_level_lump[l].name);

> What was I thinking ? Applied.

class String, perhaps...?

[snip]
-- 
| Darren Salt    | linux or ds at              | nr. Ashington, | Toon
| RISC OS, Linux | youmustbejoking,demon,co,uk | Northumberland | Army
| + Burn less waste. Use less packaging. Waste less.     USE FEWER RESOURCES.

WinCE. You will when you start using it.

Other related posts: