tmpasm: How to print includes ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Some tree nodes have a list of #include directives that need to be reproduced in the C source for proper operation. The saprator on this list is a "\" followed by an "n". For exampe: /target/libs/socket/getnameinfo/includes=#include \n#include \n\n#include \n The ---- example template start ---- # Make a copy to a temp var so the original input doesn't need to be changed # (so that the cache is not modified) put /tmpasm/tmp /target/libs/socket/getnameinfo/includes # replace all "\n" with a real newline in the temp var gsub /tmpasm/tmp {[\\]n} {\n} # make sure each #include is there only once and remove empty lines, but keep # order of #includes (by first appearance). Setting IFS to newline because the # default IFS "any whitespace". # # Note: IFS is a list of characters, not a regex; \n in {} string is # replaced while template parsing # put /tmpasm/IFS {\n} uniq /tmpasm/tmp # print the result print /tmpasm/tmp ---- example template end ----