From fb9a05f6480a53bd472199254c573fc1e0bda004 Mon Sep 17 00:00:00 2001 From: Daniel Swanson Date: Tue, 20 Oct 2020 18:47:29 -0500 Subject: [PATCH] be more careful about final LUs in analysis mode (#104) --- lttoolbox/fst_processor.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lttoolbox/fst_processor.cc b/lttoolbox/fst_processor.cc index 9282cf1f..39c7e8f6 100644 --- a/lttoolbox/fst_processor.cc +++ b/lttoolbox/fst_processor.cc @@ -1498,8 +1498,10 @@ FSTProcessor::analysis(FILE *input, FILE *output) bool firstupper = false, uppercase = false; map >::iterator rcx_map_ptr; - while(wchar_t val = readAnalysis(input)) + wchar_t val; + do { + val = readAnalysis(input); // test for final states if(current_state.isFinal(all_finals)) { @@ -1627,7 +1629,10 @@ FSTProcessor::analysis(FILE *input, FILE *output) if(current_state.size() != 0) { - alphabet.getSymbol(sf, val); + if(val) + { + alphabet.getSymbol(sf, val); + } } else { @@ -1651,7 +1656,10 @@ FSTProcessor::analysis(FILE *input, FILE *output) { fputwc_unlocked(L'\\', output); } - fputwc_unlocked(val, output); + if(val) + { + fputwc_unlocked(val, output); + } } } else if(last_postblank) @@ -1780,6 +1788,7 @@ FSTProcessor::analysis(FILE *input, FILE *output) last_preblank = false; } } + while(val); // print remaining blanks flushBlanks(output);