MCPcopy Create free account
hub / github.com/apache/kvrocks / RedisProtocolToLuaTypeVerbatimString

Function RedisProtocolToLuaTypeVerbatimString

src/storage/scripting.cc:1241–1260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1239}
1240
1241const char *RedisProtocolToLuaTypeVerbatimString(lua_State *lua, const char *reply) {
1242 const char *p = strchr(reply + 1, '\r');
1243 int64_t bulklen = ParseInt<int64_t>(std::string(reply + 1, p - reply - 1), 10).ValueOr(0);
1244 p += 2; // skip \r\n
1245
1246 lua_newtable(lua);
1247 lua_pushstring(lua, "verbatim_string");
1248
1249 lua_newtable(lua);
1250 lua_pushstring(lua, "string");
1251 lua_pushlstring(lua, p + 4, bulklen - 4);
1252 lua_settable(lua, -3);
1253
1254 lua_pushstring(lua, "format");
1255 lua_pushlstring(lua, p, 3);
1256 lua_settable(lua, -3);
1257
1258 lua_settable(lua, -3);
1259 return p + bulklen + 2;
1260}
1261
1262/* This function is used in order to push an error on the Lua stack in the
1263 * format used by redis.pcall to return errors, which is a lua table

Callers 1

RedisProtocolToLuaTypeFunction · 0.85

Calls 1

ValueOrMethod · 0.80

Tested by

no test coverage detected