Redmine #5452: add acceptance test for maparray()

(cherry picked from commit ea833b18e2de873d64a26c5e7b0d26e9e7a60e3e)
tests/acceptance/01_vars/02_functions/staging/maparray.cf: minor changes, still in staging

(cherry picked from commit eed31885a98ac1c63c2b7b3b0fd53ae98121d861)
Redmine#5882: add INFORM message when the given permissions will be filtered

(cherry picked from commit e857b30a52f2e566cc9fa8340601144f94c060ec)
Leak-fix: free db_handles[*].filename in CloseAllDBExit().

The filename was created by xstrdup() via DBIdToPath() and
MapNameCopy(), so we have a duty to free() it eventually.

Cowardice: I'm only doing it, for now, if all DB users finished, since
I don't know what pain it might cause for one of them that's still
running ... but I left a TODO comment to look into that.

(cherry picked from commit 5460cff2377db1b511e4701775e9871e7217fe00)
Move some fileno() calls outside locked intervals.

They don't need to be inside.

(cherry picked from commit b363ec92b36effcdff70b865b57c01d324fbb7b8)
Close FILE* also on premature returns from cf_pclose().

At the same time, simplify the locking and make sure we don't call
cf_pwait(-1), which made no sense.  The check that CHILDREN is
non-NULL could have been invalidated, between unlock and lock, by
another thread's attempt to realloc() it failing, so the locking
change could avoid a crash.

(cherry picked from commit ae5b3559dfc6c1f9d2c869734a6dfaaa45358110)
Leak-fix: free(CHILDREN) when done with array.

If it makes sense for CloseChildrenFD() to close all the child FDs,
surely it also makes sense to clear the array.  The previous commit's
changes to locking in cf_pclose() make this safe.

(cherry picked from commit 83f6bb66d44ffde9d95644212476fcff7bb14318)
Rename a variable for clarity.

SetChildFD's "new_fd" was just a new size for a buffer (indexed by
fd), not actually a "real" fd in any sense.

Add a TODO about why high fd values are reported as error (but handled
gracefully, so they're no real problem).  Not clear from the context.

(cherry picked from commit aa5c81170a70d39359e1acd7e0a6ce5860c28e6c)
Leak-fix: clean up lexer state after parsing.

Also make the provenance of yacc/lex globals explicit.

(cherry picked from commit 921e1d8b5f42137c5f80643e4e11f2921e0e3c22)
Document a known leak.

(cherry picked from commit 52bd57bf49af7b058fffc4e0b692e3fff7cdb215)
Fixes for inappropriate formats in a test.

unsigned long isn't size_t.

It made no sense to use an intptr_t for the counter of a loop bounded
by an int.  The counter is cast to void*, but casting it via intptr_t
(to silence warnings about size-mangling casts) makes more sense than
making the counter actually be an intptr_t.  Likewise, when collecting
the int back from a void*, cast via intptr_t but use an int.

(cherry picked from commit ffadbb0722c5c0da71e86efd147ceb61af67e7fb)
Revert "Leak-fix: clean up lexer state after parsing."

This reverts commit 921e1d8b5f42137c5f80643e4e11f2921e0e3c22.

(cherry picked from commit 4d045243961ab16376fa49fd1838a067085e0148)
Add test for failed_returncodes

When kept_returncodes or repaired_returncodes are specified
failed_returncode is not defaulted properly.

(cherry picked from commit 196fa94ae1cf10d3383b11af9e7f4c3405bc8120)
Redmine#5986: fix to assume all non-specified return codes are failed

(cherry picked from commit 4e58ff2575b51a42829c469a1d4367aabe99a012)
Redmine#5981: clarify --gainroot=env

(cherry picked from commit 6c2f125cb6bd5249c415a33ea98f81f3496b50c0)
Redmine#6063: add 0-9 A-Z _ to allowed context of module protocol

(cherry picked from commit ec62d6798ede560f496f9073c6d82ff72b1ec3cb)
replace tab by spaces

(cherry picked from commit 9457709035bffc6b122645aed2bf21487fcdc744)
Redmine#6063: refine allowed context of module protocol and test with a regex

(cherry picked from commit e38ee7932432b76de9d8e6e28619222236e52c93)
Redmine#6063: move context regex out of the code block and rename the variable helpfully

(cherry picked from commit f641b975c137a5a1e51ee7130d96914c592dc394)
Break up .gitignore and use correct syntax.

Paths relative to the top-level checkout directory should start with a
/; those that don't are matched against every sub-directory, not just
the top level.  Moved the large chunks related to docs and tests to
those directories.  Killed some ancient history along the way.

(cherry picked from commit 1e2dfc514594903e7ebc61565937477be1ddbcf6)