summaryrefslogtreecommitdiff
path: root/src/strgen
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-09-09 15:55:20 +0000
committerfrosch <frosch@openttd.org>2012-09-09 15:55:20 +0000
commit16760cff8b6a5986922110794f2a41deb12947f0 (patch)
tree2339126e1b0f9aa42672de72aa79f1e0a5d1af6e /src/strgen
parent2ec61361135d004300f3f7f1071d7fd6f8cf204d (diff)
downloadopenttd-16760cff8b6a5986922110794f2a41deb12947f0.tar.xz
(svn r24516) -Add: [GS] Support ##plural pragma in GS lang files.
Diffstat (limited to 'src/strgen')
-rw-r--r--src/strgen/strgen.cpp7
-rw-r--r--src/strgen/strgen.h2
-rw-r--r--src/strgen/strgen_base.cpp11
3 files changed, 13 insertions, 7 deletions
diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp
index 84e791677..e93036952 100644
--- a/src/strgen/strgen.cpp
+++ b/src/strgen/strgen.cpp
@@ -147,11 +147,6 @@ void FileStringReader::HandlePragma(char *str)
strecpy(_lang.own_name, str + 8, lastof(_lang.own_name));
} else if (!memcmp(str, "isocode ", 8)) {
strecpy(_lang.isocode, str + 8, lastof(_lang.isocode));
- } else if (!memcmp(str, "plural ", 7)) {
- _lang.plural_form = atoi(str + 7);
- if (_lang.plural_form >= lengthof(_plural_forms)) {
- error("Invalid pluralform %d", _lang.plural_form);
- }
} else if (!memcmp(str, "textdir ", 8)) {
if (!memcmp(str + 8, "ltr", 3)) {
_lang.text_dir = TD_LTR;
@@ -208,7 +203,7 @@ void FileStringReader::HandlePragma(char *str)
_lang.num_cases++;
}
} else {
- error("unknown pragma '%s'", str);
+ StringReader::HandlePragma(str);
}
}
diff --git a/src/strgen/strgen.h b/src/strgen/strgen.h
index badfb06f7..18ea26997 100644
--- a/src/strgen/strgen.h
+++ b/src/strgen/strgen.h
@@ -81,7 +81,7 @@ struct StringReader {
* Handle the pragma of the file.
* @param str The pragma string to parse.
*/
- virtual void HandlePragma(char *str) = 0;
+ virtual void HandlePragma(char *str);
/**
* Start parsing the file.
diff --git a/src/strgen/strgen_base.cpp b/src/strgen/strgen_base.cpp
index 3d0c91d30..7e4516f61 100644
--- a/src/strgen/strgen_base.cpp
+++ b/src/strgen/strgen_base.cpp
@@ -783,6 +783,17 @@ void StringReader::HandleString(char *str)
}
}
+void StringReader::HandlePragma(char *str)
+{
+ if (!memcmp(str, "plural ", 7)) {
+ _lang.plural_form = atoi(str + 7);
+ if (_lang.plural_form >= lengthof(_plural_forms)) {
+ strgen_fatal("Invalid pluralform %d", _lang.plural_form);
+ }
+ } else {
+ strgen_fatal("unknown pragma '%s'", str);
+ }
+}
static void rstrip(char *buf)
{