aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-09-11 18:53:02 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1996-09-11 18:53:02 -0300
commit5b9fbfa0066e86a8397c7f07a9596cb94d14e51b (patch)
tree8f0ed518ff37b29cfb90af2a65d7e39e88623def
parentf0cc2d55067d32c1232d9483721254360d4c3bae (diff)
downloadlua-5b9fbfa0066e86a8397c7f07a9596cb94d14e51b.tar.gz
lua-5b9fbfa0066e86a8397c7f07a9596cb94d14e51b.tar.bz2
lua-5b9fbfa0066e86a8397c7f07a9596cb94d14e51b.zip
"dostring" now stores the prefix of its string, to improve error messages.
-rw-r--r--inout.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/inout.c b/inout.c
index 237dd574..c77ed649 100644
--- a/inout.c
+++ b/inout.c
@@ -5,9 +5,10 @@
5** Also provides some predefined lua functions. 5** Also provides some predefined lua functions.
6*/ 6*/
7 7
8char *rcs_inout="$Id: inout.c,v 2.38 1996/07/12 20:00:26 roberto Exp roberto $"; 8char *rcs_inout="$Id: inout.c,v 2.39 1996/09/09 14:11:11 roberto Exp roberto $";
9 9
10#include <stdio.h> 10#include <stdio.h>
11#include <string.h>
11 12
12#include "lex.h" 13#include "lex.h"
13#include "opcode.h" 14#include "opcode.h"
@@ -79,12 +80,17 @@ void lua_closefile (void)
79/* 80/*
80** Function to open a string to be input unit 81** Function to open a string to be input unit
81*/ 82*/
83#define SIZE_PREF 20 /* size of string prefix to appear in error messages */
82void lua_openstring (char *s) 84void lua_openstring (char *s)
83{ 85{
84 lua_setinput (stringinput); 86 char buff[SIZE_PREF+25];
85 st = s; 87 lua_setinput(stringinput);
86 lua_linenumber = 1; 88 st = s;
87 lua_parsedfile = luaI_createfixedstring("(string)")->str; 89 lua_linenumber = 1;
90 strcpy(buff, "(dostring) >> ");
91 strncat(buff, s, SIZE_PREF);
92 if (strlen(s) > SIZE_PREF) strcat(buff, "...");
93 lua_parsedfile = luaI_createfixedstring(buff)->str;
88} 94}
89 95
90/* 96/*