mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Split _show_todos into individual bool flags.
parent
f8292a8d11
commit
77af1c89c8
|
@ -35,10 +35,10 @@
|
||||||
|
|
||||||
void StrgenWarningI(const std::string &msg)
|
void StrgenWarningI(const std::string &msg)
|
||||||
{
|
{
|
||||||
if (_show_todo > 0) {
|
if (_translation) {
|
||||||
fmt::print(stderr, LINE_NUM_FMT("warning"), _file, _cur_line, msg);
|
|
||||||
} else {
|
|
||||||
fmt::print(stderr, LINE_NUM_FMT("info"), _file, _cur_line, msg);
|
fmt::print(stderr, LINE_NUM_FMT("info"), _file, _cur_line, msg);
|
||||||
|
} else {
|
||||||
|
fmt::print(stderr, LINE_NUM_FMT("warning"), _file, _cur_line, msg);
|
||||||
}
|
}
|
||||||
_warnings++;
|
_warnings++;
|
||||||
}
|
}
|
||||||
|
@ -364,11 +364,11 @@ int CDECL main(int argc, char *argv[])
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
_show_todo |= 1;
|
_annotate_todos = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'w':
|
case 'w':
|
||||||
_show_todo |= 2;
|
_show_warnings = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'h':
|
case 'h':
|
||||||
|
@ -455,7 +455,7 @@ int CDECL main(int argc, char *argv[])
|
||||||
writer.Finalise();
|
writer.Finalise();
|
||||||
|
|
||||||
/* if showing warnings, print a summary of the language */
|
/* if showing warnings, print a summary of the language */
|
||||||
if ((_show_todo & 2) != 0) {
|
if (_show_warnings) {
|
||||||
fmt::print("{} warnings and {} errors for {}\n", _warnings, _errors, output_file);
|
fmt::print("{} warnings and {} errors for {}\n", _warnings, _errors, output_file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,7 +156,8 @@ char *ParseWord(char **buf);
|
||||||
|
|
||||||
extern const char *_file;
|
extern const char *_file;
|
||||||
extern int _cur_line;
|
extern int _cur_line;
|
||||||
extern int _errors, _warnings, _show_todo;
|
extern int _errors, _warnings;
|
||||||
|
extern bool _show_warnings, _annotate_todos, _translation;
|
||||||
extern LanguagePackHeader _lang;
|
extern LanguagePackHeader _lang;
|
||||||
|
|
||||||
#endif /* STRGEN_H */
|
#endif /* STRGEN_H */
|
||||||
|
|
|
@ -21,10 +21,11 @@
|
||||||
#include "../safeguards.h"
|
#include "../safeguards.h"
|
||||||
|
|
||||||
static bool _translated; ///< Whether the current language is not the master language
|
static bool _translated; ///< Whether the current language is not the master language
|
||||||
static bool _translation; ///< Is the current file actually a translation or not
|
bool _translation; ///< Is the current file actually a translation or not
|
||||||
const char *_file = "(unknown file)"; ///< The filename of the input, so we can refer to it in errors/warnings
|
const char *_file = "(unknown file)"; ///< The filename of the input, so we can refer to it in errors/warnings
|
||||||
int _cur_line; ///< The current line we're parsing in the input file
|
int _cur_line; ///< The current line we're parsing in the input file
|
||||||
int _errors, _warnings, _show_todo;
|
int _errors, _warnings;
|
||||||
|
bool _show_warnings = false, _annotate_todos = false;
|
||||||
LanguagePackHeader _lang; ///< Header information about a language.
|
LanguagePackHeader _lang; ///< Header information about a language.
|
||||||
static const char *_cur_ident;
|
static const char *_cur_ident;
|
||||||
static ParsedCommandStruct _cur_pcs;
|
static ParsedCommandStruct _cur_pcs;
|
||||||
|
@ -344,7 +345,7 @@ void EmitPlural(Buffer *buffer, char *buf, int)
|
||||||
StrgenFatal("{}: Invalid number of plural forms. Expecting {}, found {}.", _cur_ident,
|
StrgenFatal("{}: Invalid number of plural forms. Expecting {}, found {}.", _cur_ident,
|
||||||
expected, nw);
|
expected, nw);
|
||||||
} else {
|
} else {
|
||||||
if ((_show_todo & 2) != 0) StrgenWarning("'{}' is untranslated. Tweaking english string to allow compilation for plural forms", _cur_ident);
|
if (_show_warnings) StrgenWarning("'{}' is untranslated. Tweaking english string to allow compilation for plural forms", _cur_ident);
|
||||||
if (nw > expected) {
|
if (nw > expected) {
|
||||||
nw = expected;
|
nw = expected;
|
||||||
} else {
|
} else {
|
||||||
|
@ -728,10 +729,6 @@ void StringReader::ParseFile()
|
||||||
_translation = this->translation;
|
_translation = this->translation;
|
||||||
_file = this->file.c_str();
|
_file = this->file.c_str();
|
||||||
|
|
||||||
/* Abusing _show_todo to replace "warning" with "info" for translations. */
|
|
||||||
_show_todo &= 3;
|
|
||||||
if (!this->translation) _show_todo |= 4;
|
|
||||||
|
|
||||||
/* For each new file we parse, reset the genders, and language codes. */
|
/* For each new file we parse, reset the genders, and language codes. */
|
||||||
MemSetT(&_lang, 0);
|
MemSetT(&_lang, 0);
|
||||||
strecpy(_lang.digit_group_separator, ",");
|
strecpy(_lang.digit_group_separator, ",");
|
||||||
|
@ -903,11 +900,11 @@ void LanguageWriter::WriteLang(const StringData &data)
|
||||||
_cur_line = ls->line;
|
_cur_line = ls->line;
|
||||||
|
|
||||||
/* Produce a message if a string doesn't have a translation. */
|
/* Produce a message if a string doesn't have a translation. */
|
||||||
if (_show_todo > 0 && ls->translated.empty()) {
|
if (ls->translated.empty()) {
|
||||||
if ((_show_todo & 2) != 0) {
|
if (_show_warnings) {
|
||||||
StrgenWarning("'{}' is untranslated", ls->name);
|
StrgenWarning("'{}' is untranslated", ls->name);
|
||||||
}
|
}
|
||||||
if ((_show_todo & 1) != 0) {
|
if (_annotate_todos) {
|
||||||
const char *s = "<TODO> ";
|
const char *s = "<TODO> ";
|
||||||
while (*s != '\0') buffer.AppendByte(*s++);
|
while (*s != '\0') buffer.AppendByte(*s++);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue