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 @@
1/*1/*
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 $
3** Lua stand-alone interpreter3** Lua stand-alone interpreter
4** See Copyright Notice in lua.h4** See Copyright Notice in lua.h
5*/5*/
@@ -106,13 +106,11 @@ static void laction (int i) { · 100 unmodified lines
106 106
107 107
108static void print_usage (const char *badoption) {108static void print_usage (const char *badoption) {
109 if (badoption[1] == 'e' || badoption[1] == 'l') {109 luai_writestringerror("%s: ", progname);
110 luai_writestringerror("%s: ", progname);110 if (badoption[1] == 'e' || badoption[1] == 'l')
111 luai_writestringerror("'%s' needs argument\n", badoption);111 luai_writestringerror("'%s' needs argument\n", badoption);
112 } else {112 else
113 luai_writestringerror("%s: ", progname);
114 luai_writestringerror("unrecognized option '%s'\n", badoption);113 luai_writestringerror("unrecognized option '%s'\n", badoption);
115 }
116 luai_writestringerror(114 luai_writestringerror(
117 "usage: %s [options] [script [args]]\n"115 "usage: %s [options] [script [args]]\n"
118 "Available options are:\n"116 "Available options are:\n"
@@ -185,7 +183,8 @@ static int docall (lua_State *L, int narg, int nres) { · 66 unmodified lines
185 183
186 184
187static void print_version (void) {185static void print_version (void) {
188 printf("%s\n", LUA_COPYRIGHT);186 luai_writestring(LUA_COPYRIGHT, sizeof(LUA_COPYRIGHT));
187 luai_writeline();
189}188}
190 189
191 190
@@ -247,14 +246,14 @@ static const char *get_prompt (lua_State *L, int firstline) { · 55 unmodified lines
247}246}
248 247
249/* mark in error messages for incomplete statements */248/* mark in error messages for incomplete statements */
250#define mark "<eof>"249#define EOFMARK "<eof>"
251#define marklen (sizeof(mark) - 1)250#define marklen (sizeof(EOFMARK)/sizeof(char) - 1)
252 251
253static int incomplete (lua_State *L, int status) {252static int incomplete (lua_State *L, int status) {
254 if (status == LUA_ERRSYNTAX) {253 if (status == LUA_ERRSYNTAX) {
255 size_t lmsg;254 size_t lmsg;
256 const char *msg = lua_tolstring(L, -1, &lmsg);255 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) {
258 lua_pop(L, 1);257 lua_pop(L, 1);
259 return 1;258 return 1;
260 }259 }
@@ -322,7 +321,7 @@ static void dotty (lua_State *L) { · 61 unmodified lines
322 }321 }
323 }322 }
324 lua_settop(L, 0); /* clear stack */323 lua_settop(L, 0); /* clear stack */
325 luai_writestring("\n", 1);324 luai_writeline();
326 progname = oldprogname;325 progname = oldprogname;
327}326}
328 327