Am 18.09.2019 um 22:13 schrieb Gavin Smith:
> On Wed, Sep 18, 2019 at 9:07 PM Hans-Bernhard Bröker
> <[email protected]> wrote:
>> OTOH if what these calls are supposed to be doing is really is "copy n
>> bytes", it would be more honest to replace them by variations of
>>
>>         memcpy (dest + strlen(dest), src, n);
>>
>> (with some actual book-keeping to replace the repeated determination of
>> strlen(dest), obviously).
>>
> 
> This may be better although we'd have to check that the final string
> remained null-terminated in all instances.

For the cases in question, that'd be trivially easy, because the code
already knows exacly how many bytes it takes:

        query-regex-replace(
          strncat(\([^,]*\),\([^)]*\)
          memcpy(\1 + strlen(\1)\, \2 + 1
        )

(no warranty on the escaping and syntax...)

Reply via email to