Add negative bounds checks for string_head and string_tail

(cherry picked from commit d4560179b5d3c301e9ef501948f6f110deeaac0d)
Fail when read_file is called with a negative size

(cherry picked from commit 3d41d8dcbdeb4d75fba5ba8e3ccf3243fbc5885a)
readfile and textxform functions do not rely on 4k limit anymore

(cherry picked from commit 308ca23030566030edf0d17f73c34c2f4f6856eb)
Added text_xform tests for large sizes

(cherry picked from commit ace639a82c99bc984de556a0a627f2b2804ddac7)
CF_INFINITY is not a limit for buffer size, it's just an indication that policy has the parameter 'inf'.

(cherry picked from commit 616c51993547a178b258bcc4143948d5293f4e04)
Comment for clarity.

(cherry picked from commit 2b7e9d3bae469d842cf5f349207fbf5a05c53689)
Redmine#6674 Modifying hashing function to add info about index boudaries

When using multi-index arrays hash function is looping through each
character in index without modifying hashed value once moving form one
index to another. That's why entries like a[te][st], a[tes][t], a[t][e][st]
and all other variations are resulting in having exactly the same hash.
While trying to add new array entry to RB tree having the same characters
in indexes previous entry is updated instead of new one being created.
(cherry picked from commit 0f84c0c4e0ff5d755cc2447918ffb2c3b8f24d46)
Adjust acceptance test for Redmine#6674
(cherry picked from commit 5e4b4c1bb1fc7506f60361f71cb8c392578c4709)
Fix test relying on specific order of getindices.

As getindices returned list is not guaranteed to be in any specific
order we should sort the results before comparing expected and actual
test results.
(cherry picked from commit 165a1c9feeaf06b456cdb782ecb2574a36a4d299)
Fixing arrays hashing.

To avoid having the same hashes for variables like a[10] and a1[0]
array boundary hash moved above index hashing.
(cherry picked from commit b87c03c1c8f5964fa34ae90252362ff4d5365671)
Test case testing multi-index array hashing updated.

Now cases like a[10] and a1[0] covered while checking if hashing is
working accurately.
(cherry picked from commit fca4d13eda78143ebb53dfcb819e76a40ca81e56)
Fix test relying on ordering of array elements returning by mergedata.

This one is simple change of expected strings. We can think how to modify
this test in future to sort the merged array elements before comparing.
(cherry picked from commit c065939cdbfe1130dca404be82db17172acaf30a)
Merge pull request #2041 from pasinskim/3.6.x

Redmine#6674 cherries