From: Pascal B. <pj...@in...> - 2017-08-25 18:07:43
|
> On 25 Aug 2017, at 08:50, Bruno Haible <br...@cl...> 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. -- __Pascal J. Bourguignon__ |