aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/bif.c
diff options
context:
space:
mode:
authorRickard Green <[email protected]>2017-08-23 14:25:42 +0200
committerRickard Green <[email protected]>2017-08-23 14:25:42 +0200
commitd50bc5031eb0889c894bf20f5206cfc06162f30a (patch)
treeb8a335a5e72f26a3a93b92d8d7b473a6d16cf931 /erts/emulator/beam/bif.c
parent26416b5430795f3a27913931afbb7ef1dc51d4bd (diff)
parent319eefea3b2097b543751c63cebbb4a92011dbbf (diff)
downloadotp-d50bc5031eb0889c894bf20f5206cfc06162f30a.tar.gz
otp-d50bc5031eb0889c894bf20f5206cfc06162f30a.tar.bz2
otp-d50bc5031eb0889c894bf20f5206cfc06162f30a.zip
Merge branch 'rickard/unicode-display_string/OTP-14545' into maint
* rickard/unicode-display_string/OTP-14545: Unicode support for erlang:display_string/1
Diffstat (limited to 'erts/emulator/beam/bif.c')
-rw-r--r--erts/emulator/beam/bif.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/erts/emulator/beam/bif.c b/erts/emulator/beam/bif.c
index 52842a26eb..b6595d2a5d 100644
--- a/erts/emulator/beam/bif.c
+++ b/erts/emulator/beam/bif.c
@@ -3944,15 +3944,18 @@ BIF_RETTYPE display_string_1(BIF_ALIST_1)
{
Process* p = BIF_P;
Eterm string = BIF_ARG_1;
- Sint len = is_string(string);
- char *str;
+ Sint len = erts_unicode_list_to_buf_len(string);
+ Sint written;
+ byte *str;
+ int res;
- if (len <= 0) {
+ if (len < 0) {
BIF_ERROR(p, BADARG);
}
- str = (char *) erts_alloc(ERTS_ALC_T_TMP, sizeof(char)*(len + 1));
- if (intlist_to_buf(string, str, len) != len)
- erts_exit(ERTS_ERROR_EXIT, "%s:%d: Internal error\n", __FILE__, __LINE__);
+ str = (byte *) erts_alloc(ERTS_ALC_T_TMP, sizeof(char)*(len + 1));
+ res = erts_unicode_list_to_buf(string, str, len, &written);
+ if (res != 0 || written != len)
+ erts_exit(ERTS_ERROR_EXIT, "%s:%d: Internal error (%d)\n", __FILE__, __LINE__, res);
str[len] = '\0';
erts_fprintf(stderr, "%s", str);
erts_free(ERTS_ALC_T_TMP, (void *) str);