libs/lmo: fix po2lmo to cope with new po format
This commit is contained in:
parent
760b917114
commit
ccc8c1dae7
1 changed files with 33 additions and 17 deletions
|
@ -99,7 +99,7 @@ int main(int argc, char *argv[])
|
||||||
memset(key, 0, sizeof(val));
|
memset(key, 0, sizeof(val));
|
||||||
memset(val, 0, sizeof(val));
|
memset(val, 0, sizeof(val));
|
||||||
|
|
||||||
while( (NULL != fgets(line, sizeof(line), in)) || (state >= 2 && feof(in)) )
|
while( (NULL != fgets(line, sizeof(line), in)) || (state >= 3 && feof(in)) )
|
||||||
{
|
{
|
||||||
if( state == 0 && strstr(line, "msgid \"") == line )
|
if( state == 0 && strstr(line, "msgid \"") == line )
|
||||||
{
|
{
|
||||||
|
@ -108,17 +108,21 @@ int main(int argc, char *argv[])
|
||||||
case -1:
|
case -1:
|
||||||
die("Syntax error in msgid");
|
die("Syntax error in msgid");
|
||||||
case 0:
|
case 0:
|
||||||
continue;
|
|
||||||
default:
|
|
||||||
state = 1;
|
state = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
state = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( state == 1 && strstr(line, "msgstr \"") == line )
|
else if( state == 1 || state == 2 )
|
||||||
|
{
|
||||||
|
if( strstr(line, "msgstr \"") == line || state == 2 )
|
||||||
{
|
{
|
||||||
switch(extract_string(line, val, sizeof(val)))
|
switch(extract_string(line, val, sizeof(val)))
|
||||||
{
|
{
|
||||||
case -1:
|
case -1:
|
||||||
die("Syntax error in msgstr");
|
state = 4;
|
||||||
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
state = 2;
|
state = 2;
|
||||||
break;
|
break;
|
||||||
|
@ -126,18 +130,30 @@ int main(int argc, char *argv[])
|
||||||
state = 3;
|
state = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( state == 2 )
|
else
|
||||||
{
|
{
|
||||||
switch(extract_string(line, tmp, sizeof(tmp)))
|
switch(extract_string(line, tmp, sizeof(tmp)))
|
||||||
{
|
{
|
||||||
case -1:
|
case -1:
|
||||||
state = 3;
|
state = 4;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
strcat(key, tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( state == 3 )
|
||||||
|
{
|
||||||
|
switch(extract_string(line, tmp, sizeof(tmp)))
|
||||||
|
{
|
||||||
|
case -1:
|
||||||
|
state = 4;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
strcat(val, tmp);
|
strcat(val, tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( state == 3 )
|
else if( state == 4 )
|
||||||
{
|
{
|
||||||
if( strlen(key) > 0 && strlen(val) > 0 )
|
if( strlen(key) > 0 && strlen(val) > 0 )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue