strip \r in awk script, avoid to extra `tr' exec.diff -r1.13 -r1.14 pkgsrc/mk/tools/gettext.mk
(obache)
@@ -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]) | |
116 | TOOLS_CREATE+= msgfmt | 116 | TOOLS_CREATE+= msgfmt | |
117 | TOOLS_DEPENDS.msgfmt?= ${_TOOLS_DEP.gettext-tools}:../../devel/gettext-tools | 117 | TOOLS_DEPENDS.msgfmt?= ${_TOOLS_DEP.gettext-tools}:../../devel/gettext-tools | |
118 | TOOLS_FIND_PREFIX+= TOOLS_PREFIX.msgfmt=${TOOLS_DEPENDS.msgfmt:C/:.*//} | 118 | TOOLS_FIND_PREFIX+= TOOLS_PREFIX.msgfmt=${TOOLS_DEPENDS.msgfmt:C/:.*//} | |
119 | TOOLS_PATH.msgfmt= ${TOOLS_PREFIX.msgfmt}/bin/msgfmt | 119 | TOOLS_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]) | |
123 | USE_TOOLS+= awk sh | 123 | USE_TOOLS+= awk sh | |
124 | TOOLS_SCRIPT.msgfmt= AWK=${TOOLS_AWK:Q} CAT=${TOOLS_CAT:Q} \ | 124 | TOOLS_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) |
@@ -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 | { | |
6 | sub(/\r$/, "") | |||
6 | if (/^$/) { entry_end(); } | 7 | if (/^$/) { entry_end(); } | |
7 | else if ($1 == "msgctxt" || $2 == "msgctxt") { skip = 1; } | 8 | else if ($1 == "msgctxt" || $2 == "msgctxt") { skip = 1; } | |
8 | else if ($1 == "#~|") { skip = 1; } | 9 | else if ($1 == "#~|") { skip = 1; } | |
9 | else { entry = entry $0 "\n" } | 10 | else { entry = entry $0 "\n" } | |
10 | } | 11 | } | |
11 | 12 | |||
12 | END { entry_end(); } | 13 | END { entry_end(); } | |
13 | 14 | |||
14 | function entry_end() { | 15 | function entry_end() { | |
15 | if (!skip) | 16 | if (!skip) | |
16 | print entry; | 17 | print entry; | |
17 | entry = ""; | 18 | entry = ""; | |
18 | skip = 0; | 19 | skip = 0; |
@@ -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 | |||
89 | case "${MSGFMT}" in | 88 | case "${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 | ;; | |
94 | esac | 93 | esac | |
95 | if test ! -x "${MSGFMT}"; then | 94 | if 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 | |
98 | fi | 97 | fi | |
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" | |
163 | fi | 162 | fi | |
164 | 163 | |||
165 | ${CAT} $pofile | \ | 164 | ${CAT} $pofile | \ | |
166 | ${TR} -d '\015' | \ | |||
167 | if test "${MSGFMT_STRIP_MSGCTXT}" = "yes"; then | 165 | if test "${MSGFMT_STRIP_MSGCTXT}" = "yes"; then | |
168 | ${AWK} -f ${PKGSRCDIR}/mk/tools/msgfmt-msgctxt.awk | 166 | ${AWK} -f ${PKGSRCDIR}/mk/tools/msgfmt-msgctxt.awk | |
169 | else | 167 | else | |
170 | ${CAT} | 168 | ${CAT} | |
171 | fi | if test "$MSGFMT_STRIP_MSGID_PLURAL" = "yes"; then | 169 | fi | 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 | |
173 | else | 171 | else | |
174 | ${CAT} | 172 | ${CAT} | |
175 | fi | $debug | $cmd | 173 | fi | $debug | $cmd |