浏览代码

small changes to allow redefinition of some buffer sizes.

Roberto Ierusalimschy 25 年之前
父节点
当前提交
e3ea307434
共有 3 个文件被更改,包括 15 次插入7 次删除
  1. 1 3
      ldo.c
  2. 7 1
      llimits.h
  3. 7 3
      lua.c

+ 1 - 3
ldo.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ldo.c,v 1.77 2000/05/30 19:00:31 roberto Exp roberto $
+** $Id: ldo.c,v 1.78 2000/06/12 13:52:05 roberto Exp roberto $
 ** Stack and Call structure of Lua
 ** See Copyright Notice in lua.h
 */
@@ -330,8 +330,6 @@ static int do_main (lua_State *L, ZIO *z, int bin) {
 }
 
 
-#define	MAXFILENAME	260	/* maximum part of a file name kept */
-
 int lua_dofile (lua_State *L, const char *filename) {
   ZIO z;
   int status;

+ 7 - 1
llimits.h

@@ -1,5 +1,5 @@
 /*
-** $Id: llimits.h,v 1.8 2000/05/26 14:04:04 roberto Exp roberto $
+** $Id: llimits.h,v 1.9 2000/06/06 16:27:11 roberto Exp roberto $
 ** Limits, basic types, and some other "instalation-dependent" definitions
 ** See Copyright Notice in lua.h
 */
@@ -185,4 +185,10 @@ typedef unsigned long Instruction;
 #endif
 
 
+/* maximum part of a file name kept for error messages */
+#ifndef MAXFILENAME
+#define	MAXFILENAME	260
+#endif
+
+
 #endif

+ 7 - 3
lua.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lua.c,v 1.38 2000/05/10 17:00:21 roberto Exp roberto $
+** $Id: lua.c,v 1.39 2000/06/12 13:52:05 roberto Exp roberto $
 ** Lua stand-alone interpreter
 ** See Copyright Notice in lua.h
 */
@@ -129,12 +129,16 @@ static void file_input (const char *argv) {
   }
 }
 
+/* maximum length of an input string */
+#ifndef MAXINPUT
+#define MAXINPUT	BUFSIZ
+#endif
 
 static void manual_input (int version, int prompt) {
   int cont = 1;
   if (version) print_version();
   while (cont) {
-    char buffer[BUFSIZ];
+    char buffer[MAXINPUT];
     int i = 0;
     lua_beginblock();
     if (prompt) {
@@ -153,7 +157,7 @@ static void manual_input (int version, int prompt) {
           buffer[i-1] = '\n';
         else break;
       }
-      else if (i >= BUFSIZ-1) {
+      else if (i >= MAXINPUT-1) {
         fprintf(stderr, "lua: input line too long\n");
         break;
       }