Sophie

Sophie

distrib > Fedora > 16 > i386 > by-pkgid > 1bfd226e0abb8ffbce25664c7de06a36 > files > 1

erlang-edown-0.3.1-1.fc16.src.rpm

From c9f4a565d8663dbd8b3c80df533403ae54432331 Mon Sep 17 00:00:00 2001
From: Peter Lemenkov <lemenkov@gmail.com>
Date: Fri, 1 Jun 2012 15:29:18 +0400
Subject: [PATCH 1/1] Fix for EL5

There is no such function lists:keyfind/3 availabie in R12B.

Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
---
 src/edown_doclet.erl |  8 ++++----
 src/edown_lib.erl    |  2 +-
 src/edown_xmerl.erl  | 12 ++++++------
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/edown_doclet.erl b/src/edown_doclet.erl
index c9bf1ea..d7197c8 100644
--- a/src/edown_doclet.erl
+++ b/src/edown_doclet.erl
@@ -156,7 +156,7 @@ right_suffix(File, Options) ->
     Base ++ Ext.
 
 set_app_default(Opts) ->
-    case lists:keyfind(app_default,1,Opts) of
+    case lists:keysearch(app_default,1,Opts) of
 	false ->
 	    [{app_default, "http://www.erlang.org/doc/man"}|Opts];
 	_ ->
@@ -193,12 +193,12 @@ make_top_level_README(Data, Dir, F, BaseHRef) ->
 
 redirect_href(Attrs, Branch, BaseHRef) ->
     AppBlob = BaseHRef ++ "/blob/" ++ Branch ++ "/",
-    case lists:keyfind(href, #xmlAttribute.name, Attrs) of
+    case lists:keysearch(href, #xmlAttribute.name, Attrs) of
 	false ->
 	    false;
-	#xmlAttribute{value = "/" ++ _} ->
+        {value, #xmlAttribute{value = "/" ++ _}} ->
 	    false;
-	#xmlAttribute{value = Href} = A ->
+        {value, #xmlAttribute{value = Href} = A} ->
 	    case re:run(Href, ":", []) of
 		{match, _} ->
 		    false;
diff --git a/src/edown_lib.erl b/src/edown_lib.erl
index 81ca972..59f97bd 100644
--- a/src/edown_lib.erl
+++ b/src/edown_lib.erl
@@ -72,7 +72,7 @@ redirect_uri(Href, _Name, E) ->
     end.
 
 replace_uri(URI, #xmlElement{attributes = As} = E) ->
-    #xmlAttribute{} = A = lists:keyfind(href, #xmlAttribute.name, As),
+    {value, #xmlAttribute{} = A} = lists:keysearch(href, #xmlAttribute.name, As),
     As1 = lists:keyreplace(href, #xmlAttribute.name, As,
 			   A#xmlAttribute{value = URI}),
     E#xmlElement{attributes = As1}.
diff --git a/src/edown_xmerl.erl b/src/edown_xmerl.erl
index c029610..93e9b93 100644
--- a/src/edown_xmerl.erl
+++ b/src/edown_xmerl.erl
@@ -136,12 +136,12 @@ html_elem(Tag, Data, Attrs, Parents, E) ->
 
 md_elem(a, Data, Attrs, _Parents, _E) ->
     %% io:fwrite("A TAG = ~p~nPs = ~p~n", [_E, _Parents]),
-    case lists:keyfind(href, #xmlAttribute.name, Attrs) of
-	#xmlAttribute{value = HRef}  ->
+    case lists:keysearch(href, #xmlAttribute.name, Attrs) of
+        {value, #xmlAttribute{value = HRef}}  ->
 	    ["[", Data, "](", HRef, ")"];
 	false ->
-	    case lists:keyfind(name, #xmlAttribute.name, Attrs) of
-		#xmlAttribute{} ->
+	    case lists:keysearch(name, #xmlAttribute.name, Attrs) of
+                {value, #xmlAttribute{}} ->
 		    [ %%"\n",
 		     xmerl_lib:start_tag(a,Attrs),
 		     Data,
@@ -151,8 +151,8 @@ md_elem(a, Data, Attrs, _Parents, _E) ->
 	    end
     end;
 md_elem(img, _Data, Attrs, _Parents, _E) ->
-    #xmlAttribute{value = Src} = lists:keyfind(src,#xmlAttribute.name,Attrs),
-    #xmlAttribute{value = Alt} = lists:keyfind(alt,#xmlAttribute.name,Attrs),
+    {value, #xmlAttribute{value = Src}} = lists:keysearch(src,#xmlAttribute.name,Attrs),
+    {value, #xmlAttribute{value = Alt}} = lists:keysearch(alt,#xmlAttribute.name,Attrs),
     ["![", Alt, "](", Src, ")"];
 md_elem(li, Data, _Attrs, [{ul,_}|_], _E) ->
     ["* ", strip(Data), "\n"];
-- 
1.7.12