commit 09ce82527947669e15fd0339d32673fd7d66473e Author: Daniel Swanson Date: Mon Jun 14 19:32:10 2021 -0500 lttoolbox is switching to ICU, so the interface is changing diff --git a/src/lexd.cc b/src/lexd.cc index 6d528ba..7b0ff31 100644 --- a/src/lexd.cc +++ b/src/lexd.cc @@ -32,7 +32,7 @@ int main(int argc, char *argv[]) bool single = false; bool stats = false; UFILE* input = u_finit(stdin, NULL, NULL); - FILE* output = stdout; + UFILE* output = u_finit(stdout, NULL, NULL); LexdCompiler comp; LtLocale::tryToSetLocale(); @@ -146,7 +146,7 @@ int main(int argc, char *argv[]) if(outfile != "" && outfile != "-") { - output = fopen(outfile.c_str(), "wb"); + output = u_fopen(outfile.c_str(), "wb", NULL, NULL); if(!output) { cerr << "Error: Cannot open file '" << outfile << "' for writing." << endl; @@ -173,13 +173,13 @@ int main(int argc, char *argv[]) //comp.alphabet.write(output); //Compression::multibyte_write(1, output); //Compression::wstring_write(L"main", output); - transducer->write(output); + //transducer->write(output); } else { transducer->show(comp.alphabet, output, 0, true); } - if(output != stdout) fclose(output); + u_fclose(output); delete transducer; return 0; } diff --git a/src/lexdcompiler.cc b/src/lexdcompiler.cc index 1cc1046..0c09509 100644 --- a/src/lexdcompiler.cc +++ b/src/lexdcompiler.cc @@ -63,13 +63,13 @@ const UnicodeString &LexdCompiler::name(string_ref r) const trans_sym_t LexdCompiler::alphabet_lookup(const UnicodeString &symbol) { - wstring wsymbol = to_wstring(symbol); - if(wsymbol.length() == 1) - return trans_sym_t((int)wsymbol[0]); - else - { - alphabet.includeSymbol(wsymbol); - return trans_sym_t(alphabet(wsymbol)); + if (!symbol.hasMoreChar32Than(0, symbol.length(), 1)) { + return trans_sym_t((int)symbol.char32At(0)); + } else { + UString temp; + temp.append(symbol.getBuffer(), symbol.length()); + alphabet.includeSymbol(temp); + return trans_sym_t(alphabet(temp)); } } trans_sym_t LexdCompiler::alphabet_lookup(trans_sym_t l, trans_sym_t r) diff --git a/src/lexicon.cc b/src/lexicon.cc index 9800e32..fcafcff 100644 --- a/src/lexicon.cc +++ b/src/lexicon.cc @@ -95,7 +95,9 @@ Lexicon::getTransducerWithFlags(Alphabet& alpha, Side side, unsigned int part, w int state = t->getInitial(); if(flag.size() > 0) { - wstring f = L"@U." + flag + L"." + to_wstring(e) + L"@"; + UChar buf[64]; + u_snprintf(buf, 64, "@U.%S.%d@", flag.c_str(), e); + UString f = buf; alpha.includeSymbol(f); int s = alpha(f); state = t->insertSingleTransduction(alpha(s, s), state);