summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorobache <obache@pkgsrc.org>2013-05-06 13:20:07 +0000
committerobache <obache@pkgsrc.org>2013-05-06 13:20:07 +0000
commit1c17664ca4ae76d72418955f5965588a8efa312b (patch)
tree5e552dc0452f4d9bc2e597d3a5117ea71d8c6528 /mk
parent7c7b6575de16af4c9e70af1c8648b038b610aa8f (diff)
downloadpkgsrc-1c17664ca4ae76d72418955f5965588a8efa312b.tar.gz
Insert a dummy SPACE before the first "msgstr" start with "\n", if "msgid"
is also start with "\n", but msgctxt is inserted before it, to avoid msgfmt(1)'s format mismatch check (`msgid' and `msgstr' entries do not both begin with '\n')
Diffstat (limited to 'mk')
-rw-r--r--mk/tools/msgfmt-msgctxt.awk52
1 files changed, 50 insertions, 2 deletions
diff --git a/mk/tools/msgfmt-msgctxt.awk b/mk/tools/msgfmt-msgctxt.awk
index ff834e87b84..0caf11753c8 100644
--- a/mk/tools/msgfmt-msgctxt.awk
+++ b/mk/tools/msgfmt-msgctxt.awk
@@ -1,4 +1,4 @@
-# $NetBSD: msgfmt-msgctxt.awk,v 1.5 2013/05/05 00:34:22 obache Exp $
+# $NetBSD: msgfmt-msgctxt.awk,v 1.6 2013/05/06 13:20:07 obache Exp $
#
# Simple awk script to strip out .po entries with msgctxt and "#~|", so the
# resultant file can be handled by the msgfmt<0.15.
@@ -19,6 +19,7 @@ BEGIN {
s = 0
p = 0
obsolete = ""
+ msgid_begin_with_nl = 0
while (result == 1) {
@@ -58,8 +59,11 @@ BEGIN {
MSGID_RE = OBSOLETE_RE "msgid"
if ($0 ~ MSGID_RE KEYWORD_SEP) {
obsolete = ""
+ msgid_begin_with_nl = 0
+ msgid_find_first_str = 0
if ($0 ~ OBSOLETE_RE_MATCH) obsolete = OBSOLETE
if (s > 0) {
+ msgid_find_first_str = 1
print obsolete "msgid " singular[0]
for (i = 1; i < s; i++)
print obsolete singular[i]
@@ -86,16 +90,60 @@ BEGIN {
if (t > 0) {
if (s > 0) {
print obsolete msgid[0]
+ if (msgid[0] !~ /^""$/) {
+ msgid_find_first_str = 0
+ if (msgid[0] ~ /^"\\n/) {
+ msgid_begin_with_nl = 1
+ }
+ }
} else {
print obsolete "msgid " msgid[0]
}
- for (i = 1; i < t; i++)
+ for (i = 1; i < t; i++) {
print obsolete msgid[i]
+ if (msgid_find_first_str && (msgid[i] !~ /^""$/)) {
+ msgid_find_first_str = 0
+ if (msgid[i] ~ /^"\\n/) {
+ msgid_begin_with_nl = 1
+ }
+ }
+ }
}
s = 0
continue
}
+ # insert a SPACE before "msgstr" if "msgid" is start with "\n"
+ # but msgctx is inserted before it to avoid msgfmt(1)'s format
+ # mismatch check.
+ #
+ if (msgid_begin_with_nl) {
+ MSGSTR_RE = OBSOLETE_RE "msgstr"
+ if ($0 ~ MSGSTR_RE KEYWORD_SEP) {
+ if ($0 ~ OBSOLETE_RE_MATCH) obsolete = OBSOLETE
+ sub(MSGSTR_RE SPACE, "")
+ if ($0 ~ EMPTY) $0 = "\"\""
+ sub(/\r$/, "")
+ if ($0 ~ /\"\\n/) {
+ sub(/\\n/, " \\n")
+ }
+ print obsolete "msgstr " $0
+ while (result = getline) {
+ if ($0 !~ MSG_CONTINUATION_RE) break
+ sub(OBSOLETE_RE, "")
+ $sub(/\r$/,"")
+ if (msgid_begin_with_nl && $0 ~ /^"\\n/) {
+ sub(/^"\\n/, "\" \\n")
+ msgid_begin_with_nl = 0
+
+ }
+ print obsolete $0
+ }
+ }
+ msgid_begin_with_nl = 0
+ continue
+ }
+
# Pass everything else verbatim.
if ($0 !~ /^#~\|/) {
sub(/\r$/, "")