Skip to content

Commit 769b5e5

Browse files
committed
FIX: update transcode input position only when needed
related to: Oldes/Rebol-issues#1329
1 parent fd8188d commit 769b5e5

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

src/core/l-scan.c

+16-13
Original file line numberDiff line numberDiff line change
@@ -1918,20 +1918,23 @@ extern REBSER *Scan_Full_Block(SCAN_STATE *scan_state, REBYTE mode_char);
19181918
DS_RELOAD(ds); // in case stack moved
19191919
Set_Block(D_RET, blk);
19201920

1921-
if (VAL_BYTE_SIZE(src)) {
1922-
VAL_INDEX(src) = scan_state.end - VAL_BIN(src);
1923-
} else {
1924-
// the scan state used the shared buffer, to get how many codepoints
1925-
// we advanced, we must first mark end...
1926-
len = scan_state.end - bin;
1927-
bin[len+1] = 0;
1928-
// ... and count the real length advanced
1929-
len = Length_As_UTF8_Code_Points(bin);
1930-
//printf("%i\n", len);
1931-
VAL_INDEX(src) = len;
1932-
}
1933-
if (scan_state.opts)
1921+
if (scan_state.opts) {
1922+
// when used transcode with refinements /next, /only and /error
1923+
// the input series position must be updated
1924+
if (VAL_BYTE_SIZE(src)) {
1925+
VAL_INDEX(src) = scan_state.end - VAL_BIN(src);
1926+
} else {
1927+
// the scan state used the shared buffer, to get how many codepoints
1928+
// we advanced, we must first mark end...
1929+
len = scan_state.end - bin;
1930+
bin[len+1] = 0;
1931+
// ... and count the real length advanced
1932+
len = Length_As_UTF8_Code_Points(bin);
1933+
//printf("%i\n", len);
1934+
VAL_INDEX(src) = len;
1935+
}
19341936
Append_Val(blk, src);
1937+
}
19351938
return R_RET;
19361939
}
19371940

0 commit comments

Comments
 (0)