* evaluate boolean expression, using chkcond() to test the primitive cases */
| 263 | * evaluate boolean expression, using chkcond() to test the primitive cases |
| 264 | */ |
| 265 | static bool |
| 266 | execute(ITEM *curitem, void *checkval, void *options, bool calcnot, |
| 267 | bool (*chkcond) (void *checkval, ITEM *item, void *options)) |
| 268 | { |
| 269 | /* since this function recurses, it could be driven to stack overflow */ |
| 270 | check_stack_depth(); |
| 271 | |
| 272 | if (curitem->type == VAL) |
| 273 | return (*chkcond) (checkval, curitem, options); |
| 274 | else if (curitem->val == (int32) '!') |
| 275 | { |
| 276 | return calcnot ? |
| 277 | ((execute(curitem - 1, checkval, options, calcnot, chkcond)) ? false : true) |
| 278 | : true; |
| 279 | } |
| 280 | else if (curitem->val == (int32) '&') |
| 281 | { |
| 282 | if (execute(curitem + curitem->left, checkval, options, calcnot, chkcond)) |
| 283 | return execute(curitem - 1, checkval, options, calcnot, chkcond); |
| 284 | else |
| 285 | return false; |
| 286 | } |
| 287 | else |
| 288 | { /* |-operator */ |
| 289 | if (execute(curitem + curitem->left, checkval, options, calcnot, chkcond)) |
| 290 | return true; |
| 291 | else |
| 292 | return execute(curitem - 1, checkval, options, calcnot, chkcond); |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | /* |
| 297 | * signconsistent & execconsistent called by *_consistent |
no test coverage detected