aboutsummaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-06-19 15:47:06 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-06-19 15:47:06 -0300
commitdf0df08bc537d4f2c13446fee20f8a4335f9d9d2 (patch)
tree9ddf500c4019037c2a2b80f9d94709c28258f30a /ldo.c
parent9618aaf07d0d82ccbac91db22cb42451ec17d7ed (diff)
downloadlua-df0df08bc537d4f2c13446fee20f8a4335f9d9d2.tar.gz
lua-df0df08bc537d4f2c13446fee20f8a4335f9d9d2.tar.bz2
lua-df0df08bc537d4f2c13446fee20f8a4335f9d9d2.zip
"dostring" accepts chunk name.
Diffstat (limited to 'ldo.c')
-rw-r--r--ldo.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/ldo.c b/ldo.c
index fe644c7b..116d6eb0 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 1.25 1998/05/31 22:22:00 roberto Exp roberto $ 2** $Id: ldo.c,v 1.26 1998/06/15 21:34:14 roberto Exp roberto $
3** Stack and Call structure of Lua 3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -392,24 +392,35 @@ int lua_dofile (char *filename)
392#define SSIZE_PREF "20" 392#define SSIZE_PREF "20"
393 393
394 394
395int lua_dostring (char *str) { 395static void build_name (char *str, char *name) {
396 char name[SIZE_PREF+25]; 396 if (str == NULL || *str == ID_CHUNK)
397 char *temp; 397 strcpy(name, "(buffer)");
398 if (str == NULL || *str == ID_CHUNK) return 1; 398 else {
399 sprintf(name, "(dostring) >> \"%." SSIZE_PREF "s\"", str); 399 char *temp;
400 temp = strchr(name, '\n'); 400 sprintf(name, "(dostring) >> \"%." SSIZE_PREF "s\"", str);
401 if (temp) { /* end string after first line */ 401 temp = strchr(name, '\n');
402 *temp = '"'; 402 if (temp) { /* end string after first line */
403 *(temp+1) = 0; 403 *temp = '"';
404 *(temp+1) = 0;
405 }
404 } 406 }
405 return lua_dobuffer(str, strlen(str), name); 407}
408
409
410int lua_dostring (char *str) {
411 return lua_dobuffer(str, strlen(str), NULL);
406} 412}
407 413
408 414
409int lua_dobuffer (char *buff, int size, char *name) { 415int lua_dobuffer (char *buff, int size, char *name) {
410 int status; 416 char newname[SIZE_PREF+25];
411 ZIO z; 417 ZIO z;
412 luaZ_mopen(&z, buff, size, (name==NULL) ? "(buffer)" : name); 418 int status;
419 if (name==NULL) {
420 build_name(buff, newname);
421 name = newname;
422 }
423 luaZ_mopen(&z, buff, size, name);
413 status = do_main(&z, buff[0]==ID_CHUNK); 424 status = do_main(&z, buff[0]==ID_CHUNK);
414 return status; 425 return status;
415} 426}