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

22
lua.c
View File

@ -3,7 +3,7 @@
** 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 <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 i;
@ -44,26 +52,24 @@ int main (int argc, char *argv[])
lua_register("argv", lua_getargv);
if (argc < 2)
{
char buffer[250];
while (gets(buffer) != 0)
result = lua_dostring(buffer);
}
manual_input();
else
{
for (i=1; i<argc; i++)
{
if (strcmp(argv[i], "--") == 0)
{
lua_argc = argc-i-1;
lua_argv = argv+i;
break;
}
}
for (i=1; i<argc; i++)
{
if (strcmp(argv[i], "--") == 0)
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
result = lua_dofile (argv[i]);
}