diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-05-14 12:34:57 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-05-14 12:34:57 -0300 |
commit | e99e9a94732dcb7407777b724fb61e548d51ba33 (patch) | |
tree | 56e057e8780781c9deb4830ed688fc560f551a66 | |
parent | f35ac38e1df7e3577bc7464c8d4d09f97f892a97 (diff) | |
download | lua-e99e9a94732dcb7407777b724fb61e548d51ba33.tar.gz lua-e99e9a94732dcb7407777b724fb61e548d51ba33.tar.bz2 lua-e99e9a94732dcb7407777b724fb61e548d51ba33.zip |
patches for last two bugs (string.format and io.read)
-rw-r--r-- | bugs | 47 |
1 files changed, 42 insertions, 5 deletions
@@ -1880,8 +1880,8 @@ patch = [[ | |||
1880 | +++ lundump.c 2008/04/04 19:51:41 2.7.1.4 | 1880 | +++ lundump.c 2008/04/04 19:51:41 2.7.1.4 |
1881 | @@ -1,5 +1,5 @@ | 1881 | @@ -1,5 +1,5 @@ |
1882 | /* | 1882 | /* |
1883 | -** $Id: bugs,v 1.106 2010/04/19 16:39:25 roberto Exp roberto $ | 1883 | -** $Id: bugs,v 1.107 2010/04/19 18:04:58 roberto Exp roberto $ |
1884 | +** $Id: bugs,v 1.106 2010/04/19 16:39:25 roberto Exp roberto $ | 1884 | +** $Id: bugs,v 1.107 2010/04/19 18:04:58 roberto Exp roberto $ |
1885 | ** load precompiled Lua chunks | 1885 | ** load precompiled Lua chunks |
1886 | ** See Copyright Notice in lua.h | 1886 | ** See Copyright Notice in lua.h |
1887 | */ | 1887 | */ |
@@ -2265,7 +2265,29 @@ since = [[5.0]], | |||
2265 | example = [[ | 2265 | example = [[ |
2266 | x = string.rep("x", 10000) .. "%d" | 2266 | x = string.rep("x", 10000) .. "%d" |
2267 | print(string.format(x)) -- gives wrong error message | 2267 | print(string.format(x)) -- gives wrong error message |
2268 | patch = nil | 2268 | ]], |
2269 | patch = [[ | ||
2270 | --- lstrlib.c 2008/07/11 17:27:21 1.132.1.4 | ||
2271 | +++ lstrlib.c 2010/05/14 15:12:53 | ||
2272 | @@ -754,6 +754,7 @@ | ||
2273 | |||
2274 | |||
2275 | static int str_format (lua_State *L) { | ||
2276 | + int top = lua_gettop(L); | ||
2277 | int arg = 1; | ||
2278 | size_t sfl; | ||
2279 | const char *strfrmt = luaL_checklstring(L, arg, &sfl); | ||
2280 | @@ -768,7 +769,8 @@ | ||
2281 | else { /* format item */ | ||
2282 | char form[MAX_FORMAT]; /* to store the format (`%...') */ | ||
2283 | char buff[MAX_ITEM]; /* to store the formatted item */ | ||
2284 | - arg++; | ||
2285 | + if (++arg > top) | ||
2286 | + luaL_argerror(L, arg, "no value"); | ||
2287 | strfrmt = scanformat(L, strfrmt, form); | ||
2288 | switch (*strfrmt++) { | ||
2289 | case 'c': { | ||
2290 | ]] | ||
2269 | } | 2291 | } |
2270 | 2292 | ||
2271 | Bug{ | 2293 | Bug{ |
@@ -2273,9 +2295,24 @@ what = [['io.read(op, "*n")' may return garbage if second read fails]], | |||
2273 | report = [[Roberto I., 2010/04/12]], | 2295 | report = [[Roberto I., 2010/04/12]], |
2274 | since = [[5.0]], | 2296 | since = [[5.0]], |
2275 | example = [[ | 2297 | example = [[ |
2276 | print(io.read("*n", "*n") --<< enter "10 hi" | 2298 | print(io.read("*n", "*n")) --<< enter "10 hi" |
2277 | --> file (0x884420) nil | 2299 | --> file (0x884420) nil |
2278 | ]], | 2300 | ]], |
2279 | patch = nil | 2301 | patch = [[ |
2302 | --- liolib.c 2008/01/18 17:47:43 2.73.1.3 | ||
2303 | +++ liolib.c 2010/05/14 15:29:29 | ||
2304 | @@ -276,7 +276,10 @@ | ||
2305 | lua_pushnumber(L, d); | ||
2306 | return 1; | ||
2307 | } | ||
2308 | - else return 0; /* read fails */ | ||
2309 | + else { | ||
2310 | + lua_pushnil(L); /* "result" to be removed */ | ||
2311 | + return 0; /* read fails */ | ||
2312 | + } | ||
2313 | } | ||
2314 | |||
2315 | |||
2316 | ]] | ||
2280 | } | 2317 | } |
2281 | 2318 | ||