diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1994-12-16 13:53:57 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1994-12-16 13:53:57 -0200 |
| commit | fad57bfa008523c3568b613989a6a3f87f3cb83b (patch) | |
| tree | ca47286ada599e45f4445e16d6a410833d4735e8 /iolib.c | |
| parent | 891cab8a31ec73dddb5aa896abedbac53b4c16f8 (diff) | |
| download | lua-fad57bfa008523c3568b613989a6a3f87f3cb83b.tar.gz lua-fad57bfa008523c3568b613989a6a3f87f3cb83b.tar.bz2 lua-fad57bfa008523c3568b613989a6a3f87f3cb83b.zip | |
new constant LUA_NOOBJECT.
'lua_error' never returns
Diffstat (limited to 'iolib.c')
| -rw-r--r-- | iolib.c | 18 |
1 files changed, 9 insertions, 9 deletions
| @@ -3,7 +3,7 @@ | |||
| 3 | ** Input/output library to LUA | 3 | ** Input/output library to LUA |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | char *rcs_iolib="$Id: iolib.c,v 1.16 1994/11/16 17:38:08 roberto Stab roberto $"; | 6 | char *rcs_iolib="$Id: iolib.c,v 1.17 1994/12/13 15:55:41 roberto Exp roberto $"; |
| 7 | 7 | ||
| 8 | #include <stdio.h> | 8 | #include <stdio.h> |
| 9 | #include <ctype.h> | 9 | #include <ctype.h> |
| @@ -29,7 +29,7 @@ static FILE *in=stdin, *out=stdout; | |||
| 29 | static void io_readfrom (void) | 29 | static void io_readfrom (void) |
| 30 | { | 30 | { |
| 31 | lua_Object o = lua_getparam (1); | 31 | lua_Object o = lua_getparam (1); |
| 32 | if (o == NULL) /* restore standart input */ | 32 | if (o == LUA_NOOBJECT) /* restore standart input */ |
| 33 | { | 33 | { |
| 34 | if (in != stdin) | 34 | if (in != stdin) |
| 35 | { | 35 | { |
| @@ -74,7 +74,7 @@ static void io_readfrom (void) | |||
| 74 | static void io_writeto (void) | 74 | static void io_writeto (void) |
| 75 | { | 75 | { |
| 76 | lua_Object o = lua_getparam (1); | 76 | lua_Object o = lua_getparam (1); |
| 77 | if (o == NULL) /* restore standart output */ | 77 | if (o == LUA_NOOBJECT) /* restore standart output */ |
| 78 | { | 78 | { |
| 79 | if (out != stdout) | 79 | if (out != stdout) |
| 80 | { | 80 | { |
| @@ -120,7 +120,7 @@ static void io_writeto (void) | |||
| 120 | static void io_appendto (void) | 120 | static void io_appendto (void) |
| 121 | { | 121 | { |
| 122 | lua_Object o = lua_getparam (1); | 122 | lua_Object o = lua_getparam (1); |
| 123 | if (o == NULL) /* restore standart output */ | 123 | if (o == LUA_NOOBJECT) /* restore standart output */ |
| 124 | { | 124 | { |
| 125 | if (out != stdout) | 125 | if (out != stdout) |
| 126 | { | 126 | { |
| @@ -177,7 +177,7 @@ static void io_appendto (void) | |||
| 177 | static void io_read (void) | 177 | static void io_read (void) |
| 178 | { | 178 | { |
| 179 | lua_Object o = lua_getparam (1); | 179 | lua_Object o = lua_getparam (1); |
| 180 | if (o == NULL || !lua_isstring(o)) /* free format */ | 180 | if (!lua_isstring(o)) /* free format */ |
| 181 | { | 181 | { |
| 182 | int c; | 182 | int c; |
| 183 | char s[256]; | 183 | char s[256]; |
| @@ -442,12 +442,12 @@ static void io_write (void) | |||
| 442 | { | 442 | { |
| 443 | lua_Object o1 = lua_getparam (1); | 443 | lua_Object o1 = lua_getparam (1); |
| 444 | lua_Object o2 = lua_getparam (2); | 444 | lua_Object o2 = lua_getparam (2); |
| 445 | if (o1 == NULL) /* new line */ | 445 | if (o1 == LUA_NOOBJECT) /* new line */ |
| 446 | { | 446 | { |
| 447 | fprintf (out, "\n"); | 447 | fprintf (out, "\n"); |
| 448 | lua_pushnumber(1); | 448 | lua_pushnumber(1); |
| 449 | } | 449 | } |
| 450 | else if (o2 == NULL) /* free format */ | 450 | else if (o2 == LUA_NOOBJECT) /* free format */ |
| 451 | { | 451 | { |
| 452 | int status=0; | 452 | int status=0; |
| 453 | if (lua_isnumber(o1)) | 453 | if (lua_isnumber(o1)) |
| @@ -475,7 +475,7 @@ static void io_write (void) | |||
| 475 | static void io_execute (void) | 475 | static void io_execute (void) |
| 476 | { | 476 | { |
| 477 | lua_Object o = lua_getparam (1); | 477 | lua_Object o = lua_getparam (1); |
| 478 | if (o == NULL || !lua_isstring (o)) | 478 | if (!lua_isstring (o)) |
| 479 | { | 479 | { |
| 480 | lua_error ("incorrect argument to function 'execute`"); | 480 | lua_error ("incorrect argument to function 'execute`"); |
| 481 | lua_pushnumber (0); | 481 | lua_pushnumber (0); |
| @@ -495,7 +495,7 @@ static void io_execute (void) | |||
| 495 | static void io_remove (void) | 495 | static void io_remove (void) |
| 496 | { | 496 | { |
| 497 | lua_Object o = lua_getparam (1); | 497 | lua_Object o = lua_getparam (1); |
| 498 | if (o == NULL || !lua_isstring (o)) | 498 | if (!lua_isstring (o)) |
| 499 | { | 499 | { |
| 500 | lua_error ("incorrect argument to function 'execute`"); | 500 | lua_error ("incorrect argument to function 'execute`"); |
| 501 | lua_pushnumber (0); | 501 | lua_pushnumber (0); |
