Compare commits
1 Commits
master
...
monkeypatc
| Author | SHA1 | Date | |
|---|---|---|---|
| cb26dafd15 |
@ -1943,6 +1943,8 @@ coerce({O, N, char}, Str, to_fate) ->
|
||||
_ ->
|
||||
single_error({invalid, O, N, Str})
|
||||
end;
|
||||
coerce({O, N, {bytes, [Count]}}, Bytes, to_fate) when is_list(Bytes) ->
|
||||
coerce_bytes(O, N, Count, convert_bytes(Bytes));
|
||||
coerce({O, N, {bytes, [Count]}}, Bytes, _Direction) when is_bitstring(Bytes) ->
|
||||
coerce_bytes(O, N, Count, Bytes);
|
||||
coerce({_, _, bits}, {bits, Num}, from_fate) ->
|
||||
@ -2011,6 +2013,13 @@ coerce_bytes(O, N, Count, Bytes) when byte_size(Bytes) /= Count ->
|
||||
coerce_bytes(_, _, _, Bytes) ->
|
||||
{ok, Bytes}.
|
||||
|
||||
convert_bytes([$# | Rest]) ->
|
||||
convert_bytes(Rest, <<>>).
|
||||
|
||||
convert_bytes([A, B | T], J) -> convert_bytes(T, <<J/binary, (list_to_integer([A, B], 16))>>);
|
||||
convert_bytes([], J) -> {ok, J};
|
||||
convert_bytes(O, J) -> {error, {J, O}}.
|
||||
|
||||
coerce_chain_object(_, _, _, _, {raw, Binary}) ->
|
||||
{ok, Binary};
|
||||
coerce_chain_object(O, N, T, Tag, S) ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user