noinst_HEADERS = conf_pre.h conf_post.h common/src/help.h common/src/tap.h \
common/src/xtra.h src/cdecl.h src/scan.h src/parse.h \
- t/declgen.h t/test.h
+ src/version.h t/declgen.h t/test.h
noinst_DATA = $(MOFILES)
#include <getopt.h>
#include <gettext.h>
-#include <localcharset.h>
#include <mbswidth.h>
#include "cdecl99.h"
#include "cdecl.h"
#include "help.h"
#include "xtra.h"
-#include "copysym.h"
#include "options.h"
+#include "version.h"
#if HAVE_READLINE_READLINE_H
# include <readline/readline.h>
static void print_version(void)
{
- const char *copysign = copyright_symbol(locale_charset());
-
- puts(PACKAGE_STRING);
- printf("Copyright %s 2023 Nick Bowler.\n", copysign);
- puts("License GPLv3+: GNU GPL version 3 or any later version.");
- puts("This is free software: you are free to change and redistribute it.");
- puts("There is NO WARRANTY, to the extent permitted by law.");
+ do_print_version(PACKAGE_STRING);
}
static void print_usage(FILE *f)
--- /dev/null
+/*
+ * Copyright © 2023 Nick Bowler
+ *
+ * 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 <https://www.gnu.org/licenses/>.
+ */
+
+#ifndef CDECL99_VERSION_H_
+#define CDECL99_VERSION_H_
+
+#define version_blurb(s, copyright) \
+ s "\n" \
+ copyright "2023 Nick Bowler\n" \
+ "License GPLv3+: GNU GPL version 3 or any later version.\n" \
+ "This is free software: you are free to change and redistribute it.\n" \
+ "There is NO WARRANTY, to the extent permitted by law." \
+
+#if ENABLE_NLS && !VERSION_NO_COPYRIGHT_SYMBOL
+#include <localcharset.h>
+#include "copysym.h"
+
+#define do_print_version(s) do { \
+ printf(version_blurb(s, "Copyright %s ")"\n", \
+ copyright_symbol(locale_charset())); \
+} while (0)
+#else
+#define do_print_version(s) do { \
+ puts(version_blurb(s, "Copyright (C) ")); \
+} while (0)
+#endif
+
+#endif
#include <cdecl.h>
#include "test.h"
-#define PROGNAME "outbuf"
+#define PROGNAME "rendertest"
static const char *progname = PROGNAME;
static const char sopts[] = "n:ECVH";
static const struct option lopts[] = {
bool strict_strtoul(unsigned long *val, const char *str, int base);
-void test_print_version(const char *program);
void test_print_options(const struct option *lopts);
/*
return test_rng_uniform_int(rng, 2) == 0;
}
+#define VERSION_NO_COPYRIGHT_SYMBOL 1
+#include "version.h"
+
+#define test_print_version(s) \
+ do_print_version(s " (" PACKAGE_NAME ") " PACKAGE_VERSION)
+
#endif
return true;
}
-void test_print_version(const char *program)
-{
- printf("%s (%s) %s\n", program, PACKAGE_NAME, PACKAGE_VERSION);
- puts("Copyright (C) 2023 Nick Bowler.");
- puts("License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.");
- puts("This is free software: you are free to change and redistribute it.");
- puts("There is NO WARRANTY, to the extent permitted by law.");
-}
-
void test_print_options(const struct option *lopts)
{
const struct option *opt;