Sat Apr 10 00:46:23 2010 UTC ()
strip \r in awk script, avoid to extra `tr' exec.


(obache)
diff -r1.13 -r1.14 pkgsrc/mk/tools/gettext.mk
diff -r1.1 -r1.2 pkgsrc/mk/tools/msgfmt-msgctxt.awk
diff -r1.33 -r1.34 pkgsrc/mk/tools/msgfmt.sh

cvs diff -r1.13 -r1.14 pkgsrc/mk/tools/gettext.mk (switch to unified diff)

--- pkgsrc/mk/tools/gettext.mk 2010/04/09 15:44:17 1.13
+++ pkgsrc/mk/tools/gettext.mk 2010/04/10 00:46:23 1.14
@@ -1,153 +1,152 @@ @@ -1,153 +1,152 @@
1# $NetBSD: gettext.mk,v 1.13 2010/04/09 15:44:17 wiz Exp $ 1# $NetBSD: gettext.mk,v 1.14 2010/04/10 00:46:23 obache Exp $
2# 2#
3# Copyright (c) 2006 The NetBSD Foundation, Inc. 3# Copyright (c) 2006 The NetBSD Foundation, Inc.
4# All rights reserved. 4# All rights reserved.
5# 5#
6# This code is derived from software contributed to The NetBSD Foundation 6# This code is derived from software contributed to The NetBSD Foundation
7# by Johnny C. Lam. 7# by Johnny C. Lam.
8# 8#
9# Redistribution and use in source and binary forms, with or without 9# Redistribution and use in source and binary forms, with or without
10# modification, are permitted provided that the following conditions 10# modification, are permitted provided that the following conditions
11# are met: 11# are met:
12# 1. Redistributions of source code must retain the above copyright 12# 1. Redistributions of source code must retain the above copyright
13# notice, this list of conditions and the following disclaimer. 13# notice, this list of conditions and the following disclaimer.
14# 2. Redistributions in binary form must reproduce the above copyright 14# 2. Redistributions in binary form must reproduce the above copyright
15# notice, this list of conditions and the following disclaimer in the 15# notice, this list of conditions and the following disclaimer in the
16# documentation and/or other materials provided with the distribution. 16# documentation and/or other materials provided with the distribution.
17# 3. All advertising materials mentioning features or use of this software 17# 3. All advertising materials mentioning features or use of this software
18# must display the following acknowledgement: 18# must display the following acknowledgement:
19# This product includes software developed by the NetBSD 19# This product includes software developed by the NetBSD
20# Foundation, Inc. and its contributors. 20# Foundation, Inc. and its contributors.
21# 4. Neither the name of The NetBSD Foundation nor the names of its 21# 4. Neither the name of The NetBSD Foundation nor the names of its
22# contributors may be used to endorse or promote products derived 22# contributors may be used to endorse or promote products derived
23# from this software without specific prior written permission. 23# from this software without specific prior written permission.
24# 24#
25# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 25# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 26# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 28# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 29# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 30# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 32# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35# POSSIBILITY OF SUCH DAMAGE. 35# POSSIBILITY OF SUCH DAMAGE.
36# 36#
37 37
38# These tools are all supplied by the devel/gettext-tools package if there 38# These tools are all supplied by the devel/gettext-tools package if there
39# is no native tool available. Don't add "msgfmt" to this list as it's 39# is no native tool available. Don't add "msgfmt" to this list as it's
40# treated specially below. 40# treated specially below.
41# 41#
42_TOOLS.gettext-tools= gettext msgmerge xgettext msgconv 42_TOOLS.gettext-tools= gettext msgmerge xgettext msgconv
43_TOOLS_DEP.gettext-tools= {gettext-tools>=0.14.5,gettext>=0.10.36<0.14.5} 43_TOOLS_DEP.gettext-tools= {gettext-tools>=0.14.5,gettext>=0.10.36<0.14.5}
44 44
45.for _t_ in ${_TOOLS.gettext-tools} 45.for _t_ in ${_TOOLS.gettext-tools}
46. if !defined(TOOLS_IGNORE.${_t_}) && !empty(USE_TOOLS:C/:.*//:M${_t_}) 46. if !defined(TOOLS_IGNORE.${_t_}) && !empty(USE_TOOLS:C/:.*//:M${_t_})
47USE_TOOLS+= msgfmt 47USE_TOOLS+= msgfmt
48. endif 48. endif
49.endfor 49.endfor
50 50
51### 51###
52### Handle "msgfmt". We use either the pkgsrc version or the built-in 52### Handle "msgfmt". We use either the pkgsrc version or the built-in
53### version of msgfmt depending on availability and version. 53### version of msgfmt depending on availability and version.
54### 54###
55.if !defined(TOOLS_IGNORE.msgfmt) && !empty(USE_TOOLS:C/:.*//:Mmsgfmt) 55.if !defined(TOOLS_IGNORE.msgfmt) && !empty(USE_TOOLS:C/:.*//:Mmsgfmt)
56. if !empty(PKGPATH:Mdevel/gettext-tools) 56. if !empty(PKGPATH:Mdevel/gettext-tools)
57MAKEFLAGS+= TOOLS_IGNORE.msgfmt= 57MAKEFLAGS+= TOOLS_IGNORE.msgfmt=
58. else 58. else
59. if defined(TOOLS_PLATFORM.msgfmt) && !empty(TOOLS_PLATFORM.msgfmt) 59. if defined(TOOLS_PLATFORM.msgfmt) && !empty(TOOLS_PLATFORM.msgfmt)
60_TOOLS_USE_PKGSRC.msgfmt?= no 60_TOOLS_USE_PKGSRC.msgfmt?= no
61# 61#
62# MSGFMT_STRIP_MSGID_PLURAL: Yes for msgfmt < 0.10.36 62# MSGFMT_STRIP_MSGID_PLURAL: Yes for msgfmt < 0.10.36
63# MSGFMT_STRIP_MSGCTXT: Yes for msgfmt < 0.15 63# MSGFMT_STRIP_MSGCTXT: Yes for msgfmt < 0.15
64# 64#
65# Determine if the platform-supplied msgfmt is new enough to support 65# Determine if the platform-supplied msgfmt is new enough to support
66# the msgid_plural statement. We need at least 0.10.36 for GNU msgfmt. 66# the msgid_plural statement. We need at least 0.10.36 for GNU msgfmt.
67# 67#
68# XXX Solaris msgfmt also understands msgid_plural but more tests are 68# XXX Solaris msgfmt also understands msgid_plural but more tests are
69# XXX needed to take advantage of this. 69# XXX needed to take advantage of this.
70# XXX 70# XXX
71. if !defined(_TOOLS_USE_MSGFMT_SH) 71. if !defined(_TOOLS_USE_MSGFMT_SH)
72_TOOLS_VERSION.msgfmt!= ${TOOLS_PLATFORM.msgfmt} --version | \ 72_TOOLS_VERSION.msgfmt!= ${TOOLS_PLATFORM.msgfmt} --version | \
73 ${AWK} '{ print $$4; exit }' 73 ${AWK} '{ print $$4; exit }'
74. if !defined(MSGFMT_STRIP_MSGID_PLURAL) 74. if !defined(MSGFMT_STRIP_MSGID_PLURAL)
75MSGFMT_STRIP_MSGID_PLURAL!= \ 75MSGFMT_STRIP_MSGID_PLURAL!= \
76 if ${PKG_ADMIN} pmatch "gettext>0.10.35" \ 76 if ${PKG_ADMIN} pmatch "gettext>0.10.35" \
77 gettext-${_TOOLS_VERSION.msgfmt:Q}; then \ 77 gettext-${_TOOLS_VERSION.msgfmt:Q}; then \
78 ${ECHO} no; \ 78 ${ECHO} no; \
79 else \ 79 else \
80 ${ECHO} yes; \ 80 ${ECHO} yes; \
81 fi 81 fi
82. endif 82. endif
83. endif 83. endif
84. if !defined(MSGFMT_STRIP_MSGCTXT) 84. if !defined(MSGFMT_STRIP_MSGCTXT)
85MSGFMT_STRIP_MSGCTXT!= \ 85MSGFMT_STRIP_MSGCTXT!= \
86 if ${PKG_ADMIN} pmatch "gettext>=0.15" \ 86 if ${PKG_ADMIN} pmatch "gettext>=0.15" \
87 gettext-${_TOOLS_VERSION.msgfmt:Q}; then \ 87 gettext-${_TOOLS_VERSION.msgfmt:Q}; then \
88 ${ECHO} no; \ 88 ${ECHO} no; \
89 else \ 89 else \
90 ${ECHO} yes; \ 90 ${ECHO} yes; \
91 fi 91 fi
92. endif 92. endif
93. else 93. else
94_TOOLS_USE_PKGSRC.msgfmt= yes 94_TOOLS_USE_PKGSRC.msgfmt= yes
95. endif 95. endif
96MSGFMT_STRIP_MSGID_PLURAL?= no 96MSGFMT_STRIP_MSGID_PLURAL?= no
97MSGFMT_STRIP_MSGCTXT?= yes # pkgsrc version is too old 97MSGFMT_STRIP_MSGCTXT?= yes # pkgsrc version is too old
98.if ${MSGFMT_STRIP_MSGID_PLURAL} == "yes" || ${MSGFMT_STRIP_MSGCTXT} == "yes" 98.if ${MSGFMT_STRIP_MSGID_PLURAL} == "yes" || ${MSGFMT_STRIP_MSGCTXT} == "yes"
99_TOOLS_USE_MSGFMT_SH= yes 99_TOOLS_USE_MSGFMT_SH= yes
100.else 100.else
101_TOOLS_USE_MSGFMT_SH= no 101_TOOLS_USE_MSGFMT_SH= no
102.endif 102.endif
103MAKEVARS+= _TOOLS_USE_MSGFMT_SH 103MAKEVARS+= _TOOLS_USE_MSGFMT_SH
104 104
105# If we're not using the builtin gettext implementation, then we should 105# If we're not using the builtin gettext implementation, then we should
106# definitely be using the pkgsrc version of msgfmt (gettext-tools). 106# definitely be using the pkgsrc version of msgfmt (gettext-tools).
107# 107#
108CHECK_BUILTIN.gettext:= yes 108CHECK_BUILTIN.gettext:= yes
109. include "../../devel/gettext-lib/builtin.mk" 109. include "../../devel/gettext-lib/builtin.mk"
110CHECK_BUILTIN.gettext:= no 110CHECK_BUILTIN.gettext:= no
111. if !empty(USE_BUILTIN.gettext:M[nN][oO]) 111. if !empty(USE_BUILTIN.gettext:M[nN][oO])
112_TOOLS_USE_PKGSRC.msgfmt= yes 112_TOOLS_USE_PKGSRC.msgfmt= yes
113. endif 113. endif
114 114
115. if !empty(_TOOLS_USE_PKGSRC.msgfmt:M[yY][eE][sS]) 115. if !empty(_TOOLS_USE_PKGSRC.msgfmt:M[yY][eE][sS])
116TOOLS_CREATE+= msgfmt 116TOOLS_CREATE+= msgfmt
117TOOLS_DEPENDS.msgfmt?= ${_TOOLS_DEP.gettext-tools}:../../devel/gettext-tools 117TOOLS_DEPENDS.msgfmt?= ${_TOOLS_DEP.gettext-tools}:../../devel/gettext-tools
118TOOLS_FIND_PREFIX+= TOOLS_PREFIX.msgfmt=${TOOLS_DEPENDS.msgfmt:C/:.*//} 118TOOLS_FIND_PREFIX+= TOOLS_PREFIX.msgfmt=${TOOLS_DEPENDS.msgfmt:C/:.*//}
119TOOLS_PATH.msgfmt= ${TOOLS_PREFIX.msgfmt}/bin/msgfmt 119TOOLS_PATH.msgfmt= ${TOOLS_PREFIX.msgfmt}/bin/msgfmt
120. endif 120. endif
121 121
122. if !empty(_TOOLS_USE_MSGFMT_SH:M[yY][eE][sS]) 122. if !empty(_TOOLS_USE_MSGFMT_SH:M[yY][eE][sS])
123USE_TOOLS+= awk sh 123USE_TOOLS+= awk sh
124TOOLS_SCRIPT.msgfmt= AWK=${TOOLS_AWK:Q} CAT=${TOOLS_CAT:Q} \ 124TOOLS_SCRIPT.msgfmt= AWK=${TOOLS_AWK:Q} CAT=${TOOLS_CAT:Q} \
125 TR=${TOOLS_TR:Q} \ 125 MSGFMT=${TOOLS_PATH.msgfmt:Q} \
126 MSGFMT=${TOOLS_PATH.msgfmt:Q} \ 
127 PKGSRCDIR=${PKGSRCDIR:Q} \ 126 PKGSRCDIR=${PKGSRCDIR:Q} \
128 MSGFMT_STRIP_MSGID_PLURAL=${MSGFMT_STRIP_MSGID_PLURAL} \ 127 MSGFMT_STRIP_MSGID_PLURAL=${MSGFMT_STRIP_MSGID_PLURAL} \
129 MSGFMT_STRIP_MSGCTXT=${MSGFMT_STRIP_MSGCTXT} \ 128 MSGFMT_STRIP_MSGCTXT=${MSGFMT_STRIP_MSGCTXT} \
130 ${TOOLS_SH} ${PKGSRCDIR}/mk/tools/msgfmt.sh "$$@" 129 ${TOOLS_SH} ${PKGSRCDIR}/mk/tools/msgfmt.sh "$$@"
131. endif 130. endif
132. endif 131. endif
133.endif 132.endif
134 133
135.for _t_ in ${_TOOLS.gettext-tools} 134.for _t_ in ${_TOOLS.gettext-tools}
136. if !defined(TOOLS_IGNORE.${_t_}) && !empty(USE_TOOLS:C/:.*//:M${_t_}) 135. if !defined(TOOLS_IGNORE.${_t_}) && !empty(USE_TOOLS:C/:.*//:M${_t_})
137. if !empty(_TOOLS_USE_PKGSRC.msgfmt:M[yY][eE][sS]) 136. if !empty(_TOOLS_USE_PKGSRC.msgfmt:M[yY][eE][sS])
138_TOOLS_USE_PKGSRC.${_t_}= yes 137_TOOLS_USE_PKGSRC.${_t_}= yes
139. elif defined(TOOLS_PLATFORM.msgfmt) && !empty(TOOLS_PLATFORM.msgfmt) 138. elif defined(TOOLS_PLATFORM.msgfmt) && !empty(TOOLS_PLATFORM.msgfmt)
140_TOOLS_USE_PKGSRC.${_t_}?= no 139_TOOLS_USE_PKGSRC.${_t_}?= no
141. else 140. else
142_TOOLS_USE_PKGSRC.${_t_}?= yes 141_TOOLS_USE_PKGSRC.${_t_}?= yes
143. endif 142. endif
144. if !empty(PKGPATH:Mdevel/gettext-tools) 143. if !empty(PKGPATH:Mdevel/gettext-tools)
145MAKEFLAGS+= TOOLS_IGNORE.${_t_}= 144MAKEFLAGS+= TOOLS_IGNORE.${_t_}=
146. elif !empty(_TOOLS_USE_PKGSRC.${_t_}:M[yY][eE][sS]) 145. elif !empty(_TOOLS_USE_PKGSRC.${_t_}:M[yY][eE][sS])
147TOOLS_DEPENDS.${_t_}?= ${_TOOLS_DEP.gettext-tools}:../../devel/gettext-tools 146TOOLS_DEPENDS.${_t_}?= ${_TOOLS_DEP.gettext-tools}:../../devel/gettext-tools
148TOOLS_CREATE+= ${_t_} 147TOOLS_CREATE+= ${_t_}
149TOOLS_FIND_PREFIX+= TOOLS_PREFIX.${_t_}=${TOOLS_DEPENDS.${_t_}:C/:.*//} 148TOOLS_FIND_PREFIX+= TOOLS_PREFIX.${_t_}=${TOOLS_DEPENDS.${_t_}:C/:.*//}
150TOOLS_PATH.${_t_}= ${TOOLS_PREFIX.${_t_}}/bin/${_t_} 149TOOLS_PATH.${_t_}= ${TOOLS_PREFIX.${_t_}}/bin/${_t_}
151. endif 150. endif
152. endif 151. endif
153.endfor 152.endfor

cvs diff -r1.1 -r1.2 pkgsrc/mk/tools/msgfmt-msgctxt.awk (switch to unified diff)

--- pkgsrc/mk/tools/msgfmt-msgctxt.awk 2009/03/20 16:13:02 1.1
+++ pkgsrc/mk/tools/msgfmt-msgctxt.awk 2010/04/10 00:46:23 1.2
@@ -1,19 +1,20 @@ @@ -1,19 +1,20 @@
1# $NetBSD: msgfmt-msgctxt.awk,v 1.1 2009/03/20 16:13:02 joerg Exp $ 1# $NetBSD: msgfmt-msgctxt.awk,v 1.2 2010/04/10 00:46:23 obache Exp $
2# 2#
3# Simple awk script to strip out .po entries with "msgctxt" or "#~|", so the 3# Simple awk script to strip out .po entries with "msgctxt" or "#~|", so the
4# resultant file can be handled by the msgfmt 0.14.x. 4# resultant file can be handled by the msgfmt 0.14.x.
5{ 5{
 6sub(/\r$/, "")
6if (/^$/) { entry_end(); } 7if (/^$/) { entry_end(); }
7else if ($1 == "msgctxt" || $2 == "msgctxt") { skip = 1; } 8else if ($1 == "msgctxt" || $2 == "msgctxt") { skip = 1; }
8else if ($1 == "#~|") { skip = 1; } 9else if ($1 == "#~|") { skip = 1; }
9else { entry = entry $0 "\n" } 10else { entry = entry $0 "\n" }
10} 11}
11 12
12END { entry_end(); } 13END { entry_end(); }
13 14
14function entry_end() { 15function entry_end() {
15 if (!skip) 16 if (!skip)
16 print entry; 17 print entry;
17 entry = ""; 18 entry = "";
18 skip = 0; 19 skip = 0;
19} 20}

cvs diff -r1.33 -r1.34 pkgsrc/mk/tools/msgfmt.sh (switch to unified diff)

--- pkgsrc/mk/tools/msgfmt.sh 2010/04/09 15:44:17 1.33
+++ pkgsrc/mk/tools/msgfmt.sh 2010/04/10 00:46:23 1.34
@@ -1,175 +1,173 @@ @@ -1,175 +1,173 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# $NetBSD: msgfmt.sh,v 1.33 2010/04/09 15:44:17 wiz Exp $ 3# $NetBSD: msgfmt.sh,v 1.34 2010/04/10 00:46:23 obache Exp $
4# 4#
5# Copyright (c) 2006 The NetBSD Foundation, Inc. 5# Copyright (c) 2006 The NetBSD Foundation, Inc.
6# All rights reserved. 6# All rights reserved.
7# 7#
8# This code is derived from software contributed to The NetBSD Foundation 8# This code is derived from software contributed to The NetBSD Foundation
9# by Johnny C. Lam. 9# by Johnny C. Lam.
10# 10#
11# Redistribution and use in source and binary forms, with or without 11# Redistribution and use in source and binary forms, with or without
12# modification, are permitted provided that the following conditions 12# modification, are permitted provided that the following conditions
13# are met: 13# are met:
14# 1. Redistributions of source code must retain the above copyright 14# 1. Redistributions of source code must retain the above copyright
15# notice, this list of conditions and the following disclaimer. 15# notice, this list of conditions and the following disclaimer.
16# 2. Redistributions in binary form must reproduce the above copyright 16# 2. Redistributions in binary form must reproduce the above copyright
17# notice, this list of conditions and the following disclaimer in the 17# notice, this list of conditions and the following disclaimer in the
18# documentation and/or other materials provided with the distribution. 18# documentation and/or other materials provided with the distribution.
19# 3. All advertising materials mentioning features or use of this software 19# 3. All advertising materials mentioning features or use of this software
20# must display the following acknowledgement: 20# must display the following acknowledgement:
21# This product includes software developed by the NetBSD 21# This product includes software developed by the NetBSD
22# Foundation, Inc. and its contributors. 22# Foundation, Inc. and its contributors.
23# 4. Neither the name of The NetBSD Foundation nor the names of its 23# 4. Neither the name of The NetBSD Foundation nor the names of its
24# contributors may be used to endorse or promote products derived 24# contributors may be used to endorse or promote products derived
25# from this software without specific prior written permission. 25# from this software without specific prior written permission.
26# 26#
27# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37# POSSIBILITY OF SUCH DAMAGE. 37# POSSIBILITY OF SUCH DAMAGE.
38# 38#
39# 39#
40# Copyright (c) 2004, 2005, 2006 Julio M. Merino Vidal <jmmv@NetBSD.org> 40# Copyright (c) 2004, 2005, 2006 Julio M. Merino Vidal <jmmv@NetBSD.org>
41# 41#
42# Redistribution and use in source and binary forms, with or without 42# Redistribution and use in source and binary forms, with or without
43# modification, are permitted provided that the following conditions 43# modification, are permitted provided that the following conditions
44# are met: 44# are met:
45# 1. Redistributions of source code must retain the above copyright 45# 1. Redistributions of source code must retain the above copyright
46# notice, this list of conditions and the following disclaimer. 46# notice, this list of conditions and the following disclaimer.
47# 2. Redistributions in binary form must reproduce the above copyright 47# 2. Redistributions in binary form must reproduce the above copyright
48# notice, this list of conditions and the following disclaimer in 48# notice, this list of conditions and the following disclaimer in
49# the documentation and/or other materials provided with the 49# the documentation and/or other materials provided with the
50# distribution. 50# distribution.
51# 3. Neither the name of author nor the names of its contributors may 51# 3. Neither the name of author nor the names of its contributors may
52# be used to endorse or promote products derived from this software 52# be used to endorse or promote products derived from this software
53# without specific prior written permission. 53# without specific prior written permission.
54# 54#
55# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 55# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
56# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 56# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
57# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 57# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
58# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 58# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
59# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 59# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
60# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 60# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
61# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 61# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
62# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 62# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
63# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 63# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
64# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 64# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
65# POSSIBILITY OF SUCH DAMAGE. 65# POSSIBILITY OF SUCH DAMAGE.
66# 66#
67 67
68# If you make changes to this file, please test that it can process all 68# If you make changes to this file, please test that it can process all
69# of the *.po files in each of the following packages: 69# of the *.po files in each of the following packages:
70# 70#
71# databases/libgnomedb 71# databases/libgnomedb
72# devel/libgnome 72# devel/libgnome
73# fonts/fontforge 73# fonts/fontforge
74# multimedia/gmencoder 74# multimedia/gmencoder
75# multimedia/gnome2-media 75# multimedia/gnome2-media
76# net/gtk-gnutella 76# net/gtk-gnutella
77# sysutils/gnome-vfs 77# sysutils/gnome-vfs
78# wm/icewm 78# wm/icewm
79# www/epiphany 79# www/epiphany
80# x11/matchbox-panel 80# x11/matchbox-panel
81# 81#
82 82
83: ${AWK=awk} 83: ${AWK=awk}
84: ${CAT=cat} 84: ${CAT=cat}
85: ${MSGFMT=/usr/bin/msgfmt} 85: ${MSGFMT=/usr/bin/msgfmt}
86: ${TEE=tee} 86: ${TEE=tee}
87: ${TR=tr} 
88 87
89case "${MSGFMT}" in 88case "${MSGFMT}" in
90/*) ;; 89/*) ;;
91*) echo 1>&2 "$0: \`\`${MSGFMT}'' must be an absolute pathname." 90*) echo 1>&2 "$0: \`\`${MSGFMT}'' must be an absolute pathname."
92 exit 1 91 exit 1
93 ;; 92 ;;
94esac 93esac
95if test ! -x "${MSGFMT}"; then 94if test ! -x "${MSGFMT}"; then
96 echo 1>&2 "$0: \`\`${MSGFMT}'' does not exist." 95 echo 1>&2 "$0: \`\`${MSGFMT}'' does not exist."
97 exit 1 96 exit 1
98fi 97fi
99 98
100# Parse the command line options. 99# Parse the command line options.
101version= 100version=
102pofile= 101pofile=
103debug= 102debug=
104cmd="${MSGFMT}" 103cmd="${MSGFMT}"
105while test $# -gt 0; do 104while test $# -gt 0; do
106 case "$1" in 105 case "$1" in
107 --debug) 106 --debug)
108 debug=yes; shift 107 debug=yes; shift
109 ;; 108 ;;
110 --version) 109 --version)
111 version="$1" 110 version="$1"
112 cmd="$cmd $1"; shift 111 cmd="$cmd $1"; shift
113 ;; 112 ;;
114 --statistics|--tcl) 113 --statistics|--tcl)
115 cmd="$cmd $1"; shift 114 cmd="$cmd $1"; shift
116 ;; 115 ;;
117 -[aDodl]|--alignment|--directory|--output-file) 116 -[aDodl]|--alignment|--directory|--output-file)
118 cmd="$cmd $1 $2"; shift; shift; 117 cmd="$cmd $1 $2"; shift; shift;
119 ;; 118 ;;
120 -c) 119 -c)
121 # skip all checks 120 # skip all checks
122 shift 121 shift
123 ;; 122 ;;
124 [!-]*|-) 123 [!-]*|-)
125 pofile="$1" 124 pofile="$1"
126 cmd="$cmd -"; shift 125 cmd="$cmd -"; shift
127 ;; 126 ;;
128 *) 127 *)
129 cmd="$cmd $1"; shift 128 cmd="$cmd $1"; shift
130 ;; 129 ;;
131 esac 130 esac
132done 131done
133 132
134# If we are asked for just the version, then avoid spawning awk. 133# If we are asked for just the version, then avoid spawning awk.
135test -z "$version" || exec $cmd 134test -z "$version" || exec $cmd
136test -n "$pofile" || exec $cmd 135test -n "$pofile" || exec $cmd
137 136
138# If --debug is specified, then dump the output from the awk script 137# If --debug is specified, then dump the output from the awk script
139# to $pofile.debug along the way. 138# to $pofile.debug along the way.
140# 139#
141if test -z "$debug"; then 140if test -z "$debug"; then
142 debug="${CAT}" 141 debug="${CAT}"
143else 142else
144 debug="${TEE} $pofile.debug" 143 debug="${TEE} $pofile.debug"
145fi 144fi
146 145
147# If the input file cannot be found as named, then also search for a file 146# If the input file cannot be found as named, then also search for a file
148# with the same name that ends in ".po". 147# with the same name that ends in ".po".
149# 148#
150if test "$pofile" != "-" -a ! -e "$pofile"; then 149if test "$pofile" != "-" -a ! -e "$pofile"; then
151 popofile="" 150 popofile=""
152 for extension in po pot; do 151 for extension in po pot; do
153 if test -e "$pofile.$extension"; then 152 if test -e "$pofile.$extension"; then
154 popofile="$pofile.$extension" 153 popofile="$pofile.$extension"
155 break; 154 break;
156 fi 155 fi
157 done 156 done
158 if test "x$popofile" = "x"; then 157 if test "x$popofile" = "x"; then
159 echo 1>&2 "$0: error while opening \"$pofile\" for reading: No such file or directory" 158 echo 1>&2 "$0: error while opening \"$pofile\" for reading: No such file or directory"
160 exit 1 159 exit 1
161 fi 160 fi
162 pofile="$popofile" 161 pofile="$popofile"
163fi 162fi
164 163
165${CAT} $pofile | \ 164${CAT} $pofile | \
166${TR} -d '\015' | \ 
167if test "${MSGFMT_STRIP_MSGCTXT}" = "yes"; then 165if test "${MSGFMT_STRIP_MSGCTXT}" = "yes"; then
168 ${AWK} -f ${PKGSRCDIR}/mk/tools/msgfmt-msgctxt.awk 166 ${AWK} -f ${PKGSRCDIR}/mk/tools/msgfmt-msgctxt.awk
169else 167else
170 ${CAT} 168 ${CAT}
171fi | if test "$MSGFMT_STRIP_MSGID_PLURAL" = "yes"; then 169fi | if test "$MSGFMT_STRIP_MSGID_PLURAL" = "yes"; then
172 ${AWK} -f ${PKGSRCDIR}/mk/tools/msgfmt-msgid_plural.awk 170 ${AWK} -f ${PKGSRCDIR}/mk/tools/msgfmt-msgid_plural.awk
173else 171else
174 ${CAT} 172 ${CAT}
175fi | $debug | $cmd 173fi | $debug | $cmd