Paolo Bonzini wrote:
> * configure.ac: Add COPYRIGHT_YEAR #define.
> * README-release: Document it.
> * src/main.c (main): Use it.
> ---
> README-release | 3 +++
> configure.ac | 1 +
> src/main.c | 4 ++--
> 3 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/README-release b/README-release
> index 0df5ff5..5be29b2 100644
> --- a/README-release
> +++ b/README-release
> @@ -4,6 +4,9 @@ Here are most of the steps we (maintainers) follow when
> making a release.
>
> git checkout master; git pull
>
> +* Ensure that COPYRIGHT_YEAR is correct in configure.ac. If not, update
> + it and commit the change.
> +
> * Run ./configure && make maintainer-clean
>
> * Ensure that the desired versions of autoconf, automake, etc.
> diff --git a/configure.ac b/configure.ac
> index 01ae0f2..744fa00 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -25,6 +25,7 @@ AC_INIT([GNU grep],
> AC_CONFIG_AUX_DIR(build-aux)
> AC_CONFIG_SRCDIR(src/grep.c)
> AC_DEFINE([GREP], 1, [We are building grep])
> +AC_DEFINE([COPYRIGHT_YEAR], 2010, [Copyright year for --version.])
> AC_PREREQ(2.59)
>
> dnl Automake stuff.
> diff --git a/src/main.c b/src/main.c
> index 5314912..e4ea374 100644
> --- a/src/main.c
> +++ b/src/main.c
> @@ -2158,11 +2158,11 @@ main (int argc, char **argv)
> {
> printf ("%s\n\n", PACKAGE_STRING);
> printf (_("\
> -Copyright (C) %s Free Software Foundation, Inc.\n\
> +Copyright (C) %d Free Software Foundation, Inc.\n\
> License GPLv3+: GNU GPL version 3 or later
> <http://gnu.org/licenses/gpl.html>\n\
> This is free software: you are free to change and redistribute it.\n\
> There is NO WARRANTY, to the extent permitted by law.\n"),
> - "2009");
> + COPYRIGHT_YEAR);
Hi Paolo,
Thanks for the patch!
Did you consider using gnulib's version_etc function?
That would automate keeping the copyright year up to date
and it would also factor out the copyright text.
The only trick is to identify the authors, since --version
should print a list of author names (per GCS). However,
the AUTHORS file already outlines that.
How about the change below instead?
With it, grep --version prints this:
grep (GNU grep) 2.6.3.85-f53b-dirty
Copyright (C) 2010 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 Mike Haertel and others, see
<http://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.
>From 24037ee44d0e4c2bb22c31fe9e3747ab13caf22b Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email protected]>
Date: Mon, 30 Aug 2010 10:52:39 +0200
Subject: [PATCH] maint: use gnulib's standard --version-printing code
This includes author names and keeps the copyright year up to date.
* bootstrap.conf (gnulib_modules): Add propername and version-etc-fsf.
* src/main.c (AUTHORS): Define.
(main): Use version_etc, rather than hard-coding the copyright text.
Prompted by a patch from Paolo Bonzini.
---
bootstrap.conf | 2 ++
src/main.c | 18 +++++++++---------
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/bootstrap.conf b/bootstrap.conf
index 77870fe..8edf429 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -58,6 +58,7 @@ minmax
obstack
open
progname
+propername
quotearg
realloc
regex
@@ -76,6 +77,7 @@ unistd
unlocked-io
update-copyright
useless-if-before-free
+version-etc-fsf
wchar
wcrtomb
wctob
diff --git a/src/main.c b/src/main.c
index 5314912..6f5c4ae 100644
--- a/src/main.c
+++ b/src/main.c
@@ -43,7 +43,9 @@
#include "intprops.h"
#include "isdir.h"
#include "progname.h"
+#include "propername.h"
#include "savedir.h"
+#include "version-etc.h"
#include "xalloc.h"
#include "xstrtol.h"
@@ -53,6 +55,10 @@
#define STREQ(a, b) (strcmp (a, b) == 0)
+#define AUTHORS \
+ proper_name ("Mike Haertel"), \
+ _("others, see <http://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>")
+
struct stats
{
struct stats const *parent;
@@ -2156,15 +2162,9 @@ main (int argc, char **argv)
if (show_version)
{
- printf ("%s\n\n", PACKAGE_STRING);
- printf (_("\
-Copyright (C) %s Free Software Foundation, Inc.\n\
-License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>\n\
-This is free software: you are free to change and redistribute it.\n\
-There is NO WARRANTY, to the extent permitted by law.\n"),
- "2009");
- printf ("\n");
- exit (EXIT_SUCCESS);
+ version_etc (stdout, program_name, PACKAGE_NAME, VERSION, AUTHORS, \
+ (char *) NULL); \
+ exit (EXIT_SUCCESS); \
}
if (show_help)
--
1.7.2.2.510.g7180a