diff options
author | Andrei Karas <akaras@inbox.ru> | 2018-02-27 00:44:10 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2018-02-27 00:44:10 +0300 |
commit | 9421aeddd73397479def88d6776f01ee16cba7b8 (patch) | |
tree | 2dc6552f7748b25d8cdbff7266aa6dc0da19b2e7 /src/emap | |
parent | 68886b570125930f7a5d6343900a16d584a6dccd (diff) | |
download | plugin-9421aeddd73397479def88d6776f01ee16cba7b8.tar.gz plugin-9421aeddd73397479def88d6776f01ee16cba7b8.tar.bz2 plugin-9421aeddd73397479def88d6776f01ee16cba7b8.tar.xz plugin-9421aeddd73397479def88d6776f01ee16cba7b8.zip |
Revert "make the translation buildin use sprintf"
This reverts commit 68886b570125930f7a5d6343900a16d584a6dccd.
Fix translation errors.
Diffstat (limited to 'src/emap')
-rw-r--r-- | src/emap/utils/formatutils.c | 55 |
1 files changed, 17 insertions, 38 deletions
diff --git a/src/emap/utils/formatutils.c b/src/emap/utils/formatutils.c index 3e8c842..00ea637 100644 --- a/src/emap/utils/formatutils.c +++ b/src/emap/utils/formatutils.c @@ -97,46 +97,25 @@ int format_sub(struct script_state* st, int translate) } char *ptr = line; - - 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 + int sz = (int)strlen(line); + while (script_hasdata(st, 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); + 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); return 0; } |