From e34a0aee1e615ef1153a7a80106455936b4d41f3 Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Sat, 27 May 2023 02:10:50 -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 at the start of an interactive session. Using the new, single-purpose function reduces code size quite a bit. --- Makefile.am | 17 +++++++++++++---- bootstrap | 9 +++++---- common | 2 +- configure.ac | 4 +++- m4/gnulib-cache.m4 | 4 +--- src/slotifier.c | 14 ++------------ 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Makefile.am b/Makefile.am index b073658..cd868b3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -21,11 +21,20 @@ AM_CFLAGS = $(LIBGERBV_CFLAGS) $(CNEARTREE_CFLAGS) bin_PROGRAMS = slotifier noinst_HEADERS = common/src/help.h common/src/xtra.h -slotifier_SOURCES = src/slotifier.c src/options.h common/src/help.c -slotifier_LDADD = $(LIBGERBV_LIBS) $(CNEARTREE_LIBS) libgnu.a \ - $(LTLIBICONV) $(LTLIBINTL) $(HYPOT_LIBM) +slotifier_SOURCES = src/options.h common/src/help.c +EXTRA_slotifier_DEPENDENCIES = $(libslotifiermain_a_OBJECTS) +slotifier_LDADD = $(EXTRA_slotifier_DEPENDENCIES) \ + $(LIBGERBV_LIBS) $(CNEARTREE_LIBS) libgnu.a \ + $(LTLIBINTL) $(HYPOT_LIBM) $(slotifier_OBJECTS): $(gnulib_headers) -$(slotifier_OBJECTS): src/options.h + +if USE_NLS +slotifier_SOURCES += common/src/copysym.c +endif + +EXTRA_LIBRARIES += libslotifiermain.a +libslotifiermain_a_SOURCES = src/slotifier.c +$(libslotifiermain_a_OBJECTS): $(gnulib_headers) src/options.h dist_man_MANS = doc/slotifier.1 diff --git a/bootstrap b/bootstrap index f92c1c7..7bb1f8d 100755 --- a/bootstrap +++ b/bootstrap @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright © 2011-2012, 2021 Nick Bowler +# Copyright © 2011-2012, 2015, 2021-2023 Nick Bowler # # Simple script to get started from a fresh git checkout. # @@ -22,7 +22,8 @@ die () { err "$@"; exit 1; } $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 --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' @@ -39,8 +40,8 @@ EOF exit 1 fi -$PERL common/scripts/fix-gnulib.pl -o lib/gnulib.mk -i lib/gnulib.mk.in || - die "Failed to fixup Gnulib makefile fragment." +$PERL common/scripts/fix-gnulib.pl -o lib/gnulib.mk -i lib/gnulib.mk.in \ + || die "Failed to fixup Gnulib makefile fragment." # Rewrite if ! ... construts produced by gnulib conditional dependencies # as these fail in heirloom-sh. diff --git a/common b/common index e599119..207d0db 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit e599119f0492b01f1f21a8cce8d695c314dab3b1 +Subproject commit 207d0dbfbbfa7ad70b59ada3a741895842958885 diff --git a/configure.ac b/configure.ac index 165e1a4..c7bc907 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -dnl Copyright © 2018-2019, 2021-2022 Nick Bowler +dnl Copyright © 2018-2019, 2021-2023 Nick Bowler dnl dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2. dnl This is free software: you are free to do what the fuck you want to. @@ -54,6 +54,8 @@ m4_newline([DX_LIB_USERFLAG_BLURB([libgerbv])]) m4_newline([DX_LIB_PKGCONFIG_BLURB([libgerbv])]) ])]) +AM_CONDITIONAL([USE_NLS], [test x"$USE_NLS" = x"yes"]) + AC_CONFIG_TESTDIR([.]) DX_PROG_AUTOTEST AM_CONDITIONAL([HAVE_AUTOTEST], [test x"$dx_cv_autotest_works" = x"yes"]) diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4 index 83a1141..cf43546 100644 --- a/m4/gnulib-cache.m4 +++ b/m4/gnulib-cache.m4 @@ -45,8 +45,7 @@ # gitlog-to-changelog \ # hypot \ # 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([ hypot localcharset mbswidth - striconv ]) gl_AVOID([std-gnu11]) gl_SOURCE_BASE([lib]) diff --git a/src/slotifier.c b/src/slotifier.c index 312f9f6..09e5aee 100644 --- a/src/slotifier.c +++ b/src/slotifier.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #include @@ -36,6 +35,7 @@ #include "options.h" #include "help.h" #include "xtra.h" +#include "copysym.h" #if !ENABLE_NLS # undef ENABLE_NLS @@ -49,23 +49,13 @@ static unsigned verbose; static void print_version(void) { - const char *copysign = "(C)"; - void *convsign = NULL; + const char *copysign = copyright_symbol(locale_charset()); puts(PACKAGE_STRING); - - if (ENABLE_NLS) { - convsign = str_iconv("\xc2\xa9", "UTF-8", locale_charset()); - if (convsign) - copysign = convsign; - } - 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."); - - free(convsign); } static void print_usage(FILE *f) -- 2.43.2