diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-09-11 17:29:27 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-09-11 17:29:27 -0300 |
commit | 8060193702b21a06af3541555db4cd317c733ce9 (patch) | |
tree | d1cfa3a4ac41dc6766188680659c1bd1311e22a8 /lobject.c | |
parent | 2779e81fbbdebf8b7cac97c167ff109bad537c4b (diff) | |
download | lua-8060193702b21a06af3541555db4cd317c733ce9.tar.gz lua-8060193702b21a06af3541555db4cd317c733ce9.tar.bz2 lua-8060193702b21a06af3541555db4cd317c733ce9.zip |
`lauxlib' is now part of the libraries (not used by core Lua)
Diffstat (limited to 'lobject.c')
-rw-r--r-- | lobject.c | 36 |
1 files changed, 35 insertions, 1 deletions
@@ -1,11 +1,14 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.c,v 1.45 2000/08/11 16:17:28 roberto Exp roberto $ | 2 | ** $Id: lobject.c,v 1.46 2000/09/11 17:38:42 roberto Exp roberto $ |
3 | ** Some generic functions over Lua objects | 3 | ** Some generic functions over Lua objects |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #include <ctype.h> | 7 | #include <ctype.h> |
8 | #include <stdarg.h> | ||
9 | #include <stdio.h> | ||
8 | #include <stdlib.h> | 10 | #include <stdlib.h> |
11 | #include <string.h> | ||
9 | 12 | ||
10 | #include "lua.h" | 13 | #include "lua.h" |
11 | 14 | ||
@@ -123,3 +126,34 @@ int luaO_str2d (const char *s, Number *result) { /* LUA_NUMBER */ | |||
123 | return 1; | 126 | return 1; |
124 | } | 127 | } |
125 | 128 | ||
129 | |||
130 | void luaO_verror (lua_State *L, const char *fmt, ...) { | ||
131 | char buff[500]; | ||
132 | va_list argp; | ||
133 | va_start(argp, fmt); | ||
134 | vsprintf(buff, fmt, argp); | ||
135 | va_end(argp); | ||
136 | lua_error(L, buff); | ||
137 | } | ||
138 | |||
139 | |||
140 | #define EXTRALEN sizeof("string \"...\"0") | ||
141 | |||
142 | void luaO_chunkid (char *out, const char *source, int len) { | ||
143 | if (*source == '(') { | ||
144 | strncpy(out, source+1, len-1); /* remove first char */ | ||
145 | out[len-1] = '\0'; /* make sure `out' has an end */ | ||
146 | out[strlen(out)-1] = '\0'; /* remove last char */ | ||
147 | } | ||
148 | else { | ||
149 | len -= EXTRALEN; | ||
150 | if (*source == '@') | ||
151 | sprintf(out, "file `%.*s'", len, source+1); | ||
152 | else { | ||
153 | const char *b = strchr(source , '\n'); /* stop at first new line */ | ||
154 | int lim = (b && (b-source)<len) ? b-source : len; | ||
155 | sprintf(out, "string \"%.*s\"", lim, source); | ||
156 | strcpy(out+lim+(EXTRALEN-sizeof("...\"0")), "...\""); | ||
157 | } | ||
158 | } | ||
159 | } | ||