fix(lua): fix architecture-dependent behavior in usercmd "reg" (#20384)

I don't think using an integer as a NUL-terminated string can work on
big-endian systems, at least.

This is also not tested. Add a test.

Also fix a mistake in the docs of nvim_parse_cmd.
This commit is contained in:
zeertzjq
2022-09-28 18:27:59 +08:00
committed by GitHub
parent eb4844b5ed
commit 35e2c4a2ed
4 changed files with 42 additions and 6 deletions

View File

@@ -2036,7 +2036,8 @@ int nlua_do_ucmd(ucmd_T *cmd, exarg_T *eap, bool preview)
}
lua_setfield(lstate, -2, "fargs");
lua_pushstring(lstate, (const char *)&eap->regname);
char reg[2] = { (char)eap->regname, NUL };
lua_pushstring(lstate, reg);
lua_setfield(lstate, -2, "reg");
lua_pushinteger(lstate, eap->addr_count);