2010-05-07 Marcus Brinkmann <marcus@g10code.de>

* engine-g13.c, gpgme.c, engine-gpgsm.c, engine-gpg.c,
	op-support.c, engine-assuan.c, gpgme-tool.c: Include <locale.h>
	only if available with HAVE_LOCALE_H and conditionalize use of
	LC_CTYPE on its definition.
	* engine-gpgconf.c: Do not include <locale.h>.
This commit is contained in:
Marcus Brinkmann 2010-05-07 01:32:54 +00:00
parent 97df297ae2
commit be3a828e70
11 changed files with 55 additions and 5 deletions

View File

@ -1,3 +1,7 @@
2010-05-07 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Check for locale.h.
2010-05-06 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Detect Windows CE.

View File

@ -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])

View File

@ -1,5 +1,11 @@
2010-05-07 Marcus Brinkmann <marcus@g10code.de>
* engine-g13.c, gpgme.c, engine-gpgsm.c, engine-gpg.c,
op-support.c, engine-assuan.c, gpgme-tool.c: Include <locale.h>
only if available with HAVE_LOCALE_H and conditionalize use of
LC_CTYPE on its definition.
* engine-gpgconf.c: Do not include <locale.h>.
* 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.

View File

@ -33,7 +33,9 @@
#include <sys/types.h>
#include <assert.h>
#include <unistd.h>
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
#include <errno.h>
#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)
{

View File

@ -28,7 +28,9 @@
#include <sys/types.h>
#include <assert.h>
#include <unistd.h>
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
#include <fcntl.h> /* FIXME */
#include <errno.h>
@ -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)
{

View File

@ -28,7 +28,9 @@
#include <assert.h>
#include <errno.h>
#include <unistd.h>
#ifdef HAVE_LOCALE_H
#include <locale.h>
#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)
{

View File

@ -27,7 +27,6 @@
#include <sys/types.h>
#include <assert.h>
#include <unistd.h>
#include <locale.h>
#include <fcntl.h> /* FIXME */
#include <errno.h>

View File

@ -29,7 +29,9 @@
#include <sys/types.h>
#include <assert.h>
#include <unistd.h>
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
#include <fcntl.h> /* FIXME */
#include <errno.h>
@ -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)
{

View File

@ -28,7 +28,9 @@
#include <getopt.h>
#include <ctype.h>
#include <stdarg.h>
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
#ifdef HAVE_ARGP_H
#include <argp.h>
#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);

View File

@ -27,7 +27,9 @@
#include <string.h>
#include <assert.h>
#include <errno.h>
#ifdef HAVE_LOCALE_H
#include <locale.h>
#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

View File

@ -23,7 +23,9 @@
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#ifdef HAVE_LOCALE_H
#include <locale.h>
#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,