| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/coreutils/src/gnulib/lib/version-etc.c |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | /* Print --version and bug-reporting information in a consistent format. | - | ||||||
| 2 | Copyright (C) 1999-2018 Free Software Foundation, Inc. | - | ||||||
| 3 | - | |||||||
| 4 | This program is free software: you can redistribute it and/or modify | - | ||||||
| 5 | it under the terms of the GNU 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 General Public License for more details. | - | ||||||
| 13 | - | |||||||
| 14 | You should have received a copy of the GNU General Public License | - | ||||||
| 15 | along with this program. If not, see <https://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 | - | |||||||
| 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 | - | |||||||
| 41 | enum { COPYRIGHT_YEAR = 2018 }; | - | ||||||
| 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. */ | - | ||||||
| 61 | void | - | ||||||
| 62 | version_etc_arn (FILE *stream, | - | ||||||
| 63 | const char *command_name, const char *package, | - | ||||||
| 64 | const char *version, | - | ||||||
| 65 | const char * const * authors, size_t n_authors) | - | ||||||
| 66 | { | - | ||||||
| 67 | if (command_name)
| 0-858 | ||||||
| 68 | fprintf (stream, "%s (%s) %s\n", command_name, package, version); executed 858 times by 104 tests: fprintf (stream, "%s (%s) %s\n", command_name, package, version);Executed by:
| 858 | ||||||
| 69 | else | - | ||||||
| 70 | fprintf (stream, "%s %s\n", package, version); never executed: fprintf (stream, "%s %s\n", package, version); | 0 | ||||||
| 71 | - | |||||||
| 72 | #ifdef PACKAGE_PACKAGER | - | ||||||
| 73 | # ifdef PACKAGE_PACKAGER_VERSION | - | ||||||
| 74 | fprintf (stream, _("Packaged by %s (%s)\n"), PACKAGE_PACKAGER, | - | ||||||
| 75 | PACKAGE_PACKAGER_VERSION); | - | ||||||
| 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\ | - | ||||||
| 88 | License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.\n\ | - | ||||||
| 89 | This is free software: you are free to change and redistribute it.\n\ | - | ||||||
| 90 | There is NO WARRANTY, to the extent permitted by law.\n\ | - | ||||||
| 91 | \n\ | - | ||||||
| 92 | "), | - | ||||||
| 93 | stream); | - | ||||||
| 94 | - | |||||||
| 95 | switch (n_authors) | - | ||||||
| 96 | { | - | ||||||
| 97 | case 0: never executed: case 0: | 0 | ||||||
| 98 | /* The caller must provide at least one author name. */ | - | ||||||
| 99 | abort (); never executed: abort (); | 0 | ||||||
| 100 | case 1: code before this statement never executed: case 1:executed 269 times by 49 tests: case 1:Executed by:
| 0-269 | ||||||
| 101 | /* TRANSLATORS: %s denotes an author name. */ | - | ||||||
| 102 | fprintf (stream, _("Written by %s.\n"), authors[0]); | - | ||||||
| 103 | break; executed 269 times by 49 tests: break;Executed by:
| 269 | ||||||
| 104 | case 2: executed 235 times by 33 tests: case 2:Executed by:
| 235 | ||||||
| 105 | /* TRANSLATORS: Each %s denotes an author name. */ | - | ||||||
| 106 | fprintf (stream, _("Written by %s and %s.\n"), authors[0], authors[1]); | - | ||||||
| 107 | break; executed 235 times by 33 tests: break;Executed by:
| 235 | ||||||
| 108 | case 3: executed 217 times by 18 tests: case 3:Executed by:
| 217 | ||||||
| 109 | /* TRANSLATORS: Each %s denotes an author name. */ | - | ||||||
| 110 | fprintf (stream, _("Written by %s, %s, and %s.\n"), | - | ||||||
| 111 | authors[0], authors[1], authors[2]); | - | ||||||
| 112 | break; executed 217 times by 18 tests: break;Executed by:
| 217 | ||||||
| 113 | case 4: executed 118 times by 3 tests: case 4:Executed by:
| 118 | ||||||
| 114 | /* TRANSLATORS: Each %s denotes an author name. | - | ||||||
| 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. */ | - | ||||||
| 117 | fprintf (stream, _("Written by %s, %s, %s,\nand %s.\n"), | - | ||||||
| 118 | authors[0], authors[1], authors[2], authors[3]); | - | ||||||
| 119 | break; executed 118 times by 3 tests: break;Executed by:
| 118 | ||||||
| 120 | case 5: executed 19 times by 1 test: case 5:Executed by:
| 19 | ||||||
| 121 | /* TRANSLATORS: Each %s denotes an author name. | - | ||||||
| 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. */ | - | ||||||
| 124 | fprintf (stream, _("Written by %s, %s, %s,\n%s, and %s.\n"), | - | ||||||
| 125 | authors[0], authors[1], authors[2], authors[3], authors[4]); | - | ||||||
| 126 | break; executed 19 times by 1 test: break;Executed by:
| 19 | ||||||
| 127 | case 6: never executed: case 6: | 0 | ||||||
| 128 | /* TRANSLATORS: Each %s denotes an author name. | - | ||||||
| 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. */ | - | ||||||
| 131 | fprintf (stream, _("Written by %s, %s, %s,\n%s, %s, and %s.\n"), | - | ||||||
| 132 | authors[0], authors[1], authors[2], authors[3], authors[4], | - | ||||||
| 133 | authors[5]); | - | ||||||
| 134 | break; never executed: break; | 0 | ||||||
| 135 | case 7: never executed: case 7: | 0 | ||||||
| 136 | /* TRANSLATORS: Each %s denotes an author name. | - | ||||||
| 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. */ | - | ||||||
| 139 | fprintf (stream, _("Written by %s, %s, %s,\n%s, %s, %s, and %s.\n"), | - | ||||||
| 140 | authors[0], authors[1], authors[2], authors[3], authors[4], | - | ||||||
| 141 | authors[5], authors[6]); | - | ||||||
| 142 | break; never executed: break; | 0 | ||||||
| 143 | case 8: never executed: case 8: | 0 | ||||||
| 144 | /* TRANSLATORS: Each %s denotes an author name. | - | ||||||
| 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. */ | - | ||||||
| 147 | fprintf (stream, _("\ | - | ||||||
| 148 | Written by %s, %s, %s,\n%s, %s, %s, %s,\nand %s.\n"), | - | ||||||
| 149 | authors[0], authors[1], authors[2], authors[3], authors[4], | - | ||||||
| 150 | authors[5], authors[6], authors[7]); | - | ||||||
| 151 | break; never executed: break; | 0 | ||||||
| 152 | case 9: never executed: case 9: | 0 | ||||||
| 153 | /* TRANSLATORS: Each %s denotes an author name. | - | ||||||
| 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. */ | - | ||||||
| 156 | fprintf (stream, _("\ | - | ||||||
| 157 | Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, and %s.\n"), | - | ||||||
| 158 | authors[0], authors[1], authors[2], authors[3], authors[4], | - | ||||||
| 159 | authors[5], authors[6], authors[7], authors[8]); | - | ||||||
| 160 | break; never executed: break; | 0 | ||||||
| 161 | default: never executed: default: | 0 | ||||||
| 162 | /* 10 or more authors. Use an abbreviation, since the human reader | - | ||||||
| 163 | will probably not want to read the entire list anyway. */ | - | ||||||
| 164 | /* TRANSLATORS: Each %s denotes an author name. | - | ||||||
| 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. */ | - | ||||||
| 167 | fprintf (stream, _("\ | - | ||||||
| 168 | Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, %s, and others.\n"), | - | ||||||
| 169 | authors[0], authors[1], authors[2], authors[3], authors[4], | - | ||||||
| 170 | authors[5], authors[6], authors[7], authors[8]); | - | ||||||
| 171 | break; never executed: break; | 0 | ||||||
| 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. */ | - | ||||||
| 179 | void | - | ||||||
| 180 | version_etc_ar (FILE *stream, | - | ||||||
| 181 | const char *command_name, const char *package, | - | ||||||
| 182 | const char *version, const char * const * authors) | - | ||||||
| 183 | { | - | ||||||
| 184 | size_t n_authors; | - | ||||||
| 185 | - | |||||||
| 186 | for (n_authors = 0; authors[n_authors]; n_authors++)
| 0 | ||||||
| 187 | ; never executed: ; | 0 | ||||||
| 188 | version_etc_arn (stream, command_name, package, version, authors, n_authors); | - | ||||||
| 189 | } never executed: end of block | 0 | ||||||
| 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. */ | - | ||||||
| 195 | void | - | ||||||
| 196 | version_etc_va (FILE *stream, | - | ||||||
| 197 | const char *command_name, const char *package, | - | ||||||
| 198 | const char *version, va_list authors) | - | ||||||
| 199 | { | - | ||||||
| 200 | size_t n_authors; | - | ||||||
| 201 | const char *authtab[10]; | - | ||||||
| 202 | - | |||||||
| 203 | for (n_authors = 0; | - | ||||||
| 204 | n_authors < 10
| 0-2815 | ||||||
| 205 | && (authtab[n_authors] = va_arg (authors, const char *)) != NULL;
| 858-1957 | ||||||
| 206 | n_authors++) | - | ||||||
| 207 | ; executed 1957 times by 104 tests: ;Executed by:
| 1957 | ||||||
| 208 | version_etc_arn (stream, command_name, package, version, | - | ||||||
| 209 | authtab, n_authors); | - | ||||||
| 210 | } executed 858 times by 104 tests: end of blockExecuted by:
| 858 | ||||||
| 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. */ | - | ||||||
| 226 | void | - | ||||||
| 227 | version_etc (FILE *stream, | - | ||||||
| 228 | const char *command_name, const char *package, | - | ||||||
| 229 | const char *version, /* const char *author1, ...*/ ...) | - | ||||||
| 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 | } executed 786 times by 90 tests: end of blockExecuted by:
| 786 | ||||||
| 237 | - | |||||||
| 238 | void | - | ||||||
| 239 | emit_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, | - | ||||||
| 248 | PACKAGE_PACKAGER_BUG_REPORTS); | - | ||||||
| 249 | #endif | - | ||||||
| 250 | #ifdef PACKAGE_URL | - | ||||||
| 251 | printf (_("%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL); | - | ||||||
| 252 | #else | - | ||||||
| 253 | printf (_("%s home page: <https://www.gnu.org/software/%s/>\n"), | - | ||||||
| 254 | PACKAGE_NAME, PACKAGE); | - | ||||||
| 255 | #endif | - | ||||||
| 256 | fputs (_("General help using GNU software: <https://www.gnu.org/gethelp/>\n"), | - | ||||||
| 257 | stdout); | - | ||||||
| 258 | } never executed: end of block | 0 | ||||||
| Source code | Switch to Preprocessed file |