|
@ -3,7 +3,7 @@ |
|
|
** Input/output library to LUA |
|
|
** Input/output library to LUA |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
char *rcs_iolib="$Id: $"; |
|
|
char *rcs_iolib="$Id: iolib.c,v 1.1 1993/12/17 18:41:19 celes Exp roberto $"; |
|
|
|
|
|
|
|
|
#include <stdlib.h> |
|
|
#include <stdlib.h> |
|
|
#include <string.h> |
|
|
#include <string.h> |
|
@ -272,22 +272,25 @@ static void io_read (void) |
|
|
case 'i': |
|
|
case 'i': |
|
|
{ |
|
|
{ |
|
|
long int l; |
|
|
long int l; |
|
|
fscanf (in, "%ld", &l); |
|
|
if (fscanf (in, "%ld", &l) == EOF) |
|
|
lua_pushnumber(l); |
|
|
lua_pushnil(); |
|
|
|
|
|
else lua_pushnumber(l); |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
case 'f': case 'g': case 'e': |
|
|
case 'f': case 'g': case 'e': |
|
|
{ |
|
|
{ |
|
|
float f; |
|
|
float f; |
|
|
fscanf (in, "%f", &f); |
|
|
if (fscanf (in, "%f", &f) == EOF) |
|
|
lua_pushnumber(f); |
|
|
lua_pushnil(); |
|
|
|
|
|
else lua_pushnumber(f); |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
default: |
|
|
default: |
|
|
{ |
|
|
{ |
|
|
char s[256]; |
|
|
char s[256]; |
|
|
fscanf (in, "%s", s); |
|
|
if (fscanf (in, "%s", s) == EOF) |
|
|
lua_pushstring(s); |
|
|
lua_pushnil(); |
|
|
|
|
|
else lua_pushstring(s); |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
@ -406,8 +409,8 @@ static void io_write (void) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/*
|
|
|
/*
|
|
|
** Execute a executable program using "sustem". |
|
|
** Execute a executable program using "system". |
|
|
** On error put 0 on stack, otherwise put 1. |
|
|
** Return the result of execution. |
|
|
*/ |
|
|
*/ |
|
|
void io_execute (void) |
|
|
void io_execute (void) |
|
|
{ |
|
|
{ |
|
@ -419,8 +422,8 @@ void io_execute (void) |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
system(lua_getstring(o)); |
|
|
int res = system(lua_getstring(o)); |
|
|
lua_pushnumber (1); |
|
|
lua_pushnumber (res); |
|
|
} |
|
|
} |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|