* Hoist this out of the loop, and make sure it always has a '&' prefix.
*/
if (name2) {
- snprintf(list_buffer, sizeof(list_buffer), "&%s", name2);
- list = list_buffer;
+ snprintf(list_buffer, sizeof(list_buffer), "&%s", name2);
+ } else {
+ snprintf(list_buffer, sizeof(list_buffer), "&%s", fr_table_str_by_value(pair_list_table, unlang_ctx->rules->attr.list_def, "???"));
}
+ list = list_buffer;
/*
* Loop over the entries, rewriting them.
*/
if (*attr == '&') attr++;
+ list = list_buffer;
+
/*
- * Parse the LHS attribute reference for request ref and pair list ref.
- *
- * All of the other tmpl functions do full parsing into tmpls, which we don't want. We
- * just want to know how long the prefix is.
+ * Separate out the various possibilities for the
+ * "name", which could be a list, an attribute
+ * name, or a list followed by an attribute name.
*/
- if (!name2) {
+ {
char const *p, *q;
p = attr;
}
/*
- * Move the list to a separate buffer.
+ * Separate the list reference from the attribute reference.
*/
if (p > (attr + 1)) {
snprintf(ref_buffer, sizeof(ref_buffer), "&%.*s", (int) (p - attr) - 1, attr);
list = ref_buffer;
- /*
- * Move the attribute name to a separate buffer.
- */
if (*p) {
attr = p;
attr = NULL;
}
- } else if (p) {
+ } else if (!p) {
/*
- * There is no list reference, so print out the default one.
+ * No trailing attribute name, the entire thing is a list
+ *
+ * @todo - handle &control[*]
*/
- snprintf(ref_buffer, sizeof(ref_buffer), "&%s", fr_table_str_by_value(pair_list_table, unlang_ctx->rules->attr.list_def, "???"));
- list = ref_buffer;
-
- } else {
- snprintf(ref_buffer, sizeof(ref_buffer), "&%s", attr);
- list = ref_buffer;
+ list = cf_pair_attr(cp);
attr = NULL;
}
}
#
# All of the "update" tests which should also be run with "-S rewrite_update=yes"
#
-KEYWORD_UPDATE_TESTS := update-attr-ref-null update-error-3 update-group-error update-filter update-list-error update-list-null-rhs update-null-value-assign update-remove-index update-exec
+KEYWORD_UPDATE_TESTS := update-attr-ref-null update-error-3 update-group-error update-filter update-list-error update-null-value-assign update-remove-index update-exec
-KEYWORD_UPDATE_REWRITE_TESTS := update-all update-array update-delete update-remove-any update-group update-hex update-remove-value update-index update-remove-list update-prepend unknown-update update-error update-error-2 update-exec-error
+KEYWORD_UPDATE_REWRITE_TESTS := update-all update-array update-delete update-remove-any update-group update-hex update-remove-value update-index update-remove-list update-prepend unknown-update update-error update-error-2 update-exec-error update-list-null-rhs
#
# Migration support. Some of the tests don't run under the new