REBOL3 tracker
  0.9.12 beta
Ticket #0001501 User: anonymous

Project:



rss
TypeBug Statustested Date21-Feb-2010 22:42
Versionalpha 97 CategoryNative Submitted byBrianH
PlatformAll Severitymajor Priorityurgent

Summary Weird native bug in SOURCE mezzanine
Description There's no apparent bug in the source of SOURCE, but there seems to be an obscure output bug that (so far) only affects the source of the REPLACE function. See the code, and note the difference in the line with the do-break.
Example code
>> print mold :replace
make function! [[
    {Replaces the search value with the replace value within the target series.}
    target [series!] "Series that is being modified"
    search "Value to be replaced"
    replace {Value to replace with (will be called each time if a function)}
    /all "Replace all occurrences"
    /case "Case-sensitive replacement"
    /tail "Return target after the last replacement position"
    /local save-target len value pos do-break
][
    save-target: target
    len: system/contexts/exports/case [
        bitset? :search 1
        any-string? target [
            if any [not any-string? :search tag? :search] [search: form :search]
            length? :search
        ]
        any-block? :search [length? :search]
        true 1
    ]
    do-break: unless all [:break]
    while pick [
        [pos: find target :search]
        [pos: find/case target :search]
    ] not case [
        (value: replace pos)
        target: change/part pos :value len
        do-break
    ]
    either tail [target] [save-target]
]]

>> source replace
replace: make function! [[
    {Replaces the search value with the replace value within the target series.}
    target [series!] "Series that is being modified"
    search "Value to be replaced"
    replace {Value to replace with (will be called each time if a function)}
    /all "Replace all occurrences"
    /case "Case-sensitive replacement"
    /tail "Return target after the last replacement position"
    /local save-target len value pos do-break
][
    save-target: target
    len: system/contexts/exports/case [
        bitset? :search 1
        any-string? target [
            if any [not any-string? :search tag? :search] [search: form :search]
            length? :search
        ]
        any-block? :search [length? :search]
        true 1
    ]
    do-break: unless all [:break]
    while pick [
        [pos: find target :search]
        [pos: find/case target :search]
    ] not case [
        (value: replace pos)
        target: change/part pos :value len
    ]   do-break
    either tail [target] [save-target]
]]

Assigned ton/a Fixed inalpha 98 Last Update6-May-2010 08:24


Comments
(0002044)
meijeru
22-Feb-2010 20:05

The error occurs in this line from SOURCE: print head insert mold get word reduce [word ": "]
So if we do:
>> word: 'replace
>> print head insert mold get word reduce [word ": "]
the error occurs.
But I found out by accident (by making a typing mistake) that if we do
>> print head insert mold get word reduce [word ":"] ; leave out the space after ":"
the error is gone!
(0002045)
meijeru
22-Feb-2010 22:43

Furthermore, if the reduced block does not contain the exact word REPLACE but any other word, the error does not occur. It looks like the REPLACE function is invoked somehow ?!?
(0002053)
BrianH
1-Mar-2010 23:42

Naw, the REPLACE function isn't being invoked, it's something else. The newline at the particular line (index 999) is being printed out like a CR instead of a CRLF. I would be surprised if this problem wasn't Windows-specific. Given the closeness of that index to 1000, it might be a buffer issue in PRINT.
(0002056)
meijeru
2-Mar-2010 12:45

I have tried to provoke that Windows-specific error by printing out a string with a newline at index 999, but wasn't successful.
(0002059)
BrianH
3-Mar-2010 10:31

Same here. It's something about that specific string, though the characters after the index of the printing error don't affect it.
(0002290)
Carl
1-May-2010 05:28

BrianH: "Bug of the week." The bug is in console printing. It's related to UTF-8 encoding at a buffer split precisely on CR insertion at an LF. Classic. Fixed it.

Date User Field Action Change
6-May-2010 08:24 BrianH Status Modified built => tested
1-May-2010 08:40 carl Comment : 0002290 Modified -
1-May-2010 06:12 carl Status Modified reviewed => built
1-May-2010 06:12 carl Fixedin Modified => alpha 98
1-May-2010 06:11 carl Comment : 0002290 Modified -
1-May-2010 06:11 carl Comment : 0002290 Modified -
1-May-2010 05:41 carl Comment : 0002290 Modified -
1-May-2010 05:28 carl Comment : 0002290 Added -
1-May-2010 04:50 carl Severity Modified minor => major
1-May-2010 04:47 carl Priority Modified normal => urgent
1-May-2010 04:47 carl Status Modified submitted => reviewed
1-May-2010 04:47 carl Code Modified -
3-Mar-2010 10:31 BrianH Comment : 0002059 Added -
2-Mar-2010 12:45 meijeru Comment : 0002056 Added -
1-Mar-2010 23:42 BrianH Comment : 0002053 Added -
22-Feb-2010 22:43 meijeru Comment : 0002045 Added -
22-Feb-2010 20:05 meijeru Comment : 0002044 Added -
21-Feb-2010 22:42 BrianH Ticket Added -