[Pkg-gnupg-commit] [libgpg-error] 03/15: doc: Update yat2m.c
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Thu Jul 14 23:49:27 UTC 2016
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch master
in repository libgpg-error.
commit 9b5e3d1608922f4aaf9958e022431849d5a58501
Author: Werner Koch <wk at gnupg.org>
Date: Sat Jun 25 11:10:28 2016 +0200
doc: Update yat2m.c
* doc/yat2m.c: Update from gnupg.
--
yat2m.c has been taken from
gnupg commit 22b9bea1c3d0e944aa539a87d79e47d92ca5309f
and the copy here shall now be considered as the canonical version.
Signed-off-by: Werner Koch <wk at gnupg.org>
---
doc/Makefile.am | 2 +-
doc/yat2m.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
2 files changed, 57 insertions(+), 8 deletions(-)
diff --git a/doc/Makefile.am b/doc/Makefile.am
index ddb7e48..3d7b143 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -65,4 +65,4 @@ $(myman_pages) : yat2m-stamp
# been modified. This is required so that the version.texi magic
# updates the release date.
gpgrt.texi : $(gpgrt_TEXINFOS)
- touch $(srcdir)/gcrypt.texi
+ touch $(srcdir)/gpgrt.texi
diff --git a/doc/yat2m.c b/doc/yat2m.c
index 5039cc2..7599081 100644
--- a/doc/yat2m.c
+++ b/doc/yat2m.c
@@ -1,5 +1,5 @@
/* yat2m.c - Yet Another Texi 2 Man converter
- * Copyright (C) 2005, 2013 g10 Code GmbH
+ * Copyright (C) 2005, 2013, 2015, 2016 g10 Code GmbH
* Copyright (C) 2006, 2008, 2011 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
@@ -104,6 +104,29 @@
#include <time.h>
+#if __GNUC__
+# define MY_GCC_VERSION (__GNUC__ * 10000 \
+ + __GNUC_MINOR__ * 100 \
+ + __GNUC_PATCHLEVEL__)
+#else
+# define MY_GCC_VERSION 0
+#endif
+
+#if MY_GCC_VERSION >= 20500
+# define ATTR_PRINTF(f, a) __attribute__ ((format(printf,f,a)))
+# define ATTR_NR_PRINTF(f, a) __attribute__ ((noreturn, format(printf,f,a)))
+#else
+# define ATTR_PRINTF(f, a)
+# define ATTR_NR_PRINTF(f, a)
+#endif
+#if MY_GCC_VERSION >= 30200
+# define ATTR_MALLOC __attribute__ ((__malloc__))
+#else
+# define ATTR_MALLOC
+#endif
+
+
+
#define PGM "yat2m"
#define VERSION "1.0"
@@ -120,6 +143,7 @@ static int quiet;
static int debug;
static const char *opt_source;
static const char *opt_release;
+static const char *opt_date;
static const char *opt_select;
static const char *opt_include;
static int opt_store;
@@ -213,8 +237,16 @@ static const char * const standard_sections[] =
static void proc_texi_buffer (FILE *fp, const char *line, size_t len,
int *table_level, int *eol_action);
+static void die (const char *format, ...) ATTR_NR_PRINTF(1,2);
+static void err (const char *format, ...) ATTR_PRINTF(1,2);
+static void inf (const char *format, ...) ATTR_PRINTF(1,2);
+static void *xmalloc (size_t n) ATTR_MALLOC;
+static void *xcalloc (size_t n, size_t m) ATTR_MALLOC;
+
+/*-- Functions --*/
+
/* Print diagnostic message and exit with failure. */
static void
die (const char *format, ...)
@@ -323,8 +355,12 @@ isodatestring (void)
{
static char buffer[11+5];
struct tm *tp;
- time_t atime = time (NULL);
+ time_t atime;
+ if (opt_date && *opt_date)
+ atime = strtoul (opt_date, NULL, 10);
+ else
+ atime = time (NULL);
if (atime < 0)
strcpy (buffer, "????" "-??" "-??");
else
@@ -553,7 +589,7 @@ get_section_buffer (const char *name)
for (i=0; i < thepage.n_sections; i++)
if (!thepage.sections[i].name)
break;
- if (i < thepage.n_sections)
+ if (thepage.n_sections && i < thepage.n_sections)
sect = thepage.sections + i;
else
{
@@ -656,6 +692,7 @@ write_th (FILE *fp)
*p++ = 0;
fprintf (fp, ".TH %s %s %s \"%s\" \"%s\"\n",
name, p, isodatestring (), opt_release, opt_source);
+ free (name);
return 0;
}
@@ -678,6 +715,7 @@ proc_texi_cmd (FILE *fp, const char *command, const char *rest, size_t len,
} cmdtbl[] = {
{ "command", 0, "\\fB", "\\fR" },
{ "code", 0, "\\fB", "\\fR" },
+ { "url", 0, "\\fB", "\\fR" },
{ "sc", 0, "\\fB", "\\fR" },
{ "var", 0, "\\fI", "\\fR" },
{ "samp", 0, "\\(aq", "\\(aq" },
@@ -698,6 +736,7 @@ proc_texi_cmd (FILE *fp, const char *command, const char *rest, size_t len,
{ "emph", 0, "\\fI", "\\fR" },
{ "w", 1 },
{ "c", 5 },
+ { "efindex", 1 },
{ "opindex", 1 },
{ "cpindex", 1 },
{ "cindex", 1 },
@@ -845,7 +884,7 @@ proc_texi_cmd (FILE *fp, const char *command, const char *rest, size_t len,
}
else
inf ("texinfo command '%s' not supported (%.*s)", command,
- ((s = memchr (rest, '\n', len)), (s? (s-rest) : len)), rest);
+ (int)((s = memchr (rest, '\n', len)), (s? (s-rest) : len)), rest);
}
if (*rest == '{')
@@ -957,7 +996,7 @@ proc_texi_buffer (FILE *fp, const char *line, size_t len,
assert (n <= len);
s += n; len -= n;
s--; len++;
- in_cmd = 0;
+ /* in_cmd = 0; -- doc only */
}
}
@@ -1366,7 +1405,7 @@ parse_file (const char *fname, FILE *fp, char **section_name, int in_pause)
}
if (!incfp)
- err ("can't open include file '%s':%s",
+ err ("can't open include file '%s': %s",
incname, strerror (errno));
else
{
@@ -1465,13 +1504,14 @@ main (int argc, char **argv)
"Extract man pages from a Texinfo source.\n\n"
" --source NAME use NAME as source field\n"
" --release STRING use STRING as the release field\n"
+ " --date EPOCH use EPOCH as publication date\n"
" --store write output using @manpage name\n"
" --select NAME only output pages with @manpage NAME\n"
" --verbose enable extra informational output\n"
" --debug enable additional debug output\n"
" --help display this help and exit\n"
" -I DIR also search in include DIR\n"
- " -D gpgone the only useable define\n\n"
+ " -D gpgone the only usable define\n\n"
"With no FILE, or when FILE is -, read standard input.\n\n"
"Report bugs to <bugs at g10code.com>.");
exit (0);
@@ -1518,6 +1558,15 @@ main (int argc, char **argv)
argc--; argv++;
}
}
+ else if (!strcmp (*argv, "--date"))
+ {
+ argc--; argv++;
+ if (argc)
+ {
+ opt_date = *argv;
+ argc--; argv++;
+ }
+ }
else if (!strcmp (*argv, "--store"))
{
opt_store = 1;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/libgpg-error.git
More information about the Pkg-gnupg-commit
mailing list