commit de65253f2d927603b6becf87b4d177aa96a54fc2
parent 12b45c2df21beac17d49a92a4e098cb212238c1a
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Mon, 20 Dec 1999 11:02:58 -0200
new way to handle _PROMPT
Diffstat:
M | lua.c | | | 14 | ++++++++++---- |
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/lua.c b/lua.c
@@ -1,5 +1,5 @@
/*
-** $Id: lua.c,v 1.27 1999/11/22 13:12:07 roberto Exp roberto $
+** $Id: lua.c,v 1.28 1999/12/06 11:41:28 roberto Exp roberto $
** Lua stand-alone interpreter
** See Copyright Notice in lua.h
*/
@@ -15,6 +15,10 @@
#include "lualib.h"
+#ifndef PROMPT
+#define PROMPT "> "
+#endif
+
#ifdef _POSIX_SOURCE
#include <unistd.h>
#else
@@ -119,8 +123,11 @@ static void manual_input (int prompt) {
char buffer[BUFSIZ];
int i = 0;
lua_beginblock();
- if (prompt)
- printf("%s", lua_getstring(lua_getglobal("_PROMPT")));
+ if (prompt) {
+ const char *s = lua_getstring(lua_getglobal("_PROMPT"));
+ if (!s) s = PROMPT;
+ printf("%s", s);
+ }
for(;;) {
int c = getchar();
if (c == EOF) {
@@ -149,7 +156,6 @@ static void manual_input (int prompt) {
int main (int argc, char *argv[]) {
int i;
lua_state = lua_newstate("stack", 1024, "builtin", 1, NULL);
- lua_pushstring("> "); lua_setglobal("_PROMPT");
lua_userinit();
getargs(argc, argv);
if (argc < 2) { /* no arguments? */