aat

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

commit e55b0ac8ac206b514a97a73da05d42a34eee0300
parent 237f7d9ab209abf97fa539be34e358f2048c39a2
Author: Jan Pobrislo <ccx@webprojekty.cz>
Date:   Tue, 29 Oct 2013 09:11:15 +0100

fix some regexps
Diffstat:
Mbin/query.awk | 14+++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/bin/query.awk b/bin/query.awk @@ -4,8 +4,10 @@ BEGIN { } function out(str) { - printf "%s", str - last_out = str + if(length(str)) { + printf "%s", str + last_out = str + } } # called for expanding {< >} @@ -43,9 +45,9 @@ function expand_query( expanded) { function parse_line(line) { while(length(line)) { - if(DEBUG) printf "%d: \"%s\"\n", in_string, line >"/dev/stderr" + if(DEBUG) printf "%d: →%s←\n", in_string, line >"/dev/stderr" if(in_string) { - if(match(line, /^\(\\[^"]\|[^"\\]\)/)) { + if(match(line, /^(\\[^"]|[^"\\])+/)) { out(substr(line, 1, RLENGTH)) line = substr(line, RLENGTH+1) } @@ -60,6 +62,7 @@ function parse_line(line) { # is this valid? } else { print "string parsing error" >"/dev/stderr" + if(DEBUG) printf "%d: →%s←\n", in_string, line >"/dev/stderr" exit 1 } } else if(match(line, /[<"]/)) { @@ -69,7 +72,8 @@ function parse_line(line) { line = substr(line, 2) in_string = 1 } else { - if(match(last_out, /[\n\t([ ]$/) && match(line, /^<\([a-zA-Z0-9._]\|'[^']*'\)*>/)) { + if(DEBUG) printf "q: →%s← →%s←\n", last_out, line >"/dev/stderr" + if(match(last_out, /[\n\t([ ]$/) && match(line, /^<([a-zA-Z0-9._]|'[^']*')*>/)) { expand_remaining = substr(line, 2, RLENGTH-2) line = substr(line, RLENGTH+1) out(expand_query())