aat

git mirror of https://ccx.te2000.cz/bzr/aat
git clone https://ccx.te2000.cz/git/aat
Log | Files | Refs | README

commit 07797588c0a2ba7b9d71c1bcdb9fd64f8a75adef
parent 721a1f05d3a54107cf5bf5f474f29eacb529dab9
Author: Jan Pobrislo <ccx@webprojekty.cz>
Date:   Tue,  8 Jul 2014 22:27:15 +0200

generalize the filename changing to all macros
Diffstat:
Mbin/aat.awk | 13+++++--------
1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/bin/aat.awk b/bin/aat.awk @@ -93,44 +93,41 @@ function macro_readinto(args, varname, fname) { token(varname " = \"" $0 "\\n\"\n") } close(filename) - filename = file_old } function call_macro(name, args, file_old) { if(DEBUG) printf "call_macro(\"%s\", \"%s\")\n", name, args >"/dev/stderr" + + # store current filename so macros can change it, restore before function exits + file_old = filename + # Macro to recursively parse another template if(name == "include"){ - file_old = filename find_file(args) while(getline <filename) { parse_line($0) } close(filename) - filename = file_old } # Macro to insert another file as verbatim code else if(name == "awk"){ - file_old = filename find_file(args) tok_type=T_AWK while(getline <filename) { token($0 "\n") } close(filename) - filename = file_old } # Macro to insert another file as text else if(name == "text"){ - file_old = filename find_file(args) tok_type=T_TEXT while(getline <filename) { token($0 "\n") } close(filename) - filename = file_old } # Macro to insert source filename as a variable into produced code @@ -138,7 +135,6 @@ function call_macro(name, args, file_old) { tok_type=T_AWK token("filename = \"" gsub(/["\\]/, "\\&", args) "\n") close(filename) - filename = file_old } # Macro to read content of a file into a variable @@ -175,6 +171,7 @@ function call_macro(name, args, file_old) { tok_type=T_AWK token("@" name " " args "\n") } + filename = file_old } function parse_line(line) {