diff --git a/src/eval.c b/src/eval.c index 3f2513074..c2b73cb9f 100644 --- a/src/eval.c +++ b/src/eval.c @@ -111,7 +111,7 @@ void sha1hex(char *digest, char *script, size_t len) { * Allows to stop execution during a debugging session from within * the Lua code implementation, like if a breakpoint was set in the code * immediately after the function. */ -int luaRedisBreakpointCommand(lua_State *lua) { +int luaRedictBreakpointCommand(lua_State *lua) { if (ldb.active) { ldb.luabp = 1; lua_pushboolean(lua,1); @@ -126,7 +126,7 @@ int luaRedisBreakpointCommand(lua_State *lua) { * Log a string message into the output console. * Can take multiple arguments that will be separated by commas. * Nothing is returned to the caller. */ -int luaRedisDebugCommand(lua_State *lua) { +int luaRedictDebugCommand(lua_State *lua) { if (!ldb.active) return 0; int argc = lua_gettop(lua); sds log = sdscatprintf(sdsempty()," line %d: ", ldb.currentline); @@ -145,7 +145,7 @@ int luaRedisDebugCommand(lua_State *lua) { * a write command so far, and returns true. Otherwise if the script * already started to write, returns false and stick to whole scripts * replication, which is our default. */ -int luaRedisReplicateCommandsCommand(lua_State *lua) { +int luaRedictReplicateCommandsCommand(lua_State *lua) { lua_pushboolean(lua,1); return 1; } @@ -181,19 +181,19 @@ void scriptingInit(int setup) { /* register debug commands */ lua_getglobal(lua,REDICT_API_NAME); - /* redis.breakpoint */ + /* redict.breakpoint */ lua_pushstring(lua,"breakpoint"); - lua_pushcfunction(lua,luaRedisBreakpointCommand); + lua_pushcfunction(lua,luaRedictBreakpointCommand); lua_settable(lua,-3); - /* redis.debug */ + /* redict.debug */ lua_pushstring(lua,"debug"); - lua_pushcfunction(lua,luaRedisDebugCommand); + lua_pushcfunction(lua,luaRedictDebugCommand); lua_settable(lua,-3); - /* redis.replicate_commands */ + /* redict.replicate_commands */ lua_pushstring(lua, "replicate_commands"); - lua_pushcfunction(lua, luaRedisReplicateCommandsCommand); + lua_pushcfunction(lua, luaRedictReplicateCommandsCommand); lua_settable(lua, -3); lua_setglobal(lua,REDICT_API_NAME); @@ -201,19 +201,19 @@ void scriptingInit(int setup) { /* register debug commands */ lua_getglobal(lua,REDICT_API_NAME); - /* redis.breakpoint */ + /* redict.breakpoint */ lua_pushstring(lua,"breakpoint"); - lua_pushcfunction(lua,luaRedisBreakpointCommand); + lua_pushcfunction(lua,luaRedictBreakpointCommand); lua_settable(lua,-3); - /* redis.debug */ + /* redict.debug */ lua_pushstring(lua,"debug"); - lua_pushcfunction(lua,luaRedisDebugCommand); + lua_pushcfunction(lua,luaRedictDebugCommand); lua_settable(lua,-3); - /* redis.replicate_commands */ + /* redict.replicate_commands */ lua_pushstring(lua, "replicate_commands"); - lua_pushcfunction(lua, luaRedisReplicateCommandsCommand); + lua_pushcfunction(lua, luaRedictReplicateCommandsCommand); lua_settable(lua, -3); lua_setglobal(lua,REDICT_API_NAME); @@ -1229,48 +1229,48 @@ void ldbLogStackValue(lua_State *lua, char *prefix) { ldbLogWithMaxLen(s); } -char *ldbRedisProtocolToHuman_Int(sds *o, char *reply); -char *ldbRedisProtocolToHuman_Bulk(sds *o, char *reply); -char *ldbRedisProtocolToHuman_Status(sds *o, char *reply); -char *ldbRedisProtocolToHuman_MultiBulk(sds *o, char *reply); -char *ldbRedisProtocolToHuman_Set(sds *o, char *reply); -char *ldbRedisProtocolToHuman_Map(sds *o, char *reply); -char *ldbRedisProtocolToHuman_Null(sds *o, char *reply); -char *ldbRedisProtocolToHuman_Bool(sds *o, char *reply); -char *ldbRedisProtocolToHuman_Double(sds *o, char *reply); +char *ldbRedictProtocolToHuman_Int(sds *o, char *reply); +char *ldbRedictProtocolToHuman_Bulk(sds *o, char *reply); +char *ldbRedictProtocolToHuman_Status(sds *o, char *reply); +char *ldbRedictProtocolToHuman_MultiBulk(sds *o, char *reply); +char *ldbRedictProtocolToHuman_Set(sds *o, char *reply); +char *ldbRedictProtocolToHuman_Map(sds *o, char *reply); +char *ldbRedictProtocolToHuman_Null(sds *o, char *reply); +char *ldbRedictProtocolToHuman_Bool(sds *o, char *reply); +char *ldbRedictProtocolToHuman_Double(sds *o, char *reply); /* Get Redict protocol from 'reply' and appends it in human readable form to * the passed SDS string 'o'. * * Note that the SDS string is passed by reference (pointer of pointer to * char*) so that we can return a modified pointer, as for SDS semantics. */ -char *ldbRedisProtocolToHuman(sds *o, char *reply) { +char *ldbRedictProtocolToHuman(sds *o, char *reply) { char *p = reply; switch(*p) { - case ':': p = ldbRedisProtocolToHuman_Int(o,reply); break; - case '$': p = ldbRedisProtocolToHuman_Bulk(o,reply); break; - case '+': p = ldbRedisProtocolToHuman_Status(o,reply); break; - case '-': p = ldbRedisProtocolToHuman_Status(o,reply); break; - case '*': p = ldbRedisProtocolToHuman_MultiBulk(o,reply); break; - case '~': p = ldbRedisProtocolToHuman_Set(o,reply); break; - case '%': p = ldbRedisProtocolToHuman_Map(o,reply); break; - case '_': p = ldbRedisProtocolToHuman_Null(o,reply); break; - case '#': p = ldbRedisProtocolToHuman_Bool(o,reply); break; - case ',': p = ldbRedisProtocolToHuman_Double(o,reply); break; + case ':': p = ldbRedictProtocolToHuman_Int(o,reply); break; + case '$': p = ldbRedictProtocolToHuman_Bulk(o,reply); break; + case '+': p = ldbRedictProtocolToHuman_Status(o,reply); break; + case '-': p = ldbRedictProtocolToHuman_Status(o,reply); break; + case '*': p = ldbRedictProtocolToHuman_MultiBulk(o,reply); break; + case '~': p = ldbRedictProtocolToHuman_Set(o,reply); break; + case '%': p = ldbRedictProtocolToHuman_Map(o,reply); break; + case '_': p = ldbRedictProtocolToHuman_Null(o,reply); break; + case '#': p = ldbRedictProtocolToHuman_Bool(o,reply); break; + case ',': p = ldbRedictProtocolToHuman_Double(o,reply); break; } return p; } -/* The following functions are helpers for ldbRedisProtocolToHuman(), each +/* The following functions are helpers for ldbRedictProtocolToHuman(), each * take care of a given Redict return type. */ -char *ldbRedisProtocolToHuman_Int(sds *o, char *reply) { +char *ldbRedictProtocolToHuman_Int(sds *o, char *reply) { char *p = strchr(reply+1,'\r'); *o = sdscatlen(*o,reply+1,p-reply-1); return p+2; } -char *ldbRedisProtocolToHuman_Bulk(sds *o, char *reply) { +char *ldbRedictProtocolToHuman_Bulk(sds *o, char *reply) { char *p = strchr(reply+1,'\r'); long long bulklen; @@ -1284,14 +1284,14 @@ char *ldbRedisProtocolToHuman_Bulk(sds *o, char *reply) { } } -char *ldbRedisProtocolToHuman_Status(sds *o, char *reply) { +char *ldbRedictProtocolToHuman_Status(sds *o, char *reply) { char *p = strchr(reply+1,'\r'); *o = sdscatrepr(*o,reply,p-reply); return p+2; } -char *ldbRedisProtocolToHuman_MultiBulk(sds *o, char *reply) { +char *ldbRedictProtocolToHuman_MultiBulk(sds *o, char *reply) { char *p = strchr(reply+1,'\r'); long long mbulklen; int j = 0; @@ -1304,14 +1304,14 @@ char *ldbRedisProtocolToHuman_MultiBulk(sds *o, char *reply) { } *o = sdscatlen(*o,"[",1); for (j = 0; j < mbulklen; j++) { - p = ldbRedisProtocolToHuman(o,p); + p = ldbRedictProtocolToHuman(o,p); if (j != mbulklen-1) *o = sdscatlen(*o,",",1); } *o = sdscatlen(*o,"]",1); return p; } -char *ldbRedisProtocolToHuman_Set(sds *o, char *reply) { +char *ldbRedictProtocolToHuman_Set(sds *o, char *reply) { char *p = strchr(reply+1,'\r'); long long mbulklen; int j = 0; @@ -1320,14 +1320,14 @@ char *ldbRedisProtocolToHuman_Set(sds *o, char *reply) { p += 2; *o = sdscatlen(*o,"~(",2); for (j = 0; j < mbulklen; j++) { - p = ldbRedisProtocolToHuman(o,p); + p = ldbRedictProtocolToHuman(o,p); if (j != mbulklen-1) *o = sdscatlen(*o,",",1); } *o = sdscatlen(*o,")",1); return p; } -char *ldbRedisProtocolToHuman_Map(sds *o, char *reply) { +char *ldbRedictProtocolToHuman_Map(sds *o, char *reply) { char *p = strchr(reply+1,'\r'); long long mbulklen; int j = 0; @@ -1336,22 +1336,22 @@ char *ldbRedisProtocolToHuman_Map(sds *o, char *reply) { p += 2; *o = sdscatlen(*o,"{",1); for (j = 0; j < mbulklen; j++) { - p = ldbRedisProtocolToHuman(o,p); + p = ldbRedictProtocolToHuman(o,p); *o = sdscatlen(*o," => ",4); - p = ldbRedisProtocolToHuman(o,p); + p = ldbRedictProtocolToHuman(o,p); if (j != mbulklen-1) *o = sdscatlen(*o,",",1); } *o = sdscatlen(*o,"}",1); return p; } -char *ldbRedisProtocolToHuman_Null(sds *o, char *reply) { +char *ldbRedictProtocolToHuman_Null(sds *o, char *reply) { char *p = strchr(reply+1,'\r'); *o = sdscatlen(*o,"(null)",6); return p+2; } -char *ldbRedisProtocolToHuman_Bool(sds *o, char *reply) { +char *ldbRedictProtocolToHuman_Bool(sds *o, char *reply) { char *p = strchr(reply+1,'\r'); if (reply[1] == 't') *o = sdscatlen(*o,"#true",5); @@ -1360,7 +1360,7 @@ char *ldbRedisProtocolToHuman_Bool(sds *o, char *reply) { return p+2; } -char *ldbRedisProtocolToHuman_Double(sds *o, char *reply) { +char *ldbRedictProtocolToHuman_Double(sds *o, char *reply) { char *p = strchr(reply+1,'\r'); *o = sdscatlen(*o,"(double) ",9); *o = sdscatlen(*o,reply+1,p-reply-1); @@ -1372,7 +1372,7 @@ char *ldbRedisProtocolToHuman_Double(sds *o, char *reply) { * used as prefix, it gets truncated. */ void ldbLogRedictReply(char *reply) { sds log = sdsnew(" "); - ldbRedisProtocolToHuman(&log,reply); + ldbRedictProtocolToHuman(&log,reply); ldbLogWithMaxLen(log); } @@ -1514,7 +1514,7 @@ void ldbEval(lua_State *lua, sds *argv, int argc) { * the implementation very simple: we just call the Lua redict.call() command * implementation, with ldb.step enabled, so as a side effect the Redict command * and its reply are logged. */ -void ldbRedis(lua_State *lua, sds *argv, int argc) { +void ldbRedict(lua_State *lua, sds *argv, int argc) { int j; if (!lua_checkstack(lua, argc + 1)) { @@ -1674,11 +1674,11 @@ ldbLog(sdsnew(" next line of code.")); luaError(lua); } else if (argc > 1 && (!strcasecmp(argv[0],"r") || !strcasecmp(argv[0],"redis"))) { - ldbRedis(lua,argv,argc); + ldbRedict(lua,argv,argc); ldbSendLogs(); } else if (argc > 1 && (!strcasecmp(argv[0],"r") || !strcasecmp(argv[0],"redict"))) { - ldbRedis(lua,argv,argc); + ldbRedict(lua,argv,argc); ldbSendLogs(); } else if ((!strcasecmp(argv[0],"p") || !strcasecmp(argv[0],"print"))) { if (argc == 2) diff --git a/src/function_lua.c b/src/function_lua.c index 5148174e6..89ca8c8ae 100644 --- a/src/function_lua.c +++ b/src/function_lua.c @@ -254,7 +254,7 @@ static int luaRegisterFunctionReadNamedArgs(lua_State *lua, registerFunctionArgs luaFunctionCtx *lua_f_ctx = NULL; uint64_t flags = 0; if (!lua_istable(lua, 1)) { - err = "calling redis.register_function with a single argument is only applicable to Lua table (representing named arguments)."; + err = "calling redict.register_function with a single argument is only applicable to Lua table (representing named arguments)."; goto error; } @@ -263,23 +263,23 @@ static int luaRegisterFunctionReadNamedArgs(lua_State *lua, registerFunctionArgs while (lua_next(lua, -2)) { /* Stack now: table, key, value */ if (!lua_isstring(lua, -2)) { - err = "named argument key given to redis.register_function is not a string"; + err = "named argument key given to redict.register_function is not a string"; goto error; } const char *key = lua_tostring(lua, -2); if (!strcasecmp(key, "function_name")) { if (!(name = luaGetStringSds(lua, -1))) { - err = "function_name argument given to redis.register_function must be a string"; + err = "function_name argument given to redict.register_function must be a string"; goto error; } } else if (!strcasecmp(key, "description")) { if (!(desc = luaGetStringSds(lua, -1))) { - err = "description argument given to redis.register_function must be a string"; + err = "description argument given to redict.register_function must be a string"; goto error; } } else if (!strcasecmp(key, "callback")) { if (!lua_isfunction(lua, -1)) { - err = "callback argument given to redis.register_function must be a function"; + err = "callback argument given to redict.register_function must be a function"; goto error; } int lua_function_ref = luaL_ref(lua, LUA_REGISTRYINDEX); @@ -289,7 +289,7 @@ static int luaRegisterFunctionReadNamedArgs(lua_State *lua, registerFunctionArgs continue; /* value was already popped, so no need to pop it out. */ } else if (!strcasecmp(key, "flags")) { if (!lua_istable(lua, -1)) { - err = "flags argument to redis.register_function must be a table representing function flags"; + err = "flags argument to redict.register_function must be a table representing function flags"; goto error; } if (luaRegisterFunctionReadFlags(lua, &flags) != C_OK) { @@ -298,19 +298,19 @@ static int luaRegisterFunctionReadNamedArgs(lua_State *lua, registerFunctionArgs } } else { /* unknown argument was given, raise an error */ - err = "unknown argument given to redis.register_function"; + err = "unknown argument given to redict.register_function"; goto error; } lua_pop(lua, 1); /* pop the value to continue the iteration */ } if (!name) { - err = "redis.register_function must get a function name argument"; + err = "redict.register_function must get a function name argument"; goto error; } if (!lua_f_ctx) { - err = "redis.register_function must get a callback argument"; + err = "redict.register_function must get a callback argument"; goto error; } @@ -335,12 +335,12 @@ static int luaRegisterFunctionReadPositionalArgs(lua_State *lua, registerFunctio sds desc = NULL; luaFunctionCtx *lua_f_ctx = NULL; if (!(name = luaGetStringSds(lua, 1))) { - err = "first argument to redis.register_function must be a string"; + err = "first argument to redict.register_function must be a string"; goto error; } if (!lua_isfunction(lua, 2)) { - err = "second argument to redis.register_function must be a function"; + err = "second argument to redict.register_function must be a function"; goto error; } @@ -363,7 +363,7 @@ error: static int luaRegisterFunctionReadArgs(lua_State *lua, registerFunctionArgs *register_f_args) { int argc = lua_gettop(lua); if (argc < 1 || argc > 2) { - luaPushError(lua, "wrong number of arguments to redis.register_function"); + luaPushError(lua, "wrong number of arguments to redict.register_function"); return C_ERR; } @@ -379,7 +379,7 @@ static int luaRegisterFunction(lua_State *lua) { loadCtx *load_ctx = luaGetFromRegistry(lua, REGISTRY_LOAD_CTX_NAME); if (!load_ctx) { - luaPushError(lua, "redis.register_function can only be called on FUNCTION LOAD command"); + luaPushError(lua, "redict.register_function can only be called on FUNCTION LOAD command"); return luaError(lua); } diff --git a/src/script_lua.c b/src/script_lua.c index ee4af5128..f46fa6df7 100644 --- a/src/script_lua.c +++ b/src/script_lua.c @@ -1404,15 +1404,15 @@ void luaRegisterRedictAPI(lua_State* lua) { lua_pushcfunction(lua,luaRedictPcall); lua_setglobal(lua, "pcall"); - /* Register the redis commands table and fields */ + /* Register the redict commands table and fields */ lua_newtable(lua); - /* redis.call */ + /* redict.call */ lua_pushstring(lua,"call"); lua_pushcfunction(lua,luaRedictCallCommand); lua_settable(lua,-3); - /* redis.pcall */ + /* redict.pcall */ lua_pushstring(lua,"pcall"); lua_pushcfunction(lua,luaRedictPCallCommand); lua_settable(lua,-3); @@ -1421,17 +1421,17 @@ void luaRegisterRedictAPI(lua_State* lua) { luaRegisterVersion(lua); - /* redis.setresp */ + /* redict.setresp */ lua_pushstring(lua,"setresp"); lua_pushcfunction(lua,luaSetResp); lua_settable(lua,-3); - /* redis.sha1hex */ + /* redict.sha1hex */ lua_pushstring(lua, "sha1hex"); lua_pushcfunction(lua, luaRedictSha1hexCommand); lua_settable(lua, -3); - /* redis.error_reply and redis.status_reply */ + /* redict.error_reply and redict.status_reply */ lua_pushstring(lua, "error_reply"); lua_pushcfunction(lua, luaRedictErrorReplyCommand); lua_settable(lua, -3); @@ -1439,7 +1439,7 @@ void luaRegisterRedictAPI(lua_State* lua) { lua_pushcfunction(lua, luaRedictStatusReplyCommand); lua_settable(lua, -3); - /* redis.set_repl and associated flags. */ + /* redict.set_repl and associated flags. */ lua_pushstring(lua,"set_repl"); lua_pushcfunction(lua,luaRedictSetReplCommand); lua_settable(lua,-3); @@ -1464,7 +1464,7 @@ void luaRegisterRedictAPI(lua_State* lua) { lua_pushnumber(lua,PROPAGATE_AOF|PROPAGATE_REPL); lua_settable(lua,-3); - /* redis.acl_check_cmd */ + /* redict.acl_check_cmd */ lua_pushstring(lua,"acl_check_cmd"); lua_pushcfunction(lua,luaRedictAclCheckCmdPermissionsCommand); lua_settable(lua,-3); diff --git a/tests/unit/functions.tcl b/tests/unit/functions.tcl index 3b0ded30f..a1353efe5 100644 --- a/tests/unit/functions.tcl +++ b/tests/unit/functions.tcl @@ -520,7 +520,7 @@ start_server {tags {"scripting"}} { ) } } e - assert_match {*second argument to redis.register_function must be a function*} $e + assert_match {*second argument to redict.register_function must be a function*} $e assert_equal [r fcall f1 0] {2} assert_equal [r fcall f2 0] {3} } @@ -568,7 +568,7 @@ start_server {tags {"scripting"}} { } } e set _ $e - } {*wrong number of arguments to redis.register_function*} + } {*wrong number of arguments to redict.register_function*} test {LIBRARIES - test registration with only name} { catch { @@ -577,7 +577,7 @@ start_server {tags {"scripting"}} { } } e set _ $e - } {*calling redis.register_function with a single argument is only applicable to Lua table*} + } {*calling redict.register_function with a single argument is only applicable to Lua table*} test {LIBRARIES - test registration with to many arguments} { catch { @@ -586,7 +586,7 @@ start_server {tags {"scripting"}} { } } e set _ $e - } {*wrong number of arguments to redis.register_function*} + } {*wrong number of arguments to redict.register_function*} test {LIBRARIES - test registration with no string name} { catch { @@ -595,7 +595,7 @@ start_server {tags {"scripting"}} { } } e set _ $e - } {*first argument to redis.register_function must be a string*} + } {*first argument to redict.register_function must be a string*} test {LIBRARIES - test registration with wrong name format} { catch { @@ -781,7 +781,7 @@ start_server {tags {"scripting"}} { } } e set _ $e - } {*function_name argument given to redis.register_function must be a string*} + } {*function_name argument given to redict.register_function must be a string*} test {LIBRARIES - named arguments, bad callback type} { catch { @@ -794,7 +794,7 @@ start_server {tags {"scripting"}} { } } e set _ $e - } {*callback argument given to redis.register_function must be a function*} + } {*callback argument given to redict.register_function must be a function*} test {LIBRARIES - named arguments, bad description} { catch { @@ -809,7 +809,7 @@ start_server {tags {"scripting"}} { } } e set _ $e - } {*description argument given to redis.register_function must be a string*} + } {*description argument given to redict.register_function must be a string*} test {LIBRARIES - named arguments, unknown argument} { catch { @@ -825,7 +825,7 @@ start_server {tags {"scripting"}} { } } e set _ $e - } {*unknown argument given to redis.register_function*} + } {*unknown argument given to redict.register_function*} test {LIBRARIES - named arguments, missing function name} { catch { @@ -839,7 +839,7 @@ start_server {tags {"scripting"}} { } } e set _ $e - } {*redis.register_function must get a function name argument*} + } {*redict.register_function must get a function name argument*} test {LIBRARIES - named arguments, missing callback} { catch { @@ -851,7 +851,7 @@ start_server {tags {"scripting"}} { } } e set _ $e - } {*redis.register_function must get a callback argument*} + } {*redict.register_function must get a callback argument*} test {FUNCTION - test function restore with function name collision} { r function flush @@ -1013,7 +1013,7 @@ start_server {tags {"scripting"}} { } }} e set _ $e - } {*flags argument to redis.register_function must be a table representing function flags*} + } {*flags argument to redict.register_function must be a table representing function flags*} test {FUNCTION - wrong flag type} { catch {r function load replace {#!lua name=test