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 | |
parent | 891cab8a31ec73dddb5aa896abedbac53b4c16f8 (diff) | |
download | lua-fad57bfa008523c3568b613989a6a3f87f3cb83b.tar.gz lua-fad57bfa008523c3568b613989a6a3f87f3cb83b.tar.bz2 lua-fad57bfa008523c3568b613989a6a3f87f3cb83b.zip |
new constant LUA_NOOBJECT.
'lua_error' never returns
-rw-r--r-- | iolib.c | 18 | ||||
-rw-r--r-- | mathlib.c | 114 | ||||
-rw-r--r-- | strlib.c | 16 |
3 files changed, 74 insertions, 74 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); |
@@ -3,7 +3,7 @@ | |||
3 | ** Mathematics library to LUA | 3 | ** Mathematics library to LUA |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_mathlib="$Id: mathlib.c,v 1.5 1994/11/17 19:43:34 roberto Exp roberto $"; | 6 | char *rcs_mathlib="$Id: mathlib.c,v 1.6 1994/11/18 19:46:21 roberto Stab roberto $"; |
7 | 7 | ||
8 | #include <stdio.h> /* NULL */ | 8 | #include <stdio.h> /* NULL */ |
9 | #include <math.h> | 9 | #include <math.h> |
@@ -19,10 +19,10 @@ static void math_abs (void) | |||
19 | { | 19 | { |
20 | double d; | 20 | double d; |
21 | lua_Object o = lua_getparam (1); | 21 | lua_Object o = lua_getparam (1); |
22 | if (o == NULL) | 22 | if (o == LUA_NOOBJECT) |
23 | { lua_error ("too few arguments to function `abs'"); return; } | 23 | lua_error ("too few arguments to function `abs'"); |
24 | if (!lua_isnumber(o)) | 24 | if (!lua_isnumber(o)) |
25 | { lua_error ("incorrect arguments to function `abs'"); return; } | 25 | lua_error ("incorrect arguments to function `abs'"); |
26 | d = lua_getnumber(o); | 26 | d = lua_getnumber(o); |
27 | if (d < 0) d = -d; | 27 | if (d < 0) d = -d; |
28 | lua_pushnumber (d); | 28 | lua_pushnumber (d); |
@@ -33,10 +33,10 @@ static void math_sin (void) | |||
33 | { | 33 | { |
34 | double d; | 34 | double d; |
35 | lua_Object o = lua_getparam (1); | 35 | lua_Object o = lua_getparam (1); |
36 | if (o == NULL) | 36 | if (o == LUA_NOOBJECT) |
37 | { lua_error ("too few arguments to function `sin'"); return; } | 37 | lua_error ("too few arguments to function `sin'"); |
38 | if (!lua_isnumber(o)) | 38 | if (!lua_isnumber(o)) |
39 | { lua_error ("incorrect arguments to function `sin'"); return; } | 39 | lua_error ("incorrect arguments to function `sin'"); |
40 | d = lua_getnumber(o); | 40 | d = lua_getnumber(o); |
41 | lua_pushnumber (sin(TORAD(d))); | 41 | lua_pushnumber (sin(TORAD(d))); |
42 | } | 42 | } |
@@ -47,10 +47,10 @@ static void math_cos (void) | |||
47 | { | 47 | { |
48 | double d; | 48 | double d; |
49 | lua_Object o = lua_getparam (1); | 49 | lua_Object o = lua_getparam (1); |
50 | if (o == NULL) | 50 | if (o == LUA_NOOBJECT) |
51 | { lua_error ("too few arguments to function `cos'"); return; } | 51 | lua_error ("too few arguments to function `cos'"); |
52 | if (!lua_isnumber(o)) | 52 | if (!lua_isnumber(o)) |
53 | { lua_error ("incorrect arguments to function `cos'"); return; } | 53 | lua_error ("incorrect arguments to function `cos'"); |
54 | d = lua_getnumber(o); | 54 | d = lua_getnumber(o); |
55 | lua_pushnumber (cos(TORAD(d))); | 55 | lua_pushnumber (cos(TORAD(d))); |
56 | } | 56 | } |
@@ -61,10 +61,10 @@ static void math_tan (void) | |||
61 | { | 61 | { |
62 | double d; | 62 | double d; |
63 | lua_Object o = lua_getparam (1); | 63 | lua_Object o = lua_getparam (1); |
64 | if (o == NULL) | 64 | if (o == LUA_NOOBJECT) |
65 | { lua_error ("too few arguments to function `tan'"); return; } | 65 | lua_error ("too few arguments to function `tan'"); |
66 | if (!lua_isnumber(o)) | 66 | if (!lua_isnumber(o)) |
67 | { lua_error ("incorrect arguments to function `tan'"); return; } | 67 | lua_error ("incorrect arguments to function `tan'"); |
68 | d = lua_getnumber(o); | 68 | d = lua_getnumber(o); |
69 | lua_pushnumber (tan(TORAD(d))); | 69 | lua_pushnumber (tan(TORAD(d))); |
70 | } | 70 | } |
@@ -74,10 +74,10 @@ static void math_asin (void) | |||
74 | { | 74 | { |
75 | double d; | 75 | double d; |
76 | lua_Object o = lua_getparam (1); | 76 | lua_Object o = lua_getparam (1); |
77 | if (o == NULL) | 77 | if (o == LUA_NOOBJECT) |
78 | { lua_error ("too few arguments to function `asin'"); return; } | 78 | lua_error ("too few arguments to function `asin'"); |
79 | if (!lua_isnumber(o)) | 79 | if (!lua_isnumber(o)) |
80 | { lua_error ("incorrect arguments to function `asin'"); return; } | 80 | lua_error ("incorrect arguments to function `asin'"); |
81 | d = lua_getnumber(o); | 81 | d = lua_getnumber(o); |
82 | lua_pushnumber (TODEGREE(asin(d))); | 82 | lua_pushnumber (TODEGREE(asin(d))); |
83 | } | 83 | } |
@@ -87,10 +87,10 @@ static void math_acos (void) | |||
87 | { | 87 | { |
88 | double d; | 88 | double d; |
89 | lua_Object o = lua_getparam (1); | 89 | lua_Object o = lua_getparam (1); |
90 | if (o == NULL) | 90 | if (o == LUA_NOOBJECT) |
91 | { lua_error ("too few arguments to function `acos'"); return; } | 91 | lua_error ("too few arguments to function `acos'"); |
92 | if (!lua_isnumber(o)) | 92 | if (!lua_isnumber(o)) |
93 | { lua_error ("incorrect arguments to function `acos'"); return; } | 93 | lua_error ("incorrect arguments to function `acos'"); |
94 | d = lua_getnumber(o); | 94 | d = lua_getnumber(o); |
95 | lua_pushnumber (TODEGREE(acos(d))); | 95 | lua_pushnumber (TODEGREE(acos(d))); |
96 | } | 96 | } |
@@ -101,10 +101,10 @@ static void math_atan (void) | |||
101 | { | 101 | { |
102 | double d; | 102 | double d; |
103 | lua_Object o = lua_getparam (1); | 103 | lua_Object o = lua_getparam (1); |
104 | if (o == NULL) | 104 | if (o == LUA_NOOBJECT) |
105 | { lua_error ("too few arguments to function `atan'"); return; } | 105 | lua_error ("too few arguments to function `atan'"); |
106 | if (!lua_isnumber(o)) | 106 | if (!lua_isnumber(o)) |
107 | { lua_error ("incorrect arguments to function `atan'"); return; } | 107 | lua_error ("incorrect arguments to function `atan'"); |
108 | d = lua_getnumber(o); | 108 | d = lua_getnumber(o); |
109 | lua_pushnumber (TODEGREE(atan(d))); | 109 | lua_pushnumber (TODEGREE(atan(d))); |
110 | } | 110 | } |
@@ -114,10 +114,10 @@ static void math_ceil (void) | |||
114 | { | 114 | { |
115 | double d; | 115 | double d; |
116 | lua_Object o = lua_getparam (1); | 116 | lua_Object o = lua_getparam (1); |
117 | if (o == NULL) | 117 | if (o == LUA_NOOBJECT) |
118 | { lua_error ("too few arguments to function `ceil'"); return; } | 118 | lua_error ("too few arguments to function `ceil'"); |
119 | if (!lua_isnumber(o)) | 119 | if (!lua_isnumber(o)) |
120 | { lua_error ("incorrect arguments to function `ceil'"); return; } | 120 | lua_error ("incorrect arguments to function `ceil'"); |
121 | d = lua_getnumber(o); | 121 | d = lua_getnumber(o); |
122 | lua_pushnumber (ceil(d)); | 122 | lua_pushnumber (ceil(d)); |
123 | } | 123 | } |
@@ -127,10 +127,10 @@ static void math_floor (void) | |||
127 | { | 127 | { |
128 | double d; | 128 | double d; |
129 | lua_Object o = lua_getparam (1); | 129 | lua_Object o = lua_getparam (1); |
130 | if (o == NULL) | 130 | if (o == LUA_NOOBJECT) |
131 | { lua_error ("too few arguments to function `floor'"); return; } | 131 | lua_error ("too few arguments to function `floor'"); |
132 | if (!lua_isnumber(o)) | 132 | if (!lua_isnumber(o)) |
133 | { lua_error ("incorrect arguments to function `floor'"); return; } | 133 | lua_error ("incorrect arguments to function `floor'"); |
134 | d = lua_getnumber(o); | 134 | d = lua_getnumber(o); |
135 | lua_pushnumber (floor(d)); | 135 | lua_pushnumber (floor(d)); |
136 | } | 136 | } |
@@ -141,7 +141,7 @@ static void math_mod (void) | |||
141 | lua_Object o1 = lua_getparam (1); | 141 | lua_Object o1 = lua_getparam (1); |
142 | lua_Object o2 = lua_getparam (2); | 142 | lua_Object o2 = lua_getparam (2); |
143 | if (!lua_isnumber(o1) || !lua_isnumber(o2)) | 143 | if (!lua_isnumber(o1) || !lua_isnumber(o2)) |
144 | { lua_error ("incorrect arguments to function `mod'"); return; } | 144 | lua_error ("incorrect arguments to function `mod'"); |
145 | d1 = (int) lua_getnumber(o1); | 145 | d1 = (int) lua_getnumber(o1); |
146 | d2 = (int) lua_getnumber(o2); | 146 | d2 = (int) lua_getnumber(o2); |
147 | lua_pushnumber (d1%d2); | 147 | lua_pushnumber (d1%d2); |
@@ -152,10 +152,10 @@ static void math_sqrt (void) | |||
152 | { | 152 | { |
153 | double d; | 153 | double d; |
154 | lua_Object o = lua_getparam (1); | 154 | lua_Object o = lua_getparam (1); |
155 | if (o == NULL) | 155 | if (o == LUA_NOOBJECT) |
156 | { lua_error ("too few arguments to function `sqrt'"); return; } | 156 | lua_error ("too few arguments to function `sqrt'"); |
157 | if (!lua_isnumber(o)) | 157 | if (!lua_isnumber(o)) |
158 | { lua_error ("incorrect arguments to function `sqrt'"); return; } | 158 | lua_error ("incorrect arguments to function `sqrt'"); |
159 | d = lua_getnumber(o); | 159 | d = lua_getnumber(o); |
160 | lua_pushnumber (sqrt(d)); | 160 | lua_pushnumber (sqrt(d)); |
161 | } | 161 | } |
@@ -188,15 +188,15 @@ static void math_min (void) | |||
188 | int i=1; | 188 | int i=1; |
189 | double d, dmin; | 189 | double d, dmin; |
190 | lua_Object o; | 190 | lua_Object o; |
191 | if ((o = lua_getparam(i++)) == NULL) | 191 | if ((o = lua_getparam(i++)) == LUA_NOOBJECT) |
192 | { lua_error ("too few arguments to function `min'"); return; } | 192 | lua_error ("too few arguments to function `min'"); |
193 | if (!lua_isnumber(o)) | 193 | if (!lua_isnumber(o)) |
194 | { lua_error ("incorrect arguments to function `min'"); return; } | 194 | lua_error ("incorrect arguments to function `min'"); |
195 | dmin = lua_getnumber (o); | 195 | dmin = lua_getnumber (o); |
196 | while ((o = lua_getparam(i++)) != NULL) | 196 | while ((o = lua_getparam(i++)) != LUA_NOOBJECT) |
197 | { | 197 | { |
198 | if (!lua_isnumber(o)) | 198 | if (!lua_isnumber(o)) |
199 | { lua_error ("incorrect arguments to function `min'"); return; } | 199 | lua_error ("incorrect arguments to function `min'"); |
200 | d = lua_getnumber (o); | 200 | d = lua_getnumber (o); |
201 | if (d < dmin) dmin = d; | 201 | if (d < dmin) dmin = d; |
202 | } | 202 | } |
@@ -209,15 +209,15 @@ static void math_max (void) | |||
209 | int i=1; | 209 | int i=1; |
210 | double d, dmax; | 210 | double d, dmax; |
211 | lua_Object o; | 211 | lua_Object o; |
212 | if ((o = lua_getparam(i++)) == NULL) | 212 | if ((o = lua_getparam(i++)) == LUA_NOOBJECT) |
213 | { lua_error ("too few arguments to function `max'"); return; } | 213 | lua_error ("too few arguments to function `max'"); |
214 | if (!lua_isnumber(o)) | 214 | if (!lua_isnumber(o)) |
215 | { lua_error ("incorrect arguments to function `max'"); return; } | 215 | lua_error ("incorrect arguments to function `max'"); |
216 | dmax = lua_getnumber (o); | 216 | dmax = lua_getnumber (o); |
217 | while ((o = lua_getparam(i++)) != NULL) | 217 | while ((o = lua_getparam(i++)) != LUA_NOOBJECT) |
218 | { | 218 | { |
219 | if (!lua_isnumber(o)) | 219 | if (!lua_isnumber(o)) |
220 | { lua_error ("incorrect arguments to function `max'"); return; } | 220 | lua_error ("incorrect arguments to function `max'"); |
221 | d = lua_getnumber (o); | 221 | d = lua_getnumber (o); |
222 | if (d > dmax) dmax = d; | 222 | if (d > dmax) dmax = d; |
223 | } | 223 | } |
@@ -229,10 +229,10 @@ static void math_log (void) | |||
229 | { | 229 | { |
230 | double d; | 230 | double d; |
231 | lua_Object o = lua_getparam (1); | 231 | lua_Object o = lua_getparam (1); |
232 | if (o == NULL) | 232 | if (o == LUA_NOOBJECT) |
233 | { lua_error ("too few arguments to function `log'"); return; } | 233 | lua_error ("too few arguments to function `log'"); |
234 | if (!lua_isnumber(o)) | 234 | if (!lua_isnumber(o)) |
235 | { lua_error ("incorrect arguments to function `log'"); return; } | 235 | lua_error ("incorrect arguments to function `log'"); |
236 | d = lua_getnumber(o); | 236 | d = lua_getnumber(o); |
237 | lua_pushnumber (log(d)); | 237 | lua_pushnumber (log(d)); |
238 | } | 238 | } |
@@ -242,10 +242,10 @@ static void math_log10 (void) | |||
242 | { | 242 | { |
243 | double d; | 243 | double d; |
244 | lua_Object o = lua_getparam (1); | 244 | lua_Object o = lua_getparam (1); |
245 | if (o == NULL) | 245 | if (o == LUA_NOOBJECT) |
246 | { lua_error ("too few arguments to function `log10'"); return; } | 246 | lua_error ("too few arguments to function `log10'"); |
247 | if (!lua_isnumber(o)) | 247 | if (!lua_isnumber(o)) |
248 | { lua_error ("incorrect arguments to function `log10'"); return; } | 248 | lua_error ("incorrect arguments to function `log10'"); |
249 | d = lua_getnumber(o); | 249 | d = lua_getnumber(o); |
250 | lua_pushnumber (log10(d)); | 250 | lua_pushnumber (log10(d)); |
251 | } | 251 | } |
@@ -255,10 +255,10 @@ static void math_exp (void) | |||
255 | { | 255 | { |
256 | double d; | 256 | double d; |
257 | lua_Object o = lua_getparam (1); | 257 | lua_Object o = lua_getparam (1); |
258 | if (o == NULL) | 258 | if (o == LUA_NOOBJECT) |
259 | { lua_error ("too few arguments to function `exp'"); return; } | 259 | lua_error ("too few arguments to function `exp'"); |
260 | if (!lua_isnumber(o)) | 260 | if (!lua_isnumber(o)) |
261 | { lua_error ("incorrect arguments to function `exp'"); return; } | 261 | lua_error ("incorrect arguments to function `exp'"); |
262 | d = lua_getnumber(o); | 262 | d = lua_getnumber(o); |
263 | lua_pushnumber (exp(d)); | 263 | lua_pushnumber (exp(d)); |
264 | } | 264 | } |
@@ -267,10 +267,10 @@ static void math_deg (void) | |||
267 | { | 267 | { |
268 | float d; | 268 | float d; |
269 | lua_Object o = lua_getparam (1); | 269 | lua_Object o = lua_getparam (1); |
270 | if (o == NULL) | 270 | if (o == LUA_NOOBJECT) |
271 | { lua_error ("too few arguments to function `deg'"); return; } | 271 | lua_error ("too few arguments to function `deg'"); |
272 | if (!lua_isnumber(o)) | 272 | if (!lua_isnumber(o)) |
273 | { lua_error ("incorrect arguments to function `deg'"); return; } | 273 | lua_error ("incorrect arguments to function `deg'"); |
274 | d = lua_getnumber(o); | 274 | d = lua_getnumber(o); |
275 | lua_pushnumber (d*180./PI); | 275 | lua_pushnumber (d*180./PI); |
276 | } | 276 | } |
@@ -279,10 +279,10 @@ static void math_rad (void) | |||
279 | { | 279 | { |
280 | float d; | 280 | float d; |
281 | lua_Object o = lua_getparam (1); | 281 | lua_Object o = lua_getparam (1); |
282 | if (o == NULL) | 282 | if (o == LUA_NOOBJECT) |
283 | { lua_error ("too few arguments to function `rad'"); return; } | 283 | lua_error ("too few arguments to function `rad'"); |
284 | if (!lua_isnumber(o)) | 284 | if (!lua_isnumber(o)) |
285 | { lua_error ("incorrect arguments to function `rad'"); return; } | 285 | lua_error ("incorrect arguments to function `rad'"); |
286 | d = lua_getnumber(o); | 286 | d = lua_getnumber(o); |
287 | lua_pushnumber (d/180.*PI); | 287 | lua_pushnumber (d/180.*PI); |
288 | } | 288 | } |
@@ -3,7 +3,7 @@ | |||
3 | ** String library to LUA | 3 | ** String library to LUA |
4 | */ | 4 | */ |
5 | 5 | ||
6 | char *rcs_strlib="$Id: strlib.c,v 1.5 1994/11/16 17:38:08 roberto Stab $"; | 6 | char *rcs_strlib="$Id: strlib.c,v 1.6 1994/12/13 15:54:21 roberto Exp roberto $"; |
7 | 7 | ||
8 | #include <string.h> | 8 | #include <string.h> |
9 | #include <ctype.h> | 9 | #include <ctype.h> |
@@ -23,7 +23,7 @@ static void str_find (void) | |||
23 | lua_Object o1 = lua_getparam (1); | 23 | lua_Object o1 = lua_getparam (1); |
24 | lua_Object o2 = lua_getparam (2); | 24 | lua_Object o2 = lua_getparam (2); |
25 | if (!lua_isstring(o1) || !lua_isstring(o2)) | 25 | if (!lua_isstring(o1) || !lua_isstring(o2)) |
26 | { lua_error ("incorrect arguments to function `strfind'"); return; } | 26 | lua_error ("incorrect arguments to function `strfind'"); |
27 | s1 = lua_getstring(o1); | 27 | s1 = lua_getstring(o1); |
28 | s2 = lua_getstring(o2); | 28 | s2 = lua_getstring(o2); |
29 | f = strstr(s1,s2); | 29 | f = strstr(s1,s2); |
@@ -42,7 +42,7 @@ static void str_len (void) | |||
42 | { | 42 | { |
43 | lua_Object o = lua_getparam (1); | 43 | lua_Object o = lua_getparam (1); |
44 | if (!lua_isstring(o)) | 44 | if (!lua_isstring(o)) |
45 | { lua_error ("incorrect arguments to function `strlen'"); return; } | 45 | lua_error ("incorrect arguments to function `strlen'"); |
46 | lua_pushnumber(strlen(lua_getstring(o))); | 46 | lua_pushnumber(strlen(lua_getstring(o))); |
47 | } | 47 | } |
48 | 48 | ||
@@ -60,9 +60,9 @@ static void str_sub (void) | |||
60 | lua_Object o2 = lua_getparam (2); | 60 | lua_Object o2 = lua_getparam (2); |
61 | lua_Object o3 = lua_getparam (3); | 61 | lua_Object o3 = lua_getparam (3); |
62 | if (!lua_isstring(o1) || !lua_isnumber(o2)) | 62 | if (!lua_isstring(o1) || !lua_isnumber(o2)) |
63 | { lua_error ("incorrect arguments to function `strsub'"); return; } | 63 | lua_error ("incorrect arguments to function `strsub'"); |
64 | if (o3 != NULL && !lua_isnumber(o3)) | 64 | if (o3 != LUA_NOOBJECT && !lua_isnumber(o3)) |
65 | { lua_error ("incorrect third argument to function `strsub'"); return; } | 65 | lua_error ("incorrect third argument to function `strsub'"); |
66 | s = lua_copystring(o1); | 66 | s = lua_copystring(o1); |
67 | start = lua_getnumber (o2); | 67 | start = lua_getnumber (o2); |
68 | end = o3 == NULL ? strlen(s) : lua_getnumber (o3); | 68 | end = o3 == NULL ? strlen(s) : lua_getnumber (o3); |
@@ -86,7 +86,7 @@ static void str_lower (void) | |||
86 | char *s, *c; | 86 | char *s, *c; |
87 | lua_Object o = lua_getparam (1); | 87 | lua_Object o = lua_getparam (1); |
88 | if (!lua_isstring(o)) | 88 | if (!lua_isstring(o)) |
89 | { lua_error ("incorrect arguments to function `strlower'"); return; } | 89 | lua_error ("incorrect arguments to function `strlower'"); |
90 | c = s = strdup(lua_getstring(o)); | 90 | c = s = strdup(lua_getstring(o)); |
91 | while (*c != 0) | 91 | while (*c != 0) |
92 | { | 92 | { |
@@ -108,7 +108,7 @@ static void str_upper (void) | |||
108 | char *s, *c; | 108 | char *s, *c; |
109 | lua_Object o = lua_getparam (1); | 109 | lua_Object o = lua_getparam (1); |
110 | if (!lua_isstring(o)) | 110 | if (!lua_isstring(o)) |
111 | { lua_error ("incorrect arguments to function `strlower'"); return; } | 111 | lua_error ("incorrect arguments to function `strlower'"); |
112 | c = s = strdup(lua_getstring(o)); | 112 | c = s = strdup(lua_getstring(o)); |
113 | while (*c != 0) | 113 | while (*c != 0) |
114 | { | 114 | { |