]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
continue to "next" in xlat alternate. Fixes #1866
authorAlan T. DeKok <aland@freeradius.org>
Wed, 7 Dec 2016 14:56:01 +0000 (09:56 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 7 Dec 2016 14:59:04 +0000 (09:59 -0500)
src/main/xlat.c

index fd2cc52c31811a2b5d54a3987814f52f434898fa..a95f8b2d04bde4ff4578e2f37ba5b92f724f92dc 100644 (file)
@@ -2361,16 +2361,31 @@ static char *xlat_aprint(TALLOC_CTX *ctx, REQUEST *request, xlat_exp_t const * c
                rad_assert(node->child != NULL);
                rad_assert(node->alternate != NULL);
 
-               str = xlat_aprint(ctx, request, node->child, escape, escape_ctx, lvl + 1);
-               if (str) {
-                       XLAT_DEBUG("%.*sALTERNATE got string: %s", lvl, xlat_spaces, str);
-                       break;
-               }
+               /*
+                *      If there are no "next" nodes, call ourselves
+                *      recursively, which is fast.
+                *
+                *      If there are "next" nodes, call xlat_process()
+                *      which does a ton more work.
+                */
+               if (!node->next) {
+                       str = xlat_aprint(ctx, request, node->child, escape, escape_ctx, lvl);
+                       if (str) {
+                               XLAT_DEBUG("%.*sALTERNATE got first string: %s", lvl, xlat_spaces, str);
+                       } else {
+                               str = xlat_aprint(ctx, request, node->alternate, escape, escape_ctx, lvl);
+                               XLAT_DEBUG("%.*sALTERNATE got alternate string %s", lvl, xlat_spaces, str);
+                       }
+               } else {
 
-               XLAT_DEBUG("%.*sALTERNATE going to alternate", lvl, xlat_spaces);
-               str = xlat_aprint(ctx, request, node->alternate, escape, escape_ctx, lvl + 1);
+                       if (xlat_process(&str, request, node->child, escape, escape_ctx) > 0) {
+                               XLAT_DEBUG("%.*sALTERNATE got first string: %s", lvl, xlat_spaces, str);
+                       } else {
+                               (void) xlat_process(&str, request, node->alternate, escape, escape_ctx);
+                               XLAT_DEBUG("%.*sALTERNATE got alternate string %s", lvl, xlat_spaces, str);
+                       }
+               }
                break;
-
        }
 
        /*