libgpg-error/backport-make-lib-version-work.patch
yangl777 11423e57d0 make the lib-version option work
(cherry picked from commit d0e761030950c5130f820842b51085e00701188a)
2024-01-05 14:27:08 +08:00

95 lines
2.7 KiB
Diff

From e0dab4843ded8af172c2566b4d7313a1a13e7e26 Mon Sep 17 00:00:00 2001
From: Werner Koch <wk@gnupg.org>
Date: Wed, 5 Aug 2020 12:19:56 +0200
Subject: [PATCH] Make --lib-version work again.
* src/gpg-error.c (main): Add printing code.
--
This was lost while changing to the included option parser back in
2018. The new code also does some prettying of the output.
Fixes-commit: 11ce9bc3d6fe75859e18112824ae7ec3ca0fc8df
Signed-off-by: Werner Koch <wk@gnupg.org>
Conflict:NA
Reference:https://github.com/gpg/libgpg-error/commit/e0dab4843ded8af172c2566b4d7313a1a13e7e26
---
src/gpg-error.c | 39 ++++++++++++++++++++++++++++++++++++---
1 file changed, 36 insertions(+), 3 deletions(-)
diff --git a/src/gpg-error.c b/src/gpg-error.c
index cc92c10..4e8bd8b 100644
--- a/src/gpg-error.c
+++ b/src/gpg-error.c
@@ -571,9 +571,11 @@ main (int argc, char *argv[])
gpgrt_argparse_t pargs = { &argc, &argv };
int i;
+ int libversion = 0;
int listmode = 0;
int localemode = 0;
int desc = 0;
+ const char *s, *s2;
const char *source_sym;
const char *error_sym;
gpg_error_t err;
@@ -588,7 +590,7 @@ main (int argc, char *argv[])
{
switch (pargs.r_opt)
{
- case CMD_LIB_VERSION: break;
+ case CMD_LIB_VERSION: libversion = 1; break;
case CMD_LIST: listmode = 1; break;
case CMD_DEFINES: listmode = 2; break;
case CMD_LOCALE: localemode = 1; break;
@@ -598,7 +600,12 @@ main (int argc, char *argv[])
}
gpgrt_argparse (NULL, &pargs, NULL); /* Free internal memory. */
- if (localemode)
+ if (libversion)
+ {
+ if (argc)
+ gpgrt_usage (1);
+ }
+ else if (localemode)
{
if (argc > 1)
gpgrt_usage (1);
@@ -606,7 +613,33 @@ main (int argc, char *argv[])
else if ((argc && listmode) || (!argc && !listmode))
gpgrt_usage (1);
- if (localemode)
+
+ if (libversion)
+ {
+ argc--; argv++;
+ printf ("Version from header: %s (0x%06x)\n",
+ GPG_ERROR_VERSION, GPG_ERROR_VERSION_NUMBER);
+ printf ("Version from binary: %s\n", gpg_error_check_version (NULL));
+ s = gpg_error_check_version ("\x01\x01");
+ while (*s && *s == '\n')
+ s++;
+ fputs ("Copyright blurb ...: ", stdout);
+ for (; *s; s++)
+ {
+ if (*s == '\n')
+ {
+ for (s2=s+1; *s2 == '\n'; s2++)
+ ;
+ if (!*s2)
+ break; /* Cut off trailing LFs. */
+ fputs ("\n ", stdout);
+ }
+ else
+ putc (*s, stdout);
+ }
+ putc ('\n', stdout);
+ }
+ else if (localemode)
{
#if HAVE_W32_SYSTEM
if (argc)