Skip to content

Commit f9a10bf

Browse files
committed
FIX: fine tunning CRLF/CR conversion to LF - now the conversion is used with READ/STRING,
but not when converting binary to string (so it is close to R2/Red behavior) ``` ;; on Windows: >> write/lines %foo ["a" "b"] >> read/string %foo == "a^/b^/" ;; but: >> to-string read %foo == "a^M^/b^M^/" ``` Related issue: metaeducation/rebol-issues#2336
1 parent d09fffa commit f9a10bf

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

src/core/a-lib.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ RL_API REBSER* RL_Encode_UTF8_String(void *src, REBCNT len, REBFLG uni, REBFLG o
979979
return Encode_UTF8_String(src, len, uni, opts);
980980
}
981981

982-
RL_API REBSER* RL_Decode_UTF_String(REBYTE *src, REBCNT len, REBINT utf)
982+
RL_API REBSER* RL_Decode_UTF_String(REBYTE *src, REBCNT len, REBINT utf, REBFLG ccr)
983983
/*
984984
** Decode the UTF8 encoded data into Rebol series.
985985
**
@@ -989,9 +989,10 @@ RL_API REBSER* RL_Decode_UTF_String(REBYTE *src, REBCNT len, REBINT utf)
989989
** src - UTF8 encoded data
990990
** len - number of source bytes to convert.
991991
** utf - is 0, 8, +/-16, +/-32.
992+
** ccr - Convert LF/CRLF
992993
*/
993994
{
994-
return Decode_UTF_String(src, len, utf);
995+
return Decode_UTF_String(src, len, utf, ccr);
995996
}
996997

997998

src/core/p-file.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ REBINT Mode_Syms[] = {
266266
// Convert to string or block of strings.
267267
// NOTE: This code is incorrect for files read in chunks!!!
268268
if (args & (AM_READ_STRING | AM_READ_LINES)) {
269-
ser = Decode_UTF_String(BIN_HEAD(ser), file->actual, -1);
269+
ser = Decode_UTF_String(BIN_HEAD(ser), file->actual, -1, TRUE);
270270
Set_String(ds, ser);
271271
if (args & AM_READ_LINES) Set_Block(ds, Split_Lines(ds));
272272
}

src/core/s-unicode.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ ConversionResult ConvertUTF8toUTF32 (
919919

920920
/***********************************************************************
921921
**
922-
*/ REBSER *Decode_UTF_String(REBYTE *bp, REBCNT len, REBINT utf)
922+
*/ REBSER *Decode_UTF_String(REBYTE *bp, REBCNT len, REBINT utf, REBFLG ccr)
923923
/*
924924
** Do all the details to decode a string.
925925
** Input is a byte series. Len is len of input.
@@ -932,7 +932,7 @@ ConversionResult ConvertUTF8toUTF32 (
932932
REBSER *dst;
933933
REBINT size;
934934

935-
REBFLG ccr = FALSE; // in original R3-alpha if was TRUE
935+
//REBFLG ccr = FALSE; // in original R3-alpha if was TRUE
936936
//@@ https://github.com/rebol/rebol-issues/issues/2336
937937

938938
if (utf == -1) {

src/core/t-string.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static REBSER *make_string(REBVAL *arg, REBOOL make)
164164
default:
165165
Trap0(RE_BAD_DECODE);
166166
}
167-
ser = Decode_UTF_String(bp, len, 8); // UTF-8
167+
ser = Decode_UTF_String(bp, len, 8, FALSE); // UTF-8
168168
}
169169
// MAKE/TO <type> <any-string>
170170
else if (ANY_BINSTR(arg)) {

0 commit comments

Comments
 (0)