summaryrefslogtreecommitdiff
path: root/src/strgen/strgen_base.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/strgen/strgen_base.cpp')
-rw-r--r--src/strgen/strgen_base.cpp11
1 files changed, 10 insertions, 1 deletions
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 ? "<empty>" : cmd->cmd);
+ }
+ offset = cmd->default_plural_offset;
+ }
+
/* Parse each string */
for (nw = 0; nw < MAX_PLURALS; nw++) {
words[nw] = ParseWord(&buf);