]> git.draconx.ca Git - dxcommon.git/commitdiff
Fix multiple language substitution in DX_LINGUAS.
authorNick Bowler <nbowler@draconx.ca>
Mon, 15 Feb 2021 04:57:05 +0000 (23:57 -0500)
committerNick Bowler <nbowler@draconx.ca>
Mon, 15 Feb 2021 05:22:34 +0000 (00:22 -0500)
For some reason this macro inserts newlines between successive values
in the calculated POFILES/MOFILES settings.  This causes syntax errors
when these get substituted into makefiles and is very, very broken.

So this macro has basically never worked except for trivial cases.  This
happens when you don't bother to test things.  So let's fix that up and
add a test case to expose this issue.

m4/linguas.m4
tests/macros.at

index 61613b6dc2f2c42c610ca2ca662971a2cf746ab7..c6ad9736ab5bbfbbcb62d1a5310d8170c47410ac 100644 (file)
@@ -38,25 +38,21 @@ if test -f "$srcdir/po/LINGUAS"; then
     } | sort -u >conftest.ena
   fi
 
-  ALL_LINGUAS=`cat conftest.all`
-  LINGUAS=`join conftest.ena conftest.all`
-
-  # Note: $srcdir is not used here because these variables are for make.
-  set x $ALL_LINGUAS; shift
-  case ${#} in
-  0) ;;
-  *) POFILES=`printf "po/%s.po\n" "${@}"` ;;
-  esac
+  exec 3<conftest.all
+  while read x <&3; do
+    AS_VAR_APPEND([POFILES], ["${POFILES:+ }po/$x.po"])
+  done
 
   if test x"$USE_NLS" = x"yes"; then
-    set x $LINGUAS; shift
-    case ${#} in
-    0) ;;
-    *) MOFILES=`printf "po/%s.mo\n" "${@}"` ;;
-    esac
+    join conftest.ena conftest.all >conftest.out
+    exec 3<conftest.out
+    while read x <&3; do
+      AS_VAR_APPEND([MOFILES], ["${MOFILES:+ }po/$x.mo"])
+    done
   fi
 
-  rm -f conftest.all conftest.ena
+  exec 3<&-
+  rm -f conftest.all conftest.ena conftest.out
 fi
 
 AC_SUBST([POFILES])
index 9a49e35dc0fad93c14847fc7481be9bc14cc9977..04dcfb7a20e9c7ac8a57b2c12d8386268355cba8 100644 (file)
@@ -139,3 +139,38 @@ MOFILES = po/en.mo
 ]])
 
 AT_CLEANUP
+
+AT_SETUP([DX_LINGUAS default install all])
+AT_KEYWORDS([DX_LINGUAS macro])
+
+AS_UNSET([LINGUAS])
+AT_SKIP_IF([test ${LINGUAS+y}])
+
+echo : >config.rpath
+chmod +x config.rpath
+
+mkdir po
+AT_DATA([po/LINGUAS], [[en ja # a comment ko
+zh
+]])
+
+AT_DATA([test.in], [[POFILES = @POFILES@
+MOFILES = @MOFILES@
+]])
+
+TEST_CONFIGURE_AC(
+[[m4@&t@_traceoff([AM_GNU_GETTEXT])
+AM_GNU_GETTEXT([external])
+DX_LINGUAS
+AC_CONFIG_FILES([test])
+]])
+
+TEST_AUTORECONF
+TEST_CONFIGURE
+
+AT_CHECK([cat test], [0],
+[[POFILES = po/en.po po/ja.po po/zh.po
+MOFILES = po/en.mo po/ja.mo po/zh.mo
+]])
+
+AT_CLEANUP