[git] GPG-ERROR - branch, master, updated. libgpg-error-1.32-63-g0b190ce

by Werner Koch cvs at cvs.gnupg.org
Fri Dec 7 14:50:17 CET 2018


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Error codes used by GnuPG et al.".

The branch, master has been updated
       via  0b190ce89de7b3df873c3896d5126c7882b82e18 (commit)
       via  9e62d5e73f30c1386de5153c93fd169889e9e66d (commit)
      from  b7fae45c24cccb9898c6d5a3a633897afb4649dc (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 0b190ce89de7b3df873c3896d5126c7882b82e18
Author: Werner Koch <wk at gnupg.org>
Date:   Fri Dec 7 14:46:25 2018 +0100

    Add W32-only function gpgrt_w32_override_locale.
    
    * src/w32-gettext.c (struct override_locale): new.
    (my_nl_locale_name): Take care of that.
    (gpgrt_w32_override_locale): New.
    * src/gpg-error.def.in: Add gpgrt_w32_override_locale.
    * src/gpg-error.c: New command --locale for Windows.
    --
    
    GnuPG-bug-id: 3733
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/src/gpg-error.c b/src/gpg-error.c
index ade2bae..13703ef 100644
--- a/src/gpg-error.c
+++ b/src/gpg-error.c
@@ -483,6 +483,7 @@ main (int argc, char *argv[])
          CMD_LIB_VERSION = 501,
          CMD_LIST,
          CMD_DEFINES,
+         CMD_LOCALE,
          OPT_DESC
   };
   static gpgrt_opt_t opts[] = {
@@ -492,6 +493,13 @@ main (int argc, char *argv[])
                 "Print all error codes"),
     ARGPARSE_c (CMD_DEFINES, "defines",
                 "Print all error codes as #define lines"),
+    ARGPARSE_c (CMD_LOCALE, "locale",
+#if HAVE_W32_SYSTEM
+                "Return the locale used for gettext"
+#else
+                "@"
+#endif
+                ),
     ARGPARSE_s_n (OPT_DESC, "desc",
                   "Print with error description"),
     ARGPARSE_end()
@@ -500,6 +508,7 @@ main (int argc, char *argv[])
 
   int i;
   int listmode = 0;
+  int localemode = 0;
   int desc = 0;
   const char *source_sym;
   const char *error_sym;
@@ -518,18 +527,41 @@ main (int argc, char *argv[])
         case CMD_LIB_VERSION: break;
         case CMD_LIST:       listmode = 1; break;
         case CMD_DEFINES:    listmode = 2; break;
+        case CMD_LOCALE:     localemode = 1; break;
         case OPT_DESC:       desc = 1; break;
-
         default: pargs.err = ARGPARSE_PRINT_WARNING; break;
         }
     }
   gpgrt_argparse (NULL, &pargs, NULL);  /* Free internal memory.  */
 
-  if ((argc && listmode) || (!argc && !listmode))
+  if (localemode)
+    {
+      if (argc > 1)
+        gpgrt_usage (1);
+    }
+  else if ((argc && listmode) || (!argc && !listmode))
     gpgrt_usage (1);
 
+  if (localemode)
+    {
+#if HAVE_W32_SYSTEM
+      if (argc)
+        {
+          /* Warning: What we do here is not allowed because
+           * gpgrt_w32_override_locale needs to be called as early as
+           * possible.  However for this very purpose it is okay.  */
+          if (**argv >= '0' && **argv <= '9')
+            gpgrt_w32_override_locale (NULL, strtoul (*argv, NULL, 0));
+          else
+            gpgrt_w32_override_locale (*argv, 0);
+        }
 
-  if (listmode == 1)
+      printf ("%s\n", gettext_localename ());
+#else
+      log_info ("this command is only useful on Windows\n");
+#endif
+    }
+  else if (listmode == 1)
     {
       for (i=0; i <  GPG_ERR_SOURCE_DIM; i++)
         {
diff --git a/src/gpg-error.def.in b/src/gpg-error.def.in
index f03a7e3..0eca3c7 100644
--- a/src/gpg-error.def.in
+++ b/src/gpg-error.def.in
@@ -224,5 +224,6 @@ EXPORTS
  gpgrt_fprintf_sf             @171
  gpgrt_fprintf_sf_unlocked    @172
 
+ gpgrt_w32_override_locale    @173
 
 ;; end of file with public symbols for Windows.
diff --git a/src/w32-add.h b/src/w32-add.h
index 07e3c7d..3428961 100644
--- a/src/w32-add.h
+++ b/src/w32-add.h
@@ -37,6 +37,10 @@ int _gpg_w32_gettext_use_utf8 (int value);
 # define gettext_use_utf8(a) _gpg_w32_gettext_use_utf8 (a)
 #endif /*GPG_ERR_ENABLE_GETTEXT_MACROS*/
 
+/* Force the use of the locale NAME or if NAME is NULL the one derived
+ * from LANGID.  This function must be used early and is not thread-safe. */
+void gpgrt_w32_override_locale (const char *name, unsigned short langid);
+
 
 /* A simple iconv implementation w/o the need for an extra DLL.  */
 struct _gpgrt_w32_iconv_s;
diff --git a/src/w32-gettext.c b/src/w32-gettext.c
index 3b54ebd..11e4f3d 100644
--- a/src/w32-gettext.c
+++ b/src/w32-gettext.c
@@ -53,6 +53,16 @@
 #include "init.h"
 #include "gpg-error.h"
 
+/* Override values initialized by gpgrt_w32_override_locale.  If NAME
+ * is not the empty string LANGID will be used.  */
+static struct
+{
+  unsigned short active;  /* If not zero this override is active. */
+  unsigned short langid;
+  char name[28];
+} override_locale;
+
+
 #ifdef HAVE_W32CE_SYSTEM
 /* Forward declaration.  */
 static wchar_t *utf8_to_wchar (const char *string, size_t length, size_t *retlen);
@@ -647,33 +657,42 @@ my_nl_locale_name (const char *categoryname)
 #ifndef HAVE_W32CE_SYSTEM
   const char *retval;
 #endif
-  LCID lcid;
   LANGID langid;
   int primary, sub;
 
-  /* Let the user override the system settings through environment
-     variables, as on POSIX systems.  */
+  if (override_locale.active)
+    {
+      if (*override_locale.name)
+        return override_locale.name;
+      langid = override_locale.langid;
+    }
+  else
+    {
+      LCID lcid;
+
+      /* Let the user override the system settings through environment
+       *  variables, as on POSIX systems.  */
 #ifndef HAVE_W32CE_SYSTEM
-  retval = getenv ("LC_ALL");
-  if (retval != NULL && retval[0] != '\0')
-    return retval;
-  retval = getenv (categoryname);
-  if (retval != NULL && retval[0] != '\0')
-    return retval;
-  retval = getenv ("LANG");
-  if (retval != NULL && retval[0] != '\0')
-    return retval;
+      retval = getenv ("LC_ALL");
+      if (retval != NULL && retval[0] != '\0')
+        return retval;
+      retval = getenv (categoryname);
+      if (retval != NULL && retval[0] != '\0')
+        return retval;
+      retval = getenv ("LANG");
+      if (retval != NULL && retval[0] != '\0')
+        return retval;
 #endif /*!HAVE_W32CE_SYSTEM*/
 
-  /* Use native Win32 API locale ID.  */
+      /* Use native Win32 API locale ID.  */
 #ifdef HAVE_W32CE_SYSTEM
-  lcid = GetSystemDefaultLCID ();
+      lcid = GetSystemDefaultLCID ();
 #else
-  lcid = GetThreadLocale ();
+      lcid = GetThreadLocale ();
 #endif
-
-  /* Strip off the sorting rules, keep only the language part.  */
-  langid = LANGIDFROMLCID (lcid);
+      /* Strip off the sorting rules, keep only the language part.  */
+      langid = LANGIDFROMLCID (lcid);
+    }
 
   /* Split into language and territory part.  */
   primary = PRIMARYLANGID (langid);
@@ -1922,6 +1941,24 @@ _gpg_w32_gettext_use_utf8 (int value)
 }
 
 
+/* Force the use of the locale NAME or if NAME is NULL the locale
+ * derived from LANGID will be used.  This function is not thread-safe
+ * and must be used early - even before gpgrt_check_version. */
+void
+gpgrt_w32_override_locale (const char *name, unsigned short langid)
+{
+  if (name)
+    {
+      strncpy (override_locale.name, name, sizeof (override_locale.name) - 1);
+      override_locale.name[sizeof (override_locale.name) - 1] = 0;
+    }
+  else
+    *override_locale.name = 0;
+  override_locale.langid = langid;
+  override_locale.active = 1;
+}
+
+
 #ifdef TEST
 int
 main (int argc, char **argv)

commit 9e62d5e73f30c1386de5153c93fd169889e9e66d
Author: Werner Koch <wk at gnupg.org>
Date:   Fri Dec 7 14:44:41 2018 +0100

    doc: Replace gpg-error-config by gpgrt-config.
    
    --
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/doc/gpgrt.texi b/doc/gpgrt.texi
index cc652f5..d4a3b41 100644
--- a/doc/gpgrt.texi
+++ b/doc/gpgrt.texi
@@ -210,25 +210,19 @@ file search path (via the @option{-I} option).
 
 However, the path to the include file is determined at the time the
 source is configured.  To solve this problem, Libgpg-error ships with
-the small helper programs @command{gpg-error-config} and
- at command{gpgrt-config} which both know the path to the include file
+the small helper program @command{gpgrt-config}
+which know the path to the include file
 and other configuration options.  The options that need to be added to
 the compiler invocation at compile time are output by the
- at option{--cflags} option to @command{gpg-error-config} (or
- at command{gpgrt-config}.  The following example shows how it can be
+ at option{--cflags} option to @command{gpgrt-config}
+The following example shows how it can be
 used at the command line:
 
 @example
-gcc -c foo.c $(gpg-error-config --cflags)
- at end example
-
-or with the identical
-
- at example
 gcc -c foo.c $(gpgrt-config --cflags)
 @end example
 
-Adding the output of @samp{gpg-error-config --cflags} to the
+Adding the output of @samp{gpgrt-config --cflags} to the
 compiler’s command line will ensure that the compiler can find the
 Libgpg-error header file.
 
@@ -236,19 +230,19 @@ A similar problem occurs when linking the program with the library.
 Again, the compiler has to find the library files.  For this to work,
 the path to the library files has to be added to the library search
 path (via the @option{-L} option).  For this, the option
- at option{--libs} to @command{gpg-error-config} can be used.  The
+ at option{--libs} to @command{gpgrt-config} can be used.  The
 example shows how to link @file{foo.o} with the Libgpg-error library
 to a program @command{foo}.
 
 @example
-gcc -o foo foo.o $(gpg-error-config --libs)
+gcc -o foo foo.o $(gpgrt-config --libs)
 @end example
 
 Of course you can also combine both examples to a single command by
-specifying both options to @command{gpg-error-config}:
+specifying both options to @command{gpgrt-config}:
 
 @example
-gcc -o foo foo.c $(gpg-error-config --cflags --libs)
+gcc -o foo foo.c $(gpgrt-config --cflags --libs)
 @end example
 
 @node Building sources using Automake
@@ -256,7 +250,7 @@ gcc -o foo foo.c $(gpg-error-config --cflags --libs)
 
 It is much easier if you use GNU Automake instead of writing your own
 Makefiles.  If you do that, you do not have to worry about finding and
-invoking the @command{gpg-error-config} script at all.  Libgpg-error
+invoking the @command{gpgrt-config} script at all.  Libgpg-error
 provides an extension to Automake that does all the work for you.
 
 @c A simple macro for optional variables.
@@ -277,7 +271,7 @@ the used helper script does not match the target type you are building
 for a warning is printed and the string @code{libgpg-error} is
 appended to the variable @code{gpg_config_script_warn}.
 
-This macro searches for @command{gpg-error-config} along the PATH.  If
+This macro searches for @command{gpgrt-config} along the PATH.  If
 you are cross-compiling, it is useful to set the environment variable
 @code{SYSROOT} to the top directory of your target.  The macro will
 then first look for the helper program in the @file{bin} directory
@@ -346,27 +340,27 @@ TBD.  (Description of the error function may be taken from Libgcrypt.)
 @chapter Tools
 
 @menu
-* gpg-error-config::    Print required compiler flags
+* gpgrt-config::    Print required compiler flags
 @end menu
 
 @c The original version of this man page has been written for Debian and was
 @c contributed to libgpg-error by Daniel Kahn Gillmor <dkg at fifthhorseman.net>.
- at manpage gpg-error-config.1
- at node gpg-error-config
+ at manpage gpgrt-config.1
+ at node gpgrt-config
 @section Print required compiler flags
 @ifset manverb
-.B gpg-error-config
+.B gpgrt-config
 \- Script to get information about the installed version of libgpg-error
 @end ifset
 
 @mansect synopsis
 @ifset manverb
-.B  gpg-error-config
+.B  gpgrt-config
 .RI [ options ]
 @end ifset
 
 @mansect description
- at command{gpg-error-config} is a tool that is used to configure to
+ at command{gpgrt-config} is a tool that is used to configure to
 determine the compiler and linker flags that should be used to compile
 and link programs that use Libgpg-error. It is also used
 internally to the @code{.m4} macros for GNU autoconf that are included
@@ -374,7 +368,7 @@ with Libgpg-error.
 
 @mansect options
 @noindent
- at command{gpg-error-config} accepts the following options:
+ at command{gpgrt-config} accepts the following options:
 
 @table @gnupgtabopt
 

-----------------------------------------------------------------------

Summary of changes:
 doc/gpgrt.texi       | 42 +++++++++++++-----------------
 src/gpg-error.c      | 38 ++++++++++++++++++++++++---
 src/gpg-error.def.in |  1 +
 src/w32-add.h        |  4 +++
 src/w32-gettext.c    | 73 +++++++++++++++++++++++++++++++++++++++-------------
 5 files changed, 113 insertions(+), 45 deletions(-)


hooks/post-receive
-- 
Error codes used by GnuPG et al.
http://git.gnupg.org




More information about the Gnupg-commits mailing list