| Author |
Message |
|
| Guest |
Posted: Mon Nov 27, 2006 3:55 pm |
|
|
|
Guest
|
Howdy!
The version of yaws_api:htmlize/1 in CVS uses binaries for its
accumulator when the input is a binary and this blows the (R9)
emulator's heap on a decent-sized input due to bad GC behaviour.
Here's a version that doesn't have the problem:
%% htmlize
htmlize(Bin) when binary(Bin) ->
list_to_binary(htmlize_l(binary_to_list(Bin)));
htmlize(List) when list(List) ->
htmlize_l(List).
And a ChangeLog entry:
2006-11-28 Luke Gorrie <luke@synap.se>
* src/yaws_api.erl (htmlize): Changed the treatment of binaries to
avoid blowing the emulator's heap. The original code created lots
Sorry not to send a proper diff but me and sourceforge are not on
speaking terms these days.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist |
|
|
| Back to top |
|
| Guest |
Posted: Mon Nov 27, 2006 8:32 pm |
|
|
|
Guest
|
Luke Gorrie wrote:
> Howdy!
>
> The version of yaws_api:htmlize/1 in CVS uses binaries for its
> accumulator when the input is a binary and this blows the (R9)
> emulator's heap on a decent-sized input due to bad GC behaviour.
>
> Here's a version that doesn't have the problem:
>
> %% htmlize
> htmlize(Bin) when binary(Bin) ->
> list_to_binary(htmlize_l(binary_to_list(Bin)));
> htmlize(List) when list(List) ->
> htmlize_l(List).
>
Yeah, current code looks like:
%% htmlize
htmlize(<<Char, Tail/binary>>) ->
case htmlize_char(Char) of
Char ->
<<Char, (htmlize(Tail))/binary>>;
Bin ->
<<Bin/binary, (htmlize(Tail))/binary>>
end;
htmlize(<<>>) ->
<<>>;
htmlize(List) when list(List) ->
htmlize_l(List).
I don't think the R11's work especially well with that code
either ...
Hmmmm, what's really missing is a lot of builtin
binary functions, such as bin_map(Fun, Binary), bin_re_match()
bin_x ...
I changed CVS
/klacke
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist |
|
|
| Back to top |
|
| Guest |
Posted: Tue Nov 28, 2006 11:06 am |
|
|
|
Guest
|
Here is my own modification of htmlize_list. I added this to support
Japanese text. When a form doesn't specify an encoding, Firefox
converts Unicode characters to HTML entities. For example, the
Japanese text '日本語' is encoded as 日本語. The old
htmlize function mangles such unicode entities. I believe that the
version below preserves all html entities and maintains safe html
output.
%% htmlize_list from yaws-1.57 by klacke
%%
%% Modified 2005-10-02 by Michael Leonhard to preserve html character entity
%% references. The HTML 4.01 entity with the longest name is ϑ hence
%% this function supports up to eight characters in the entity. Numeric
%% entities are also supported by this scheme:
%% &#nnnnnnn; seven decimal digits (0 through 9,999,999)
%% &#Xnnnnnn; six hexadecimal digits (0 through 16,777,215)
%%
%% Modified 2005-11-25 by Michael Leonhard to convert CRLF to <br>
htmlize(List) when is_list(List) -> htmlize_l(List, []). % modified by Michael
htmlize_l(List) -> htmlize_l(List, []).
htmlize_l([], Acc) -> lists:reverse(Acc);
htmlize_l([13,10|Tail], Acc) -> htmlize_l(Tail, ["<br/>"|Acc]);
htmlize_l([13|Tail], Acc) -> htmlize_l(Tail, ["<br/>"|Acc]);
htmlize_l([10|Tail], Acc) -> htmlize_l(Tail, ["<br/>"|Acc]);
htmlize_l([$>|Tail], Acc) -> htmlize_l(Tail, [$;,$t,$g,$&|Acc]);
htmlize_l([$<|Tail], Acc) -> htmlize_l(Tail, [$;,$t,$l,$&|Acc]);
htmlize_l([$&,A,$;|Tail], Acc) -> htmlize_l(Tail, [$;,A,$&|Acc]);
htmlize_l([$&,A,B,$;|Tail], Acc) -> htmlize_l(Tail, [$;,B,A,$&|Acc]);
htmlize_l([$&,A,B,C,$;|Tail], Acc) -> htmlize_l(Tail, [$;,C,B,A,$&|Acc]);
htmlize_l([$&,A,B,C,D,$;|Tail], Acc) -> htmlize_l(Tail, [$;,D,C,B,A,$&|Acc]);
htmlize_l([$&,A,B,C,D,E,$;|Tail], Acc) -> htmlize_l(Tail,
[$;,E,D,C,B,A,$&|Acc]);
htmlize_l([$&,A,B,C,D,E,F,$;|Tail], Acc) -> htmlize_l(Tail,
[$;,F,E,D,C,B,A,$&|Acc]);
htmlize_l([$&,A,B,C,D,E,F,G,$;|Tail], Acc) -> htmlize_l(Tail,
[$;,G,F,E,D,C,B,A,$&|Acc]);
htmlize_l([$&,A,B,C,D,E,F,G,H,$;|Tail], Acc) -> htmlize_l(Tail,
[$;,H,G,F,E,D,C,B,A,$&|Acc]);
htmlize_l([$&|Tail], Acc) -> htmlize_l(Tail, [$;,$p,$m,$a,$&|Acc]);
htmlize_l([$"|Tail], Acc) -> htmlize_l(Tail, [$; , $t, $o, $u, $q ,$&|Acc]);
htmlize_l([X|Tail], Acc) when integer(X) -> htmlize_l(Tail, [X|Acc]);
htmlize_l([X|Tail], Acc) when binary(X) ->
X2 = htmlize_l(binary_to_list(X)),
htmlize_l(Tail, [X2|Acc]);
htmlize_l([X|Tail], Ack) when is_list(X) ->
X2 = htmlize_l(X),
htmlize_l(Tail, [X2|Ack]).
klacke wrote:
> Hmmmm, what's really missing is a lot of builtin
> binary functions, such as bin_map(Fun, Binary), bin_re_match()
> bin_x ...
That is a great idea.
-Michael
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|
|