mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +02:00
yat2m: Silence lint warnings and fix a printf format bug.
* doc/yat2m.c (ATTR_PRINTF, ATTR_NR_PRINTF, ATTR_MALLOC): New. (die, err, inf, xmalloc, xcalloc): New prototypes with attributes. (get_section_buffer): Take care of !N_SECTIONS. (proc_texi_cmd): Cast precision format arg. (proc_texi_buffer): Do not set IN_CMD when not used afterwards. -- Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
7bca3be65e
commit
22b9bea1c3
41
doc/yat2m.c
41
doc/yat2m.c
@ -1,5 +1,5 @@
|
|||||||
/* yat2m.c - Yet Another Texi 2 Man converter
|
/* yat2m.c - Yet Another Texi 2 Man converter
|
||||||
* Copyright (C) 2005, 2013, 2015 g10 Code GmbH
|
* Copyright (C) 2005, 2013, 2015, 2016 g10 Code GmbH
|
||||||
* Copyright (C) 2006, 2008, 2011 Free Software Foundation, Inc.
|
* Copyright (C) 2006, 2008, 2011 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -13,7 +13,7 @@
|
|||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
* along with this program; if not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -104,6 +104,29 @@
|
|||||||
#include <time.h>
|
#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 PGM "yat2m"
|
||||||
#define VERSION "1.0"
|
#define VERSION "1.0"
|
||||||
|
|
||||||
@ -214,8 +237,16 @@ static const char * const standard_sections[] =
|
|||||||
static void proc_texi_buffer (FILE *fp, const char *line, size_t len,
|
static void proc_texi_buffer (FILE *fp, const char *line, size_t len,
|
||||||
int *table_level, int *eol_action);
|
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. */
|
/* Print diagnostic message and exit with failure. */
|
||||||
static void
|
static void
|
||||||
die (const char *format, ...)
|
die (const char *format, ...)
|
||||||
@ -558,7 +589,7 @@ get_section_buffer (const char *name)
|
|||||||
for (i=0; i < thepage.n_sections; i++)
|
for (i=0; i < thepage.n_sections; i++)
|
||||||
if (!thepage.sections[i].name)
|
if (!thepage.sections[i].name)
|
||||||
break;
|
break;
|
||||||
if (i < thepage.n_sections)
|
if (thepage.n_sections && i < thepage.n_sections)
|
||||||
sect = thepage.sections + i;
|
sect = thepage.sections + i;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -853,7 +884,7 @@ proc_texi_cmd (FILE *fp, const char *command, const char *rest, size_t len,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
inf ("texinfo command '%s' not supported (%.*s)", command,
|
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 == '{')
|
if (*rest == '{')
|
||||||
@ -965,7 +996,7 @@ proc_texi_buffer (FILE *fp, const char *line, size_t len,
|
|||||||
assert (n <= len);
|
assert (n <= len);
|
||||||
s += n; len -= n;
|
s += n; len -= n;
|
||||||
s--; len++;
|
s--; len++;
|
||||||
in_cmd = 0;
|
/* in_cmd = 0; -- doc only */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user