Skip to content

Commit 5596b6e

Browse files
committed
FIX: ENTAB strips first character from line
fixes: Oldes/Rebol-issues#2216
1 parent 53c991f commit 5596b6e

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/core/s-ops.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,10 @@ static REBYTE seed_str[SEED_LEN] = {
541541

542542
// Copy chars thru end-of-line (or end of buffer):
543543
while (index < len) {
544-
if ((*dp++ = bp[index++]) == '\n') break;
544+
if ((*dp++ = bp[index++]) == '\n') {
545+
index--;
546+
break;
547+
}
545548
}
546549
}
547550
}
@@ -588,7 +591,10 @@ static REBYTE seed_str[SEED_LEN] = {
588591

589592
// Copy chars thru end-of-line (or end of buffer):
590593
while (index < len) {
591-
if ((*dp++ = bp[index++]) == '\n') break;
594+
if ((*dp++ = bp[index++]) == '\n') {
595+
index--;
596+
break;
597+
}
592598
}
593599
}
594600
}

src/tests/units/series-test.r3

+17
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,23 @@ Rebol [
466466

467467
===end-group===
468468

469+
===start-group=== "DETAB / ENTAB"
470+
471+
--test-- "DETAB"
472+
--assert " A^/ B" = detab "^-A^/^-B"
473+
--assert " A^/ Š" = detab "^-A^/^-Š"
474+
--assert " A^/ B" = detab/size "^-A^/^-B" 2
475+
--assert " A^/ Š" = detab/size "^-A^/^-Š" 2
476+
--test-- "ENTAB"
477+
;@@ https://github.com/Oldes/Rebol-issues/issues/2216
478+
--assert "^-A^/^-B" = entab { A^/ B}
479+
--assert "^-A^/^-Š" = entab { A^/ Š}
480+
--assert "^-^-A^/^-^-B" = entab/size { A^/ B} 2
481+
--assert "^-^-A^/^-^-Š" = entab/size { A^/ Š} 2
482+
--assert "^-^-^- A" = entab { ^- A}
483+
484+
===end-group===
485+
469486
===start-group=== "AS coercion"
470487

471488
--test-- "AS datatype! any-string!"

0 commit comments

Comments
 (0)