Lennart Poettering wrote: > On Tue, 11.08.09 22:27, Pádraig Brady (p...@draigbrady.com) wrote: > >> this is equivalent I think: >> >> static const char *arrow = " -> "; >> #ifdef HAVE_NL_LANGINFO >> if (fancy_chars && STREQ (nl_langinfo (CODESET), "UTF-8")) >> arrow = " \xe2\x86\x92 "; >> #endif >> DIRED_FPUTS_LITERAL (arrow, stdout); > > You evaluate the whole expression on every iteration. The whole point > of making this variable static is to make sure this isn't necessary.
Oh right, so something like: static const char *arrow; if (!arrow) { if (fancy_chars && STREQ (locale_charset(), "UTF-8")) arrow = " \xe2\x86\x92 "; else arrow = " -> "; } DIRED_FPUTS_LITERAL (arrow, stdout); Note the use of locale_charset() from gnulib for portability. cheers, Pádraig.