commit 80c7141faa9ec07c408c20854ab0c9ddaa33cd77 Author: Daniel Swanson Date: Thu Jun 17 10:12:17 2021 -0500 no wstring in reformatters diff --git a/apertium/reformat.xsl b/apertium/reformat.xsl index 07ad1b2..0cf5c7e 100644 --- a/apertium/reformat.xsl +++ b/apertium/reformat.xsl @@ -26,7 +26,6 @@ #ifndef GENFORMAT #include "apertium_config.h" #endif -#include <utf8.h> #include <apertium/unlocked_cstdio.h> #include <cstdlib> @@ -36,21 +35,13 @@ #include <string> #include <unistd.h> #include <lttoolbox/lt_locale.h> -#include <apertium/string_to_wostream.h> -#include <wchar.h> -#ifdef _WIN32 -#include <io.h> -#include <fcntl.h> -#define utf8to32 utf8to16 -#define utf32to8 utf16to8 -#endif using namespace std; - + @@ -60,9 +51,9 @@ using namespace std; - + - + @@ -71,19 +62,6 @@ using namespace std; -string memconv; - -wstring convertir(char const *multibyte, int const length) -{ - std::wstring rv; - memconv.append(multibyte, length); - if (utf8::is_valid(memconv.begin(), memconv.end())) { - utf8::utf8to32(memconv.begin(), memconv.end(), std::back_inserter(rv)); - memconv.clear(); - } - return rv; -} - %} %option nounput @@ -100,26 +78,22 @@ wstring convertir(char const *multibyte, int const length) string filename = yytext; filename = filename.substr(2, filename.size()-3); FILE *temp = fopen(filename.c_str(), "rb"); - wint_t mychar; -#ifdef _MSC_VER - _setmode(_fileno(temp), _O_U8TEXT); -#endif + char mychar; if(!temp) { - wcerr << "ERROR: File '" << filename <<"' not found." << endl; + cerr << "ERROR: File '" << filename <<"' not found." << endl; exit(EXIT_FAILURE); } - while(static_cast<int>(mychar = fgetwc_unlocked(temp)) != EOF) - { - fputwc_unlocked(mychar, yyout); + while((mychar = fgetc(temp)) != EOF) { + fputc_unlocked(mychar, yyout); } fclose(temp); unlink(filename.c_str()); } "[\\@" { - fputwc_unlocked(L'@', yyout); + fputc_unlocked('@', yyout); } ".[]" { @@ -127,13 +101,13 @@ wstring convertir(char const *multibyte, int const length) } "\\" { - fputws_unlocked(convertir(yytext+1, yyleng-1).c_str(), yyout); + fwrite(yytext+1, 1, yyleng-1, yyout); } .|\n { - wstring yytext_conv = convertir(yytext, yyleng); + string yytext_conv = yytext; @@ -147,7 +121,7 @@ wstring convertir(char const *multibyte, int const length) - + @@ -156,7 +130,7 @@ wstring convertir(char const *multibyte, int const length) - + @@ -170,8 +144,8 @@ wstring convertir(char const *multibyte, int const length) void usage(string const &progname) { - wcerr << "USAGE: " << progname << " [input_file [output_file]" << ']' << endl; - wcerr << " format processor " << endl; + cerr << "USAGE: " << progname << " [input_file [output_file]" << ']' << endl; + cerr << " format processor " << endl; exit(EXIT_SUCCESS); } @@ -202,10 +176,6 @@ int main(int argc, char *argv[]) default: break; } -#ifdef _MSC_VER - _setmode(_fileno(yyin), _O_U8TEXT); - _setmode(_fileno(yyout), _O_U8TEXT); -#endif