diff options
Diffstat (limited to 'lauxlib.c')
| -rw-r--r-- | lauxlib.c | 19 |
1 files changed, 17 insertions, 2 deletions
| @@ -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 | |||
| 115 | void 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 | |||
