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 (expand / 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,14 +1,14 @@ @@ -1,14 +1,14 @@
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
@@ -112,28 +112,27 @@ CHECK_BUILTIN.gettext:= no @@ -112,28 +112,27 @@ CHECK_BUILTIN.gettext:= no
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)

cvs diff -r1.1 -r1.2 pkgsrc/mk/tools/msgfmt-msgctxt.awk (expand / 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,18 +1,19 @@ @@ -1,18 +1,19 @@
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;

cvs diff -r1.33 -r1.34 pkgsrc/mk/tools/msgfmt.sh (expand / 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,16 +1,16 @@ @@ -1,16 +1,16 @@
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
@@ -74,27 +74,26 @@ @@ -74,27 +74,26 @@
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.
@@ -153,23 +152,22 @@ if test "$pofile" != "-" -a ! -e "$pofil @@ -153,23 +152,22 @@ if test "$pofile" != "-" -a ! -e "$pofil
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