diff options
| author | ruki <[email protected]> | 2015-06-02 11:55:07 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2015-06-02 11:55:07 +0800 |
| commit | 1c87d48b17adb5a43076b2a7725582703a49701a (patch) | |
| tree | ef6a2a253dde751387924761591d3b5617c75d43 /core/src | |
| parent | e1498eebcd687db0ccd8786906746642a173c01a (diff) | |
replace single project config
Diffstat (limited to 'core/src')
| -rwxr-xr-x | core/src/xmake/machine.c | 4 | ||||
| -rwxr-xr-x | core/src/xmake/makefile | 1 | ||||
| -rwxr-xr-x | core/src/xmake/string/endswith.c | 56 |
3 files changed, 60 insertions, 1 deletions
diff --git a/core/src/xmake/machine.c b/core/src/xmake/machine.c index 476a6a7eb..c09955e85 100755 --- a/core/src/xmake/machine.c +++ b/core/src/xmake/machine.c @@ -71,6 +71,7 @@ tb_int_t xm_path_translate(lua_State* lua); tb_int_t xm_path_is_absolute(lua_State* lua); // the string functions +tb_int_t xm_string_endswith(lua_State* lua); tb_int_t xm_string_startswith(lua_State* lua); // the preprocessor functions @@ -112,7 +113,8 @@ static luaL_Reg const g_path_functions[] = // the string functions static luaL_Reg const g_string_functions[] = { - { "startswith", xm_string_startswith } + { "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 dc4c1cee5..cfb8510fb 100755 --- a/core/src/xmake/makefile +++ b/core/src/xmake/makefile @@ -31,6 +31,7 @@ xmake_C_FILES += \ path/absolute \ path/translate \ path/is_absolute \ + string/endswith \ string/startswith \ preprocessor/loadx diff --git a/core/src/xmake/string/endswith.c b/core/src/xmake/string/endswith.c new file mode 100755 index 000000000..f4806635f --- /dev/null +++ b/core/src/xmake/string/endswith.c @@ -0,0 +1,56 @@ +/*!The Automatic Cross-platform Build Tool + * + * XMake is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * XMake is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with XMake; + * If not, see <a href="http://www.gnu.org/licenses/"> http://www.gnu.org/licenses/</a> + * + * Copyright (C) 2009 - 2015, ruki All rights reserved. + * + * @author ruki + * @file endswith.c + * + */ + +/* ////////////////////////////////////////////////////////////////////////////////////// + * trace + */ +#define TB_TRACE_MODULE_NAME "endswith" +#define TB_TRACE_MODULE_DEBUG (0) + +/* ////////////////////////////////////////////////////////////////////////////////////// + * includes + */ +#include "prefix.h" + +/* ////////////////////////////////////////////////////////////////////////////////////// + * implementation + */ +tb_int_t xm_string_endswith(lua_State* lua) +{ + // check + tb_assert_and_check_return_val(lua, 0); + + // get the string and suffix + size_t string_size = 0; + size_t suffix_size = 0; + tb_char_t const* string = luaL_checklstring(lua, 1, &string_size); + 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)); + + // ok + return 1; +} |
