diff options
author | Jim Meyering <jim@meyering.net> | 2000-07-09 15:46:46 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2000-07-09 15:46:46 +0000 |
commit | 96b16428cc3c7fbdeab6adb58ea03f021fb7e273 (patch) | |
tree | a15f902b00e67f908e159213c42c7033edb22417 | |
parent | f5211a209e4c471ac60326f702c50e7577d57d3a (diff) | |
download | coreutils-96b16428cc3c7fbdeab6adb58ea03f021fb7e273.tar.xz |
The old behavior of quoting `like this' doesn't look good with
newer, ISO-style fonts. See:
http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html
Instead, quote "like this" by default. Let the translator
tailor the locale-specific quoting behavior by providing
translations for {LEFT QUOTATION MARK} and {RIGHT QUOTATION MARK}.
(N_): New macro.
(gettext_default): New function.
(quotearg_buffer_restyled): Use
gettext_default ("{LEFT QUOTATION MARK}", "\"") for left quote, and
gettext_default ("{RIGHT QUOTATION MARK}", "\"") for right quote.
-rw-r--r-- | lib/quotearg.c | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/lib/quotearg.c b/lib/quotearg.c index 111b1c1aa..7ccb7599d 100644 --- a/lib/quotearg.c +++ b/lib/quotearg.c @@ -33,6 +33,7 @@ #else # define _(text) text #endif +#define N_(text) text #if HAVE_LIMITS_H # include <limits.h> @@ -174,6 +175,15 @@ set_char_quoting (struct quoting_options *o, char c, int i) return r; } +/* Return the translation of MSGID if there is one, and + DEFAULT_TRANSLATION otherwise. */ +static char const * +gettext_default (char const *msgid, char const *default_translation) +{ + char const *translation = _(msgid); + return translation == msgid ? default_translation : translation; +} + /* Place into buffer BUFFER (of size BUFFERSIZE) a quoted version of argument ARG (of size ARGSIZE), using QUOTING_STYLE and the non-quoting-style part of O to control quoting. @@ -222,11 +232,36 @@ quotearg_buffer_restyled (char *buffer, size_t buffersize, break; case locale_quoting_style: - for (quote_string = _("`"); *quote_string; quote_string++) - STORE (*quote_string); - backslash_escapes = 1; - quote_string = _("'"); - quote_string_len = strlen (quote_string); + { + /* Get translations for open and closing quotation marks. + + The message catalog should translate "{LEFT QUOTATION + MARK}" to a left quotation mark suitable for the locale, + and similarly for "{RIGHT QUOTATION MARK}". If the catalog + has no translation, the code below uses a neutral + (vertical) quotation mark instead, as it is the most + appropriate for the C locale. + + For example, an American English Unicode locale should + translate the string "{LEFT QUOTATION MARK}" to the + character U+201C (LEFT DOUBLE QUOTATION MARK), and should + translate the string "{RIGHT QUOTATION MARK}" to the + character U+201D (RIGHT DOUBLE QUOTATION MARK). A British + English Unicode locale should instead translate these to + U+2018 (LEFT SINGLE QUOTATION MARK) and U+2019 (RIGHT + SINGLE QUOTATION MARK), respectively. */ + + static char const quotation_mark[] = "\""; + char const *left = gettext_default (N_("{LEFT QUOTATION MARK}"), + quotation_mark); + char const *right = gettext_default (N_("{RIGHT QUOTATION MARK}"), + quotation_mark); + for (quote_string = left; *quote_string; quote_string++) + STORE (*quote_string); + backslash_escapes = 1; + quote_string = right; + quote_string_len = strlen (quote_string); + } break; case shell_always_quoting_style: @@ -481,7 +516,7 @@ quotearg_buffer (char *buffer, size_t buffersize, OPTIONS specifies the quoting options. The returned value points to static storage that can be reused by the next call to this function with the same value of N. - N must be nonnegative. N is deliberately declared with type `int' + N must be nonnegative. N is deliberately declared with type "int" to allow for future extensions (using negative values). */ static char * quotearg_n_options (int n, char const *arg, |