summaryrefslogtreecommitdiff
path: root/plugins/MirOTR/Libgpg-error/gpg-error.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/MirOTR/Libgpg-error/gpg-error.c')
-rw-r--r--plugins/MirOTR/Libgpg-error/gpg-error.c45
1 files changed, 28 insertions, 17 deletions
diff --git a/plugins/MirOTR/Libgpg-error/gpg-error.c b/plugins/MirOTR/Libgpg-error/gpg-error.c
index 9cddb3d463..034a61b6e0 100644
--- a/plugins/MirOTR/Libgpg-error/gpg-error.c
+++ b/plugins/MirOTR/Libgpg-error/gpg-error.c
@@ -7,12 +7,12 @@
modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version.
-
+
libgpg-error is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
-
+
You should have received a copy of the GNU Lesser General Public
License along with libgpg-error; if not, write to the Free
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@ -30,7 +30,7 @@
#include <stdio.h>
#ifdef HAVE_LOCALE_H
-# include <locale.h>
+# include <locale.h>
#endif
#ifdef ENABLE_NLS
#ifdef HAVE_W32_SYSTEM
@@ -66,7 +66,16 @@ i18n_init (void)
{
#ifdef ENABLE_NLS
char *locale_dir;
-
+
+#ifdef HAVE_LC_MESSAGES
+ setlocale (LC_TIME, "");
+ setlocale (LC_MESSAGES, "");
+#else
+# ifndef HAVE_W32_SYSTEM
+ setlocale (LC_ALL, "" );
+# endif
+#endif
+
/* Note that for this program we would only need the textdomain call
because libgpg-error already initializes itself to its locale dir
(via gpg_err_init or a constructor). However this is only done
@@ -106,7 +115,7 @@ get_locale_dir (void)
nbytes = WideCharToMultiByte (CP_UTF8, 0, moddir, -1, NULL, 0, NULL, NULL);
if (nbytes < 0)
return NULL;
-
+
result = malloc (nbytes + strlen (SLDIR) + 1);
if (result)
{
@@ -122,6 +131,12 @@ get_locale_dir (void)
p = strrchr (result, '\\');
if (p)
*p = 0;
+ /* If we are installed below "bin" strip that part and
+ use the top directory instead. */
+ p = strrchr (result, '\\');
+ if (p && !strcmp (p+1, "bin"))
+ *p = 0;
+ /* Append the static part. */
strcat (result, SLDIR);
}
}
@@ -134,8 +149,8 @@ get_locale_dir (void)
strcpy (result, "c:\\gnupg");
strcat (result, SLDIR);
}
- }
-#undef SLDIR
+ }
+#undef SLDIR
return result;
}
@@ -299,7 +314,7 @@ get_err_from_str_one (char *str, gpg_error_t *err,
{
if (*have_code)
return 0;
-
+
*have_code = 1;
*err |= code;
return 1;
@@ -318,7 +333,7 @@ get_err_from_str (char *str, gpg_error_t *err)
int have_code = 0;
int ret;
char *saved_pos = NULL;
- char saved_char;
+ char saved_char = 0; /* (avoid warning) */
*err = 0;
ret = get_err_from_str_one (str, err, &have_source, &have_code);
@@ -365,22 +380,18 @@ main (int argc, char *argv[])
const char *error_sym;
gpg_error_t err;
-#ifndef GPG_ERR_INITIALIZED
- gpg_err_init ();
-#endif
-
+ gpgrt_init ();
i18n_init ();
-
if (argc == 1)
{
- fprintf (stderr, _("Usage: %s GPG-ERROR [...]\n"),
+ fprintf (stderr, _("Usage: %s GPG-ERROR [...]\n"),
strrchr (argv[0],'/')? (strrchr (argv[0], '/')+1): argv[0]);
exit (1);
}
else if (argc == 2 && !strcmp (argv[1], "--version"))
{
- fputs ( ("gpg-error ("PACKAGE_NAME") "PACKAGE_VERSION"\n") , stdout);
+ fputs ("gpg-error (" PACKAGE_NAME ") " PACKAGE_VERSION "\n", stdout);
exit (0);
}
else if (argc == 2 && !strcmp (argv[1], "--list"))
@@ -423,7 +434,7 @@ main (int argc, char *argv[])
{
source_sym = gpg_strsource_sym (err);
error_sym = gpg_strerror_sym (err);
-
+
printf ("%u = (%u, %u) = (%s, %s) = (%s, %s)\n",
err, gpg_err_source (err), gpg_err_code (err),
source_sym ? source_sym : "-", error_sym ? error_sym : "-",