commit c23ef203e55a78b9e37199ca5ff888dfa3c37870 Author: Daniel Swanson Date: Thu Jul 29 15:12:49 2021 -0500 drop config header and switch rtx-comp to InputFile diff --git a/configure.ac b/configure.ac index 3b82216..58bc6f5 100644 --- a/configure.ac +++ b/configure.ac @@ -6,7 +6,6 @@ m4_define([required_lttoolbox_version], [3.6.0]) AC_INIT([apertium-recursive], [1.1.0], [awesomeevildudes@gmail.com]) AM_INIT_AUTOMAKE -AC_CONFIG_HEADER([src/auto_config.h]) AC_CONFIG_MACRO_DIR([m4]) AC_PROG_CXX @@ -49,6 +48,7 @@ AC_CHECK_LIB(xml2, xmlReaderForFile) AC_CHECK_FUNCS([setlocale strdup getopt_long]) AC_CHECK_DECLS([fread_unlocked, fwrite_unlocked, fgetc_unlocked, fputc_unlocked, fputs_unlocked, getopt_long]) +AC_CHECK_HEADERS([string_view]) CPPFLAGS="$CPPFLAGS $CFLAGS $LTTOOLBOX_CFLAGS $APERTIUM_CFLAGS $LIBXML_CFLAGS $ICU_CFLAGS" LIBS="$LIBS $LTTOOLBOX_LIBS $APERTIUM_LIBS $LIBXML_LIBS $ICU_LIBS" diff --git a/src/bytecode.h b/src/bytecode.h index 65acc92..596a244 100644 --- a/src/bytecode.h +++ b/src/bytecode.h @@ -1,7 +1,6 @@ #ifndef __RTXBYTECODE__ #define __RTXBYTECODE__ -#include #include // Stack Operations diff --git a/src/chunk.cc b/src/chunk.cc index cf57077..3ed52a4 100644 --- a/src/chunk.cc +++ b/src/chunk.cc @@ -1,4 +1,3 @@ -#include #include #include diff --git a/src/chunk.h b/src/chunk.h index 9e6f6d0..bd30049 100644 --- a/src/chunk.h +++ b/src/chunk.h @@ -1,7 +1,6 @@ #ifndef __RTXCHUNK__ #define __RTXCHUNK__ -#include #include #include diff --git a/src/matcher.h b/src/matcher.h index a1c8f78..1107f2a 100644 --- a/src/matcher.h +++ b/src/matcher.h @@ -1,7 +1,6 @@ #ifndef __RTXMATCHER__ #define __RTXMATCHER__ -#include #include #include #include diff --git a/src/pattern.cc b/src/pattern.cc index 54e9593..3a5af2a 100644 --- a/src/pattern.cc +++ b/src/pattern.cc @@ -1,4 +1,3 @@ -#include #include #include diff --git a/src/pattern.h b/src/pattern.h index a1882ed..cc68b14 100644 --- a/src/pattern.h +++ b/src/pattern.h @@ -1,7 +1,6 @@ #ifndef __RTXPATTERNBUILDER__ #define __RTXPATTERNBUILDER__ -#include #include #include #include diff --git a/src/pool.h b/src/pool.h index b6fa4d9..4f4e5cc 100644 --- a/src/pool.h +++ b/src/pool.h @@ -1,7 +1,6 @@ #ifndef __RTXALLOCATORPOOL__ #define __RTXALLOCATORPOOL__ -#include #include template//1024> diff --git a/src/randpath.cc b/src/randpath.cc index b8ae2da..5ea4ce0 100644 --- a/src/randpath.cc +++ b/src/randpath.cc @@ -1,4 +1,3 @@ -#include #include #include #include diff --git a/src/rtx_comp.cc b/src/rtx_comp.cc index d9deb8e..caab4fe 100644 --- a/src/rtx_comp.cc +++ b/src/rtx_comp.cc @@ -1,4 +1,3 @@ -#include #include #include #include diff --git a/src/rtx_compiler.cc b/src/rtx_compiler.cc index 423333c..889e9a1 100644 --- a/src/rtx_compiler.cc +++ b/src/rtx_compiler.cc @@ -1,4 +1,3 @@ -#include #include #include @@ -60,10 +59,10 @@ RTXCompiler::die(UString message) exit(EXIT_FAILURE); } -UChar +UChar32 RTXCompiler::getchar() { - UChar c; + UChar32 c; if(unreadbuf.size() > 0) { c = unreadbuf[0]; @@ -74,7 +73,7 @@ RTXCompiler::getchar() return c; } -UChar +UChar32 RTXCompiler::peekchar() { if(unreadbuf.size() > 0) return unreadbuf[0]; @@ -192,7 +191,7 @@ RTXCompiler::nextTokenNoSpace() } bool -RTXCompiler::isNextToken(UChar c) +RTXCompiler::isNextToken(UChar32 c) { if(peekchar() == c) { @@ -2476,12 +2475,7 @@ RTXCompiler::read(const string &fname) { currentLine = 1; sourceFile = fname; - source.open(fname); - if(!source.is_open()) - { - cerr << "Unable to open file " << fname.c_str() << " for reading." << endl; - exit(EXIT_FAILURE); - } + source.open_or_exit(fname.c_str()); while(true) { eatSpaces(); diff --git a/src/rtx_compiler.h b/src/rtx_compiler.h index 6d333c6..2929f63 100644 --- a/src/rtx_compiler.h +++ b/src/rtx_compiler.h @@ -1,9 +1,9 @@ #ifndef __RTXCOMPILER__ #define __RTXCOMPILER__ -#include #include #include +#include #include #include @@ -266,7 +266,7 @@ private: /** * Input stream */ - ifstream source; + InputFile source; ////////// // ERROR REPORTING @@ -298,7 +298,7 @@ private: * to ensure that recentlyRead gets updated properly * @return character */ - UChar getchar(); + UChar32 getchar(); /** * Return the next character in the input stream without reading @@ -306,7 +306,7 @@ private: * in order to properly manage unreadbuf * @ return character */ - UChar peekchar(); + UChar32 peekchar(); /** * Mark the current location so that it can be jumped back to with unread() @@ -362,7 +362,7 @@ private: * If the next character in the input stream is c, consume it and return true * Otherwise return false */ - bool isNextToken(UChar c); + bool isNextToken(UChar32 c); ////////// // COMPONENT PARSING diff --git a/src/rtx_config.h b/src/rtx_config.h deleted file mode 100644 index d277ea9..0000000 --- a/src/rtx_config.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __RTX_CONFIG_H__ -#define __RTX_CONFIG_H__ - -#include - -#if !defined(HAVE_DECL_FGETC_UNLOCKED) || !HAVE_DECL_FGETC_UNLOCKED - #define fgetc_unlocked fgetc - #define fputc_unlocked fputc - #define fputs_unlocked fputs - #define fread_unlocked fread - #define fwrite_unlocked fwrite -#endif - -#endif diff --git a/src/rtx_decomp.cc b/src/rtx_decomp.cc index e964e3f..61c8a6c 100644 --- a/src/rtx_decomp.cc +++ b/src/rtx_decomp.cc @@ -1,4 +1,3 @@ -#include #include #include #include diff --git a/src/rtx_proc.cc b/src/rtx_proc.cc index 63093cb..9156d6d 100644 --- a/src/rtx_proc.cc +++ b/src/rtx_proc.cc @@ -1,4 +1,3 @@ -#include #include #include #include diff --git a/src/rtx_processor.cc b/src/rtx_processor.cc index 65532b4..ebd2e86 100644 --- a/src/rtx_processor.cc +++ b/src/rtx_processor.cc @@ -1,4 +1,3 @@ -#include #include #include //#include diff --git a/src/rtx_processor.h b/src/rtx_processor.h index 47603c5..8705442 100644 --- a/src/rtx_processor.h +++ b/src/rtx_processor.h @@ -1,7 +1,6 @@ #ifndef __RTXPROCESSOR__ #define __RTXPROCESSOR__ -#include #include #include #include diff --git a/src/trx_compiler.cc b/src/trx_compiler.cc index 8b01907..726b5ea 100644 --- a/src/trx_compiler.cc +++ b/src/trx_compiler.cc @@ -1,4 +1,3 @@ -#include #include #include #include diff --git a/src/trx_compiler.h b/src/trx_compiler.h index 86cb3dc..ee5f494 100644 --- a/src/trx_compiler.h +++ b/src/trx_compiler.h @@ -1,7 +1,6 @@ #ifndef __TRXCOMPILER__ #define __TRXCOMPILER__ -#include #include #include #include