# HG changeset patch # User Matti Hamalainen # Date 1424286832 -7200 # Node ID a2cd862315c57290d786663ecd1d1dff655116d9 # Parent 7638fa9d191f1994a28439d130a90b85de1ec1ee Use th_get_boolean() in configuration parser. diff -r 7638fa9d191f -r a2cd862315c5 th_config.c --- a/th_config.c Wed Feb 18 21:13:44 2015 +0200 +++ b/th_config.c Wed Feb 18 21:13:52 2015 +0200 @@ -605,47 +605,37 @@ // Boolean parsing mode if (isStart) { - tmpCh = c; isStart = FALSE; + strPos = 0; } - else if (VISEND(c)) - { - BOOL tmpBool = FALSE; - - // End of boolean parsing - switch (th_toupper(tmpCh)) - { - case 'Y': - case 'T': - case '1': - tmpBool = TRUE; - break; - case 'N': - case 'F': - case '0': - tmpBool = FALSE; - break; - - default: - isError = TRUE; - } - - if (isError) - { - th_ioctx_error(ctx, -1, - "Invalid boolean value for '%s'.\n", - item->name); - parseMode = PM_ERROR; - } + if (th_isalnum(c)) + { + VADDCH(c) else + isError = TRUE; + } + else + if (VISEND(c)) + { + BOOL tmpBool; + tmpStr[strPos] = 0; + isError = !th_get_boolean(tmpStr, &tmpBool); + if (!isError) { *(item->v.val_bool) = tmpBool; - prevMode = parseMode; parseMode = PM_IDLE; } } + + if (isError) + { + th_ioctx_error(ctx, -1, + "Invalid boolean value for '%s'.\n", + item->name); + parseMode = PM_ERROR; + } c = -1; break; }