commit 34aa5441783347112fa4d7b0ef35eda2df0604ae Author: Daniel Swanson Date: Thu Jun 17 10:27:02 2021 -0500 remove wstring from postlatex-raw diff --git a/apertium/apertium-postlatex-raw.l b/apertium/apertium-postlatex-raw.l index 05d811f..05a4094 100644 --- a/apertium/apertium-postlatex-raw.l +++ b/apertium/apertium-postlatex-raw.l @@ -6,10 +6,7 @@ #include #include -#include #include -#include -#include extern "C" { #if !defined(__STDC__) @@ -23,46 +20,9 @@ extern "C" { #include "apertium_config.h" #endif #include -#ifdef _WIN32 -#include -#include -#endif using namespace std; -AccentsMap accentsMap(true); -wstring closesym = L""; -string memconv = ""; - -wstring convertir(string const &multibyte, int const length) -{ - memconv.append(multibyte.c_str(), length); - int tam = memconv.size(); - wchar_t *retval = new wchar_t[tam+1]; - size_t l = mbstowcs(retval, memconv.c_str(), tam); - - if(l == ((size_t) -1)) - { - delete[] retval; - if(memconv.size() >= 4) - { - wcerr << L"Warning: wrong encoding" << endl; - } - return L""; - } - else - { - memconv = ""; - retval[l] = 0; - wstring ret = retval; - delete[] retval; - return ret; - } -} - - - - %} @@ -78,106 +38,107 @@ wstring convertir(string const &multibyte, int const length) " { - fputws(L"\"",yyout); + fputs_unlocked("\"",yyout); } ' { - fputws(L"\'",yyout); + fputs_unlocked("\'",yyout); } < { - fputws(L"<",yyout); + fputs_unlocked("<",yyout); } > { - fputws(L">",yyout); + fputs_unlocked(">",yyout); } & { - fputws(L"\\&",yyout); + fputs_unlocked("\\&",yyout); } \ { - fputws(L"&",yyout); + fputs_unlocked("&",yyout); } \ { - fputws(L"\\{", yyout); + fputs_unlocked("\\{", yyout); } \ { - fputws(L"\\}", yyout); + fputs_unlocked("\\}", yyout); } \ { - fputws(L"\\%", yyout); + fputs_unlocked("\\%", yyout); } ¿ { - fputws(L"?`",yyout); + fputs_unlocked("?`",yyout); } ¡ { - fputws(L"!`",yyout); + fputs_unlocked("!`",yyout); } \ { BEGIN(mathenv); - fputws(L"$$",yyout); + fputs_unlocked("$$",yyout); } \<\/MATH_DOLLARS\> { - fputws(L"$$",yyout); + fputs_unlocked("$$",yyout); BEGIN(0); } \ { BEGIN(mathenv); - fputws(L"$",yyout); + fputs_unlocked("$",yyout); } \<\/MATH_DOLLAR\> { - fputws(L"$",yyout); + fputs_unlocked("$",yyout); BEGIN(0); } \ { - fputws(L"\\(",yyout); + fputs_unlocked("\\(",yyout); } \<\/MATH_PAR\> { - fputws(L"\\)",yyout); + fputs_unlocked("\\)",yyout); } \ { - fputws(L"\\[",yyout); + fputs_unlocked("\\[",yyout); } \<\/MATH_BRA\> { - fputws(L"\\]",yyout); + fputs_unlocked("\\]",yyout); } \ { - fputws(L"{",yyout); + fputs_unlocked("{",yyout); } \<\/CONTENTS\> { - fputws(L"}",yyout); + fputs_unlocked("}",yyout); } &NBSP; { - fputws(L"~",yyout); + fputs_unlocked("~",yyout); } \ { - fputws(L"\\\\",yyout); + fputs_unlocked("\\\\",yyout); } \[^\<]* { - fputws((wstring(L"\%")+convertir(yytext+9,yyleng-9)).c_str(),yyout); + fputs_unlocked("\%", yyout); + fwrite(yytext+9, 1, yyleng-9, yyout); } \<\/COMMENT\> { @@ -185,14 +146,15 @@ wstring convertir(string const &multibyte, int const length) \[^\<]* { - fputws((wstring(L"[")+convertir(yytext+7,yyleng-7)).c_str(),yyout); + fputs_unlocked("[", yyout); + fwrite(yytext+7, 1, yyleng-7, yyout); } \<\/PARAM\> { - fputws(L"]", yyout); + fputs_unlocked("]", yyout); } \ { - fputws(L"\\verb", yyout); + fputs_unlocked("\\verb", yyout); } \<\/VERB\> { @@ -201,40 +163,51 @@ wstring convertir(string const &multibyte, int const length) \<[a-zA-Z0-9]+\> { - fputws((wstring(L"\\begin{")+convertir(yytext+1,yyleng-2)+wstring(L"}")).c_str(),yyout); + fputs_unlocked("\\begin{", yyout); + fwrite(yytext+1, 1, yyleng-2, yyout); + fputs_unlocked("}", yyout); } \<[a-zA-Z0-9]+_STAR\> { - fputws((wstring(L"\\begin{")+convertir(yytext+1,yyleng-7)+wstring(L"*}")).c_str(),yyout); + fputs_unlocked("\\begin{", yyout); + fwrite(yytext+1, 1, yyleng-7, yyout); + fputs_unlocked("*}", yyout); } \<\/[a-zA-Z0-9]+\> { - fputws((wstring(L"\\end{")+convertir(yytext+2,yyleng-3)+wstring(L"}")).c_str(),yyout); + fputs_unlocked("\\end{", yyout); + fwrite(yytext+2, 1, yyleng-3, yyout); + fputs_unlocked("}", yyout); } \<\/[a-zA-Z0-9]+_STAR\> { - fputws((wstring(L"\\end{")+convertir(yytext+2,yyleng-8)+wstring(L"*}")).c_str(),yyout); + fputs_unlocked("\\end{", yyout); + fwrite(yytext+2, 1, yyleng-8, yyout); + fputs_unlocked("*}", yyout); } \<[a-zA-Z0-9]+\/\> { - fputws((wstring(L"\\")+convertir(yytext+1,yyleng-3)).c_str(),yyout); + fputs_unlocked("\\", yyout); + fwrite(yytext+1, 1, yyleng-3, yyout); } \<[a-zA-Z0-9]+_STAR\/\> { - fputws((wstring(L"\\")+convertir(yytext+1,yyleng-8)+wstring(L"*")).c_str(),yyout); + fputc_unlocked('\\', yyout); + fwrite(yytext+1, 1, yyleng-8, yyout); + fputc_unlocked('*', yyout); } \# { - fputws(L"\\#", yyout); + fputs_unlocked("\\#", yyout); } (.|\n) { - fputws(convertir(yytext,yyleng).c_str(),yyout); + fwrite(yytext, 1, yyleng, yyout); } (.|\n) { - fputws(convertir(yytext,yyleng).c_str(),yyout); + fwrite(yytext, 1, yyleng, yyout); } @@ -288,10 +261,6 @@ int main(int argc, char *argv[]) break; } -#ifdef _MSC_VER - _setmode(_fileno(yyin), _O_U8TEXT); - _setmode(_fileno(yyout), _O_U8TEXT); -#endif // prevent warning message yy_push_state(1); yy_top_state();