lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

On Wed, Aug 20, 2008 at 2:07 AM, E. Wing <ewmailing@gmail.com> wrote:
> I want to get the filename (with absolute path) and line number
> reported from luaL_loadfile. Is there a reliable way to get at this
> data?

You have the (relative) file name/path; you passed it to
luaL_loadfile. Parsing the error message is your best option (afaik):

if (luaL_loadfile(L, "filepath") == LUA_ERRSYNTAX)
{
  lua_getfield(L, -1, "match");
  lua_pushvalue(L, -2);
  lua_pushliteral(L, ":(%d+):");
  lua_call(L, 2, 1);
  // Do something with the line number...
}

Cheers,

-- 
-Patrick Donnelly

"One of the lessons of history is that nothing is often a good thing
to do and always a clever thing to say."

-Will Durant