bad dec2hex implementation #20

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

Comments

Projects
None yet
2 participants
Contributor

fdmanana commented Nov 10, 2010

Hi Chandru. The commit message explains it all:

fdmanana/ibrowse@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

Contributor

fdmanana commented Nov 10, 2010

An ever simpler conversion:

fdmanana/ibrowse@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 :)

Contributor

fdmanana commented Nov 10, 2010

Just in case:
fdmanana/ibrowse@41fe7ac

Owner

cmullaparthi commented Nov 10, 2010

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

Contributor

fdmanana commented Nov 10, 2010

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

Contributor

fdmanana commented Nov 19, 2010

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>

Owner

cmullaparthi commented Nov 19, 2010

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

Owner

cmullaparthi commented Dec 14, 2010

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