From 50a3f4453907447373e8aaa758ec08d9f4208c9d Mon Sep 17 00:00:00 2001 From: frosch Date: Thu, 28 May 2015 17:26:53 +0000 Subject: (svn r27295) -Add: [strgen] Default plural subparameter positions for CARGO_xxx string control codes. --- src/strgen/strgen_base.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/strgen') diff --git a/src/strgen/strgen_base.cpp b/src/strgen/strgen_base.cpp index 95d3291e4..c41f3d9b4 100644 --- a/src/strgen/strgen_base.cpp +++ b/src/strgen/strgen_base.cpp @@ -388,7 +388,7 @@ static void EmitWordList(Buffer *buffer, const char * const *words, uint nw) void EmitPlural(Buffer *buffer, char *buf, int value) { int argidx = _cur_argidx; - int offset = 0; + int offset = -1; int expected = _plural_forms[_lang.plural_form].plural_count; const char **words = AllocaM(const char *, max(expected, MAX_PLURALS)); int nw = 0; @@ -396,6 +396,15 @@ void EmitPlural(Buffer *buffer, char *buf, int value) /* Parse out the number, if one exists. Otherwise default to prev arg. */ if (!ParseRelNum(&buf, &argidx, &offset)) argidx--; + const CmdStruct *cmd = _cur_pcs.cmd[argidx]; + if (offset == -1) { + /* Use default offset */ + if (cmd == NULL || cmd->default_plural_offset < 0) { + strgen_fatal("Command '%s' has no (default) plural position", cmd == NULL ? "" : cmd->cmd); + } + offset = cmd->default_plural_offset; + } + /* Parse each string */ for (nw = 0; nw < MAX_PLURALS; nw++) { words[nw] = ParseWord(&buf); -- cgit v1.2.3-70-g09d2