Index: branches/apertium-separable/src/lsx_FSTProcessor.cc =================================================================== --- branches/apertium-separable/src/lsx_FSTProcessor.cc (revision 81138) +++ branches/apertium-separable/src/lsx_FSTProcessor.cc (revision 81139) @@ -1181,10 +1181,8 @@ { vector new_states; vector alive_states; - // list blankqueue; wstring blank; bool outOfWord = true; - // bool isEscaped = false; bool finalFound = false; wstring in = L""; wstring out; @@ -1195,28 +1193,38 @@ { int val = fgetwc(input); - if(alive_states.size() == 0 && !finalFound) + if((val == L'^' && isEscaped(val) && outOfWord) || feof(input)) { + outOfWord = false; + blankqueue.push(blank); + + if(alive_states.size() == 0) + { + // cout << "??"; + if(blankqueue.size() > 0) + { + fputws(blankqueue.front().c_str(), output); + fflush(output); + blankqueue.pop(); + } + if(!finalFound) + { alive_states.push_back(*initial_state); fputws(in.c_str(), output); in = L""; } - else if(alive_states.size() == 0 && finalFound) + else if(finalFound) { in = L""; finalFound = false; } - // cout << endl << "isEscaped? " << (char) val << " " << isEscaped(val) << endl; - if((val == L'^' && isEscaped(val) && outOfWord) || feof(input)) - { - // wcout << L"" << blank << L""; - // wcout << L"ESCAPED? " << isEscaped(val) << L" " << (char) val; - outOfWord = false; - blankqueue.push(blank); + } + blank = L""; in += val; continue; } + if(outOfWord) { blank += val; @@ -1225,7 +1233,6 @@ if((feof(input) || val == L'$') && isEscaped(val) && !outOfWord) { - // cout << "HERE"; new_states.clear(); for(vector::const_iterator it = alive_states.begin(); it != alive_states.end(); it++) { @@ -1248,17 +1255,6 @@ outOfWord = true; in += val; - if(alive_states.size() == 0) - { - // cout << "HERE"; - if(blankqueue.size() > 0) - { - fputws(blankqueue.front().c_str(), output); - fflush(output); - blankqueue.pop(); - } - } - continue; } @@ -1311,7 +1307,6 @@ for (int i=0; i < (int) out.size(); i++) { wchar_t c = out[i]; - /* FIXME these hacks (?) */ if(c == L'/') { out[i] = L'^'; @@ -1326,7 +1321,7 @@ out = out.substr(0, out.length()-3); // remove extra trailing for(int i=0; i < (int) out.size(); i++) { - if(out[i] == L'$' && blankqueue.size()>0) + if(out[i] == L'$' && blankqueue.size() > 0) { out.insert(i+1, blankqueue.front().c_str()); blankqueue.pop();