diff options
| author | ruki <[email protected]> | 2017-06-16 15:45:31 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-06-16 15:45:31 +0800 |
| commit | b3cc1e1c42d8b367f2d0b1a93c236abe1cc94b34 (patch) | |
| tree | 206f6249f3f61d856ecbfb731661a2514923a91f /core/src/xmake/string | |
| parent | 4ce04f4a25ac9fa21e19ae4c568d7a253959680a (diff) | |
replace old find compiler scripts and fix string.endswith
Diffstat (limited to 'core/src/xmake/string')
| -rw-r--r-- | core/src/xmake/string/endswith.c | 6 | ||||
| -rw-r--r-- | core/src/xmake/string/startswith.c | 2 | ||||
| -rw-r--r-- | core/src/xmake/string/strcmp.c | 57 |
3 files changed, 4 insertions, 61 deletions
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; -} |
