aboutsummaryrefslogtreecommitdiff
path: root/lauxlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-03-04 18:23:39 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1999-03-04 18:23:39 -0300
commit5a8bb00df443dfdb5708689f32c64e90f2557bf8 (patch)
treef0328ef79978ce9bd8ceb63fdef2299b74c87490 /lauxlib.c
parent677188de8aa0c4ed49a3db570f0c9ee7cd641ddc (diff)
downloadlua-5a8bb00df443dfdb5708689f32c64e90f2557bf8.tar.gz
lua-5a8bb00df443dfdb5708689f32c64e90f2557bf8.tar.bz2
lua-5a8bb00df443dfdb5708689f32c64e90f2557bf8.zip
storing chunk "sources" instead of "filenames".
Diffstat (limited to 'lauxlib.c')
-rw-r--r--lauxlib.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/lauxlib.c b/lauxlib.c
index 37931dc6..090ded3c 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.c,v 1.13 1998/09/07 18:59:59 roberto Exp roberto $ 2** $Id: lauxlib.c,v 1.14 1999/02/25 19:13:56 roberto Exp roberto $
3** Auxiliary functions for building Lua libraries 3** Auxiliary functions for building Lua libraries
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -34,7 +34,7 @@ void luaL_argerror (int numarg, char *extramsg) {
34 lua_getobjname(f, &funcname); 34 lua_getobjname(f, &funcname);
35 numarg -= lua_nups(f); 35 numarg -= lua_nups(f);
36 if (funcname == NULL) 36 if (funcname == NULL)
37 funcname = "(unknown)"; 37 funcname = "?";
38 if (extramsg == NULL) 38 if (extramsg == NULL)
39 luaL_verror("bad argument #%d to function `%.50s'", numarg, funcname); 39 luaL_verror("bad argument #%d to function `%.50s'", numarg, funcname);
40 else 40 else
@@ -111,3 +111,18 @@ void luaL_verror (char *fmt, ...)
111 lua_error(buff); 111 lua_error(buff);
112} 112}
113 113
114
115void luaL_chunkid (char *out, char *source, int len) {
116 len -= 13; /* 13 = strlen("string ''...\0") */
117 if (*source == '@')
118 sprintf(out, "file `%.*s'", len, source+1);
119 else if (*source == '(')
120 strcpy(out, "(C code)");
121 else {
122 char *b = strchr(source , '\n'); /* stop string at first new line */
123 int lim = (b && (b-source)<len) ? b-source : len;
124 sprintf(out, "string `%.*s'", lim, source);
125 strcpy(out+lim+(13-5), "...'"); /* 5 = strlen("...'\0") */
126 }
127}
128