History

Lua 5.2.0-beta-rc1

Lua Team committed 15 years ago

Commit 30837cc1 parent 9bce00553 files · +2418 −1456Browse files

Showing the changes to src/lua.c (1 of 53 files). Show all

Unified · Split

src/lua.c+10−11
@@ -1,5 +1,5 @@
11 /*
2−** $Id: lua.c,v 1.194 2010/10/25 19:01:37 roberto Exp $
2+** $Id: lua.c,v 1.199 2011/05/26 16:09:40 roberto Exp $
33 ** Lua stand-alone interpreter
44 ** See Copyright Notice in lua.h
55 */
@@ -106,13 +106,11 @@ static void laction (int i) { · 100 unmodified lines
106106
107107
108108 static void print_usage (const char *badoption) {
109− if (badoption[1] == 'e' || badoption[1] == 'l') {
110− luai_writestringerror("%s: ", progname);
109+ luai_writestringerror("%s: ", progname);
110+ if (badoption[1] == 'e' || badoption[1] == 'l')
111111 luai_writestringerror("'%s' needs argument\n", badoption);
112− } else {
113− luai_writestringerror("%s: ", progname);
112+ else
114113 luai_writestringerror("unrecognized option '%s'\n", badoption);
115− }
116114 luai_writestringerror(
117115 "usage: %s [options] [script [args]]\n"
118116 "Available options are:\n"
@@ -185,7 +183,8 @@ static int docall (lua_State *L, int narg, int nres) { · 66 unmodified lines
185183
186184
187185 static void print_version (void) {
188− printf("%s\n", LUA_COPYRIGHT);
186+ luai_writestring(LUA_COPYRIGHT, sizeof(LUA_COPYRIGHT));
187+ luai_writeline();
189188 }
190189
191190
@@ -247,14 +246,14 @@ static const char *get_prompt (lua_State *L, int firstline) { · 55 unmodified lines
247246 }
248247
249248 /* mark in error messages for incomplete statements */
250−#define mark "<eof>"
251−#define marklen (sizeof(mark) - 1)
249+#define EOFMARK "<eof>"
250+#define marklen (sizeof(EOFMARK)/sizeof(char) - 1)
252251
253252 static int incomplete (lua_State *L, int status) {
254253 if (status == LUA_ERRSYNTAX) {
255254 size_t lmsg;
256255 const char *msg = lua_tolstring(L, -1, &lmsg);
257− if (lmsg >= marklen && strcmp(msg + lmsg - marklen, mark) == 0) {
256+ if (lmsg >= marklen && strcmp(msg + lmsg - marklen, EOFMARK) == 0) {
258257 lua_pop(L, 1);
259258 return 1;
260259 }
@@ -322,7 +321,7 @@ static void dotty (lua_State *L) { · 61 unmodified lines
322321 }
323322 }
324323 lua_settop(L, 0); /* clear stack */
325− luai_writestring("\n", 1);
324+ luai_writeline();
326325 progname = oldprogname;
327326 }
328327