Changeset 5451

Show
Ignore:
Timestamp:
10/31/09 18:46:13 (4 years ago)
Author:
jow
Message:

libs/lmo: fix po2lmo to cope with new po format

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • luci/trunk/libs/lmo/src/lmo_po2lmo.c

    r5035 r5451  
    100100    memset(val, 0, sizeof(val)); 
    101101 
    102     while( (NULL != fgets(line, sizeof(line), in)) || (state >= 2 && feof(in)) ) 
     102    while( (NULL != fgets(line, sizeof(line), in)) || (state >= 3 && feof(in)) ) 
    103103    { 
    104104        if( state == 0 && strstr(line, "msgid \"") == line ) 
     
    109109                    die("Syntax error in msgid"); 
    110110                case 0: 
    111                     continue; 
    112                 default: 
    113111                    state = 1; 
    114             } 
    115         } 
    116         else if( state == 1 && strstr(line, "msgstr \"") == line ) 
    117         { 
    118             switch(extract_string(line, val, sizeof(val))) 
    119             { 
    120                 case -1: 
    121                     die("Syntax error in msgstr"); 
    122                 case 0: 
    123                     state = 2; 
    124112                    break; 
    125113                default: 
    126                     state = 3; 
    127             } 
    128         } 
    129         else if( state == 2 ) 
     114                    state = 2; 
     115            } 
     116        } 
     117        else if( state == 1 || state == 2 ) 
     118        { 
     119            if( strstr(line, "msgstr \"") == line || state == 2 ) 
     120            { 
     121                switch(extract_string(line, val, sizeof(val))) 
     122                { 
     123                    case -1: 
     124                        state = 4; 
     125                        break; 
     126                    case 0: 
     127                        state = 2; 
     128                        break; 
     129                    default: 
     130                        state = 3; 
     131                } 
     132            } 
     133            else 
     134            { 
     135                switch(extract_string(line, tmp, sizeof(tmp))) 
     136                { 
     137                    case -1: 
     138                        state = 4; 
     139                        break; 
     140                    default: 
     141                        strcat(key, tmp); 
     142                } 
     143            } 
     144        } 
     145        else if( state == 3 ) 
    130146        { 
    131147            switch(extract_string(line, tmp, sizeof(tmp))) 
    132148            { 
    133149                case -1: 
    134                     state = 3; 
     150                    state = 4; 
    135151                    break; 
    136152                default: 
     
    138154            } 
    139155        } 
    140         else if( state == 3 ) 
     156        else if( state == 4 ) 
    141157        { 
    142158            if( strlen(key) > 0 && strlen(val) > 0 )