From 8060193702b21a06af3541555db4cd317c733ce9 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 11 Sep 2000 17:29:27 -0300 Subject: `lauxlib' is now part of the libraries (not used by core Lua) --- lobject.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'lobject.c') diff --git a/lobject.c b/lobject.c index 7f3d71fc..c4f45d8b 100644 --- a/lobject.c +++ b/lobject.c @@ -1,11 +1,14 @@ /* -** $Id: lobject.c,v 1.45 2000/08/11 16:17:28 roberto Exp roberto $ +** $Id: lobject.c,v 1.46 2000/09/11 17:38:42 roberto Exp roberto $ ** Some generic functions over Lua objects ** See Copyright Notice in lua.h */ #include +#include +#include #include +#include #include "lua.h" @@ -123,3 +126,34 @@ int luaO_str2d (const char *s, Number *result) { /* LUA_NUMBER */ return 1; } + +void luaO_verror (lua_State *L, const char *fmt, ...) { + char buff[500]; + va_list argp; + va_start(argp, fmt); + vsprintf(buff, fmt, argp); + va_end(argp); + lua_error(L, buff); +} + + +#define EXTRALEN sizeof("string \"...\"0") + +void luaO_chunkid (char *out, const char *source, int len) { + if (*source == '(') { + strncpy(out, source+1, len-1); /* remove first char */ + out[len-1] = '\0'; /* make sure `out' has an end */ + out[strlen(out)-1] = '\0'; /* remove last char */ + } + else { + len -= EXTRALEN; + if (*source == '@') + sprintf(out, "file `%.*s'", len, source+1); + else { + const char *b = strchr(source , '\n'); /* stop at first new line */ + int lim = (b && (b-source)