From be3a828e7057e2ea01772b2a00d2ad3e5c46776c Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Fri, 7 May 2010 01:32:54 +0000 Subject: [PATCH] 2010-05-07 Marcus Brinkmann * engine-g13.c, gpgme.c, engine-gpgsm.c, engine-gpg.c, op-support.c, engine-assuan.c, gpgme-tool.c: Include only if available with HAVE_LOCALE_H and conditionalize use of LC_CTYPE on its definition. * engine-gpgconf.c: Do not include . --- ChangeLog | 4 ++++ configure.ac | 1 + src/ChangeLog | 6 ++++++ src/engine-assuan.c | 8 +++++++- src/engine-g13.c | 8 +++++++- src/engine-gpg.c | 8 +++++++- src/engine-gpgconf.c | 1 - src/engine-gpgsm.c | 8 +++++++- src/gpgme-tool.c | 5 +++++ src/gpgme.c | 6 ++++++ src/op-support.c | 5 +++++ 11 files changed, 55 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 38e126f..baaa69e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-05-07 Marcus Brinkmann + + * configure.ac: Check for locale.h. + 2010-05-06 Marcus Brinkmann * configure.ac: Detect Windows CE. diff --git a/configure.ac b/configure.ac index c0bcac1..6ac1a5e 100644 --- a/configure.ac +++ b/configure.ac @@ -203,6 +203,7 @@ AM_CONDITIONAL(HAVE_PTHREAD, test "$have_pthread" = "yes") # Checks for header files. +AC_CHECK_HEADERS([locale.h]) AC_CHECK_HEADERS(sys/select.h) AC_CHECK_HEADERS([sys/uio.h]) diff --git a/src/ChangeLog b/src/ChangeLog index a283501..4f1ca96 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,11 @@ 2010-05-07 Marcus Brinkmann + * engine-g13.c, gpgme.c, engine-gpgsm.c, engine-gpg.c, + op-support.c, engine-assuan.c, gpgme-tool.c: Include + only if available with HAVE_LOCALE_H and conditionalize use of + LC_CTYPE on its definition. + * engine-gpgconf.c: Do not include . + * engine-gpgsm.c (gpgsm_new, start): Cast between int and assuan_fd_t. * assuan-support.c (my_pipe, my_close, my_read, my_write): Likewise. diff --git a/src/engine-assuan.c b/src/engine-assuan.c index d8d3086..73ece80 100644 --- a/src/engine-assuan.c +++ b/src/engine-assuan.c @@ -33,7 +33,9 @@ #include #include #include +#ifdef HAVE_LOCALE_H #include +#endif #include #include "gpgme.h" @@ -358,7 +360,10 @@ llass_set_locale (void *engine, int category, const char *value) /* FIXME: If value is NULL, we need to reset the option to default. But we can't do this. So we error out here. gpg-agent needs support for this. */ - if (category == LC_CTYPE) + if (0) + ; +#ifdef LC_CTYPE + else if (category == LC_CTYPE) { catstr = "lc-ctype"; if (!value && llass->lc_ctype_set) @@ -366,6 +371,7 @@ llass_set_locale (void *engine, int category, const char *value) if (value) llass->lc_ctype_set = 1; } +#endif #ifdef LC_MESSAGES else if (category == LC_MESSAGES) { diff --git a/src/engine-g13.c b/src/engine-g13.c index 208fb35..8b2af4d 100644 --- a/src/engine-g13.c +++ b/src/engine-g13.c @@ -28,7 +28,9 @@ #include #include #include +#ifdef HAVE_LOCALE_H #include +#endif #include /* FIXME */ #include @@ -354,7 +356,10 @@ g13_set_locale (void *engine, int category, const char *value) /* FIXME: If value is NULL, we need to reset the option to default. But we can't do this. So we error out here. G13 needs support for this. */ - if (category == LC_CTYPE) + if (0) + ; +#ifdef LC_CTYPE + else if (category == LC_CTYPE) { catstr = "lc-ctype"; if (!value && g13->lc_ctype_set) @@ -362,6 +367,7 @@ g13_set_locale (void *engine, int category, const char *value) if (value) g13->lc_ctype_set = 1; } +#endif #ifdef LC_MESSAGES else if (category == LC_MESSAGES) { diff --git a/src/engine-gpg.c b/src/engine-gpg.c index a05fca2..da66d4d 100644 --- a/src/engine-gpg.c +++ b/src/engine-gpg.c @@ -28,7 +28,9 @@ #include #include #include +#ifdef HAVE_LOCALE_H #include +#endif #include "gpgme.h" #include "util.h" @@ -563,7 +565,10 @@ gpg_set_locale (void *engine, int category, const char *value) { engine_gpg_t gpg = engine; - if (category == LC_CTYPE) + if (0) + ; +#ifdef LC_CTYPE + else if (category == LC_CTYPE) { if (gpg->lc_ctype) { @@ -577,6 +582,7 @@ gpg_set_locale (void *engine, int category, const char *value) return gpg_error_from_syserror (); } } +#endif #ifdef LC_MESSAGES else if (category == LC_MESSAGES) { diff --git a/src/engine-gpgconf.c b/src/engine-gpgconf.c index 6448b06..d3c47a7 100644 --- a/src/engine-gpgconf.c +++ b/src/engine-gpgconf.c @@ -27,7 +27,6 @@ #include #include #include -#include #include /* FIXME */ #include diff --git a/src/engine-gpgsm.c b/src/engine-gpgsm.c index fce4659..64189bf 100644 --- a/src/engine-gpgsm.c +++ b/src/engine-gpgsm.c @@ -29,7 +29,9 @@ #include #include #include +#ifdef HAVE_LOCALE_H #include +#endif #include /* FIXME */ #include @@ -507,7 +509,10 @@ gpgsm_set_locale (void *engine, int category, const char *value) /* FIXME: If value is NULL, we need to reset the option to default. But we can't do this. So we error out here. GPGSM needs support for this. */ - if (category == LC_CTYPE) + if (0) + ; +#ifdef LC_CTYPE + else if (category == LC_CTYPE) { catstr = "lc-ctype"; if (!value && gpgsm->lc_ctype_set) @@ -515,6 +520,7 @@ gpgsm_set_locale (void *engine, int category, const char *value) if (value) gpgsm->lc_ctype_set = 1; } +#endif #ifdef LC_MESSAGES else if (category == LC_MESSAGES) { diff --git a/src/gpgme-tool.c b/src/gpgme-tool.c index 63df70d..f102979 100644 --- a/src/gpgme-tool.c +++ b/src/gpgme-tool.c @@ -28,7 +28,9 @@ #include #include #include +#ifdef HAVE_LOCALE_H #include +#endif #ifdef HAVE_ARGP_H #include #endif @@ -2908,10 +2910,13 @@ main (int argc, char *argv[]) setlocale (LC_ALL, ""); gpgme_check_version (NULL); +#ifdef LC_CTYPE gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL)); +#endif #ifdef LC_MESSAGES gpgme_set_locale (NULL, LC_MESSAGES, setlocale (LC_MESSAGES, NULL)); #endif + args_init (&args); argp_parse (&argp, argc, argv, 0, 0, &args); diff --git a/src/gpgme.c b/src/gpgme.c index fe601a0..b6a518f 100644 --- a/src/gpgme.c +++ b/src/gpgme.c @@ -27,7 +27,9 @@ #include #include #include +#ifdef HAVE_LOCALE_H #include +#endif #include "util.h" #include "context.h" @@ -600,7 +602,9 @@ gpgme_set_locale (gpgme_ctx_t ctx, int category, const char *value) failed = 1; \ } +#ifdef LC_CTYPE PREPARE_ONE_LOCALE (ctype, CTYPE); +#endif #ifdef LC_MESSAGES PREPARE_ONE_LOCALE (messages, MESSAGES); #endif @@ -636,7 +640,9 @@ gpgme_set_locale (gpgme_ctx_t ctx, int category, const char *value) if (!ctx) LOCK (def_lc_lock); +#ifdef LC_CTYPE SET_ONE_LOCALE (ctype, CTYPE); +#endif #ifdef LC_MESSAGES SET_ONE_LOCALE (messages, MESSAGES); #endif diff --git a/src/op-support.c b/src/op-support.c index 6738536..66e6849 100644 --- a/src/op-support.c +++ b/src/op-support.c @@ -23,7 +23,9 @@ #include #include #include +#ifdef HAVE_LOCALE_H #include +#endif #include "gpgme.h" #include "context.h" @@ -114,7 +116,10 @@ _gpgme_op_reset (gpgme_ctx_t ctx, int type) if (!reuse_engine) { + err = 0; +#ifdef LC_CTYPE err = _gpgme_engine_set_locale (ctx->engine, LC_CTYPE, ctx->lc_ctype); +#endif #ifdef LC_MESSAGES if (!err) err = _gpgme_engine_set_locale (ctx->engine, -- 2.26.2