summaryrefslogtreecommitdiff
path: root/lib-src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2012-05-09 17:27:32 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2012-05-09 17:27:32 -0700
commitdb5a3003037a018f47151bb6daaf249d422be2ba (patch)
tree11d9c39e9004ce36773b5b37c818b0e212c16d98 /lib-src
parent5cb6795418c32b8077e3818680a65cba00ea66b6 (diff)
etags: pacify gcc -Wstack-protector on Ubuntu 12.04 x86
* etags.c: Include <stdarg.h>. (error): Declare as printf-style, as that's what it really is. All uses changed. (add_regex): Use single char rather than array-of-one char.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/ChangeLog8
-rw-r--r--lib-src/etags.c39
2 files changed, 27 insertions, 20 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index cf7494cb5d..fe00c29cff 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,3 +1,11 @@
+2012-05-10 Paul Eggert <eggert@cs.ucla.edu>
+
+ etags: pacify gcc -Wstack-protector on Ubuntu 12.04 x86
+ * etags.c: Include <stdarg.h>.
+ (error): Declare as printf-style, as that's what it really is.
+ All uses changed.
+ (add_regex): Use single char rather than array-of-one char.
+
2012-05-05 Jim Meyering <meyering@redhat.com>
* lib-src/pop.c (pop_stat, pop_list, pop_multi_first, pop_last):
diff --git a/lib-src/etags.c b/lib-src/etags.c
index c88473ad52..ccf97a8357 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -158,6 +158,7 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4";
# endif
#endif /* HAVE_UNISTD_H */
+#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
@@ -380,7 +381,7 @@ static void get_tag (char *, char **);
static void analyse_regex (char *);
static void free_regexps (void);
static void regex_tag_multiline (void);
-static void error (const char *, const char *);
+static void error (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2);
static void suggest_asking_for_help (void) NO_RETURN;
void fatal (const char *, const char *) NO_RETURN;
static void pfatal (const char *) NO_RETURN;
@@ -1140,7 +1141,7 @@ main (int argc, char **argv)
case 'o':
if (tagfile)
{
- error ("-o option may only be given once.", (char *)NULL);
+ error ("-o option may only be given once.");
suggest_asking_for_help ();
/* NOTREACHED */
}
@@ -1224,7 +1225,7 @@ main (int argc, char **argv)
if (nincluded_files == 0 && file_count == 0)
{
- error ("no input files specified.", (char *)NULL);
+ error ("no input files specified.");
suggest_asking_for_help ();
/* NOTREACHED */
}
@@ -1447,7 +1448,7 @@ get_language_from_langname (const char *name)
language *lang;
if (name == NULL)
- error ("empty language name", (char *)NULL);
+ error ("empty language name");
else
{
for (lang = lang_names; lang->name != NULL; lang++)
@@ -2233,7 +2234,7 @@ put_entries (register node *np)
{
/* Ctags mode */
if (np->name == NULL)
- error ("internal error: NULL name in ctags mode.", (char *)NULL);
+ error ("internal error: NULL name in ctags mode.");
if (cxref_style)
{
@@ -2773,7 +2774,7 @@ consider_token (register char *str, register int len, register int c, int *c_ext
case dignorerest:
return FALSE;
default:
- error ("internal error: definedef value.", (char *)NULL);
+ error ("internal error: definedef value.");
}
/*
@@ -3061,7 +3062,7 @@ make_C_tag (int isfun)
make_tag (concat ("INVALID TOKEN:-->", token_name.buffer, ""),
token_name.len + 17, isfun, token.line,
token.offset+token.length+1, token.lineno, token.linepos);
- error ("INVALID TOKEN", NULL);
+ error ("INVALID TOKEN");
}
token.valid = FALSE;
@@ -5706,7 +5707,7 @@ add_regex (char *regexp_pattern, language *lang)
{
static struct re_pattern_buffer zeropattern;
char sep, *pat, *name, *modifiers;
- char empty[] = "";
+ char empty = '\0';
const char *err;
struct re_pattern_buffer *patbuf;
regexp *rp;
@@ -5719,7 +5720,7 @@ add_regex (char *regexp_pattern, language *lang)
if (strlen (regexp_pattern) < 3)
{
- error ("null regexp", (char *)NULL);
+ error ("null regexp");
return;
}
sep = regexp_pattern[0];
@@ -5738,7 +5739,7 @@ add_regex (char *regexp_pattern, language *lang)
if (modifiers == NULL) /* no terminating separator --> no name */
{
modifiers = name;
- name = empty;
+ name = &empty;
}
else
modifiers += 1; /* skip separator */
@@ -5749,7 +5750,7 @@ add_regex (char *regexp_pattern, language *lang)
{
case 'N':
if (modifiers == name)
- error ("forcing explicit tag name but no name, ignoring", NULL);
+ error ("forcing explicit tag name but no name, ignoring");
force_explicit_name = TRUE;
break;
case 'i':
@@ -5763,12 +5764,7 @@ add_regex (char *regexp_pattern, language *lang)
need_filebuf = TRUE;
break;
default:
- {
- char wrongmod [2];
- wrongmod[0] = modifiers[0];
- wrongmod[1] = '\0';
- error ("invalid regexp modifier `%s', ignoring", wrongmod);
- }
+ error ("invalid regexp modifier `%c', ignoring", modifiers[0]);
break;
}
@@ -6423,13 +6419,16 @@ suggest_asking_for_help (void)
exit (EXIT_FAILURE);
}
-/* Print error message. `s1' is printf control string, `s2' is arg for it. */
+/* Output a diagnostic with printf-style FORMAT and args. */
static void
-error (const char *s1, const char *s2)
+error (const char *format, ...)
{
+ va_list ap;
+ va_start (ap, format);
fprintf (stderr, "%s: ", progname);
- fprintf (stderr, s1, s2);
+ vfprintf (stderr, format, ap);
fprintf (stderr, "\n");
+ va_end (ap);
}
/* Return a newly-allocated string whose contents