aboutsummaryrefslogtreecommitdiff
path: root/liolib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-07-12 15:11:58 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-07-12 15:11:58 -0300
commitae1cf64348ca7bcb6d3abb19a0b97918e343914c (patch)
tree23bd25ec0cc4d29ad62a64fad039495fbbee8bb5 /liolib.c
parenta264fd089e1814bc13d6de924b928959af2e38d9 (diff)
downloadlua-ae1cf64348ca7bcb6d3abb19a0b97918e343914c.tar.gz
lua-ae1cf64348ca7bcb6d3abb19a0b97918e343914c.tar.bz2
lua-ae1cf64348ca7bcb6d3abb19a0b97918e343914c.zip
better names for type-related functions
Diffstat (limited to 'liolib.c')
-rw-r--r--liolib.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/liolib.c b/liolib.c
index b0cb6381..81d3e05b 100644
--- a/liolib.c
+++ b/liolib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: liolib.c,v 1.117 2001/06/28 14:45:44 roberto Exp roberto $ 2** $Id: liolib.c,v 1.118 2001/07/12 14:59:14 roberto Exp roberto $
3** Standard I/O (and system) library 3** Standard I/O (and system) library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -77,14 +77,14 @@ static int pushresult (lua_State *L, int i) {
77*/ 77*/
78 78
79 79
80#define checkfile(L,f) (strcmp(lua_xtypename(L,(f)), FILEHANDLE) == 0) 80#define checkfile(L,f) (strcmp(lua_type(L,(f)), FILEHANDLE) == 0)
81 81
82 82
83static FILE *getopthandle (lua_State *L, int inout) { 83static FILE *getopthandle (lua_State *L, int inout) {
84 FILE *p = (FILE *)lua_touserdata(L, 1); 84 FILE *p = (FILE *)lua_touserdata(L, 1);
85 if (p != NULL) { /* is it a userdata ? */ 85 if (p != NULL) { /* is it a userdata ? */
86 if (!checkfile(L, 1)) { /* not a valid file handle? */ 86 if (!checkfile(L, 1)) { /* not a valid file handle? */
87 if (strcmp(lua_xtypename(L, 1), CLOSEDFILEHANDLE) == 0) 87 if (strcmp(lua_type(L, 1), CLOSEDFILEHANDLE) == 0)
88 luaL_argerror(L, 1, l_s("file is closed")); 88 luaL_argerror(L, 1, l_s("file is closed"));
89 else 89 else
90 luaL_argerror(L, 1, l_s("(invalid value)")); 90 luaL_argerror(L, 1, l_s("(invalid value)"));
@@ -310,7 +310,7 @@ static int io_read (lua_State *L) {
310 luaL_checkstack(L, nargs+LUA_MINSTACK, l_s("too many arguments")); 310 luaL_checkstack(L, nargs+LUA_MINSTACK, l_s("too many arguments"));
311 success = 1; 311 success = 1;
312 for (n = 1; n<=nargs && success; n++) { 312 for (n = 1; n<=nargs && success; n++) {
313 if (lua_type(L, n) == LUA_TNUMBER) { 313 if (lua_rawtag(L, n) == LUA_TNUMBER) {
314 size_t l = (size_t)lua_tonumber(L, n); 314 size_t l = (size_t)lua_tonumber(L, n);
315 success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l); 315 success = (l == 0) ? test_eof(L, f) : read_chars(L, f, l);
316 } 316 }
@@ -362,7 +362,7 @@ static int io_write (lua_State *L) {
362 int arg; 362 int arg;
363 int status = 1; 363 int status = 1;
364 for (arg=1; arg<=nargs; arg++) { 364 for (arg=1; arg<=nargs; arg++) {
365 if (lua_type(L, arg) == LUA_TNUMBER) { 365 if (lua_rawtag(L, arg) == LUA_TNUMBER) {
366 /* optimization: could be done exactly as for strings */ 366 /* optimization: could be done exactly as for strings */
367 status = status && 367 status = status &&
368 fprintf(f, l_s(LUA_NUMBER_FMT), lua_tonumber(L, arg)) > 0; 368 fprintf(f, l_s(LUA_NUMBER_FMT), lua_tonumber(L, arg)) > 0;
@@ -686,8 +686,8 @@ static const luaL_reg iolib[] = {
686 686
687 687
688LUALIB_API int lua_iolibopen (lua_State *L) { 688LUALIB_API int lua_iolibopen (lua_State *L) {
689 int iotag = lua_newxtype(L, FILEHANDLE, LUA_TUSERDATA); 689 int iotag = lua_newtype(L, FILEHANDLE, LUA_TUSERDATA);
690 lua_newxtype(L, CLOSEDFILEHANDLE, LUA_TUSERDATA); 690 lua_newtype(L, CLOSEDFILEHANDLE, LUA_TUSERDATA);
691 luaL_openl(L, iolib); 691 luaL_openl(L, iolib);
692 /* predefined file handles */ 692 /* predefined file handles */
693 newfilewithname(L, stdin, basicfiles[INFILE]); 693 newfilewithname(L, stdin, basicfiles[INFILE]);