list(POP_FRONT) list(POP_BACK) escape sequence handling
Actual
list(POP_FRONT)
and list(POP_BACK)
re-evaluates escape sequences changing the remaining contents after removing the first/last item.
Given list defined as [[\\]] [[\]] [[\"]] [["]] [[\/]] [[/]] [[\t]] "\t"
list(POP_BACK)
reduces the list to the following on each call:
-
[[\]] [[]] [[\"]] [["]] [[\/]] [[/]] [[\t]]
popping"\t"
. -
[[]] [[]] [[\"]] [["]] [[\/]] [[/]]
popping[[\t]]
. -
[[\"]] [["]] [[\/]]
popping[[/]]
and raising CMP0007.
list(POP_FRONT)
is stranger, popping the first three items on the first iteration:
-
[["]] [[\/]] [[/]] [[\t]] "\t"
popping\;;\"
?
I can follow that list(POP_BACK)
is unravelling the escape characters in the string; but do not see how list(POP_FRONT)
is combining the first three (3) items on its first call.
Expected
I would expect these calls not to modify content of the list other than the element being popped.
Test Case
set (ENTITIES [[\\]] [[\]] [[\"]] [["]] [[\/]] [[/]] [[\t]] "\t")
set (ent "${ENTITIES}")
message (STATUS "ENTITIES: \t\t[${ent}]")
while (ent)
list (POP_FRONT ent tok)
message (STATUS "POP_FRONT:[${tok}]\t[${ent}]")
endwhile ()
set (ent "${ENTITIES}")
message (STATUS "ENTITIES: \t\t[${ent}]")
while (ent)
list (POP_BACK ent tok)
message (STATUS "POP_BACK: [${tok}]\t[${ent}]")
endwhile ()
Use Case
This was encountered as the lists hold entity pairs for a set of codecs - this example is for JSON encoding. Other entity tables are used for XML, URL, etc.
Workaround
I'll try to implement a string(SUBSTRING)
based solution for our use-case; the lists will not contain ;
as part of any item as we use "generator-expression" substitutions ($<SEMICOLON>
) in their definitions.