Import Gnulib's `log1p' and `round' modules.
[bpt/guile.git] / lib / version-etc.c
CommitLineData
4f02b98d 1/* Print --version and bug-reporting information in a consistent format.
49114fd4 2 Copyright (C) 1999-2011 Free Software Foundation, Inc.
4f02b98d
LC
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
16
17/* Written by Jim Meyering. */
18
19#include <config.h>
20
21/* Specification. */
22#include "version-etc.h"
23
24#include <stdarg.h>
25#include <stdio.h>
26#include <stdlib.h>
27
28#if USE_UNLOCKED_IO
29# include "unlocked-io.h"
30#endif
31
32#include "gettext.h"
33#define _(msgid) gettext (msgid)
34
1cd4fffc
LC
35/* If you use AM_INIT_AUTOMAKE's no-define option,
36 PACKAGE is not defined. Use PACKAGE_TARNAME instead. */
37#if ! defined PACKAGE && defined PACKAGE_TARNAME
38# define PACKAGE PACKAGE_TARNAME
39#endif
40
49114fd4 41enum { COPYRIGHT_YEAR = 2011 };
4f02b98d
LC
42
43/* The three functions below display the --version information the
44 standard way.
45
46 If COMMAND_NAME is NULL, the PACKAGE is assumed to be the name of
47 the program. The formats are therefore:
48
49 PACKAGE VERSION
50
51 or
52
53 COMMAND_NAME (PACKAGE) VERSION.
54
55 The functions differ in the way they are passed author names. */
56
57/* Display the --version information the standard way.
58
59 Author names are given in the array AUTHORS. N_AUTHORS is the
60 number of elements in the array. */
61void
62version_etc_arn (FILE *stream,
1cd4fffc
LC
63 const char *command_name, const char *package,
64 const char *version,
65 const char * const * authors, size_t n_authors)
4f02b98d
LC
66{
67 if (command_name)
68 fprintf (stream, "%s (%s) %s\n", command_name, package, version);
69 else
70 fprintf (stream, "%s %s\n", package, version);
71
72#ifdef PACKAGE_PACKAGER
73# ifdef PACKAGE_PACKAGER_VERSION
74 fprintf (stream, _("Packaged by %s (%s)\n"), PACKAGE_PACKAGER,
1cd4fffc 75 PACKAGE_PACKAGER_VERSION);
4f02b98d
LC
76# else
77 fprintf (stream, _("Packaged by %s\n"), PACKAGE_PACKAGER);
78# endif
79#endif
80
81 /* TRANSLATORS: Translate "(C)" to the copyright symbol
82 (C-in-a-circle), if this symbol is available in the user's
83 locale. Otherwise, do not translate "(C)"; leave it as-is. */
84 fprintf (stream, version_etc_copyright, _("(C)"), COPYRIGHT_YEAR);
85
86 fputs (_("\
87\n\
88License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\n\
89This is free software: you are free to change and redistribute it.\n\
90There is NO WARRANTY, to the extent permitted by law.\n\
91\n\
92"),
1cd4fffc 93 stream);
4f02b98d
LC
94
95 switch (n_authors)
96 {
97 case 0:
98 /* The caller must provide at least one author name. */
99 abort ();
100 case 1:
101 /* TRANSLATORS: %s denotes an author name. */
102 fprintf (stream, _("Written by %s.\n"), authors[0]);
103 break;
104 case 2:
105 /* TRANSLATORS: Each %s denotes an author name. */
106 fprintf (stream, _("Written by %s and %s.\n"), authors[0], authors[1]);
107 break;
108 case 3:
109 /* TRANSLATORS: Each %s denotes an author name. */
110 fprintf (stream, _("Written by %s, %s, and %s.\n"),
1cd4fffc 111 authors[0], authors[1], authors[2]);
4f02b98d
LC
112 break;
113 case 4:
114 /* TRANSLATORS: Each %s denotes an author name.
1cd4fffc
LC
115 You can use line breaks, estimating that each author name occupies
116 ca. 16 screen columns and that a screen line has ca. 80 columns. */
4f02b98d 117 fprintf (stream, _("Written by %s, %s, %s,\nand %s.\n"),
1cd4fffc 118 authors[0], authors[1], authors[2], authors[3]);
4f02b98d
LC
119 break;
120 case 5:
121 /* TRANSLATORS: Each %s denotes an author name.
1cd4fffc
LC
122 You can use line breaks, estimating that each author name occupies
123 ca. 16 screen columns and that a screen line has ca. 80 columns. */
4f02b98d 124 fprintf (stream, _("Written by %s, %s, %s,\n%s, and %s.\n"),
1cd4fffc 125 authors[0], authors[1], authors[2], authors[3], authors[4]);
4f02b98d
LC
126 break;
127 case 6:
128 /* TRANSLATORS: Each %s denotes an author name.
1cd4fffc
LC
129 You can use line breaks, estimating that each author name occupies
130 ca. 16 screen columns and that a screen line has ca. 80 columns. */
4f02b98d 131 fprintf (stream, _("Written by %s, %s, %s,\n%s, %s, and %s.\n"),
1cd4fffc
LC
132 authors[0], authors[1], authors[2], authors[3], authors[4],
133 authors[5]);
4f02b98d
LC
134 break;
135 case 7:
136 /* TRANSLATORS: Each %s denotes an author name.
1cd4fffc
LC
137 You can use line breaks, estimating that each author name occupies
138 ca. 16 screen columns and that a screen line has ca. 80 columns. */
4f02b98d 139 fprintf (stream, _("Written by %s, %s, %s,\n%s, %s, %s, and %s.\n"),
1cd4fffc
LC
140 authors[0], authors[1], authors[2], authors[3], authors[4],
141 authors[5], authors[6]);
4f02b98d
LC
142 break;
143 case 8:
144 /* TRANSLATORS: Each %s denotes an author name.
1cd4fffc
LC
145 You can use line breaks, estimating that each author name occupies
146 ca. 16 screen columns and that a screen line has ca. 80 columns. */
4f02b98d
LC
147 fprintf (stream, _("\
148Written by %s, %s, %s,\n%s, %s, %s, %s,\nand %s.\n"),
1cd4fffc
LC
149 authors[0], authors[1], authors[2], authors[3], authors[4],
150 authors[5], authors[6], authors[7]);
4f02b98d
LC
151 break;
152 case 9:
153 /* TRANSLATORS: Each %s denotes an author name.
1cd4fffc
LC
154 You can use line breaks, estimating that each author name occupies
155 ca. 16 screen columns and that a screen line has ca. 80 columns. */
4f02b98d
LC
156 fprintf (stream, _("\
157Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, and %s.\n"),
1cd4fffc
LC
158 authors[0], authors[1], authors[2], authors[3], authors[4],
159 authors[5], authors[6], authors[7], authors[8]);
4f02b98d
LC
160 break;
161 default:
162 /* 10 or more authors. Use an abbreviation, since the human reader
1cd4fffc 163 will probably not want to read the entire list anyway. */
4f02b98d 164 /* TRANSLATORS: Each %s denotes an author name.
1cd4fffc
LC
165 You can use line breaks, estimating that each author name occupies
166 ca. 16 screen columns and that a screen line has ca. 80 columns. */
4f02b98d
LC
167 fprintf (stream, _("\
168Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, %s, and others.\n"),
1cd4fffc
LC
169 authors[0], authors[1], authors[2], authors[3], authors[4],
170 authors[5], authors[6], authors[7], authors[8]);
4f02b98d
LC
171 break;
172 }
173}
174
175/* Display the --version information the standard way. See the initial
176 comment to this module, for more information.
177
178 Author names are given in the NULL-terminated array AUTHORS. */
179void
180version_etc_ar (FILE *stream,
1cd4fffc
LC
181 const char *command_name, const char *package,
182 const char *version, const char * const * authors)
4f02b98d
LC
183{
184 size_t n_authors;
185
186 for (n_authors = 0; authors[n_authors]; n_authors++)
187 ;
188 version_etc_arn (stream, command_name, package, version, authors, n_authors);
189}
190
191/* Display the --version information the standard way. See the initial
192 comment to this module, for more information.
193
194 Author names are given in the NULL-terminated va_list AUTHORS. */
195void
196version_etc_va (FILE *stream,
1cd4fffc
LC
197 const char *command_name, const char *package,
198 const char *version, va_list authors)
4f02b98d
LC
199{
200 size_t n_authors;
201 const char *authtab[10];
202
203 for (n_authors = 0;
204 n_authors < 10
1cd4fffc 205 && (authtab[n_authors] = va_arg (authors, const char *)) != NULL;
4f02b98d
LC
206 n_authors++)
207 ;
208 version_etc_arn (stream, command_name, package, version,
1cd4fffc 209 authtab, n_authors);
4f02b98d
LC
210}
211
212
213/* Display the --version information the standard way.
214
215 If COMMAND_NAME is NULL, the PACKAGE is assumed to be the name of
216 the program. The formats are therefore:
217
218 PACKAGE VERSION
219
220 or
221
222 COMMAND_NAME (PACKAGE) VERSION.
223
224 The authors names are passed as separate arguments, with an additional
225 NULL argument at the end. */
226void
227version_etc (FILE *stream,
1cd4fffc
LC
228 const char *command_name, const char *package,
229 const char *version, /* const char *author1, ...*/ ...)
4f02b98d
LC
230{
231 va_list authors;
232
233 va_start (authors, version);
234 version_etc_va (stream, command_name, package, version, authors);
235 va_end (authors);
236}
237
238void
239emit_bug_reporting_address (void)
240{
241 /* TRANSLATORS: The placeholder indicates the bug-reporting address
242 for this package. Please add _another line_ saying
243 "Report translation bugs to <...>\n" with the address for translation
244 bugs (typically your translation team's web or email address). */
245 printf (_("\nReport bugs to: %s\n"), PACKAGE_BUGREPORT);
246#ifdef PACKAGE_PACKAGER_BUG_REPORTS
247 printf (_("Report %s bugs to: %s\n"), PACKAGE_PACKAGER,
1cd4fffc 248 PACKAGE_PACKAGER_BUG_REPORTS);
4f02b98d
LC
249#endif
250#ifdef PACKAGE_URL
251 printf (_("%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
252#else
253 printf (_("%s home page: <http://www.gnu.org/software/%s/>\n"),
1cd4fffc 254 PACKAGE_NAME, PACKAGE);
4f02b98d
LC
255#endif
256 fputs (_("General help using GNU software: <http://www.gnu.org/gethelp/>\n"),
1cd4fffc 257 stdout);
4f02b98d 258}