* gpgv.c (i18n_init): Always use LC_ALL.

* kbxutil.c (i18n_init): Always use LC_ALL.

* gpgsm.c (i18n_init): Always use LC_ALL.

* certdump.c (gpgsm_format_name): Factored code out to ..
(gpgsm_format_name2): .. new.
(gpgsm_print_name): Factored code out to ..
(gpgsm_print_name2): .. new.
(print_dn_part): New arg TRANSLATE.  Changed all callers.
(print_dn_parts): Ditto.
(gpgsm_format_keydesc): Do not translate the SUBJECT; we require
it to stay UTF-8 but we still want to filter out bad control
characters.

* gpgconf.c (i18n_init): Always use LC_ALL.
This commit is contained in:
Werner Koch 2004-09-30 21:37:11 +00:00
parent 335b5e4ac4
commit 048635bede
11 changed files with 59 additions and 35 deletions

2
NEWS
View File

@ -10,6 +10,8 @@ Noteworthy changes in version 1.9.11
* [gpg-agent] When used without --daemon or --server, gpg-agent now * [gpg-agent] When used without --daemon or --server, gpg-agent now
check whether a agent is already running and usable. check whether a agent is already running and usable.
* Fixed some i18n problems.
Noteworthy changes in version 1.9.10 (2004-07-22) Noteworthy changes in version 1.9.10 (2004-07-22)
------------------------------------------------- -------------------------------------------------

View File

@ -1,5 +1,7 @@
2004-09-30 Werner Koch <wk@g10code.com> 2004-09-30 Werner Koch <wk@g10code.com>
* gpgv.c (i18n_init): Always use LC_ALL.
* Makefile.am (LDADD): Adjusted for gettext 0.14. * Makefile.am (LDADD): Adjusted for gettext 0.14.
2004-09-20 Werner Koch <wk@g10code.com> 2004-09-20 Werner Koch <wk@g10code.com>

View File

@ -119,12 +119,7 @@ i18n_init(void)
set_gettext_file( PACKAGE_GT ); set_gettext_file( PACKAGE_GT );
#else #else
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
#ifdef HAVE_LC_MESSAGES setlocale( LC_ALL, "" );
setlocale( LC_TIME, "" );
setlocale( LC_MESSAGES, "" );
#else
setlocale( LC_ALL, "" );
#endif
bindtextdomain( PACKAGE_GT, LOCALEDIR ); bindtextdomain( PACKAGE_GT, LOCALEDIR );
textdomain( PACKAGE_GT ); textdomain( PACKAGE_GT );
#endif #endif

View File

@ -1,6 +1,8 @@
2004-09-30 Werner Koch <wk@g10code.com> 2004-09-30 Werner Koch <wk@g10code.com>
* Makefile.am: Adjusted fro gettext 0.14. * kbxutil.c (i18n_init): Always use LC_ALL.
* Makefile.am: Adjusted for gettext 0.14.
2004-08-24 Werner Koch <wk@g10code.de> 2004-08-24 Werner Koch <wk@g10code.de>

View File

@ -129,12 +129,7 @@ i18n_init(void)
set_gettext_file( PACKAGE_GT ); set_gettext_file( PACKAGE_GT );
#else #else
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
#ifdef HAVE_LC_MESSAGES setlocale( LC_ALL, "" );
setlocale( LC_TIME, "" );
setlocale( LC_MESSAGES, "" );
#else
setlocale( LC_ALL, "" );
#endif
bindtextdomain( PACKAGE_GT, LOCALEDIR ); bindtextdomain( PACKAGE_GT, LOCALEDIR );
textdomain( PACKAGE_GT ); textdomain( PACKAGE_GT );
#endif #endif

View File

@ -1,5 +1,17 @@
2004-09-30 Werner Koch <wk@g10code.com> 2004-09-30 Werner Koch <wk@g10code.com>
* gpgsm.c (i18n_init): Always use LC_ALL.
* certdump.c (gpgsm_format_name): Factored code out to ..
(gpgsm_format_name2): .. new.
(gpgsm_print_name): Factored code out to ..
(gpgsm_print_name2): .. new.
(print_dn_part): New arg TRANSLATE. Changed all callers.
(print_dn_parts): Ditto.
(gpgsm_format_keydesc): Do not translate the SUBJECT; we require
it to stay UTF-8 but we still want to filter out bad control
characters.
* Makefile.am: Adjusted for gettext 0.14. * Makefile.am: Adjusted for gettext 0.14.
* keylist.c (list_cert_colon): Make sure that the expired flag has * keylist.c (list_cert_colon): Make sure that the expired flag has

View File

@ -427,7 +427,7 @@ parse_dn (const unsigned char *string)
static void static void
print_dn_part (FILE *fp, struct dn_array_s *dn, const char *key) print_dn_part (FILE *fp, struct dn_array_s *dn, const char *key, int translate)
{ {
struct dn_array_s *first_dn = dn; struct dn_array_s *first_dn = dn;
@ -446,7 +446,10 @@ print_dn_part (FILE *fp, struct dn_array_s *dn, const char *key)
if (!dn->done && dn->value && *dn->value) if (!dn->done && dn->value && *dn->value)
{ {
fprintf (fp, "/%s=", dn->key); fprintf (fp, "/%s=", dn->key);
print_sanitized_utf8_string (fp, dn->value, '/'); if (translate)
print_sanitized_utf8_string (fp, dn->value, '/');
else
print_sanitized_string (fp, dn->value, '/');
} }
dn->done = 1; dn->done = 1;
if (dn > first_dn && dn[-1].multivalued) if (dn > first_dn && dn[-1].multivalued)
@ -461,7 +464,7 @@ print_dn_part (FILE *fp, struct dn_array_s *dn, const char *key)
/* Print all parts of a DN in a "standard" sequence. We first print /* Print all parts of a DN in a "standard" sequence. We first print
all the known parts, followed by the uncommon ones */ all the known parts, followed by the uncommon ones */
static void static void
print_dn_parts (FILE *fp, struct dn_array_s *dn) print_dn_parts (FILE *fp, struct dn_array_s *dn, int translate)
{ {
const char *stdpart[] = { const char *stdpart[] = {
"CN", "OU", "O", "STREET", "L", "ST", "C", "EMail", NULL "CN", "OU", "O", "STREET", "L", "ST", "C", "EMail", NULL
@ -469,17 +472,17 @@ print_dn_parts (FILE *fp, struct dn_array_s *dn)
int i; int i;
for (i=0; stdpart[i]; i++) for (i=0; stdpart[i]; i++)
print_dn_part (fp, dn, stdpart[i]); print_dn_part (fp, dn, stdpart[i], translate);
/* Now print the rest without any specific ordering */ /* Now print the rest without any specific ordering */
for (; dn->key; dn++) for (; dn->key; dn++)
print_dn_part (fp, dn, dn->key); print_dn_part (fp, dn, dn->key, translate);
} }
void void
gpgsm_print_name (FILE *fp, const char *name) gpgsm_print_name2 (FILE *fp, const char *name, int translate)
{ {
const unsigned char *s; const unsigned char *s;
int i; int i;
@ -493,7 +496,12 @@ gpgsm_print_name (FILE *fp, const char *name)
{ {
const unsigned char *s2 = strchr (s+1, '>'); const unsigned char *s2 = strchr (s+1, '>');
if (s2) if (s2)
print_sanitized_utf8_buffer (fp, s + 1, s2 - s - 1, 0); {
if (translate)
print_sanitized_utf8_buffer (fp, s + 1, s2 - s - 1, 0);
else
print_sanitized_buffer (fp, s + 1, s2 - s - 1, 0);
}
} }
else if (*s == '(') else if (*s == '(')
fputs (_("[Error - unknown encoding]"), fp); fputs (_("[Error - unknown encoding]"), fp);
@ -508,7 +516,7 @@ gpgsm_print_name (FILE *fp, const char *name)
fputs (_("[Error - invalid DN]"), fp); fputs (_("[Error - invalid DN]"), fp);
else else
{ {
print_dn_parts (fp, dn); print_dn_parts (fp, dn, translate);
for (i=0; dn[i].key; i++) for (i=0; dn[i].key; i++)
{ {
xfree (dn[i].key); xfree (dn[i].key);
@ -520,6 +528,12 @@ gpgsm_print_name (FILE *fp, const char *name)
} }
void
gpgsm_print_name (FILE *fp, const char *name)
{
gpgsm_print_name2 (fp, name, 1);
}
/* A cookie structure used for the memory stream. */ /* A cookie structure used for the memory stream. */
struct format_name_cookie struct format_name_cookie
@ -558,9 +572,11 @@ format_name_writer (void *cookie, const char *buffer, size_t size)
/* Format NAME which is expected to be in rfc2253 format into a better /* Format NAME which is expected to be in rfc2253 format into a better
human readable format. Caller must free the returned string. NULL human readable format. Caller must free the returned string. NULL
is returned in case of an error. */ is returned in case of an error. With TRANSLATE set to true the
name will be translated to the native encodig. Note that NAME is
internally always UTF-8 encoded. */
char * char *
gpgsm_format_name (const char *name) gpgsm_format_name2 (const char *name, int translate)
{ {
#if defined (HAVE_FOPENCOOKIE) || defined (HAVE_FUNOPEN) #if defined (HAVE_FOPENCOOKIE) || defined (HAVE_FUNOPEN)
FILE *fp; FILE *fp;
@ -587,7 +603,7 @@ gpgsm_format_name (const char *name)
errno = save_errno; errno = save_errno;
return NULL; return NULL;
} }
gpgsm_print_name (fp, name); gpgsm_print_name2 (fp, name, translate);
fclose (fp); fclose (fp);
if (cookie.error || !cookie.buffer) if (cookie.error || !cookie.buffer)
{ {
@ -601,6 +617,12 @@ gpgsm_format_name (const char *name)
#endif /* No fun. */ #endif /* No fun. */
} }
char *
gpgsm_format_name (const char *name)
{
return gpgsm_format_name2 (name, 1);
}
/* Create a key description for the CERT, this may be passed to the /* Create a key description for the CERT, this may be passed to the
pinentry. The caller must free the returned string. NULL may be pinentry. The caller must free the returned string. NULL may be
@ -618,7 +640,7 @@ gpgsm_format_keydesc (ksba_cert_t cert)
char *orig_codeset = NULL; char *orig_codeset = NULL;
name = ksba_cert_get_subject (cert, 0); name = ksba_cert_get_subject (cert, 0);
subject = name? gpgsm_format_name (name) : NULL; subject = name? gpgsm_format_name2 (name, 0) : NULL;
ksba_free (name); name = NULL; ksba_free (name); name = NULL;
sexp = ksba_cert_get_serial (cert); sexp = ksba_cert_get_serial (cert);

View File

@ -560,12 +560,7 @@ i18n_init(void)
set_gettext_file (PACKAGE_GT); set_gettext_file (PACKAGE_GT);
#else #else
# ifdef ENABLE_NLS # ifdef ENABLE_NLS
# ifdef HAVE_LC_MESSAGES
setlocale (LC_TIME, "");
setlocale (LC_MESSAGES, "");
# else
setlocale (LC_ALL, "" ); setlocale (LC_ALL, "" );
# endif
bindtextdomain (PACKAGE_GT, LOCALEDIR); bindtextdomain (PACKAGE_GT, LOCALEDIR);
textdomain (PACKAGE_GT); textdomain (PACKAGE_GT);
# endif # endif

View File

@ -202,6 +202,7 @@ void gpgsm_destroy_writer (Base64Context ctx);
/*-- certdump.c --*/ /*-- certdump.c --*/
void gpgsm_print_serial (FILE *fp, ksba_const_sexp_t p); void gpgsm_print_serial (FILE *fp, ksba_const_sexp_t p);
void gpgsm_print_time (FILE *fp, ksba_isotime_t t); void gpgsm_print_time (FILE *fp, ksba_isotime_t t);
void gpgsm_print_name2 (FILE *fp, const char *string, int translate);
void gpgsm_print_name (FILE *fp, const char *string); void gpgsm_print_name (FILE *fp, const char *string);
void gpgsm_dump_cert (const char *text, ksba_cert_t cert); void gpgsm_dump_cert (const char *text, ksba_cert_t cert);
@ -210,6 +211,7 @@ void gpgsm_dump_time (ksba_isotime_t t);
void gpgsm_dump_string (const char *string); void gpgsm_dump_string (const char *string);
char *gpgsm_format_serial (ksba_const_sexp_t p); char *gpgsm_format_serial (ksba_const_sexp_t p);
char *gpgsm_format_name2 (const char *name, int translate);
char *gpgsm_format_name (const char *name); char *gpgsm_format_name (const char *name);
char *gpgsm_format_keydesc (ksba_cert_t cert); char *gpgsm_format_keydesc (ksba_cert_t cert);

View File

@ -1,5 +1,7 @@
2004-09-30 Werner Koch <wk@g10code.com> 2004-09-30 Werner Koch <wk@g10code.com>
* gpgconf.c (i18n_init): Always use LC_ALL.
* Makefile.am: Adjusted for gettext 0.14. * Makefile.am: Adjusted for gettext 0.14.
2004-09-29 Werner Koch <wk@g10code.com> 2004-09-29 Werner Koch <wk@g10code.com>

View File

@ -106,12 +106,7 @@ i18n_init(void)
set_gettext_file (PACKAGE_GT); set_gettext_file (PACKAGE_GT);
#else #else
# ifdef ENABLE_NLS # ifdef ENABLE_NLS
# ifdef HAVE_LC_MESSAGES
setlocale (LC_TIME, "");
setlocale (LC_MESSAGES, "");
# else
setlocale (LC_ALL, "" ); setlocale (LC_ALL, "" );
# endif
bindtextdomain (PACKAGE_GT, LOCALEDIR); bindtextdomain (PACKAGE_GT, LOCALEDIR);
textdomain (PACKAGE_GT); textdomain (PACKAGE_GT);
# endif # endif