Changeset - r19585:5d8a500e4d2b
[Not reviewed]
master
0 4 0
frosch - 12 years ago 2012-09-09 15:55:20
frosch@openttd.org
(svn r24516) -Add: [GS] Support ##plural pragma in GS lang files.
4 files changed with 13 insertions and 12 deletions:
0 comments (0 inline, 0 general)
src/game/game_text.cpp
Show inline comments
 
@@ -147,11 +147,6 @@ struct StringListReader : StringReader {
 

	
 
		return buffer;
 
	}
 

	
 
	/* virtual */ void HandlePragma(char *str)
 
	{
 
		strgen_fatal("unknown pragma '%s'", str);
 
	}
 
};
 

	
 
/** Class for writing an encoded language. */
src/strgen/strgen.cpp
Show inline comments
 
@@ -147,11 +147,6 @@ void FileStringReader::HandlePragma(char
 
		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
 
			_lang.num_cases++;
 
		}
 
	} else {
 
		error("unknown pragma '%s'", str);
 
		StringReader::HandlePragma(str);
 
	}
 
}
 

	
src/strgen/strgen.h
Show inline comments
 
@@ -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.
src/strgen/strgen_base.cpp
Show inline comments
 
@@ -783,6 +783,17 @@ void StringReader::HandleString(char *st
 
	}
 
}
 

	
 
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)
 
{
0 comments (0 inline, 0 general)