Fixed strtolower
and strtoupper
script functions (bug:5331).
git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@15580 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
0b9e91afe9
commit
4b96270a30
@ -12581,15 +12581,10 @@ BUILDIN_FUNC(setchar)
|
|||||||
const char *str = script_getstr(st,2);
|
const char *str = script_getstr(st,2);
|
||||||
const char *c = script_getstr(st,3);
|
const char *c = script_getstr(st,3);
|
||||||
int index = script_getnum(st,4);
|
int index = script_getnum(st,4);
|
||||||
char *output;
|
char *output = aStrdup(str);
|
||||||
size_t len = strlen(str);
|
|
||||||
|
|
||||||
output = (char*)aMallocA(len + 1);
|
if(index >= 0 && index < strlen(output))
|
||||||
memcpy(output, str, len);
|
output[index] = *c;
|
||||||
output[len] = '\0';
|
|
||||||
|
|
||||||
if(index >= 0 && index < len)
|
|
||||||
output[index] = c[0];
|
|
||||||
|
|
||||||
script_pushstr(st, output);
|
script_pushstr(st, output);
|
||||||
return 0;
|
return 0;
|
||||||
@ -12634,9 +12629,7 @@ BUILDIN_FUNC(delchar)
|
|||||||
|
|
||||||
if(index < 0 || index > len) {
|
if(index < 0 || index > len) {
|
||||||
//return original
|
//return original
|
||||||
++len;
|
output = aStrdup(str);
|
||||||
output = (char*)aMallocA(len);
|
|
||||||
memcpy(output, str, len);
|
|
||||||
script_pushstr(st, output);
|
script_pushstr(st, output);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -12656,16 +12649,13 @@ BUILDIN_FUNC(delchar)
|
|||||||
BUILDIN_FUNC(strtoupper)
|
BUILDIN_FUNC(strtoupper)
|
||||||
{
|
{
|
||||||
const char *str = script_getstr(st,2);
|
const char *str = script_getstr(st,2);
|
||||||
char *output;
|
char *output = aStrdup(str);
|
||||||
int i = 0;
|
char *cursor = output;
|
||||||
|
|
||||||
output = (char*)aMallocA(strlen(str) + 1);
|
|
||||||
|
|
||||||
while(str[i] != '\0') {
|
while (*cursor != '\0') {
|
||||||
i = i + 1;
|
*cursor = TOUPPER(*cursor);
|
||||||
output[i] = TOUPPER(str[i]);
|
cursor++;
|
||||||
}
|
}
|
||||||
output[i] = '\0';
|
|
||||||
|
|
||||||
script_pushstr(st, output);
|
script_pushstr(st, output);
|
||||||
return 0;
|
return 0;
|
||||||
@ -12677,16 +12667,13 @@ BUILDIN_FUNC(strtoupper)
|
|||||||
BUILDIN_FUNC(strtolower)
|
BUILDIN_FUNC(strtolower)
|
||||||
{
|
{
|
||||||
const char *str = script_getstr(st,2);
|
const char *str = script_getstr(st,2);
|
||||||
char *output;
|
char *output = aStrdup(str);
|
||||||
int i = 0;
|
char *cursor = output;
|
||||||
|
|
||||||
output = (char*)aMallocA(strlen(str) + 1);
|
|
||||||
|
|
||||||
while(str[i] != '\0') {
|
while (*cursor != '\0') {
|
||||||
i = i + 1;
|
*cursor = TOLOWER(*cursor);
|
||||||
output[i] = TOLOWER(str[i]);
|
cursor++;
|
||||||
}
|
}
|
||||||
output[i] = '\0';
|
|
||||||
|
|
||||||
script_pushstr(st, output);
|
script_pushstr(st, output);
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user