diff --git a/langen.cpp b/langen.cpp index b88d3837..b4f4d6e5 100644 --- a/langen.cpp +++ b/langen.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #define GEN_M 0 #define GEN_F 1 @@ -28,6 +29,8 @@ template int isize(const T& x) { return x.size(); } #define NUMLAN 9 +FILE *f; + // language generator std::string current_language; @@ -42,7 +45,7 @@ template struct dictionary { m.emplace(s, std::move(val)); } else if (val != it->second) { - printf("// #warning Two translations for %s [%s]\n", escape(s, s), current_language.c_str()); + fprintf(f, "// #warning Two translations for %s [%s]\n", escape(s, s), current_language.c_str()); } } T& operator [] (const std::string& s) { return m[s]; } @@ -125,7 +128,7 @@ std::map buildHashTable(std::set& s) { const char *escape(std::string s, const std::string& dft) { if(s == "") { - printf("/*MISSING*/ "); + fprintf(f, "/*MISSING*/ "); s = dft; } static std::string t; @@ -341,16 +344,23 @@ void compute_completeness(const T& dict) if(mis1 != "") mis1.pop_back(); if(exist_in != "") exist_in.pop_back(); if(in_important && mis != "") - printf("// #warning Missing [%s : %s] from [%s]: %s\n", mis.c_str(), mis1.c_str(), exist_in.c_str(), escape(elt, "?")); + fprintf(f, "// #warning Missing [%s : %s] from [%s]: %s\n", mis.c_str(), mis1.c_str(), exist_in.c_str(), escape(elt, "?")); completeness[0]++; for(int i=1; i, or without arguments to output to standard output\n"); + exit(1); + } + + fprintf(f, "// DO NOT EDIT -- this file is generated automatically with langen\n\n"); nothe.insert("R'Lyeh"); nothe.insert("Camelot"); @@ -395,24 +405,24 @@ int main() { for(auto&& elt : allchars) { if(isize(elt) >= 2) { javastring += elt; vchars.push_back(elt); } } - printf("\n"); - printf("#if HDR\n"); - printf("#if CAP_TRANS\n"); - printf("#define NUMEXTRA %d\n", isize(vchars)); - printf("#define NATCHARS {"); - for(auto&& elt : vchars) printf("\"%s\",", elt.c_str()); - printf("}\n"); - printf("extern const char* natchars[NUMEXTRA];\n"); - printf("#endif\n"); - printf("#endif\n"); - printf("const char* natchars[NUMEXTRA] = NATCHARS;\n"); - printf("//javastring = \"%s\";\n", javastring.c_str()); + fprintf(f, "\n"); + fprintf(f, "#if HDR\n"); + fprintf(f, "#if CAP_TRANS\n"); + fprintf(f, "#define NUMEXTRA %d\n", isize(vchars)); + fprintf(f, "#define NATCHARS {"); + for(auto&& elt : vchars) fprintf(f, "\"%s\",", elt.c_str()); + fprintf(f, "}\n"); + fprintf(f, "extern const char* natchars[NUMEXTRA];\n"); + fprintf(f, "#endif\n"); + fprintf(f, "#endif\n"); + fprintf(f, "const char* natchars[NUMEXTRA] = NATCHARS;\n"); + fprintf(f, "//javastring = \"%s\";\n", javastring.c_str()); - printf("\nEX int transcompleteness[NUMLAN] = {"); - for(int i=0; i