From: Nick Bowler Date: Tue, 30 Jun 2020 03:54:43 +0000 (-0400) Subject: Output copyright symbol directly, rather than via translations. X-Git-Tag: v1~24 X-Git-Url: https://git.draconx.ca/gitweb/cdecl99.git/commitdiff_plain/debaed3750c42accb4c63378a06f5cdc9cd8be3d Output copyright symbol directly, rather than via translations. The "(C)" isn't really a translatable string. Instead of requiring translations to deal with it, use Gnulib's str_iconv module to encode it into the user's locale encoding. We fall back to (C) if that fails for any reason, or if NLS is disabled. --- diff --git a/m4/.gitignore b/m4/.gitignore index 2497a50..ab28204 100644 --- a/m4/.gitignore +++ b/m4/.gitignore @@ -1,5 +1,6 @@ 00gnulib.m4 codeset.m4 +configmake.m4 errno_h.m4 extensions.m4 extern-inline.m4 @@ -14,7 +15,10 @@ gnulib-common.m4 gnulib-comp.m4 gnulib-tool.m4 iconv.m4 +iconv_h.m4 +iconv_open.m4 include_next.m4 +inline.m4 intdiv0.m4 intl.m4 intldir.m4 @@ -27,6 +31,8 @@ lib-ld.m4 lib-link.m4 lib-prefix.m4 libtool.m4 +libunistring-base.m4 +localcharset.m4 lock.m4 longlong.m4 ltoptions.m4 @@ -45,6 +51,7 @@ readline.m4 realloc.m4 size_max.m4 ssize_t.m4 +stdbool.m4 stddef_h.m4 stdint.m4 stdint_h.m4 diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4 index 4705907..2a38a49 100644 --- a/m4/gnulib-cache.m4 +++ b/m4/gnulib-cache.m4 @@ -27,15 +27,17 @@ # Specification in the form of a command-line invocation: -# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk.in --conditional-dependencies --libtool --macro-prefix=gl --no-vc-files getopt-gnu gettext lock readline tls +# gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk.in --conditional-dependencies --libtool --macro-prefix=gl --no-vc-files getopt-gnu gettext localcharset lock readline striconv tls # Specification in the form of a few gnulib-tool.m4 macro invocations: gl_LOCAL_DIR([]) gl_MODULES([ getopt-gnu gettext + localcharset lock readline + striconv tls ]) gl_AVOID([]) diff --git a/po/en.po b/po/en.po index af09430..42dc6a0 100644 --- a/po/en.po +++ b/po/en.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: cdecl99 0.1\n" "Report-Msgid-Bugs-To: nbowler@draconx.ca\n" -"POT-Creation-Date: 2011-10-06 14:48-0400\n" +"POT-Creation-Date: 2020-06-29 22:52-0400\n" "PO-Revision-Date: 2011-09-13 21:54-0400\n" "Last-Translator: Nick Bowler \n" "Language-Team: English\n" @@ -51,138 +51,136 @@ msgstr "" msgid "%s: invalid option -- '%c'\n" msgstr "" -#: lib/getopt.c:858 lib/getopt.c:875 lib/getopt.c:1083 lib/getopt.c:1101 +#: lib/getopt.c:861 lib/getopt.c:878 lib/getopt.c:1088 lib/getopt.c:1106 #, c-format msgid "%s: option requires an argument -- '%c'\n" msgstr "" -#: lib/getopt.c:931 lib/getopt.c:947 +#: lib/getopt.c:934 lib/getopt.c:950 #, c-format msgid "%s: option '-W %s' is ambiguous\n" msgstr "" -#: lib/getopt.c:971 lib/getopt.c:989 +#: lib/getopt.c:974 lib/getopt.c:992 #, c-format msgid "%s: option '-W %s' doesn't allow an argument\n" msgstr "" -#: lib/getopt.c:1010 lib/getopt.c:1028 +#: lib/getopt.c:1013 lib/getopt.c:1031 #, c-format msgid "%s: option '-W %s' requires an argument\n" msgstr "" -#: src/cdecl99.c:38 +#: src/cdecl99.c:43 msgctxt "longopt" msgid "quiet" msgstr "" -#: src/cdecl99.c:39 +#: src/cdecl99.c:44 msgctxt "longopt" msgid "batch" msgstr "" -#: src/cdecl99.c:40 +#: src/cdecl99.c:45 msgctxt "longopt" msgid "interactive" msgstr "" -#: src/cdecl99.c:41 +#: src/cdecl99.c:46 msgctxt "longopt" msgid "file" msgstr "" -#: src/cdecl99.c:42 +#: src/cdecl99.c:47 msgctxt "longopt" msgid "execute" msgstr "" -#: src/cdecl99.c:43 +#: src/cdecl99.c:48 msgctxt "longopt" msgid "version" msgstr "" -#: src/cdecl99.c:44 +#: src/cdecl99.c:49 msgctxt "longopt" msgid "help" msgstr "" -#: src/cdecl99.c:62 +#. TRANSLATORS: Help messages are indented 20 spaces and thus should +#. not have lines longer than 60 columns. +#. +#: src/cdecl99.c:67 msgid "Suppress the welcome message.\n" msgstr "" -#: src/cdecl99.c:63 +#: src/cdecl99.c:68 msgid "Execute commands as normal, but do not print any prompts.\n" msgstr "" -#: src/cdecl99.c:64 +#: src/cdecl99.c:69 msgid "Run in interactive mode. This is the default.\n" msgstr "" -#: src/cdecl99.c:65 +#: src/cdecl99.c:70 msgid "Read commands from FILE instead of standard input.\n" msgstr "" -#: src/cdecl99.c:66 +#: src/cdecl99.c:71 msgctxt "longopt|file" msgid "FILE" msgstr "" -#: src/cdecl99.c:67 +#: src/cdecl99.c:72 msgid "" "Execute COMMAND as if it were entered at the prompt.\n" "This can be specified multiple times.\n" msgstr "" -#: src/cdecl99.c:69 +#: src/cdecl99.c:74 msgctxt "longopt|execute" msgid "COMMAND" msgstr "" -#: src/cdecl99.c:70 +#: src/cdecl99.c:75 msgid "Print a version message and then exit.\n" msgstr "" -#: src/cdecl99.c:71 +#: src/cdecl99.c:76 msgid "Print this message.\n" msgstr "" #. TRANSLATORS: ARG is only used for options without help text. -#: src/cdecl99.c:74 +#: src/cdecl99.c:79 msgctxt "longopt" msgid "ARG" msgstr "" -#. TRANSLATORS: (C) must *always* be translated as ©. -#: src/cdecl99.c:81 -msgid "(C)" -msgstr "©" - -#: src/cdecl99.c:132 +#: src/cdecl99.c:147 #, c-format msgid " -%c" msgstr "" -#: src/cdecl99.c:135 +#: src/cdecl99.c:150 #, c-format msgid " -%c, --%s=%s" msgstr "" -#: src/cdecl99.c:136 +#: src/cdecl99.c:151 #, c-format msgid " -%c, --%s" msgstr "" -#: src/cdecl99.c:141 +#: src/cdecl99.c:156 #, c-format msgid " -%c, --%s=%s, --%s=%s" msgstr "" -#: src/cdecl99.c:145 +#: src/cdecl99.c:160 #, c-format msgid " -%c, --%s, --%s" msgstr "" -#: src/cdecl99.c:181 +#: src/cdecl99.c:196 msgid "" "This is \"cdecl99\": a command-line tool for parsing and constructing\n" "complicated C declarations.\n" @@ -190,15 +188,18 @@ msgstr "" "This is “cdecl99”: a command-line tool for parsing and constructing\n" "complicated C declarations.\n" -#: src/cdecl99.c:184 +#: src/cdecl99.c:199 msgid "Options:" msgstr "" -#: src/cdecl99.c:193 +#: src/cdecl99.c:208 msgid "For more information, see the cdecl99(1) man page.\n" msgstr "" -#: src/cdecl99.c:199 +#. TRANSLATORS: Please add *another line* indicating where users should +#. report translation bugs. +#. +#: src/cdecl99.c:214 #, c-format msgid "Report bugs to <%s>.\n" msgstr "" diff --git a/src/cdecl99.c b/src/cdecl99.c index 99b5d63..bebdfff 100644 --- a/src/cdecl99.c +++ b/src/cdecl99.c @@ -1,6 +1,6 @@ /* * Command line utility for making sense of C declarations. - * Copyright © 2011-2012 Nick Bowler + * Copyright © 2011-2012, 2020 Nick Bowler * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -13,8 +13,9 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program. If not, see . */ + #include #include #include @@ -23,13 +24,16 @@ #include #include #include -#include -#include #include -#include "readline.h" #include "history.h" #include "cdecl.h" +#include +#include +#include +#include +#include + #define _(x) gettext(x) #define N_(x) x #define PN_(c, x) x @@ -78,12 +82,22 @@ static struct helptext { static void print_version(void) { + const char *copysign = "(C)"; + void *convsign = NULL; + + if (ENABLE_NLS) { + convsign = str_iconv("\xc2\xa9", "UTF-8", locale_charset()); + if (convsign) + copysign = convsign; + } + puts(PACKAGE_STRING); - /* TRANSLATORS: (C) must *always* be translated as ©. */ - printf("Copyright %s 2011 Nick Bowler.\n", gettext("(C)")); - puts("License GPLv3+: GNU GPL version 3 or later ."); + printf("Copyright %s 2020 Nick Bowler.\n", copysign); + puts("License GPLv3+: GNU GPL version 3 or any later version."); puts("This is free software: you are free to change and redistribute it."); puts("There is NO WARRANTY, to the extent permitted by law."); + + free(convsign); } static void print_usage(FILE *f) @@ -478,13 +492,13 @@ static int repl_noninteractive(void) /* Initialize gettext and setup translated long options. */ static void init_i18n(void) { + if (!ENABLE_NLS) + return; + setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - if (!ENABLE_NLS) - return; - for (int i = 0, j = NOPTS; i < NOPTS; i++) { const char *tname = pgettext_expr("longopt", lopts[i].name);