From: Alan T. DeKok Date: Sun, 18 Sep 2022 13:36:38 +0000 (-0400) Subject: indent for nested xlat expansion X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=57e09a383bf8dbd37298600a8e387b0a74a35bf8;p=thirdparty%2Ffreeradius-server.git indent for nested xlat expansion which makes the debug output rather a lot easier to read --- diff --git a/src/lib/unlang/xlat.c b/src/lib/unlang/xlat.c index 89a65efe8ee..bd76dde91a5 100644 --- a/src/lib/unlang/xlat.c +++ b/src/lib/unlang/xlat.c @@ -232,6 +232,21 @@ static int unlang_xlat_push_internal(TALLOC_CTX *ctx, bool *p_success, fr_value_ state->success = p_success; state->ctx = ctx; + if (node) switch (node->type) { + case XLAT_GROUP: + case XLAT_BOX: + break; + + case XLAT_TMPL: + if (tmpl_is_data(node->vpt)) break; + FALL_THROUGH; + + default: + RDEBUG("| %s", node->fmt); + break; + } + RINDENT(); + /* * Initialise the input and output lists */ @@ -303,6 +318,7 @@ static unlang_action_t unlang_xlat_repeat(rlm_rcode_t *p_result, request_t *requ fr_dlist_talloc_free(&state->out); if (unlang_xlat_push(state->ctx, state->success, &state->out, request, child, false) < 0) { *p_result = RLM_MODULE_FAIL; + REXDENT(); return UNLANG_ACTION_STOP_PROCESSING; } return UNLANG_ACTION_PUSHED_CHILD; @@ -322,12 +338,14 @@ static unlang_action_t unlang_xlat_repeat(rlm_rcode_t *p_result, request_t *requ case XLAT_ACTION_DONE: if (state->success) *state->success = true; *p_result = RLM_MODULE_OK; + REXDENT(); return UNLANG_ACTION_CALCULATE_RESULT; case XLAT_ACTION_FAIL: fail: if (state->success) *state->success = false; *p_result = RLM_MODULE_FAIL; + REXDENT(); return UNLANG_ACTION_CALCULATE_RESULT; default: @@ -381,12 +399,14 @@ static unlang_action_t unlang_xlat(rlm_rcode_t *p_result, request_t *request, un case XLAT_ACTION_DONE: if (state->success) *state->success = true; *p_result = RLM_MODULE_OK; + REXDENT(); return UNLANG_ACTION_CALCULATE_RESULT; case XLAT_ACTION_FAIL: fail: if (state->success) *state->success = false; *p_result = RLM_MODULE_FAIL; + REXDENT(); return UNLANG_ACTION_CALCULATE_RESULT; default: @@ -457,6 +477,7 @@ static unlang_action_t unlang_xlat_resume(rlm_rcode_t *p_result, request_t *requ case XLAT_ACTION_DONE: if (state->success) *state->success = true; *p_result = RLM_MODULE_OK; + REXDENT(); return UNLANG_ACTION_CALCULATE_RESULT; case XLAT_ACTION_PUSH_UNLANG: @@ -470,6 +491,7 @@ static unlang_action_t unlang_xlat_resume(rlm_rcode_t *p_result, request_t *requ case XLAT_ACTION_FAIL: if (state->success) *state->success = false; *p_result = RLM_MODULE_FAIL; + REXDENT(); return UNLANG_ACTION_CALCULATE_RESULT; /* DON'T SET DEFAULT */ } @@ -477,6 +499,7 @@ static unlang_action_t unlang_xlat_resume(rlm_rcode_t *p_result, request_t *requ fr_assert(0); /* Garbage xlat action */ *p_result = RLM_MODULE_FAIL; + REXDENT(); return UNLANG_ACTION_CALCULATE_RESULT; } diff --git a/src/lib/unlang/xlat_eval.c b/src/lib/unlang/xlat_eval.c index fa542c67d55..402eb366e2d 100644 --- a/src/lib/unlang/xlat_eval.c +++ b/src/lib/unlang/xlat_eval.c @@ -743,6 +743,7 @@ xlat_action_t xlat_frame_eval_resume(TALLOC_CTX *ctx, fr_dcursor_t *out, xa = resume(ctx, out, XLAT_CTX(exp->call.inst->data, t->data, t->mctx, rctx), request, result); VALUE_BOX_TALLOC_LIST_VERIFY(result); + REXDENT(); RDEBUG2("| %%%c%s:...%c", (exp->call.func->input_type == XLAT_INPUT_ARGS) ? '(' : '{', exp->call.func->name, @@ -763,6 +764,7 @@ xlat_action_t xlat_frame_eval_resume(TALLOC_CTX *ctx, fr_dcursor_t *out, case XLAT_ACTION_FAIL: break; } + RINDENT(); return xa; } @@ -835,8 +837,12 @@ xlat_action_t xlat_frame_eval_repeat(TALLOC_CTX *ctx, fr_dcursor_t *out, request, result); VALUE_BOX_TALLOC_LIST_VERIFY(result); - if (RDEBUG_ENABLED2) xlat_debug_log_expansion(request, *in, &result_copy, __LINE__); - fr_dlist_talloc_free(&result_copy); + if (RDEBUG_ENABLED2) { + REXDENT(); + xlat_debug_log_expansion(request, *in, &result_copy, __LINE__); + RINDENT(); + fr_dlist_talloc_free(&result_copy); + } switch (xa) { case XLAT_ACTION_FAIL: @@ -856,7 +862,9 @@ xlat_action_t xlat_frame_eval_repeat(TALLOC_CTX *ctx, fr_dcursor_t *out, case XLAT_ACTION_DONE: /* Process the result */ fr_dcursor_next(out); + REXDENT(); xlat_debug_log_result(request, *in, fr_dcursor_current(out)); + RINDENT(); break; } }