From 0b3b6850c90999ebf7217f51ee74184af732285d Mon Sep 17 00:00:00 2001
From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Tue, 12 Sep 2000 15:42:32 -0300
Subject: `back-up' definition for ERRORMESSAGE

---
 lstate.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/lstate.c b/lstate.c
index 44a9fc96..b45e31ce 100644
--- a/lstate.c
+++ b/lstate.c
@@ -1,11 +1,11 @@
 /*
-** $Id: lstate.c,v 1.37 2000/09/11 17:38:42 roberto Exp roberto $
+** $Id: lstate.c,v 1.38 2000/09/11 19:42:57 roberto Exp roberto $
 ** Global State
 ** See Copyright Notice in lua.h
 */
 
 
-#include <stdarg.h>
+#include <stdio.h>
 
 #include "lua.h"
 
@@ -25,6 +25,19 @@ void luaB_opentests (lua_State *L);
 #endif
 
 
+/*
+** built-in implementation for ERRORMESSAGE. In a "correct" environment
+** ERRORMESSAGE should have an external definition, and so this function
+** would not be used.
+*/
+static int errormessage (lua_State *L) {
+  const char *s = lua_tostring(L, 1);
+  if (s == NULL) s = "(no message)";
+  fprintf(stderr, "error: %s\n", s);
+  return 0;
+}
+
+
 lua_State *lua_open (int stacksize) {
   struct lua_longjmp myErrorJmp;
   lua_State *L = luaM_new(NULL, lua_State);
@@ -57,6 +70,7 @@ lua_State *lua_open (int stacksize) {
     luaS_init(L);
     luaX_init(L);
     luaT_init(L);
+    lua_register(L, LUA_ERRORMESSAGE, errormessage);
 #ifdef DEBUG
     luaB_opentests(L);
 #endif
-- 
cgit v1.2.3-55-g6feb