diff options
author | Paul Guyot <[email protected]> | 2010-06-04 10:14:00 +0200 |
---|---|---|
committer | Raimo Niskanen <[email protected]> | 2010-06-07 13:46:33 +0200 |
commit | 8215a7a3eea8f36532ceac31e48fbc6337cb9a8b (patch) | |
tree | 385bbedff0000b5fec4a853e97a86c6669e257e5 /erts | |
parent | 707c6510597e5eb6e32b88412edd717e0e3c39ba (diff) | |
download | otp-8215a7a3eea8f36532ceac31e48fbc6337cb9a8b.tar.gz otp-8215a7a3eea8f36532ceac31e48fbc6337cb9a8b.tar.bz2 otp-8215a7a3eea8f36532ceac31e48fbc6337cb9a8b.zip |
Fix erts_bld_string_n (called by enif_make_string and erlang:decode_packet/3) to work with 8 bits characters
Diffstat (limited to 'erts')
-rw-r--r-- | erts/emulator/beam/utils.c | 2 | ||||
-rw-r--r-- | erts/emulator/test/nif_SUITE.erl | 5 | ||||
-rw-r--r-- | erts/emulator/test/nif_SUITE_data/nif_SUITE.c | 6 |
3 files changed, 8 insertions, 5 deletions
diff --git a/erts/emulator/beam/utils.c b/erts/emulator/beam/utils.c index 445a8eebd9..da6f9ed12f 100644 --- a/erts/emulator/beam/utils.c +++ b/erts/emulator/beam/utils.c @@ -510,7 +510,7 @@ erts_bld_string_n(Uint **hpp, Uint *szp, const char *str, Sint len) if (hpp) { res = NIL; while (--i >= 0) { - res = CONS(*hpp, make_small(str[i]), res); + res = CONS(*hpp, make_small((byte) str[i]), res); *hpp += 2; } } diff --git a/erts/emulator/test/nif_SUITE.erl b/erts/emulator/test/nif_SUITE.erl index a1f61dad67..888bf582d8 100644 --- a/erts/emulator/test/nif_SUITE.erl +++ b/erts/emulator/test/nif_SUITE.erl @@ -967,10 +967,11 @@ make_atom(Config) when is_list(Config) -> make_string(Config) when is_list(Config) -> ?line ensure_lib_loaded(Config, 1), ?line Strings = make_strings(), - ?line 4 = size(Strings), + ?line 5 = size(Strings), A0String = "a0string", A0String0 = [$a,0,$s,$t,$r,$i,$n,$g,0], - ?line Strings = {A0String,A0String,A0String,A0String0}. + AStringWithAccents = [$E,$r,$l,$a,$n,$g,$ ,16#e4,$r,$ ,$e,$t,$t,$ ,$g,$e,$n,$e,$r,$e,$l,$l,$t,$ ,$p,$r,$o,$g,$r,$a,$m,$s,$p,$r,16#e5,$k], + ?line Strings = {A0String,A0String,A0String,A0String0, AStringWithAccents}. tmpmem() -> case erlang:system_info({allocator,temp_alloc}) of diff --git a/erts/emulator/test/nif_SUITE_data/nif_SUITE.c b/erts/emulator/test/nif_SUITE_data/nif_SUITE.c index bacf7845e2..c8cd323b7e 100644 --- a/erts/emulator/test/nif_SUITE_data/nif_SUITE.c +++ b/erts/emulator/test/nif_SUITE_data/nif_SUITE.c @@ -808,12 +808,14 @@ static ERL_NIF_TERM make_strings(ErlNifEnv* env, int argc, const ERL_NIF_TERM ar { const char a0string[8] = {'a','0','s','t','r','i','n','g'}; const char a0string0[9] = {'a','\0','s','t','r','i','n','g',0}; + const char astringwith8bits[37] = {'E','r','l','a','n','g',' ',0xE4 /* 'ä' */,'r',' ','e','t','t',' ','g','e','n','e','r','e','l','l','t',' ','p','r','o','g','r','a','m','s','p','r', 0xE5 /* 'å' */,'k',0}; - return enif_make_tuple4(env, + return enif_make_tuple5(env, enif_make_string(env, "a0string", ERL_NIF_LATIN1), enif_make_string_len(env, "a0string", 8, ERL_NIF_LATIN1), enif_make_string_len(env, a0string, 8, ERL_NIF_LATIN1), - enif_make_string_len(env, a0string0, 9, ERL_NIF_LATIN1)); + enif_make_string_len(env, a0string0, 9, ERL_NIF_LATIN1), + enif_make_string(env, astringwith8bits, ERL_NIF_LATIN1)); } static ERL_NIF_TERM send_list_seq(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { |