+2009-06-25 Eric Blake <ebb9@byu.net>
+
+ version-etc: fix regression
+ * lib/version-etc.h (ATTRIBUTE_SENTINEL): Define for new enough
+ gcc.
+ (version_etc): Use it, to catch bugs with trailing NULL.
+ * lib/version-etc.c (version_etc_arn): Delete unused argument.
+ (version_etc_va): Fix logic bug.
+ * modules/version-etc-tests: Add test.
+ * tests/test-version-etc.c: New file.
+ * tests/test-version-etc.sh: Likewise.
+
2009-06-25 Sam Steingold <sds@gnu.org>
* mbrtowc.m4 (gl_MBRTOWC_SANITYCHECK): Include <stdlib.h>, for the
fprintf (stream, _("\
Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, %s, and others.\n"),
authors[0], authors[1], authors[2], authors[3], authors[4],
- authors[5], authors[6], authors[7], authors[8], authors[9]);
+ authors[5], authors[6], authors[7], authors[8]);
break;
}
}
for (n_authors = 0;
n_authors < 10
- && (authtab[n_authors++] = va_arg (authors, const char *)) != NULL;
+ && (authtab[n_authors] = va_arg (authors, const char *)) != NULL;
n_authors++)
;
version_etc_arn (stream, command_name, package, version,
# include <stdarg.h>
# include <stdio.h>
+/* The `sentinel' attribute was added in gcc 4.0. */
+#ifndef ATTRIBUTE_SENTINEL
+# if 4 <= __GNUC__
+# define ATTRIBUTE_SENTINEL __attribute__ ((__sentinel__))
+# else
+# define ATTRIBUTE_SENTINEL /* empty */
+# endif
+#endif
+
extern const char version_etc_copyright[];
/* The three functions below display the --version information in the
The functions differ in the way they are passed author names: */
-/* N_AUTHORS names are supplied in array AUTHORS */
+/* N_AUTHORS names are supplied in array AUTHORS. */
extern void version_etc_arn (FILE *stream,
const char *command_name, const char *package,
const char *version,
const char * const * authors, size_t n_authors);
-/* Names are passed in the NULL-terminated array AUTHORS */
+/* Names are passed in the NULL-terminated array AUTHORS. */
extern void version_etc_ar (FILE *stream,
const char *command_name, const char *package,
const char *version, const char * const * authors);
-/* Names are passed in the NULL-terminated va_list */
+/* Names are passed in the NULL-terminated va_list. */
extern void version_etc_va (FILE *stream,
const char *command_name, const char *package,
const char *version, va_list authors);
/* Names are passed as separate arguments, with an additional
- NULL argument at the end. */
+ NULL argument at the end. */
extern void version_etc (FILE *stream,
const char *command_name, const char *package,
const char *version,
- /* const char *author1, ...*/ ...);
+ /* const char *author1, ..., NULL */ ...)
+ ATTRIBUTE_SENTINEL;
/* Display the usual `Report bugs to' stanza */
extern void emit_bug_reporting_address (void);
--- /dev/null
+Files:
+tests/test-version-etc.c
+tests/test-version-etc.sh
+
+Depends-on:
+progname
+version-etc-fsf
+
+Makefile.am:
+TESTS += test-version-etc.sh
+TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@'
+check_PROGRAMS += test-version-etc
+test_version_etc_LDADD = $(LDADD) @LIBINTL@
--- /dev/null
+/* Test suite for version-etc.
+ Copyright (C) 2009 Free Software Foundation, Inc.
+ This file is part of the GNUlib Library.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include "version-etc.h"
+
+#include "progname.h"
+
+#define AUTHORS "Sergey Poznyakoff", "Eric Blake"
+
+int
+main (int argc, char **argv)
+{
+ set_program_name (argv[0]);
+ version_etc (stdout, "test-version-etc", "dummy", "0", AUTHORS,
+ (const char *) NULL);
+ return 0;
+}
--- /dev/null
+#! /bin/sh
+# Test suite for version-etc.
+# Copyright (C) 2009 Free Software Foundation, Inc.
+# This file is part of the GNUlib Library.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+TMP=ve-expected.tmp
+LC_ALL=C
+export LC_ALL
+ERR=0
+
+cat > $TMP <<EOT
+test-version-etc (dummy) 0
+COPYRIGHT Free Software Foundation, Inc.
+License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
+This is free software: you are free to change and redistribute it.
+There is NO WARRANTY, to the extent permitted by law.
+
+Written by Sergey Poznyakoff and Eric Blake.
+EOT
+
+./test-version-etc --version |
+ sed '2s/Copyright (C) [0-9]\{4,4\}/COPYRIGHT/' |
+ diff -c $TMP - || ERR=1
+
+rm $TMP
+
+exit $ERR