diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1998-06-15 18:34:14 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1998-06-15 18:34:14 -0300 |
commit | d97af0de26cc4eabe5ff9d1b851a6a5110473d1a (patch) | |
tree | ccc2ec1ec4d917c3b75e447eedd5e59bc3e47205 /ldo.c | |
parent | 1917149fdd737752451da2c5f2dfbe1adde72c20 (diff) | |
download | lua-d97af0de26cc4eabe5ff9d1b851a6a5110473d1a.tar.gz lua-d97af0de26cc4eabe5ff9d1b851a6a5110473d1a.tar.bz2 lua-d97af0de26cc4eabe5ff9d1b851a6a5110473d1a.zip |
"lua_dobuffer" gets an extra argument, with the chunk name
Diffstat (limited to 'ldo.c')
-rw-r--r-- | ldo.c | 19 |
1 files changed, 7 insertions, 12 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 1.24 1998/01/29 15:59:35 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 1.25 1998/05/31 22:22:00 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,30 +392,25 @@ int lua_dofile (char *filename) | |||
392 | #define SSIZE_PREF "20" | 392 | #define SSIZE_PREF "20" |
393 | 393 | ||
394 | 394 | ||
395 | int lua_dostring (char *str) | 395 | int lua_dostring (char *str) { |
396 | { | ||
397 | int status; | ||
398 | char name[SIZE_PREF+25]; | 396 | char name[SIZE_PREF+25]; |
399 | char *temp; | 397 | char *temp; |
400 | ZIO z; | 398 | if (str == NULL || *str == ID_CHUNK) return 1; |
401 | if (str == NULL) return 1; | ||
402 | sprintf(name, "(dostring) >> \"%." SSIZE_PREF "s\"", str); | 399 | sprintf(name, "(dostring) >> \"%." SSIZE_PREF "s\"", str); |
403 | temp = strchr(name, '\n'); | 400 | temp = strchr(name, '\n'); |
404 | if (temp) { /* end string after first line */ | 401 | if (temp) { /* end string after first line */ |
405 | *temp = '"'; | 402 | *temp = '"'; |
406 | *(temp+1) = 0; | 403 | *(temp+1) = 0; |
407 | } | 404 | } |
408 | luaZ_sopen(&z, str, name); | 405 | return lua_dobuffer(str, strlen(str), name); |
409 | status = do_main(&z, 0); | ||
410 | return status; | ||
411 | } | 406 | } |
412 | 407 | ||
413 | 408 | ||
414 | int lua_dobuffer (char *buff, int size) { | 409 | int lua_dobuffer (char *buff, int size, char *name) { |
415 | int status; | 410 | int status; |
416 | ZIO z; | 411 | ZIO z; |
417 | luaZ_mopen(&z, buff, size, "(buffer)"); | 412 | luaZ_mopen(&z, buff, size, (name==NULL) ? "(buffer)" : name); |
418 | status = do_main(&z, 1); | 413 | status = do_main(&z, buff[0]==ID_CHUNK); |
419 | return status; | 414 | return status; |
420 | } | 415 | } |
421 | 416 | ||