From 2235d756dfab91fc63af0665491c6fbbd339f164 Mon Sep 17 00:00:00 2001 From: totoro Date: Tue, 12 Dec 2017 11:09:56 +0900 Subject: [PATCH] fix getting bool from web_arg with default value which the found value case was not evaluated to the right boolean value. Because the name was found the previous version always return 'true' as value, but it's not necessary the right value. --- web/CXM_web_arg_utils.anubis | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/web/CXM_web_arg_utils.anubis b/web/CXM_web_arg_utils.anubis index 3c37777..e45a318 100644 --- a/web/CXM_web_arg_utils.anubis +++ b/web/CXM_web_arg_utils.anubis @@ -295,15 +295,23 @@ public define Maybe(Bool) List(Web_arg) lwa, String arg_name ) = +// println("get_mb_Bool "+arg_name); if web_arg_value(lwa, arg_name) is { not_found then if web_arg_value(lwa, "~"+arg_name) is { - not_found then failure, - found(_) then success(false) + not_found then + //println("failure"); + failure, + found(_) then + //println("success(false)"); + success(false) }, - found(_) then success(true) + found(value) then + with return_v = to_Bool(value), +// println("value = '"+value+"' result = "+to_String(return_v)+" success("+to_String(return_v)+")"); + success(return_v) }. public define Bool @@ -312,10 +320,14 @@ public define Bool List(Web_arg) lwa, String arg_name ) = +// println("get_Bool "+arg_name); if web_arg_value(lwa, arg_name) is { not_found then false, - found(value) then to_Bool(value) + found(value) then + with return_v = to_Bool(value), +// println("value = '"+value+"' result = "+to_String(return_v)); + return_v }. public define Bool @@ -325,10 +337,17 @@ public define Bool String arg_name, Bool default_value ) = +// println("get_Bool with default ["+arg_name+"] default = "+to_String(default_value)); if web_arg_value(lwa, arg_name) is { - not_found then default_value, - found(_) then true + not_found then + //println("return default_value"); + default_value, + found(value) then + with return_v = to_Bool(value), + //println("value = '"+value+"' result = "+to_String(return_v)); + return_v + //true }. public define Maybe(Bool) -- libgit2 0.21.4