bad dec2hex implementation #20

Closed
fdmanana opened this Issue Nov 10, 2010 · 7 comments

Projects

None yet

2 participants

@fdmanana

Hi Chandru. The commit message explains it all:

fdmanana@c4991ff

Found this issue when trying to send a chunk with size > 65535 bytes.
Replaced the implementation of dec2hex with a call to io_lib:format/2. Also we don't need the width anywhere in current ibrowse's code (and chunk headers don't apply restrictions to the size's width).

cheers

@fdmanana

An ever simpler conversion:

fdmanana@5715632

Should probably be better to replace the function with a macro like:

-define(dec2hex(N), integer_to_list(N, 16)).

Anyway, it's up to you :)

@fdmanana

Just in case:
fdmanana@41fe7ac

@cmullaparthi
Owner

Hi Filipe,

I like the macro suggestion. integer_to_list/2 seems to be supported only in R14. I want to be able to support older releases of Erlang/OTP as well.

Thanks much!
Chandru

@fdmanana

Hum didn't notice that. I found out about integer_to_list/2 today.
But erldocs says it's in R13B03?
http://erldocs.com/R13B03/erts/erlang.html?search=integer_to_list&i=1#integer_to_list/2

nevertheless the io_lib:format should work even on R12

thanks Chandru

@fdmanana

Actually erlang:linteger_to_list/2 exists in R13 (B03 at least) but not integer_to_list/2:

Erlang R13B03 (erts-5.7.4) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.7.4 (abort with ^G)
1> erlang:integer_to_list(128, 16).
"80"
2> integer_to_list(128, 16).
** exception error: undefined shell command integer_to_list/2
3>

@cmullaparthi
Owner

I tested on R11B-5 just now and you're right. It works even on R9C. That is good enough for me. I'll use this - thanks much.

Chandru

@cmullaparthi
Owner

Fixed in release 2.1.1

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment