Lua: FieldInfo '==' check isn't really equality
The FieldInfo metamethod for equality (letting you use the '==' operator) doesn't check for equality, but rather if the left-hand side is within the right-hand side. It should be equality instead. Also, all of the FieldInfo operate overloads should push a boolean even if they're false result. Bug: 10820 Change-Id: Ibddaab29713f26d22ddb4d5804b9edb15e93fd79 Reviewed-on: https://code.wireshark.org/review/6186 Petri-Dish: Hadriel Kaplan <hadrielk@yahoo.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
parent
6d6ba642b9
commit
445ddc8336
|
@ -308,17 +308,15 @@ WSLUA_METAMETHOD FieldInfo__eq(lua_State* L) {
|
|||
FieldInfo l = checkFieldInfo(L,1);
|
||||
FieldInfo r = checkFieldInfo(L,2);
|
||||
|
||||
if (l->ws_fi->ds_tvb != r->ws_fi->ds_tvb) {
|
||||
WSLUA_ERROR(FieldInfo__eq,"Data source must be the same for both fields");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (l->ws_fi->start <= r->ws_fi->start && r->ws_fi->start + r->ws_fi->length <= l->ws_fi->start + l->ws_fi->length) {
|
||||
/* it is not an error if their ds_tvb are different... they're just not equal */
|
||||
if (l->ws_fi->ds_tvb == r->ws_fi->ds_tvb &&
|
||||
l->ws_fi->start == r->ws_fi->start &&
|
||||
r->ws_fi->length == l->ws_fi->length) {
|
||||
lua_pushboolean(L,1);
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
lua_pushboolean(L,0);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
WSLUA_METAMETHOD FieldInfo__le(lua_State* L) {
|
||||
|
@ -331,10 +329,10 @@ WSLUA_METAMETHOD FieldInfo__le(lua_State* L) {
|
|||
|
||||
if (r->ws_fi->start + r->ws_fi->length <= l->ws_fi->start + l->ws_fi->length) {
|
||||
lua_pushboolean(L,1);
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
lua_pushboolean(L,0);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
WSLUA_METAMETHOD FieldInfo__lt(lua_State* L) {
|
||||
|
@ -349,10 +347,10 @@ WSLUA_METAMETHOD FieldInfo__lt(lua_State* L) {
|
|||
|
||||
if (r->ws_fi->start + r->ws_fi->length < l->ws_fi->start) {
|
||||
lua_pushboolean(L,1);
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
lua_pushboolean(L,0);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Gets registered as metamethod automatically by WSLUA_REGISTER_META */
|
||||
|
|
Loading…
Reference in New Issue