Don't set $(match) during process selection and DeleteItem*

This causes EvalContext to disappear from significant amount of code.
Move SelectItemMatching to the place of use
Move MatchRegion to the place of use
Move a few $(match)-setting functions to cf-agent.
CFEngine functions ought not to reset $(match) context

Hence, they should not use FullTextMatch function
Move BlockTextMatch/FullTextMatch to cf-agent, as only useful there

Those functions set $(match) scope, which is only well-defined for
cf-agent (indeed, there is a check inside to only set it for
cf-agent). Hence any use of those functions outside of cf-agent
is a bug and has been eliminated.
Don't check for agent type, it's always cf-agent
Instead of using $(match) scope, return captures from matching function

This change makes a few CFEngine function implementations to use
matches returned directly from the StringMatchCaptures instead of
relying on side-effects of FullTextMatch.
Fix escape() testsuite

Previous tests were broken due to way regmatch() matched strings.
Copy args in FnCallNew, constify ExpandFnCall
Constify ExpandPrivateRval
Constify CompareRval, CompareRlist
Constify GetListReferenceArgument
Merge remote-tracking branch 'dottedmag/cleanups/fulltextmatch-removal'
Constify JsonWrite/Compact
libpromises/evalfunction.c: treat bad data as 0 for mean and variance
Merge pull request #1250 from tzz/feature/list-folding-utility-functions2

libpromises/evalfunction.c: treat bad data as 0 for mean and variance
Redmine#3279: datatype(), a function which returns the top-level type of a data container
Redmine#3279: datatype() acceptance test