From 5a8bb00df443dfdb5708689f32c64e90f2557bf8 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 4 Mar 1999 18:23:39 -0300 Subject: storing chunk "sources" instead of "filenames". --- lauxlib.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'lauxlib.c') diff --git a/lauxlib.c b/lauxlib.c index 37931dc6..090ded3c 100644 --- a/lauxlib.c +++ b/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.13 1998/09/07 18:59:59 roberto Exp roberto $ +** $Id: lauxlib.c,v 1.14 1999/02/25 19:13:56 roberto Exp roberto $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -34,7 +34,7 @@ void luaL_argerror (int numarg, char *extramsg) { lua_getobjname(f, &funcname); numarg -= lua_nups(f); if (funcname == NULL) - funcname = "(unknown)"; + funcname = "?"; if (extramsg == NULL) luaL_verror("bad argument #%d to function `%.50s'", numarg, funcname); else @@ -111,3 +111,18 @@ void luaL_verror (char *fmt, ...) lua_error(buff); } + +void luaL_chunkid (char *out, char *source, int len) { + len -= 13; /* 13 = strlen("string ''...\0") */ + if (*source == '@') + sprintf(out, "file `%.*s'", len, source+1); + else if (*source == '(') + strcpy(out, "(C code)"); + else { + char *b = strchr(source , '\n'); /* stop string at first new line */ + int lim = (b && (b-source)