new command line options: -v to print Copyright message, and

- to read stdin.
This commit is contained in:
Roberto Ierusalimschy 1995-10-06 11:11:40 -03:00
parent 233f0b0cc7
commit 79ce619876
1 changed files with 14 additions and 8 deletions

22
lua.c
View File

@ -3,7 +3,7 @@
** Linguagem para Usuarios de Aplicacao ** Linguagem para Usuarios de Aplicacao
*/ */
char *rcs_lua="$Id: lua.c,v 1.3 1994/12/14 19:58:20 celes Exp $"; char *rcs_lua="$Id: lua.c,v 1.4 1995/02/07 16:04:15 lhf Exp roberto $";
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -33,6 +33,14 @@ static void lua_getargv (void)
} }
static void manual_input (void)
{
char buffer[250];
while (gets(buffer) != 0)
lua_dostring(buffer);
}
int main (int argc, char *argv[]) int main (int argc, char *argv[])
{ {
int i; int i;
@ -44,26 +52,24 @@ int main (int argc, char *argv[])
lua_register("argv", lua_getargv); lua_register("argv", lua_getargv);
if (argc < 2) if (argc < 2)
{ manual_input();
char buffer[250];
while (gets(buffer) != 0)
result = lua_dostring(buffer);
}
else else
{ {
for (i=1; i<argc; i++) for (i=1; i<argc; i++)
{
if (strcmp(argv[i], "--") == 0) if (strcmp(argv[i], "--") == 0)
{ {
lua_argc = argc-i-1; lua_argc = argc-i-1;
lua_argv = argv+i; lua_argv = argv+i;
break; break;
} }
}
for (i=1; i<argc; i++) for (i=1; i<argc; i++)
{ {
if (strcmp(argv[i], "--") == 0) if (strcmp(argv[i], "--") == 0)
break; break;
else if (strcmp(argv[i], "-") == 0)
manual_input();
else if (strcmp(argv[i], "-v") == 0)
printf("%s %s\n\n", LUA_VERSION, LUA_COPYRIGHT);
else else
result = lua_dofile (argv[i]); result = lua_dofile (argv[i]);
} }