"dostring" now stores the prefix of its string, to improve error messages.

This commit is contained in:
Roberto Ierusalimschy 1996-09-11 18:53:02 -03:00
parent f0cc2d5506
commit 5b9fbfa006
1 changed files with 11 additions and 5 deletions

16
inout.c
View File

@ -5,9 +5,10 @@
** Also provides some predefined lua functions. ** Also provides some predefined lua functions.
*/ */
char *rcs_inout="$Id: inout.c,v 2.38 1996/07/12 20:00:26 roberto Exp roberto $"; char *rcs_inout="$Id: inout.c,v 2.39 1996/09/09 14:11:11 roberto Exp roberto $";
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include "lex.h" #include "lex.h"
#include "opcode.h" #include "opcode.h"
@ -79,12 +80,17 @@ void lua_closefile (void)
/* /*
** Function to open a string to be input unit ** Function to open a string to be input unit
*/ */
#define SIZE_PREF 20 /* size of string prefix to appear in error messages */
void lua_openstring (char *s) void lua_openstring (char *s)
{ {
lua_setinput (stringinput); char buff[SIZE_PREF+25];
st = s; lua_setinput(stringinput);
lua_linenumber = 1; st = s;
lua_parsedfile = luaI_createfixedstring("(string)")->str; lua_linenumber = 1;
strcpy(buff, "(dostring) >> ");
strncat(buff, s, SIZE_PREF);
if (strlen(s) > SIZE_PREF) strcat(buff, "...");
lua_parsedfile = luaI_createfixedstring(buff)->str;
} }
/* /*