Skip to content

Commit e5ebf56

Browse files
authored
Merge pull request #1581 from clasp-developers/write-char-fix
Fix encoding max length for UCS-4
2 parents 6d2136f + 9720571 commit e5ebf56

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/core/lispStream.cc

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,10 +1235,21 @@ CL_DEFUN Integer_sp cl__write_byte(Integer_sp byte, T_sp stream) {
12351235
CL_LAMBDA(string &optional output-stream);
12361236
CL_DOCSTRING(R"dx(Outputs character to output-stream.)dx");
12371237
CL_DEFUN Character_sp cl__write_char(Character_sp chr, T_sp output_stream) {
1238+
Character_sp r = chr;
12381239
stream_write_char(coerce::outputStreamDesignator(output_stream), clasp_as_claspCharacter(chr));
1239-
return chr;
1240+
return r;
12401241
};
12411242

1243+
1244+
CL_LAMBDA(string &optional output-stream);
1245+
CL_DOCSTRING(R"dx(Outputs character to output-stream.)dx");
1246+
CL_DEFUN Character_sp core__write_char_beta(Character_sp chr, T_sp output_stream) {
1247+
Character_sp r = chr;
1248+
stream_write_char(coerce::outputStreamDesignator(output_stream), clasp_as_claspCharacter(chr));
1249+
return r;
1250+
};
1251+
1252+
12421253
CL_LAMBDA(&optional input-stream);
12431254
CL_DOCSTRING(R"dx(Clears any available input from input-stream.
12441255
@@ -3129,10 +3140,10 @@ int TwoWayStream_O::file_descriptor(StreamDirection direction) const {
31293140
}
31303141

31313142
/* Maximum number of bytes required to encode a character.
3132-
* This currently corresponds to (4 + 2) for the ISO-2022-JP-* encodings
3133-
* with 4 being the charset prefix, 2 for the character.
3143+
* This currently corresponds to (4 + 4) for the UCS-4 encoding
3144+
* with 4 being the byte-order mark, 4 for the character.
31343145
*/
3135-
#define ENCODING_BUFFER_MAX_SIZE 6
3146+
#define ENCODING_BUFFER_MAX_SIZE 8
31363147
/* Size of the encoding buffer for vectors */
31373148
#define VECTOR_ENCODING_BUFFER_SIZE 2048
31383149

0 commit comments

Comments
 (0)