From bb305b31ce8cd0c2ce214fd56732905c08fe080a Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Sun, 28 May 2023 16:20:13 -0400 Subject: [PATCH] Replace Gnulib striconv with copyright_symbol from dxcommon. The only use of the striconv module is to produce the copyright symbol for --version output and the about dialog in the Motif GUI. Using the new, single-purpose function reduces code size quite a bit. --- Makefile.am | 8 ++++++-- bootstrap | 7 ++++--- common | 2 +- configure.ac | 2 ++ m4/gnulib-cache.m4 | 4 +--- src/version.c | 30 +++++------------------------- 6 files changed, 19 insertions(+), 34 deletions(-) diff --git a/Makefile.am b/Makefile.am index 2e0db6b..e8f3c8f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,8 +19,7 @@ AM_CPPFLAGS = -I$(builddir)/src -I$(srcdir)/src -I$(DX_BASEDIR)/src \ AM_CFLAGS = $(CURSES_CFLAGS) $(MOTIF_CFLAGS) GNULIB = libgnu.a $(LIB_CLOCK_GETTIME) $(LIB_GETHRXTIME) $(LIB_HARD_LOCALE) \ - $(LIB_MBRTOWC) $(LIB_SETLOCALE_NULL) $(LTLIBICONV) $(LTLIBINTL) \ - $(LTLIBUNISTRING) + $(LIB_MBRTOWC) $(LIB_SETLOCALE_NULL) $(LTLIBINTL) $(LTLIBUNISTRING) LDADD = $(GNULIB) if HAVE_CURSES @@ -67,6 +66,11 @@ libglohelp_a_CFLAGS = -DHELP_GETOPT_LONG_ONLY $(libglohelp_a_OBJECTS): $(gnulib_headers) libglohelp_a_SHORTNAME = glo +if USE_NLS +rrace_curses_SOURCES += common/src/copysym.c +rrace_motif_SOURCES += common/src/copysym.c +endif + OPTFILES = src/cursesopt.opt src/motifopt.opt .opt.h: $(AM_V_GEN) $(AWK) -f $(DX_BASEDIR)/scripts/gen-options.awk $< >$@.tmp diff --git a/bootstrap b/bootstrap index f16d302..7bb1f8d 100755 --- a/bootstrap +++ b/bootstrap @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright © 2011-2012, 2015, 2021-2022 Nick Bowler +# Copyright © 2011-2012, 2015, 2021-2023 Nick Bowler # # Simple script to get started from a fresh git checkout. # @@ -10,8 +10,8 @@ scriptname=$0 -err() { printf '%s: %s\n' "$scriptname" "$*" 1>&2; } -die() { err "$@"; exit 1; } +err () { printf '%s: %s\n' "$scriptname" "$*" 1>&2; } +die () { err "$@"; exit 1; } : ${AUTORECONF=autoreconf} : ${AUTOMAKE=automake} @@ -23,6 +23,7 @@ $GIT submodule update --init || err "Failed to update submodules from git." if test -x $GNULIB/gnulib-tool; then $GNULIB/gnulib-tool --update -S || die "Failed to update Gnulib." + $GNULIB/gnulib-tool --copy-file -S build-aux/config.rpath config.rpath else err "Gnulib sources are not properly installed in $GNULIB/" cat >&2 <<'EOF' diff --git a/common b/common index 70c8454..207d0db 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 70c84546fa5ecaba26e4ed021b292a5580f304f0 +Subproject commit 207d0dbfbbfa7ad70b59ada3a741895842958885 diff --git a/configure.ac b/configure.ac index 7239adb..11b1293 100644 --- a/configure.ac +++ b/configure.ac @@ -168,6 +168,8 @@ AS_IF([test x"$dx_cv_xpm_to_png" = x"gm convert"], AC_CHECK_PROGS([OPTIPNG], [optipng]) : "${OPTIPNG:=:}" +AM_CONDITIONAL([USE_NLS], [test x"$USE_NLS" = x"yes"]) + AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4 index a23b145..d29c1da 100644 --- a/m4/gnulib-cache.m4 +++ b/m4/gnulib-cache.m4 @@ -45,8 +45,7 @@ # gettext-h \ # inline \ # localcharset \ -# mbswidth \ -# striconv +# mbswidth # Specification in the form of a few gnulib-tool.m4 macro invocations: gl_LOCAL_DIR([]) @@ -57,7 +56,6 @@ gl_MODULES([ inline localcharset mbswidth - striconv ]) gl_AVOID([std-gnu11]) gl_SOURCE_BASE([lib]) diff --git a/src/version.c b/src/version.c index de174b5..5708c0c 100644 --- a/src/version.c +++ b/src/version.c @@ -18,52 +18,32 @@ #include #include +#include #include -#include #include #include "version.h" - -const char *init_copysign(char **alloc) -{ - *alloc = NULL; - - if (ENABLE_NLS) { - char *buf = str_iconv("\xc2\xa9", "UTF-8", locale_charset()); - if (buf) - return *alloc = buf; - } - - return "(C)"; -} +#include "copysym.h" #define VERSION_HEAD_FMT "%s (RRace) %s\nCopyright %s 2023 Nick Bowler" #define VERSION_HEAD_ARGS progname, PACKAGE_VERSION, copysign void version_print_head(const char *progname, FILE *f) { - const char *copysign; - char *copybuf; - - copysign = init_copysign(©buf); + const char *copysign = copyright_symbol(locale_charset()); printf(VERSION_HEAD_FMT, VERSION_HEAD_ARGS); putc('\n', f); - - free(copybuf); } char *version_format_head(const char *progname) { - const char *copysign; - char *copybuf, *ret; - - copysign = init_copysign(©buf); + const char *copysign = copyright_symbol(locale_charset()); + char *ret; ret = malloc(sizeof VERSION_HEAD_FMT + 100); if (ret) sprintf(ret, VERSION_HEAD_FMT, VERSION_HEAD_ARGS); - free(copybuf); return ret; } -- 2.43.2