+ if eq_cfg then
+ fvalue = cvalue
+ end
+ end
+
+ -- removed parameter "section" from function call because used/accepted nowhere
+ -- also removed call to function "transfer"
+ local vvalue, errtxt = self:validate(fvalue)
+
+ -- error handling; validate return "nil"
+ if not vvalue then
+ if novld then -- and "novld" set
+ return -- then exit without raising an error
+ end
+
+ if fexist then -- and there is a formvalue
+ self:add_error(section, "invalid", errtxt or self.title .. ": invalid")
+ return -- so data are invalid
+ elseif not rm_opt then -- and empty formvalue but NOT (rmempty or optional) set
+ self:add_error(section, "missing", errtxt or self.title .. ": missing")
+ return -- so data is missing
+ elseif errtxt then
+ self:add_error(section, "invalid", errtxt)
+ return
+ end
+-- error ("\n option: " .. self.option ..
+-- "\n fvalue: " .. tostring(fvalue) ..
+-- "\n fexist: " .. tostring(fexist) ..
+-- "\n cvalue: " .. tostring(cvalue) ..
+-- "\n vvalue: " .. tostring(vvalue) ..
+-- "\n vexist: " .. tostring(vexist) ..
+-- "\n rm_opt: " .. tostring(rm_opt) ..
+-- "\n eq_cfg: " .. tostring(eq_cfg) ..
+-- "\n eq_def: " .. tostring(eq_def) ..
+-- "\n novld : " .. tostring(novld) ..
+-- "\n errtxt: " .. tostring(errtxt) )
+ end
+
+ -- lets continue with value returned from validate
+ eq_cfg = ( vvalue == cvalue ) -- update equal_config flag
+ local vexist = ( vvalue and (#vvalue > 0) ) and true or false -- not "nil" and "not empty"
+ local eq_def = ( vvalue == self.default ) -- equal_default flag
+
+ -- (rmempty or optional) and (no data or equal_default)
+ if rm_opt and (not vexist or eq_def) then
+ if self:remove(section) then -- remove data from UCI
+ self.section.changed = true -- and push events
+ end
+ return
+ end
+
+ -- not forcewrite and no changes, so nothing to write
+ if not self.forcewrite and eq_cfg then
+ return
+ end
+
+ -- we should have a valid value here
+ assert (vvalue, "\n option: " .. self.option ..
+ "\n fvalue: " .. tostring(fvalue) ..
+ "\n fexist: " .. tostring(fexist) ..
+ "\n cvalue: " .. tostring(cvalue) ..
+ "\n vvalue: " .. tostring(vvalue) ..
+ "\n vexist: " .. tostring(vexist) ..
+ "\n rm_opt: " .. tostring(rm_opt) ..
+ "\n eq_cfg: " .. tostring(eq_cfg) ..
+ "\n eq_def: " .. tostring(eq_def) ..
+ "\n errtxt: " .. tostring(errtxt) )
+
+ -- write data to UCI; raise event only on changes
+ if self:write(section, vvalue) and not eq_cfg then