POファイルの構文解析

POファイルの構文解析

[79] POファイル構文解析について。

[1]

$ msgfmt --version
msgfmt (GNU gettext) 0.11.5

引用文字列

字句化

[2]

msgid"aa"msgstr"bb"

msgid "aa"
msgstr "bb"

[8] Input:

msgid"aa"msgstr"x"y"

Result:

<stdin>:1: keyword "y" unknown
<stdin>:1:20: syntax error
/usr/local/bin/msgfmt: found 2 fatal errors

隣接する引用文字列

[4] Input:

msgid"aa"msgstr
"a"
"b"

"c"

Result:

msgid "aa"
msgstr "abc"

[5] Input:

msgid"aa"msgstr"x""y"

Result:

msgid "aa"
msgstr "xy"

逃避

[6] Input:

msgid"aa"msgstr"x\"y"

Result:

msgid "aa"
msgstr "x\"y"

[7] Input:

msgid"aa"msgstr"x\\y"

Result:

msgid "aa"
msgstr "x\\y"

[38] Input:

msgid "z"
msgstr "a\nb"

Result:

msgid "z"
msgstr ""
"a\n"
"b"

[39] Input:

msgid "z"
msgstr "a\tb"

Result:

msgid "z"
msgstr "a\tb"

[40] Input:

msgid "z"
msgstr "a\ab"

Result:

msgid "z"
read-mo.c:240: internationalized messages should not contain the `\a' escape sequence
msgstr "a\ab"

[41] Input:

msgid "z"
msgstr "a\bb"

Result:

msgid "z"
read-mo.c:240: internationalized messages should not contain the `\b' escape sequence
msgstr "a\bb"

[42] Input:

msgid "z"
msgstr "a\cb"

Result:

<stdin>:2:11: invalid control sequence
/usr/local/bin/msgfmt: found 1 fatal error

[43] Input:

msgid "z"
msgstr "a\db"

Result:

<stdin>:2:11: invalid control sequence
/usr/local/bin/msgfmt: found 1 fatal error

[44] Input:

msgid "z"
msgstr "a\eb"

Result:

<stdin>:2:11: invalid control sequence
/usr/local/bin/msgfmt: found 1 fatal error

[45] Input:

msgid "z"
msgstr "a\fb"

Result:

msgid "z"
read-mo.c:240: internationalized messages should not contain the `\f' escape sequence
msgstr "a\fb"

[46] Input:

msgid "z"
msgstr "a\gb"

Result:

<stdin>:2:11: invalid control sequence
/usr/local/bin/msgfmt: found 1 fatal error

[47] Input:

msgid "z"
msgstr "a\hb"

Result:

<stdin>:2:11: invalid control sequence
/usr/local/bin/msgfmt: found 1 fatal error

[48] Input:

msgid "z"
msgstr "a\ib"

Result:

<stdin>:2:11: invalid control sequence
/usr/local/bin/msgfmt: found 1 fatal error

[49] Input:

msgid "z"
msgstr "a\jb"

Result:

<stdin>:2:11: invalid control sequence
/usr/local/bin/msgfmt: found 1 fatal error

[50] Input:

msgid "z"
msgstr "a\kb"

Result:

<stdin>:2:11: invalid control sequence
/usr/local/bin/msgfmt: found 1 fatal error

[51] Input:

msgid "z"
msgstr "a\lb"

Result:

<stdin>:2:11: invalid control sequence
/usr/local/bin/msgfmt: found 1 fatal error

[52] Input:

msgid "z"
msgstr "a\mb"

Result:

<stdin>:2:11: invalid control sequence
/usr/local/bin/msgfmt: found 1 fatal error

[53] Input:

msgid "z"
msgstr "a\ob"

Result:

<stdin>:2:11: invalid control sequence
/usr/local/bin/msgfmt: found 1 fatal error

[54] Input:

msgid "z"
msgstr "a\pb"

Result:

<stdin>:2:11: invalid control sequence
/usr/local/bin/msgfmt: found 1 fatal error

[55] Input:

msgid "z"
msgstr "a\qb"

Result:

<stdin>:2:11: invalid control sequence
/usr/local/bin/msgfmt: found 1 fatal error

[56] Input:

msgid "z"
msgstr "a\rb"

Result:

msgid "z"
read-mo.c:240: internationalized messages should not contain the `\r' escape sequence
msgstr "a\rb"

[57] Input:

msgid "z"
msgstr "a\sb"

Result:

<stdin>:2:11: invalid control sequence
/usr/local/bin/msgfmt: found 1 fatal error

[58] Input:

msgid "z"
msgstr "a\tb"

Result:

msgid "z"
msgstr "a\tb"

[59] Input:

msgid "z"
msgstr "a\ub"

Result:

<stdin>:2:11: invalid control sequence
/usr/local/bin/msgfmt: found 1 fatal error

[60] Input:

msgid "z"
msgstr "a\vb"

Result:

msgid "z"
read-mo.c:240: internationalized messages should not contain the `\v' escape sequence
msgstr "a\vb"

[61] Input:

msgid "z"
msgstr "a\wb"

Result:

<stdin>:2:11: invalid control sequence
/usr/local/bin/msgfmt: found 1 fatal error

[62] Input:

msgid "z"
msgstr "a\xb"

Result:

msgid "z"
read-mo.c:240: internationalized messages should not contain the `\v' escape sequence
msgstr "a\v"

[63] Input:

msgid "z"
msgstr "a\x"

Result:

<stdin>:2:12: invalid control sequence
/usr/local/bin/msgfmt: found 1 fatal error

[64] Input:

msgid "z"
msgstr "a\x01"

Result:

msgid "z"
msgstr "a"

[65] Input:

msgid "z"
msgstr "a\xff"

Result:

msgid "z"
read-mo.c:240: invalid multibyte sequence
read-mo.c:240: invalid multibyte sequence
msgstr "a"

[66] Input:

msgid "z"
msgstr "a\y"

Result:

<stdin>:2:11: invalid control sequence
/usr/local/bin/msgfmt: found 1 fatal error

[67] Input:

msgid "z"
msgstr "a\z"

Result:

<stdin>:2:11: invalid control sequence
/usr/local/bin/msgfmt: found 1 fatal error

[68] Input:

msgid "z"
msgstr "a\A"

Result:

<stdin>:2:11: invalid control sequence
/usr/local/bin/msgfmt: found 1 fatal error

[69] Input:

msgid "z"
msgstr "a\N"

Result:

<stdin>:2:11: invalid control sequence
/usr/local/bin/msgfmt: found 1 fatal error

[70] Input:

msgid "z"
msgstr "a\u0000"

Result:

<stdin>:2:11: invalid control sequence
/usr/local/bin/msgfmt: found 1 fatal error

[71] Input:

msgid "z"
msgstr "a\0"

Result:

msgid "z"
msgstr "a"

[72] Input:

msgid "z"
msgstr "a\0b"

Result:

msgid "z"
msgstr "a"

[73] Input:

msgid "z"
msgstr "a\01"

Result:

msgid "z"
msgstr "a"

[74] Input:

msgid "z"
msgstr "a\08"

Result:

msgid "z"
msgstr "a"

[75] Input:

msgid "z"
msgstr "a\033"

Result:

msgid "z"
msgstr "a"

[76] Input:

msgid "z"
msgstr "a\x0d"

Result:

msgid "z"
read-mo.c:240: internationalized messages should not contain the `\r' escape sequence
msgstr "a\r"

[77] Input:

msgid "z"
msgstr "a\X0A"

Result:

<stdin>:2:11: invalid control sequence
/usr/local/bin/msgfmt: found 1 fatal error

改行

[37] Input:

msgid "z"
msgstr "a\
b"

Result:

<stdin>:2:11: invalid control sequence
<stdin>:3: end-of-line within string
<stdin>:3:2: syntax error
<stdin>:4: end-of-line within string
/usr/local/bin/msgfmt: found 4 fatal errors

[78] >>37 は古い版ではおkだったのに。。。

エントリー

[9] Input:

msgid"aa"msgstr

Result:

<stdin>:1:16: syntax error
/usr/local/bin/msgfmt: found 1 fatal error

[10] Input:

msgstr"bb"
msgid"aa"

Result:

<stdin>:1:7: syntax error
<stdin>:2: missing `msgstr' section
/usr/local/bin/msgfmt: found 2 fatal errors

[11] Input:

msgid"aa"
msgid"bb"
msgstr"xx"

Result:

<stdin>:1: missing `msgstr' section
/usr/local/bin/msgfmt: found 1 fatal error

[12] Input:

msgid"aa"
msgstr"xx"
msgstr"yy"

Result:

<stdin>:3:7: syntax error
/usr/local/bin/msgfmt: found 1 fatal error

注釈

[3] Input:

msgid"aa"msgstr"bb"
#trailing
#comment

Result:

msgid "aa"
msgstr "bb"

[20] Input:

#? nonstandard comment
msgid "x"
msgstr "y"

Result:

msgid "x"
msgstr "y"

[31] Input:

#; "aa"
msgid "z"
msgstr "a"

Result:

msgid "z"
msgstr "a"

#:

[32] Input:

#: a:b
msgid "z"
msgstr "a"

Result:

msgid "z"
msgstr "a"

[33] Input:

#:    a:1    b:2
msgid "z"
msgstr "a"

Result:

msgid "z"
msgstr "a"

#,

[34] Input:

#, flag
msgid "z"
msgstr "a"

Result:

msgid "z"
msgstr "a"

[35] Input:

#, fuzzy
msgid "z"
msgstr "a"

Result:

/usr/local/bin/msgunfmt: file "-" is truncated

[36] Input:

#, fuzzy
msgid "z"
msgstr "a"

Result:

msgid "z"
msgstr "a"

#|

[21] Input:

#| msgid "x"
#| msgstr "y"
msgid "z"
msgstr "a"

Result:

<stdin>:2: keyword "msgstr" unknown
<stdin>:2:10: syntax error
/usr/local/bin/msgfmt: found 2 fatal errors

[29] Input:

#| aa
msgid "z"
msgstr "a"

Result:

<stdin>:1: keyword "aa" unknown
<stdin>:1:6: syntax error
/usr/local/bin/msgfmt: found 2 fatal errors

[30] Input:

#| "aa"
msgid "z"
msgstr "a"

Result:

<stdin>:1:8: syntax error
/usr/local/bin/msgfmt: found 1 fatal error

#~

[22] Input:

#~ msgid "y"
#~ msgstr "y"
msgid "z"
msgstr "a"

Result:

msgid "z"
msgstr "a"

[23] Input:

#~ msgstr "y"
msgid "z"
msgstr "a"

Result:

<stdin>:1:10: syntax error
/usr/local/bin/msgfmt: found 1 fatal error

[24] Input:

#~ msgid "y"
#~ msgstr "y"
#~ msgstr "y"
msgid "z"
msgstr "a"

Result:

<stdin>:3:10: syntax error
/usr/local/bin/msgfmt: found 1 fatal error

[25] Input:

#~ msgid "y"
#~ msgstr "y"
"x"
msgid "z"
msgstr "a"

Result:

<stdin>:3: inconsistent use of #~
/usr/local/bin/msgfmt: found 1 fatal error

[26] Input:

#~ msgid "y"
#~ msgstr "y"
# "x"
msgid "z"
msgstr "a"

Result:

msgid "z"
msgstr "a"

[27] Input:

#~ msgid "y"
#~ msgstr "y"
#~ "x"
msgid "z"
msgstr "a"

Result:

msgid "z"
msgstr "a"

[28] Input:

#~ "x"
msgid "z"
msgstr "a"

Result:

<stdin>:1:7: syntax error
/usr/local/bin/msgfmt: found 1 fatal error

頭部

[13] Input:

msgid""
msgstr""

Result:

/usr/local/bin/msgunfmt: file "-" is not in GNU .mo format

[14] Input:

msgid""
msgstr"a"

Result:

/usr/local/bin/msgunfmt: file "-" is not in GNU .mo format

[15] Input:

msgid""
msgstr""

msgid "x"
msgstr "y"

Result:

/usr/local/bin/msgunfmt: file "-" is not in GNU .mo format

[16] Input:

msgid""
msgstr"Content-Type: text/html; charset=utf-8"

msgid "x"
msgstr "y"

Result:

msgid ""
msgstr "Content-Type: text/html; charset=utf-8"

msgid "x"
msgstr "y"

[17] Input:

msgid""
msgstr"MIME-Version: 1.0"

msgid "x"
msgstr "y"

Result:

/usr/local/bin/msgunfmt: file "-" is not in GNU .mo format

[18] Input:

msgid""
msgstr""

msgid "x"
msgstr "y"

Result:

<stdin>: warning: Charset missing in header.
                  Message conversion to user's charset will not work.
/usr/local/bin/msgfmt: (null): warning: PO file header missing or invalid
                               warning: charset conversion will not work
/usr/local/bin/msgfmt: found 1 fatal error

[19] Input:

msgid""
msgstr"charset=utf-8"

msgid "x"
msgstr "y"

Result:

/usr/local/bin/msgunfmt: file "-" is not in GNU .mo format