mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-18 14:17:03 +01:00
gpgconf: Adjust -X command for the new VERSION file format
* tools/gpgconf.c (show_version_gnupg): Read and parse the entire VERSION file. -- GnuPG-bug-id: 6918
This commit is contained in:
parent
45f6357881
commit
35fd89b168
@ -1153,10 +1153,12 @@ get_revision_from_blurb (const char *blurb, int *r_len)
|
|||||||
static void
|
static void
|
||||||
show_version_gnupg (estream_t fp, const char *prefix)
|
show_version_gnupg (estream_t fp, const char *prefix)
|
||||||
{
|
{
|
||||||
char *fname, *p;
|
char *fname, *p, *p0;
|
||||||
size_t n;
|
size_t n;
|
||||||
estream_t verfp;
|
estream_t verfp;
|
||||||
char line[100];
|
char *line = NULL;
|
||||||
|
size_t line_len = 0;
|
||||||
|
ssize_t length;
|
||||||
|
|
||||||
es_fprintf (fp, "%s%sGnuPG %s (%s)\n%s%s\n", prefix, *prefix?"":"* ",
|
es_fprintf (fp, "%s%sGnuPG %s (%s)\n%s%s\n", prefix, *prefix?"":"* ",
|
||||||
gpgrt_strusage (13), BUILD_REVISION, prefix, gpgrt_strusage (17));
|
gpgrt_strusage (13), BUILD_REVISION, prefix, gpgrt_strusage (17));
|
||||||
@ -1175,20 +1177,46 @@ show_version_gnupg (estream_t fp, const char *prefix)
|
|||||||
verfp = es_fopen (fname, "r");
|
verfp = es_fopen (fname, "r");
|
||||||
if (!verfp)
|
if (!verfp)
|
||||||
es_fprintf (fp, "%s[VERSION file not found]\n", prefix);
|
es_fprintf (fp, "%s[VERSION file not found]\n", prefix);
|
||||||
else if (!es_fgets (line, sizeof line, verfp))
|
|
||||||
es_fprintf (fp, "%s[VERSION file is empty]\n", prefix);
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
int lnr = 0;
|
||||||
|
|
||||||
|
p0 = NULL;
|
||||||
|
while ((length = es_read_line (verfp, &line, &line_len, NULL))>0)
|
||||||
|
{
|
||||||
|
lnr++;
|
||||||
trim_spaces (line);
|
trim_spaces (line);
|
||||||
for (p=line; *p; p++)
|
if (lnr == 1 && *line != '[')
|
||||||
|
{
|
||||||
|
/* Old file format where we look only at the
|
||||||
|
* first line. */
|
||||||
|
p0 = line;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (!strncmp (line, "version=", 8))
|
||||||
|
{
|
||||||
|
p0 = line + 8;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (length < 0 || es_ferror (verfp))
|
||||||
|
es_fprintf (fp, "%s[VERSION file read error]\n", prefix);
|
||||||
|
else if (p0)
|
||||||
|
{
|
||||||
|
for (p=p0; *p; p++)
|
||||||
if (*p < ' ' || *p > '~' || *p == '[')
|
if (*p < ' ' || *p > '~' || *p == '[')
|
||||||
*p = '?';
|
*p = '?';
|
||||||
es_fprintf (fp, "%s%s\n", prefix, line);
|
es_fprintf (fp, "%s%s\n", prefix, p0);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
es_fprintf (fp, "%s[VERSION file is empty]\n", prefix);
|
||||||
|
|
||||||
es_fclose (verfp);
|
es_fclose (verfp);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
xfree (fname);
|
xfree (fname);
|
||||||
}
|
}
|
||||||
|
xfree (line);
|
||||||
|
|
||||||
#ifdef HAVE_W32_SYSTEM
|
#ifdef HAVE_W32_SYSTEM
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user