summaryrefslogtreecommitdiffstats
path: root/lua/lua-plugin-init.c
diff options
context:
space:
mode:
authorPeng Wu <epico@dhcp-65-116.nay.redhat.com>2010-03-22 10:00:22 +0800
committerPeng Wu <alexepico@gmail.com>2010-05-19 10:09:31 +0800
commita1a3c7e061376b6426c12f29b4131785a27e943b (patch)
tree7ad2bc2297cdd823669930ea1eda46e5b5d27da0 /lua/lua-plugin-init.c
parent9235290adcd1ca1a7c1de6bafc1a275f677aa01f (diff)
downloadibus-libpinyin-a1a3c7e061376b6426c12f29b4131785a27e943b.tar.gz
ibus-libpinyin-a1a3c7e061376b6426c12f29b4131785a27e943b.tar.xz
ibus-libpinyin-a1a3c7e061376b6426c12f29b4131785a27e943b.zip
change luaL_checklstring to lua_tolstring.
Diffstat (limited to 'lua/lua-plugin-init.c')
-rw-r--r--lua/lua-plugin-init.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/lua/lua-plugin-init.c b/lua/lua-plugin-init.c
index 8469cca..66f50e4 100644
--- a/lua/lua-plugin-init.c
+++ b/lua/lua-plugin-init.c
@@ -87,10 +87,10 @@ static int ime_push_string(lua_State* L, const char * s,
static int ime_trim_string_left(lua_State* L){
size_t l; int start, end;
- const char * s = luaL_checklstring(L, 1, &l);
+ const char * s = lua_tolstring(L, 1, &l);
IME_TRIM_PRECHECK;
- start = 0; end = strlen(s);
+ start = 0; end = l;
while( ime_is_white_space(s[start])){
start++;
}
@@ -100,11 +100,11 @@ static int ime_trim_string_left(lua_State* L){
static int ime_trim_string_right(lua_State* L){
size_t l; int start, end;
- const char * s = luaL_checklstring(L, 1, &l);
+ const char * s = lua_tolstring(L, 1, &l);
IME_TRIM_PRECHECK;
- start = 0; end = strlen(s);
- while( ime_is_white_space(s[end - 1])){
+ start = 0; end = l;
+ while( ime_is_white_space(s[end - 1]) && end > 0){
end--;
}
@@ -113,14 +113,14 @@ static int ime_trim_string_right(lua_State* L){
static int ime_trim_string(lua_State* L){
size_t l; int start, end;
- const char * s = luaL_checklstring(L, 1, &l);
+ const char * s = lua_tolstring(L, 1, &l);
IME_TRIM_PRECHECK;
- start = 0; end = strlen(s);
+ start = 0; end = l;
while( ime_is_white_space(s[start])){
start++;
}
- while( ime_is_white_space(s[end - 1])){
+ while( ime_is_white_space(s[end - 1]) && end > 0){
end--;
}