Codechange: Split _show_todos into individual bool flags.

This commit is contained in:
frosch
2025-03-24 18:45:02 +01:00
committed by frosch
parent f8292a8d11
commit 77af1c89c8
3 changed files with 15 additions and 17 deletions

View File

@@ -21,10 +21,11 @@
#include "../safeguards.h"
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
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.
static const char *_cur_ident;
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,
expected, nw);
} 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) {
nw = expected;
} else {
@@ -728,10 +729,6 @@ void StringReader::ParseFile()
_translation = this->translation;
_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. */
MemSetT(&_lang, 0);
strecpy(_lang.digit_group_separator, ",");
@@ -903,11 +900,11 @@ void LanguageWriter::WriteLang(const StringData &data)
_cur_line = ls->line;
/* Produce a message if a string doesn't have a translation. */
if (_show_todo > 0 && ls->translated.empty()) {
if ((_show_todo & 2) != 0) {
if (ls->translated.empty()) {
if (_show_warnings) {
StrgenWarning("'{}' is untranslated", ls->name);
}
if ((_show_todo & 1) != 0) {
if (_annotate_todos) {
const char *s = "<TODO> ";
while (*s != '\0') buffer.AppendByte(*s++);
}