diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1995-02-02 18:05:37 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1995-02-02 18:05:37 -0200 |
| commit | dd28b830e9a4104fe78094fc6baf15cf601c1b6b (patch) | |
| tree | 6d0a22fa6a1dd101b57aa6e4c3cf7a5bd89b7315 | |
| parent | 572ee14b523a666d2be896825f55e6d05a260f7b (diff) | |
| download | lua-dd28b830e9a4104fe78094fc6baf15cf601c1b6b.tar.gz lua-dd28b830e9a4104fe78094fc6baf15cf601c1b6b.tar.bz2 lua-dd28b830e9a4104fe78094fc6baf15cf601c1b6b.zip | |
a null lua_Object is LUA_NOOBJECT, not NULL.
| -rw-r--r-- | opcode.c | 4 | ||||
| -rw-r--r-- | strlib.c | 17 |
2 files changed, 11 insertions, 10 deletions
| @@ -3,7 +3,7 @@ | |||
| 3 | ** TecCGraf - PUC-Rio | 3 | ** TecCGraf - PUC-Rio |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | char *rcs_opcode="$Id: opcode.c,v 3.31 1994/12/30 17:45:11 roberto Exp celes $"; | 6 | char *rcs_opcode="$Id: opcode.c,v 3.32 1995/01/27 17:19:06 celes Exp roberto $"; |
| 7 | 7 | ||
| 8 | #include <setjmp.h> | 8 | #include <setjmp.h> |
| 9 | #include <stdio.h> | 9 | #include <stdio.h> |
| @@ -373,7 +373,7 @@ static int do_protectedmain (void) | |||
| 373 | */ | 373 | */ |
| 374 | int lua_callfunction (lua_Object function) | 374 | int lua_callfunction (lua_Object function) |
| 375 | { | 375 | { |
| 376 | if (function == NULL) | 376 | if (function == LUA_NOOBJECT) |
| 377 | return 1; | 377 | return 1; |
| 378 | else | 378 | else |
| 379 | return do_protectedrun (Address(function), MULT_RET); | 379 | return do_protectedrun (Address(function), MULT_RET); |
| @@ -3,12 +3,13 @@ | |||
| 3 | ** String library to LUA | 3 | ** String library to LUA |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | char *rcs_strlib="$Id: strlib.c,v 1.8 1995/01/06 20:31:10 roberto Exp roberto $"; | 6 | char *rcs_strlib="$Id: strlib.c,v 1.10 1995/02/02 18:54:58 roberto Exp $"; |
| 7 | 7 | ||
| 8 | #include <string.h> | 8 | #include <string.h> |
| 9 | #include <strings.h> | ||
| 10 | #include <stdlib.h> | ||
| 9 | #include <ctype.h> | 11 | #include <ctype.h> |
| 10 | 12 | ||
| 11 | #include "mem.h" | ||
| 12 | #include "lua.h" | 13 | #include "lua.h" |
| 13 | #include "lualib.h" | 14 | #include "lualib.h" |
| 14 | 15 | ||
| @@ -87,7 +88,7 @@ static void str_sub (void) | |||
| 87 | lua_error ("incorrect third argument to function `strsub'"); | 88 | lua_error ("incorrect third argument to function `strsub'"); |
| 88 | s = lua_copystring(o1); | 89 | s = lua_copystring(o1); |
| 89 | start = lua_getnumber (o2); | 90 | start = lua_getnumber (o2); |
| 90 | end = o3 == NULL ? strlen(s) : lua_getnumber (o3); | 91 | end = o3 == LUA_NOOBJECT ? strlen(s) : lua_getnumber (o3); |
| 91 | if (end < start || start < 1 || end > strlen(s)) | 92 | if (end < start || start < 1 || end > strlen(s)) |
| 92 | lua_pushliteral(""); | 93 | lua_pushliteral(""); |
| 93 | else | 94 | else |
| @@ -95,7 +96,7 @@ static void str_sub (void) | |||
| 95 | s[end] = 0; | 96 | s[end] = 0; |
| 96 | lua_pushstring (&s[start-1]); | 97 | lua_pushstring (&s[start-1]); |
| 97 | } | 98 | } |
| 98 | luaI_free(s); | 99 | free(s); |
| 99 | } | 100 | } |
| 100 | 101 | ||
| 101 | /* | 102 | /* |
| @@ -109,14 +110,14 @@ static void str_lower (void) | |||
| 109 | lua_Object o = lua_getparam (1); | 110 | lua_Object o = lua_getparam (1); |
| 110 | if (!lua_isstring(o)) | 111 | if (!lua_isstring(o)) |
| 111 | lua_error ("incorrect arguments to function `strlower'"); | 112 | lua_error ("incorrect arguments to function `strlower'"); |
| 112 | c = s = luaI_strdup(lua_getstring(o)); | 113 | c = s = lua_copystring(o); |
| 113 | while (*c != 0) | 114 | while (*c != 0) |
| 114 | { | 115 | { |
| 115 | *c = tolower(*c); | 116 | *c = tolower(*c); |
| 116 | c++; | 117 | c++; |
| 117 | } | 118 | } |
| 118 | lua_pushstring(s); | 119 | lua_pushstring(s); |
| 119 | luaI_free(s); | 120 | free(s); |
| 120 | } | 121 | } |
| 121 | 122 | ||
| 122 | 123 | ||
| @@ -131,14 +132,14 @@ static void str_upper (void) | |||
| 131 | lua_Object o = lua_getparam (1); | 132 | lua_Object o = lua_getparam (1); |
| 132 | if (!lua_isstring(o)) | 133 | if (!lua_isstring(o)) |
| 133 | lua_error ("incorrect arguments to function `strlower'"); | 134 | lua_error ("incorrect arguments to function `strlower'"); |
| 134 | c = s = luaI_strdup(lua_getstring(o)); | 135 | c = s = lua_copystring(o); |
| 135 | while (*c != 0) | 136 | while (*c != 0) |
| 136 | { | 137 | { |
| 137 | *c = toupper(*c); | 138 | *c = toupper(*c); |
| 138 | c++; | 139 | c++; |
| 139 | } | 140 | } |
| 140 | lua_pushstring(s); | 141 | lua_pushstring(s); |
| 141 | luaI_free(s); | 142 | free(s); |
| 142 | } | 143 | } |
| 143 | 144 | ||
| 144 | 145 | ||
