diff options
| author | ruki <[email protected]> | 2019-11-26 00:47:51 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-11-25 23:40:49 +0800 |
| commit | 2101b278bb3f1d15395110b25b63a8536ecffb94 (patch) | |
| tree | 0b8166a2708793b181cea500091c214555de2603 | |
| parent | dee47ccf498d9ed84e58885257d8f84863922a1a (diff) | |
impl hash.uuid4
| m--------- | core/src/tbox/tbox | 0 | ||||
| -rw-r--r-- | core/src/xmake/hash/uuid4.c (renamed from core/src/xmake/hash/uuid.c) | 12 | ||||
| -rw-r--r-- | core/src/xmake/machine.c | 4 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/hash.lua | 13 |
4 files changed, 12 insertions, 17 deletions
diff --git a/core/src/tbox/tbox b/core/src/tbox/tbox -Subproject eb29b093abfeb7db2d7ae95892a055749df17af +Subproject 2e773b53e4aefb143e841a05aed675f5b8da60c diff --git a/core/src/xmake/hash/uuid.c b/core/src/xmake/hash/uuid4.c index 399f224bb..5f4ca6138 100644 --- a/core/src/xmake/hash/uuid.c +++ b/core/src/xmake/hash/uuid4.c @@ -15,14 +15,14 @@ * Copyright (C) 2015 - 2019, TBOOX Open Source Group. * * @author ruki - * @file uuid.c + * @file uuid4.c * */ /* ////////////////////////////////////////////////////////////////////////////////////// * trace */ -#define TB_TRACE_MODULE_NAME "uuid" +#define TB_TRACE_MODULE_NAME "uuid4" #define TB_TRACE_MODULE_DEBUG (0) /* ////////////////////////////////////////////////////////////////////////////////////// @@ -33,7 +33,7 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * implementation */ -tb_int_t xm_hash_uuid(lua_State* lua) +tb_int_t xm_hash_uuid4(lua_State* lua) { // check tb_assert_and_check_return_val(lua, 0); @@ -41,10 +41,8 @@ tb_int_t xm_hash_uuid(lua_State* lua) // get the name tb_char_t const* name = luaL_optstring(lua, 1, tb_null); - // make uuid + // make uuid, use version 4 tb_char_t uuid[37]; - lua_pushstring(lua, tb_uuid_make_cstr(uuid, name)); - - // ok + lua_pushstring(lua, tb_uuid4_make_cstr(uuid, name)); return 1; } diff --git a/core/src/xmake/machine.c b/core/src/xmake/machine.c index faeadfe4f..dd606f0b6 100644 --- a/core/src/xmake/machine.c +++ b/core/src/xmake/machine.c @@ -137,7 +137,7 @@ tb_int_t xm_path_translate(lua_State* lua); tb_int_t xm_path_is_absolute(lua_State* lua); // the hash functions -tb_int_t xm_hash_uuid(lua_State* lua); +tb_int_t xm_hash_uuid4(lua_State* lua); tb_int_t xm_hash_sha256(lua_State* lua); // the windows functions @@ -295,7 +295,7 @@ static luaL_Reg const g_path_functions[] = // the hash functions static luaL_Reg const g_hash_functions[] = { - { "uuid", xm_hash_uuid } + { "uuid4", xm_hash_uuid4 } , { "sha256", xm_hash_sha256 } , { tb_null, tb_null } }; diff --git a/xmake/core/sandbox/modules/hash.lua b/xmake/core/sandbox/modules/hash.lua index acac0deaa..4db755c96 100644 --- a/xmake/core/sandbox/modules/hash.lua +++ b/xmake/core/sandbox/modules/hash.lua @@ -26,27 +26,24 @@ local sandbox_hash = sandbox_hash or {} -- make a new uuid function sandbox_hash.uuid(name) + return sandbox_hash.uuid4(name) +end - -- make it - local uuid = hash.uuid(name) +-- make a new uuid v4 +function sandbox_hash.uuid4(name) + local uuid = hash.uuid4(name) if not uuid then raise("cannot make uuid %s", name) end - - -- ok? return uuid end -- make sha256 from the given file function sandbox_hash.sha256(file) - - -- make it local sha256 = hash.sha256(file) if not sha256 then raise("cannot make sha256 for %s", file) end - - -- ok? return sha256 end |
