Lua: Cleanup ProtoField_time

Reverted some unneeded changes from 7f074364 because it's currently
only used for FT_ABSOLUTE_TIME.

Also fixed some small indent issues.

Change-Id: I923e35bf8ad4e991518bee973b87d4be06137463
Reviewed-on: https://code.wireshark.org/review/12539
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Stig Bjørlykke 2015-12-11 19:52:15 +01:00 committed by Anders Broman
parent 3d0f9a4397
commit bfac764797
1 changed files with 10 additions and 15 deletions

View File

@ -763,10 +763,10 @@ PROTOFIELD_BOOL(bool,FT_BOOLEAN)
static int ProtoField_time(lua_State* L,enum ftenum type) {
ProtoField f;
const gchar* abbr = NULL;
const gchar* abbr = check_field_name(L,1,type);
const gchar* name = luaL_optstring(L,2,abbr);
unsigned base = (unsigned)luaL_optinteger(L,3,ABSOLUTE_TIME_LOCAL);
const gchar* blob = NULL;
const gchar* blob = luaL_optstring(L,4,NULL);
if (!name[0]) {
luaL_argerror(L, 2, "cannot be an empty string");
@ -774,15 +774,10 @@ static int ProtoField_time(lua_State* L,enum ftenum type) {
}
if (type == FT_ABSOLUTE_TIME) {
abbr = check_field_name(L,1,type);
blob = luaL_optstring(L,4,NULL);
if (base < ABSOLUTE_TIME_LOCAL || base > ABSOLUTE_TIME_DOY_UTC) {
luaL_argerror(L, 3, "Base must be either LOCAL, UTC, or DOY_UTC");
return 0;
}
} else {
abbr = check_field_name(L,1,type);
blob = luaL_optstring(L,3,NULL);
if (base < ABSOLUTE_TIME_LOCAL || base > ABSOLUTE_TIME_DOY_UTC) {
luaL_argerror(L, 3, "Base must be either LOCAL, UTC, or DOY_UTC");
return 0;
}
}
f = g_new(wslua_field_t,1);
@ -796,9 +791,9 @@ static int ProtoField_time(lua_State* L,enum ftenum type) {
f->base = base;
f->mask = 0;
if (blob && strcmp(blob, f->name) != 0) {
f->blob = g_strdup(blob);
f->blob = g_strdup(blob);
} else {
f->blob = NULL;
f->blob = NULL;
}
pushProtoField(L,f);
@ -845,9 +840,9 @@ static int ProtoField_other(lua_State* L,enum ftenum type) {
f->base = BASE_NONE;
f->mask = 0;
if (blob && strcmp(blob, f->name) != 0) {
f->blob = g_strdup(blob);
f->blob = g_strdup(blob);
} else {
f->blob = NULL;
f->blob = NULL;
}
pushProtoField(L,f);