[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] funcsub func needed
From: |
Kjetil Flovild-Midtlie |
Subject: |
Re: [bug-gawk] funcsub func needed |
Date: |
Mon, 08 Dec 2014 09:13:29 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 |
Yes the awk impl of this new func is:
# kind of like gensub(global flag on)
# but expands grp-values
# ( userData is also a new feature )
#
# 60 TIMES slower than gensub !!!!!!!!!!
#
# .. I need a C version of this
# replaceFn has this signature:: (arr,userData) returns string
function funcsub(regex,replaceFn,userData,target){
newVal = target
while (match(target,regex,grps)) {
singleHit = substr(target, RSTART, RLENGTH);
sub(singleHit, @replaceFn(grps,userData),newVal)
# shift;
target = substr(target, RSTART + RLENGTH);
}
return newVal
}
Re: [bug-gawk] funcsub func needed, Kjetil Flovild-Midtlie, 2014/12/09
Re: [bug-gawk] funcsub func needed, Kjetil Flovild-Midtlie, 2014/12/09