aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--config.lua4
-rw-r--r--lapi.c3
-rw-r--r--lapi.h5
-rw-r--r--lobject.c26
-rw-r--r--ltm.c7
-rw-r--r--manual/manual.of2
-rw-r--r--testes/sort.lua2
7 files changed, 25 insertions, 24 deletions
diff --git a/config.lua b/config.lua
deleted file mode 100644
index 14afdc8a..00000000
--- a/config.lua
+++ /dev/null
@@ -1,4 +0,0 @@
1collectgarbage("setparam", "minormul", 25)
2-- collectgarbage("generational")
3
4
diff --git a/lapi.c b/lapi.c
index b8e58801..bb76b15a 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1262,9 +1262,8 @@ LUA_API int lua_next (lua_State *L, int idx) {
1262 api_checknelems(L, 1); 1262 api_checknelems(L, 1);
1263 t = gettable(L, idx); 1263 t = gettable(L, idx);
1264 more = luaH_next(L, t, L->top.p - 1); 1264 more = luaH_next(L, t, L->top.p - 1);
1265 if (more) { 1265 if (more)
1266 api_incr_top(L); 1266 api_incr_top(L);
1267 }
1268 else /* no more elements */ 1267 else /* no more elements */
1269 L->top.p -= 1; /* remove key */ 1268 L->top.p -= 1; /* remove key */
1270 lua_unlock(L); 1269 lua_unlock(L);
diff --git a/lapi.h b/lapi.h
index a742427c..43845648 100644
--- a/lapi.h
+++ b/lapi.h
@@ -13,9 +13,8 @@
13 13
14 14
15/* Increments 'L->top.p', checking for stack overflows */ 15/* Increments 'L->top.p', checking for stack overflows */
16#define api_incr_top(L) {L->top.p++; \ 16#define api_incr_top(L) \
17 api_check(L, L->top.p <= L->ci->top.p, \ 17 (L->top.p++, api_check(L, L->top.p <= L->ci->top.p, "stack overflow"))
18 "stack overflow");}
19 18
20 19
21/* 20/*
diff --git a/lobject.c b/lobject.c
index 5a9b435e..45a27311 100644
--- a/lobject.c
+++ b/lobject.c
@@ -73,17 +73,29 @@ unsigned int luaO_codeparam (unsigned int p) {
73 73
74 74
75/* 75/*
76** Computes 'p' times 'x', where 'p' is a floating-point byte. 76** Computes 'p' times 'x', where 'p' is a floating-point byte. Roughly,
77** we have to multiply 'x' by the mantissa and then shift accordingly to
78** the exponent. If the exponent is positive, both the multiplication
79** and the shift increase 'x', so we have to care only about overflows.
80** For negative exponents, however, multiplying before the shift keeps
81** more significant bits, as long as the multiplication does not
82** overflow, so we check which order is best.
77*/ 83*/
78l_obj luaO_applyparam (unsigned int p, l_obj x) { 84l_obj luaO_applyparam (unsigned int p, l_obj x) {
79 unsigned int m = p & 0xF; /* mantissa */ 85 unsigned int m = p & 0xF; /* mantissa */
80 int e = (p >> 4); /* exponent */ 86 int e = (p >> 4); /* exponent */
81 if (e > 0) { /* normalized? */ 87 if (e > 0) { /* normalized? */
82 e--; 88 e--; /* correct exponent */
83 m += 0x10; /* maximum 'm' is 0x1F */ 89 m += 0x10; /* correct mantissa; maximum value is 0x1F */
84 } 90 }
85 e -= 7; /* correct excess-7 */ 91 e -= 7; /* correct excess-7 */
86 if (e < 0) { 92 if (e >= 0) {
93 if (x < (MAX_LOBJ / 0x1F) >> e) /* no overflow? */
94 return (x * m) << e; /* order doesn't matter here */
95 else /* real overflow */
96 return MAX_LOBJ;
97 }
98 else { /* negative exponent */
87 e = -e; 99 e = -e;
88 if (x < MAX_LOBJ / 0x1F) /* multiplication cannot overflow? */ 100 if (x < MAX_LOBJ / 0x1F) /* multiplication cannot overflow? */
89 return (x * m) >> e; /* multiplying first gives more precision */ 101 return (x * m) >> e; /* multiplying first gives more precision */
@@ -92,12 +104,6 @@ l_obj luaO_applyparam (unsigned int p, l_obj x) {
92 else /* real overflow */ 104 else /* real overflow */
93 return MAX_LOBJ; 105 return MAX_LOBJ;
94 } 106 }
95 else {
96 if (x < (MAX_LOBJ / 0x1F) >> e) /* no overflow? */
97 return (x * m) << e; /* order doesn't matter here */
98 else /* real overflow */
99 return MAX_LOBJ;
100 }
101} 107}
102 108
103 109
diff --git a/ltm.c b/ltm.c
index c943bc7b..c28f9122 100644
--- a/ltm.c
+++ b/ltm.c
@@ -92,10 +92,9 @@ const char *luaT_objtypename (lua_State *L, const TValue *o) {
92 Table *mt; 92 Table *mt;
93 if ((ttistable(o) && (mt = hvalue(o)->metatable) != NULL) || 93 if ((ttistable(o) && (mt = hvalue(o)->metatable) != NULL) ||
94 (ttisfulluserdata(o) && (mt = uvalue(o)->metatable) != NULL)) { 94 (ttisfulluserdata(o) && (mt = uvalue(o)->metatable) != NULL)) {
95 TValue name; 95 const TValue *name = luaH_Hgetshortstr(mt, luaS_new(L, "__name"));
96 int hres = luaH_getshortstr(mt, luaS_new(L, "__name"), &name); 96 if (ttisstring(name)) /* is '__name' a string? */
97 if (hres == HOK && ttisstring(&name)) /* is '__name' a string? */ 97 return getstr(tsvalue(name)); /* use it as type name */
98 return getstr(tsvalue(&name)); /* use it as type name */
99 } 98 }
100 return ttypename(ttype(o)); /* else use standard type name */ 99 return ttypename(ttype(o)); /* else use standard type name */
101} 100}
diff --git a/manual/manual.of b/manual/manual.of
index e3cbddb3..aaaf15b7 100644
--- a/manual/manual.of
+++ b/manual/manual.of
@@ -6473,7 +6473,7 @@ Otherwise, returns the metatable of the given object.
6473 6473
6474@LibEntry{ipairs (t)| 6474@LibEntry{ipairs (t)|
6475 6475
6476Returns three values (an iterator function, the table @id{t}, and 0) 6476Returns three values (an iterator function, the value @id{t}, and 0)
6477so that the construction 6477so that the construction
6478@verbatim{ 6478@verbatim{
6479for i,v in ipairs(t) do @rep{body} end 6479for i,v in ipairs(t) do @rep{body} end
diff --git a/testes/sort.lua b/testes/sort.lua
index 45014652..7e566a5a 100644
--- a/testes/sort.lua
+++ b/testes/sort.lua
@@ -13,6 +13,8 @@ do print "testing 'table.create'"
13 assert(#t == i - 1) 13 assert(#t == i - 1)
14 t[i] = 0 14 t[i] = 0
15 end 15 end
16 for i = 1, 20 do t[#t + 1] = i * 10 end
17 assert(#t == 40 and t[39] == 190)
16 assert(not T or T.querytab(t) == 10000) 18 assert(not T or T.querytab(t) == 10000)
17 t = nil 19 t = nil
18 collectgarbage() 20 collectgarbage()