Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#148 3 argument version of replace_substring() macro built-in

development
open
nobody
Program (79)
5
2006-05-24
2006-05-24
Tony Balinski
No

This patch allows the macro programmer to drop the
parameter providing the end position of the substring
to replace. Normally replace_substring() is called as

result = replace_substring(string, start, end,
replacement)

This patch allows the call

result = replace_substring(string, start, replacement)

to be the equivalent of

result = replace_substring(string, start,
length(string), replacement)

This patch also changes the behaviour of the function
where negative values of start and end are provided,
and where the start position is beyond the end position
indicated. (These effects were never documented, so
they can be assumed not to break well built macro
programs.) The new handling matches that of changes
made to the substring() built-in, checked in on 2005-02-11.

Finally, this patch corrects a small bug in the
original code: if both string and replacement are
provided to replace_substring() as integers, only the
second would be used. For example, the call

result = replace_substring(12345, 2, 3, 9876)

would give result == "9898766" instead of result ==
"12987645".

Discussion

  • Tony Balinski
    Tony Balinski
    2006-05-24

    patch to replaceSubstringMS() in macro.c

     
    Attachments