Re: Use (f)puts instead of (f)printf when possible.

Sam Steingold <[email protected]>
Newsgroups gmane.lisp.clisp.devel
Message-ID <[email protected]>
> * Pascal Bourguignon <[email protected]> [2017-08-25 20:07:30 +0200]:
>
>> On 25 Aug 2017, at 08:50, Bruno Haible <[email protected]> wrote:
>> 
>> Pascal Bourguignon wrote:
>>> The standard way to avoid it is to use a literal format string!
>>> 
>>>    fprintf(stderr,”%s”,GETTEXTL(“Warning: “));
>> 
>> Indeed gcc recognizes "%s" (and "%c") as special cases of format strings
>> and optimizes these cases. But I still find such code harder to read than
>> 
>>      fprint(stderr,GETTEXTL(“Warning: “));
>
>
> The point is that this is some external data, obtained at run-time from
> files that are not necessarily under the control of the program
> (eg. some distributions package the localisable file separately).
>
> Therefore if you insist on avoiding “%s” you should, to keep the program
> correct and secure, do the following:
>
>      fprint(stderr,escape_print_directives(GETTEXTL(“Warning: “)));
>
> and suddenly, using “%s” looks way simpler.

This only avoids a minor problem.
What would you do with

    fprintf(stderr,GETTEXTL("OS Error: %s %d"),a,b)

In fact there is no real problem here: GETTEXTL _is_ under our control,
it takes the data from our translation files.

Thanks

-- 
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1504
http://steingoldpsychology.com http://www.childpsy.net http://iris.org.il
http://think-israel.org http://islamexposedonline.com http://jij.org
Democracy vs Despotism = Theft vs Robbery

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
clisp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/clisp-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.