diff options
| author | ruki <[email protected]> | 2022-03-09 23:12:31 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-03-09 23:12:31 +0800 |
| commit | f2030d90fa6363fb83fb03b38ff7d789ec2ea79a (patch) | |
| tree | 2c1dd955be6d682f9f427287bcd7ce6d63f1dce4 | |
| parent | 1f53c65f517c5a1c926109156e8bccfa74912b83 (diff) | |
add reduce_dot2 for path.translate
| -rw-r--r-- | core/src/xmake/path/translate.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/core/src/xmake/path/translate.c b/core/src/xmake/path/translate.c index 4a9733781..1eabc2a79 100644 --- a/core/src/xmake/path/translate.c +++ b/core/src/xmake/path/translate.c @@ -42,12 +42,23 @@ tb_int_t xm_path_translate(lua_State* lua) tb_char_t const* path = luaL_checkstring(lua, 1); tb_check_return_val(path, 0); + // get the option argument, e.g. {reduce_dot2 = true} + tb_bool_t reduce_dot2 = tb_false; + if (lua_istable(lua, 2)) + { + lua_pushstring(lua, "reduce_dot2"); + lua_gettable(lua, 2); + if (lua_toboolean(lua, -1)) + reduce_dot2 = tb_true; + lua_pop(lua, 1); + } + // copy path tb_char_t data[TB_PATH_MAXN]; tb_strlcpy(data, path, sizeof(data)); // do path:translate() - tb_size_t size = tb_path_translate(data, 0, sizeof(data) - 1); + tb_size_t size = tb_path_translate(data, 0, sizeof(data) - 1, reduce_dot2); if (size) lua_pushlstring(lua, data, (size_t)size); else lua_pushnil(lua); return 1; |
