summaryrefslogtreecommitdiff
path: root/devel/gettext
diff options
context:
space:
mode:
authorjlam <jlam@pkgsrc.org>2006-04-13 16:35:57 +0000
committerjlam <jlam@pkgsrc.org>2006-04-13 16:35:57 +0000
commit0f4967eb59854511c3cbd3d80e3a886dd7fb7fc7 (patch)
tree05edb3a0d35814dcd46fc6d587c479a7a041b561 /devel/gettext
parent56e51ad6bcbe62feec59ad6d8300df92c2e40784 (diff)
downloadpkgsrc-0f4967eb59854511c3cbd3d80e3a886dd7fb7fc7.tar.gz
Overhaul the way packages can ask for "msgfmt". If a package needs
msgfmt, then it should set the following in the package Makefile: USE_TOOLS+= msgfmt To deal with message files that use the "msgid_plural" statement, which isn't supported in NetBSD<=3.x and also in gettext<=0.10.35, we determine if the built-in "msgfmt" is sufficiently new enough to understand "msgid_plural". If it isn't, then we use the msgfmt.sh script to transform the msgid_plural statements to an equivalent construct that's understood by older msgfmt tools. The msgfmt.sh script is a straightforward translation of the original perl script msgfmt.pl script by Julio M. Merino Vidal into shell and awk, which are more lightweight dependencies than perl. We remove the USE_MSGFMT_PLURALS bits in gettext-lib/builtin.mk as they are made obsolete by the new code in mk/tools/msgfmt.mk. BUILD_USE_MSGFMT is still supported but will be removed in a separate commit.
Diffstat (limited to 'devel/gettext')
-rw-r--r--devel/gettext/files/msgfmt.pl170
1 files changed, 0 insertions, 170 deletions
diff --git a/devel/gettext/files/msgfmt.pl b/devel/gettext/files/msgfmt.pl
deleted file mode 100644
index 332f851d2cd..00000000000
--- a/devel/gettext/files/msgfmt.pl
+++ /dev/null
@@ -1,170 +0,0 @@
-#!@PERL@
-#
-# $NetBSD: msgfmt.pl,v 1.3 2006/04/06 21:42:23 jmmv Exp $
-#
-# msgfmt.pl - Workaround uses of msgid_plural to work with implementations
-# that don't support it.
-#
-# Copyright (c) 2004, 2005, 2006 Julio M. Merino Vidal <jmmv@NetBSD.org>
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in
-# the documentation and/or other materials provided with the
-# distribution.
-# 3. Neither the name of author nor the names of its contributors may
-# be used to endorse or promote products derived from this software
-# without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
-# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
-# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-
-# Parse command line. We copy almost everything as is in the @args array,
-# which will be used later when calling the real "msgfmt" utility. As an
-# exception, the file name is transformed to the temporary file we will
-# use, and the original one is stored in the $file variable.
-@args = ();
-$file = "";
-$skip = 0;
-foreach (@ARGV) {
- if ($skip) {
- $skip = 0;
- } elsif (/^-(a|D|o)$/) {
- $skip = 1;
- } elsif (/^--(alignment|directory|output-file)$/) {
- $skip = 1;
- } elsif (/^[^-]/) {
- $file = $_;
- $_ = "$file.tmp";
- }
-
- push @args, $_;
-}
-
-# Parse the catalog file to convert msgid_plural entries to the "old"
-# format, which handles each of the translations independantly.
-open INFILE, $file;
-open OUTFILE, ">$file.tmp";
-
-printf "Working-around plural forms in $file\n";
-while (<INFILE>) {
- @msgid_singular = ();
- @msgid_plural = ();
-
- s/^#~//;
-
- if (/^msgid[ \t]+(.*)$/) {
- push @msgid_singular, "$1\n";
- while (<INFILE>) {
- next if /^$/;
-
- if (/^[ \t]*"/) {
- push @msgid_singular, $_;
- } else {
- last;
- }
- }
- }
-
- if (/^msgid_plural[ \t]+(.*)$/) {
- push @msgid_plural, "$1\n";
- while (<INFILE>) {
- if (/^[ \t]*"/) {
- push @msgid_plural, $_;
- } else {
- last;
- }
- }
- }
-
- if (/^msgstr[ \t]+(.*)$/) {
- print OUTFILE "msgid ";
- foreach $line (@msgid_singular) { print OUTFILE $line; }
- print OUTFILE "msgstr $1\n";
- while (<INFILE>) {
- if (/^[ \t]*"/) {
- print OUTFILE;
- } else {
- last;
- }
- }
- }
-
- if (/^msgstr\[0\][ \t]+(.*)$/) {
- print OUTFILE "msgid ";
- foreach $line (@msgid_singular) { print OUTFILE $line; }
- print OUTFILE "msgstr $1\n";
- while (<INFILE>) {
- if (/^[ \t]*"/) {
- print OUTFILE;
- } else {
- last;
- }
- }
- }
-
- if (/^msgstr\[1\][ \t]+(.*)$/) {
- $equal = (@msgid_singular == @msgid_plural);
- if ($equal) {
- for ($i = 0; $i < @msgid_singular; $i++) {
- if (@msgid_singular[$i] ne @msgid_plural[$i]) {
- $equal = 0;
- last;
- }
- }
- }
-
- if (! $equal) {
- print OUTFILE "msgid ";
- foreach $line (@msgid_plural) { print OUTFILE $line; }
- print OUTFILE "msgstr $1\n";
- while (<INFILE>) {
- if (/^[ \t]*"/) {
- print OUTFILE;
- } else {
- last;
- }
- }
- } else {
- while (<INFILE>) {
- last if (! /^[ \t]*"/);
- }
- }
- }
-
- if (/^msgstr\[2\][ \t]+(.*)$/) {
- }
-
- if (/^#/ || /^[ \t]*$/) {
- print OUTFILE;
- next;
- }
-}
-
-close OUTFILE;
-close INFILE;
-
-# Call the real msgfmt utility, using the temporary file as the source
-# catalog.
-printf "Running `@MSGFMT@ @args'\n";
-$ret = system("@MSGFMT@ @args") >> 8;
-
-if ($ret == 0) {
- unlink "$file.tmp";
-}
-
-exit $ret;