Skip to content

Commit

Permalink
jl_array_to_string: check that argument is Vector{UInt8}
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKarpinski committed Aug 26, 2015
1 parent 8b95c0d commit 2244a5b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,8 @@ jl_array_t *jl_pchar_to_array(const char *str, size_t len)

jl_value_t *jl_array_to_string(jl_array_t *a)
{
// TODO: check type of array?
if (!(jl_typeis(a, jl_array_uint8_type) && jl_array_ndims(a) == 1))
jl_error("jl_array_to_string: argument not byte vector");

This comment has been minimized.

Copy link
@JeffBezanson

JeffBezanson Aug 26, 2015

Member

Could use jl_type_error.

This comment has been minimized.

Copy link
@StefanKarpinski

StefanKarpinski Aug 27, 2015

Author Member

Doesn't handle the number of dimensions, at least not without getting another type in the C code, which seems not worth it.

This comment has been minimized.

Copy link
@JeffBezanson

JeffBezanson Aug 27, 2015

Member

The number of dimensions is part of the type.

This comment has been minimized.

Copy link
@StefanKarpinski

StefanKarpinski Aug 27, 2015

Author Member

Ah, I see from the definition that jl_array_uint8_type should probably be called jl_vector_uint8_type.

This comment has been minimized.

Copy link
@JeffBezanson

JeffBezanson Aug 27, 2015

Member

Yes, that would be much better.

jl_datatype_t *string_type = u8_isvalid((char*)a->data, jl_array_len(a)) == 1 ? // ASCII
jl_ascii_string_type : jl_utf8_string_type;
jl_value_t *s = (jl_value_t*)jl_gc_alloc_1w();
Expand Down

0 comments on commit 2244a5b

Please sign in to comment.