Skip to content

Commit

Permalink
Use wcerr where necessary (fixes #42); Bump patch version; Also check…
Browse files Browse the repository at this point in the history
… for WEOF (see issue #25)
  • Loading branch information
TinoDidriksen committed Apr 17, 2020
1 parent 50ff9b2 commit 12357e0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ m4_define([required_libxml_version], [2.6.17])
m4_define([required_apertium_version], [3.6.1])
m4_define([required_lttoolbox_version], [3.5.1])

AC_INIT([apertium-lex-tools], [0.2.3], [[email protected]])
AC_INIT([apertium-lex-tools], [0.2.4], [[email protected]])
AM_INIT_AUTOMAKE
AC_CONFIG_MACRO_DIR([m4])

Expand Down
2 changes: 0 additions & 2 deletions src/lrx_comp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,4 @@ int main (int argc, char **argv)
FILE *output = fopen(argv[3], "wb");
compiler.write(output);
}

return 0;
}
36 changes: 18 additions & 18 deletions src/lrx_compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ LRXCompiler::procRule()
int ret = xmlTextReaderRead(reader);
if(ret != 1)
{
cerr << L"Error (" << xmlTextReaderGetParserLineNumber(reader);
cerr << L"): Parse error." << endl;
wcerr << L"Error (" << xmlTextReaderGetParserLineNumber(reader);
wcerr << L"): Parse error." << endl;
exit(EXIT_FAILURE);
}

Expand Down Expand Up @@ -348,8 +348,8 @@ LRXCompiler::procOr()
int ret = xmlTextReaderRead(reader);
if(ret != 1)
{
cerr << L"Error (" << xmlTextReaderGetParserLineNumber(reader);
cerr << L"): Parse error." << endl;
wcerr << L"Error (" << xmlTextReaderGetParserLineNumber(reader);
wcerr << L"): Parse error." << endl;
exit(EXIT_FAILURE);
}

Expand Down Expand Up @@ -411,8 +411,8 @@ LRXCompiler::procDefSeq()
int ret = xmlTextReaderRead(reader);
if(ret != 1)
{
cerr << L"Error (" << xmlTextReaderGetParserLineNumber(reader);
cerr << L"): Parse error." << endl;
wcerr << L"Error (" << xmlTextReaderGetParserLineNumber(reader);
wcerr << L"): Parse error." << endl;
exit(EXIT_FAILURE);
}

Expand Down Expand Up @@ -573,8 +573,8 @@ LRXCompiler::procMatch()
int ret = xmlTextReaderRead(reader);
if(ret != 1)
{
cerr << L"Error (" << xmlTextReaderGetParserLineNumber(reader);
cerr << L"): Parse error." << endl;
wcerr << L"Error (" << xmlTextReaderGetParserLineNumber(reader);
wcerr << L"): Parse error." << endl;
exit(EXIT_FAILURE);
}

Expand All @@ -585,8 +585,8 @@ LRXCompiler::procMatch()
{
if(!canSelect)
{
cerr << L"Error (" << xmlTextReaderGetParserLineNumber(reader);
cerr << L"): <select> is not permitted inside <repeat>." << endl;
wcerr << L"Error (" << xmlTextReaderGetParserLineNumber(reader);
wcerr << L"): <select> is not permitted inside <repeat>." << endl;
exit(EXIT_FAILURE);
}
procSelect();
Expand All @@ -595,8 +595,8 @@ LRXCompiler::procMatch()
{
if(!canSelect)
{
cerr << L"Error (" << xmlTextReaderGetParserLineNumber(reader);
cerr << L"): <remove> is not permitted inside <repeat>." << endl;
wcerr << L"Error (" << xmlTextReaderGetParserLineNumber(reader);
wcerr << L"): <remove> is not permitted inside <repeat>." << endl;
exit(EXIT_FAILURE);
}
procRemove();
Expand Down Expand Up @@ -878,14 +878,14 @@ LRXCompiler::procRepeat()
int upto = stoi(xupto);
if(from < 0 || upto < 0)
{
cerr << L"Error (" << xmlTextReaderGetParserLineNumber(reader);
cerr << L"): Number of repetitions cannot be negative." << endl;
wcerr << L"Error (" << xmlTextReaderGetParserLineNumber(reader);
wcerr << L"): Number of repetitions cannot be negative." << endl;
exit(EXIT_FAILURE);
}
else if(from > upto)
{
cerr << L"Error (" << xmlTextReaderGetParserLineNumber(reader);
cerr << L"): Lower bound on number of repetitions cannot be larger than upper bound." << endl;
wcerr << L"Error (" << xmlTextReaderGetParserLineNumber(reader);
wcerr << L"): Lower bound on number of repetitions cannot be larger than upper bound." << endl;
exit(EXIT_FAILURE);
}
int count = upto - from;
Expand All @@ -899,8 +899,8 @@ LRXCompiler::procRepeat()
int ret = xmlTextReaderRead(reader);
if(ret != 1)
{
cerr << L"Error (" << xmlTextReaderGetParserLineNumber(reader);
cerr << L"): Parse error." << endl;
wcerr << L"Error (" << xmlTextReaderGetParserLineNumber(reader);
wcerr << L"): Parse error." << endl;
exit(EXIT_FAILURE);
}

Expand Down
4 changes: 2 additions & 2 deletions src/lrx_processor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ LRXProcessor::processME(FILE *input, FILE *output)
alive_states.push_back(new State(*initial_state));

int val = 0;
while((val = fgetwc_unlocked(input)) != EOF)
while((val = fgetwc_unlocked(input)) != EOF && val != WEOF)
{

if(nullFlush && val == L'\0')
Expand Down Expand Up @@ -824,7 +824,7 @@ LRXProcessor::processME(FILE *input, FILE *output)
// Read in target equivalences
wstring trad = L"";
val = fgetwc_unlocked(input);
while(val != L'$' && val != EOF)
while(val != L'$' && val != EOF && val != WEOF)
{
if(val != L'$')
{
Expand Down

0 comments on commit 12357e0

Please sign in to comment.