summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgumi <git@gumi.ca>2018-02-15 13:16:04 -0500
committergumi <git@gumi.ca>2018-02-15 13:16:20 -0500
commit68886b570125930f7a5d6343900a16d584a6dccd (patch)
treed9ef86b4be05cd61cfb98d826a93349b7079a8aa
parentd8dc19e4b8b5afb83c326da2f12b0082f14c3c60 (diff)
downloadevol-hercules-68886b570125930f7a5d6343900a16d584a6dccd.tar.gz
evol-hercules-68886b570125930f7a5d6343900a16d584a6dccd.tar.bz2
evol-hercules-68886b570125930f7a5d6343900a16d584a6dccd.tar.xz
evol-hercules-68886b570125930f7a5d6343900a16d584a6dccd.zip
make the translation buildin use sprintfs20180222
-rw-r--r--src/emap/utils/formatutils.c55
1 files changed, 38 insertions, 17 deletions
diff --git a/src/emap/utils/formatutils.c b/src/emap/utils/formatutils.c
index 00ea637..3e8c842 100644
--- a/src/emap/utils/formatutils.c
+++ b/src/emap/utils/formatutils.c
@@ -97,25 +97,46 @@ int format_sub(struct script_state* st, int translate)
}
char *ptr = line;
- int sz = (int)strlen(line);
- while (script_hasdata(st, idx))
+
+ if (strstr(ptr, "@@"))
+ {
+ int sz = (int)strlen(line);
+
+ while (script_hasdata(st, idx))
+ {
+ char *tmp = strstr(ptr, "@@");
+ if (!tmp)
+ break;
+ const char *item = script_getstr(st, idx);
+ int len = (int)strlen(item);
+ if (len > 50)
+ break;
+ sz += len - 2;
+ if (sz > 490)
+ break;
+ memmove(tmp + len, tmp + 2, strlen(tmp + 2) + 1);
+ memcpy(tmp, item, len);
+ ptr = tmp + len;
+ idx ++;
+ }
+
+ script_pushstr(st, line);
+ }
+ else
{
- char *tmp = strstr(ptr, "@@");
- if (!tmp)
- break;
- const char *item = script_getstr(st, idx);
- int len = (int)strlen(item);
- if (len > 50)
- break;
- sz += len - 2;
- if (sz > 490)
- break;
- memmove(tmp + len, tmp + 2, strlen(tmp + 2) + 1);
- memcpy(tmp, item, len);
- ptr = tmp + len;
- idx ++;
+ struct StringBuf pfbuf;
+ StrBuf->Init(&pfbuf);
+
+ if (!script->sprintf(st, translate == 2 ? 3 : 2, &pfbuf))
+ {
+ StrBuf->Destroy(&pfbuf);
+ script_pushstr(st, line);
+ return false;
+ }
+
+ script_pushstrcopy(st, StrBuf->Value(&pfbuf));
+ StrBuf->Destroy(&pfbuf);
}
- script_pushstr(st, line);
return 0;
}