diff options
author | gepard1984 <gepard1984@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-02-14 14:46:11 +0000 |
---|---|---|
committer | gepard1984 <gepard1984@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-02-14 14:46:11 +0000 |
commit | 4c1423ea04f98647576a952be6adbc1b0d8ce2cf (patch) | |
tree | fa442c8619ea752fbd03f7370f753a77965ae0d0 /src/map | |
parent | 609c6b3e70a4fedd8e040dc79e53048b4be30eb8 (diff) | |
download | hercules-4c1423ea04f98647576a952be6adbc1b0d8ce2cf.tar.gz hercules-4c1423ea04f98647576a952be6adbc1b0d8ce2cf.tar.bz2 hercules-4c1423ea04f98647576a952be6adbc1b0d8ce2cf.tar.xz hercules-4c1423ea04f98647576a952be6adbc1b0d8ce2cf.zip |
Fixed `strtolower` and `strtoupper` script functions (bug:5331).
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15580 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/script.c | 41 |
1 files changed, 14 insertions, 27 deletions
diff --git a/src/map/script.c b/src/map/script.c index 705eb041b..f26d60b12 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -12581,15 +12581,10 @@ BUILDIN_FUNC(setchar) const char *str = script_getstr(st,2); const char *c = script_getstr(st,3); int index = script_getnum(st,4); - char *output; - size_t len = strlen(str); + char *output = aStrdup(str); - output = (char*)aMallocA(len + 1); - memcpy(output, str, len); - output[len] = '\0'; - - if(index >= 0 && index < len) - output[index] = c[0]; + if(index >= 0 && index < strlen(output)) + output[index] = *c; script_pushstr(st, output); return 0; @@ -12634,9 +12629,7 @@ BUILDIN_FUNC(delchar) if(index < 0 || index > len) { //return original - ++len; - output = (char*)aMallocA(len); - memcpy(output, str, len); + output = aStrdup(str); script_pushstr(st, output); return 0; } @@ -12656,16 +12649,13 @@ BUILDIN_FUNC(delchar) BUILDIN_FUNC(strtoupper) { const char *str = script_getstr(st,2); - char *output; - int i = 0; - - output = (char*)aMallocA(strlen(str) + 1); + char *output = aStrdup(str); + char *cursor = output; - while(str[i] != '\0') { - i = i + 1; - output[i] = TOUPPER(str[i]); + while (*cursor != '\0') { + *cursor = TOUPPER(*cursor); + cursor++; } - output[i] = '\0'; script_pushstr(st, output); return 0; @@ -12677,16 +12667,13 @@ BUILDIN_FUNC(strtoupper) BUILDIN_FUNC(strtolower) { const char *str = script_getstr(st,2); - char *output; - int i = 0; - - output = (char*)aMallocA(strlen(str) + 1); + char *output = aStrdup(str); + char *cursor = output; - while(str[i] != '\0') { - i = i + 1; - output[i] = TOLOWER(str[i]); + while (*cursor != '\0') { + *cursor = TOLOWER(*cursor); + cursor++; } - output[i] = '\0'; script_pushstr(st, output); return 0; |