diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-12-30 16:29:46 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-12-30 16:29:46 -0200 |
commit | aee07c65991621497c005f47e1b7284851ae9fb9 (patch) | |
tree | 08194fe42b446d5740682b81d5f9a8ecd526f769 | |
parent | bcdbdaccc37aacdb8305f5012c2963e4cb343005 (diff) | |
download | lua-aee07c65991621497c005f47e1b7284851ae9fb9.tar.gz lua-aee07c65991621497c005f47e1b7284851ae9fb9.tar.bz2 lua-aee07c65991621497c005f47e1b7284851ae9fb9.zip |
details
-rw-r--r-- | lua.c | 41 | ||||
-rw-r--r-- | lua.h | 6 |
2 files changed, 27 insertions, 20 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.c,v 1.29 1999/12/20 13:03:20 roberto Exp roberto $ | 2 | ** $Id: lua.c,v 1.30 1999/12/21 17:34:23 roberto Exp roberto $ |
3 | ** Lua stand-alone interpreter | 3 | ** Lua stand-alone interpreter |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -67,16 +67,22 @@ static int ldo (int (*f)(lua_State *L, const char *), const char *name) { | |||
67 | 67 | ||
68 | static void print_message (void) { | 68 | static void print_message (void) { |
69 | fprintf(stderr, | 69 | fprintf(stderr, |
70 | "Lua: command line options:\n" | 70 | "usage: lua [options]. Available options are:\n" |
71 | " -v print version information\n" | 71 | " - execute stdin as a file\n" |
72 | " -d turn debug on\n" | 72 | " -d turn debug on\n" |
73 | " -e stat dostring `stat'\n" | 73 | " -e stat execute string `stat'\n" |
74 | " -q interactive mode without prompt\n" | 74 | " -f name execute file `name' with remaining arguments in table `arg'\n" |
75 | " -i interactive mode with prompt\n" | 75 | " -i enter interactive mode with prompt\n" |
76 | " - execute stdin as a file\n" | 76 | " -q enter interactive mode without prompt\n" |
77 | " -f name dofile `name' with following arguments in table `arg'\n" | 77 | " -v print version information\n" |
78 | " a=b set global `a' with string `b'\n" | 78 | " a=b set global `a' to string `b'\n" |
79 | " name dofile `name'\n\n"); | 79 | " name execute file `name'\n" |
80 | ); | ||
81 | } | ||
82 | |||
83 | |||
84 | static void print_version (void) { | ||
85 | printf("%s %s\n", LUA_VERSION, LUA_COPYRIGHT); | ||
80 | } | 86 | } |
81 | 87 | ||
82 | 88 | ||
@@ -166,7 +172,7 @@ int main (int argc, char *argv[]) { | |||
166 | lua_userinit(); | 172 | lua_userinit(); |
167 | if (argc < 2) { /* no arguments? */ | 173 | if (argc < 2) { /* no arguments? */ |
168 | if (isatty(0)) { | 174 | if (isatty(0)) { |
169 | printf("%s %s\n", LUA_VERSION, LUA_COPYRIGHT); | 175 | print_version(); |
170 | manual_input(1); | 176 | manual_input(1); |
171 | } | 177 | } |
172 | else | 178 | else |
@@ -186,10 +192,13 @@ int main (int argc, char *argv[]) { | |||
186 | break; | 192 | break; |
187 | case 'd': | 193 | case 'd': |
188 | lua_setdebug(lua_state, 1); | 194 | lua_setdebug(lua_state, 1); |
195 | if (i==argc-1) { /* last argument? */ | ||
196 | print_version(); | ||
197 | manual_input(1); | ||
198 | } | ||
189 | break; | 199 | break; |
190 | case 'v': | 200 | case 'v': |
191 | printf("%s %s\n(written by %s)\n", | 201 | print_version(); |
192 | LUA_VERSION, LUA_COPYRIGHT, LUA_AUTHORS); | ||
193 | break; | 202 | break; |
194 | case 'e': | 203 | case 'e': |
195 | i++; | 204 | i++; |
@@ -210,9 +219,7 @@ int main (int argc, char *argv[]) { | |||
210 | } | 219 | } |
211 | getargs(argc-i, argv+i); /* collect following arguments */ | 220 | getargs(argc-i, argv+i); /* collect following arguments */ |
212 | file_input(argv, i); | 221 | file_input(argv, i); |
213 | return 0; /* stop running arguments */ | 222 | i = argc; /* stop running arguments */ |
214 | case '-': | ||
215 | i = argc; /* end loop */ | ||
216 | break; | 223 | break; |
217 | default: | 224 | default: |
218 | print_message(); | 225 | print_message(); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.h,v 1.42 1999/12/02 16:24:45 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.43 1999/12/06 11:41:28 roberto Exp roberto $ |
3 | ** Lua - An Extensible Extension Language | 3 | ** Lua - An Extensible Extension Language |
4 | ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil | 4 | ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil |
5 | ** e-mail: lua@tecgraf.puc-rio.br | 5 | ** e-mail: lua@tecgraf.puc-rio.br |
@@ -12,7 +12,7 @@ | |||
12 | #define lua_h | 12 | #define lua_h |
13 | 13 | ||
14 | #define LUA_VERSION "Lua 3.x" | 14 | #define LUA_VERSION "Lua 3.x" |
15 | #define LUA_COPYRIGHT "Copyright (C) 1994-1999 TeCGraf, PUC-Rio" | 15 | #define LUA_COPYRIGHT "Copyright (C) 1994-2000 TeCGraf, PUC-Rio" |
16 | #define LUA_AUTHORS "W. Celes, R. Ierusalimschy & L. H. de Figueiredo" | 16 | #define LUA_AUTHORS "W. Celes, R. Ierusalimschy & L. H. de Figueiredo" |
17 | 17 | ||
18 | 18 | ||
@@ -221,7 +221,7 @@ extern lua_State *lua_state; | |||
221 | 221 | ||
222 | 222 | ||
223 | /****************************************************************************** | 223 | /****************************************************************************** |
224 | * Copyright (c) 1994-1999 TeCGraf, PUC-Rio. All rights reserved. | 224 | * Copyright (C) 1994-2000 TeCGraf, PUC-Rio. All rights reserved. |
225 | * | 225 | * |
226 | * Permission is hereby granted, without written agreement and without license | 226 | * Permission is hereby granted, without written agreement and without license |
227 | * or royalty fees, to use, copy, modify, and distribute this software and its | 227 | * or royalty fees, to use, copy, modify, and distribute this software and its |