Showing the changes to src/lua.c (1 of 53 files). Show all
Unified · Split
| @@ -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 | 3 | ** Lua stand-alone interpreter |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -106,13 +106,11 @@ static void laction (int i) { · 100 unmodified lines | ||
| 106 | 106 | |
| 107 | 107 | |
| 108 | 108 | 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') | |
| 111 | 111 | luai_writestringerror("'%s' needs argument\n", badoption); |
| 112 | − } else { | |
| 113 | − luai_writestringerror("%s: ", progname); | |
| 112 | + else | |
| 114 | 113 | luai_writestringerror("unrecognized option '%s'\n", badoption); |
| 115 | − } | |
| 116 | 114 | luai_writestringerror( |
| 117 | 115 | "usage: %s [options] [script [args]]\n" |
| 118 | 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 | |
| 187 | 185 | static 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 | 248 | /* 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) | |
| 252 | 251 | |
| 253 | 252 | static int incomplete (lua_State *L, int status) { |
| 254 | 253 | if (status == LUA_ERRSYNTAX) { |
| 255 | 254 | size_t lmsg; |
| 256 | 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 | 257 | lua_pop(L, 1); |
| 259 | 258 | return 1; |
| 260 | 259 | } |
| @@ -322,7 +321,7 @@ static void dotty (lua_State *L) { · 61 unmodified lines | ||
| 322 | 321 | } |
| 323 | 322 | } |
| 324 | 323 | lua_settop(L, 0); /* clear stack */ |
| 325 | − luai_writestring("\n", 1); | |
| 324 | + luai_writeline(); | |
| 326 | 325 | progname = oldprogname; |
| 327 | 326 | } |
| 328 | 327 | |