summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorruki <[email protected]>2017-06-16 15:45:31 +0800
committerruki <[email protected]>2017-06-16 15:45:31 +0800
commitb3cc1e1c42d8b367f2d0b1a93c236abe1cc94b34 (patch)
tree206f6249f3f61d856ecbfb731661a2514923a91f /core/src
parent4ce04f4a25ac9fa21e19ae4c568d7a253959680a (diff)
replace old find compiler scripts and fix string.endswith
Diffstat (limited to 'core/src')
-rw-r--r--core/src/demo/xmake.lua2
-rw-r--r--core/src/xmake/machine.c4
-rw-r--r--core/src/xmake/makefile1
-rw-r--r--core/src/xmake/string/endswith.c6
-rw-r--r--core/src/xmake/string/startswith.c2
-rw-r--r--core/src/xmake/string/strcmp.c57
6 files changed, 6 insertions, 66 deletions
diff --git a/core/src/demo/xmake.lua b/core/src/demo/xmake.lua
index 9f4fd2f0d..40d089f7f 100644
--- a/core/src/demo/xmake.lua
+++ b/core/src/demo/xmake.lua
@@ -36,6 +36,6 @@ target("demo")
-- add the resource files (it will be enabled after publishing new version)
if is_plat("windows") then
--- add_files("*.rc")
+ add_files("*.rc")
end
diff --git a/core/src/xmake/machine.c b/core/src/xmake/machine.c
index e1638e1ab..7f1acfbd0 100644
--- a/core/src/xmake/machine.c
+++ b/core/src/xmake/machine.c
@@ -99,7 +99,6 @@ tb_int_t xm_winreg_query(lua_State* lua);
#endif
// the string functions
-tb_int_t xm_string_strcmp(lua_State* lua);
tb_int_t xm_string_endswith(lua_State* lua);
tb_int_t xm_string_startswith(lua_State* lua);
@@ -172,8 +171,7 @@ static luaL_Reg const g_path_functions[] =
// the string functions
static luaL_Reg const g_string_functions[] =
{
- { "strcmp", xm_string_strcmp }
-, { "endswith", xm_string_endswith }
+ { "endswith", xm_string_endswith }
, { "startswith", xm_string_startswith }
, { tb_null, tb_null }
};
diff --git a/core/src/xmake/makefile b/core/src/xmake/makefile
index efc32d94d..e9f5badce 100644
--- a/core/src/xmake/makefile
+++ b/core/src/xmake/makefile
@@ -45,7 +45,6 @@ xmake_C_FILES += \
path/translate \
path/is_absolute \
winreg/query \
- string/strcmp \
string/endswith \
string/startswith \
process/open \
diff --git a/core/src/xmake/string/endswith.c b/core/src/xmake/string/endswith.c
index 241e59254..8de61e2bb 100644
--- a/core/src/xmake/string/endswith.c
+++ b/core/src/xmake/string/endswith.c
@@ -49,9 +49,9 @@ tb_int_t xm_string_endswith(lua_State* lua)
tb_char_t const* suffix = luaL_checklstring(lua, 2, &suffix_size);
tb_check_return_val(string && suffix, 0);
- // done string:endswith(suffix)
- if (string_size >= suffix_size)
- lua_pushboolean(lua, !tb_strcmp(string + string_size - suffix_size, suffix));
+ // string:endswith(suffix)?
+ lua_pushboolean(lua, string_size >= suffix_size && !tb_strcmp(string + string_size - suffix_size, suffix));
+
// ok
return 1;
diff --git a/core/src/xmake/string/startswith.c b/core/src/xmake/string/startswith.c
index 84766e5ca..de039dede 100644
--- a/core/src/xmake/string/startswith.c
+++ b/core/src/xmake/string/startswith.c
@@ -48,7 +48,7 @@ tb_int_t xm_string_startswith(lua_State* lua)
tb_char_t const* prefix = luaL_checklstring(lua, 2, &prefix_size);
tb_check_return_val(string && prefix, 0);
- // done string:startswith(prefix)
+ // string:startswith(prefix)?
lua_pushboolean(lua, !tb_strncmp(string, prefix, (tb_size_t)prefix_size));
// ok
diff --git a/core/src/xmake/string/strcmp.c b/core/src/xmake/string/strcmp.c
deleted file mode 100644
index 2ad06f27d..000000000
--- a/core/src/xmake/string/strcmp.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*!The Make-like Build Utility based on Lua
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Copyright (C) 2015 - 2017, TBOOX Open Source Group.
- *
- * @author ruki
- * @file strcmp.c
- *
- */
-
-/* //////////////////////////////////////////////////////////////////////////////////////
- * trace
- */
-#define TB_TRACE_MODULE_NAME "strcmp"
-#define TB_TRACE_MODULE_DEBUG (0)
-
-/* //////////////////////////////////////////////////////////////////////////////////////
- * includes
- */
-#include "prefix.h"
-
-/* //////////////////////////////////////////////////////////////////////////////////////
- * implementation
- */
-
-// string:strcmp(s1, s2)
-tb_int_t xm_string_strcmp(lua_State* lua)
-{
- // check
- tb_assert_and_check_return_val(lua, 0);
-
- // get the strings
- tb_char_t const* s1 = luaL_checkstring(lua, 1);
- tb_char_t const* s2 = luaL_checkstring(lua, 2);
- tb_check_return_val(s1 && s2, 0);
-
- // compare them
- lua_pushinteger(lua, tb_strcmp(s1, s2));
-
- // ok
- return 1;
-}