What is the "*all* format in lua file:read() means?
lua
Solution
in the function read from liolib.c only the first two ('*' and 'a') characters are checked, the rest of the string is ignored:
// ...
const char *p = lua_tostring(L, n);
luaL_argcheck(L, p && p[0] == '*', n, "invalid option");
switch (p[1]) {
case 'n': /* number */
success = read_number(L, f);
break;
case 'l': /* line */
success = read_line(L, f);
break;
case 'a': /* file */
read_chars(L, f, ~((size_t)0)); /* read MAX_SIZE_T chars */
success = 1; /* always success */
break;
default:
return luaL_argerror(L, n, "invalid format");
//...
Problem
I maintain some old code written in LUA, there are some snippet I could not understand, ``` local f = io.open("someFile.lua", "r"); local szFileContent = "return {};"; if f then szFileContent = f:read("*all"); f:close(); end ``` The format used in `read` function is something weird, I see the format *a, and *l in lua51 manual https://www.lua.org/manual/5.1/manual.html#pdf-file:read, but not the *all format