aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Pampukha <[email protected]>2010-03-09 10:36:19 +0100
committerRaimo Niskanen <[email protected]>2010-06-09 16:19:09 +0200
commit3c3360947692d8cf55d6dc2290934ec111675cde (patch)
tree341ce8d78926b45593a67a57d50fe0cdcbed4b6f
parent2dc962eead182ca5c79c5ac8d9d31a08f22c97af (diff)
downloadotp-3c3360947692d8cf55d6dc2290934ec111675cde.tar.gz
otp-3c3360947692d8cf55d6dc2290934ec111675cde.tar.bz2
otp-3c3360947692d8cf55d6dc2290934ec111675cde.zip
Bug fix: ct_config_xml now returns items in right order
-rwxr-xr-xlib/common_test/src/ct_config_xml.erl18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/common_test/src/ct_config_xml.erl b/lib/common_test/src/ct_config_xml.erl
index 4b16c7c675..e14bb0f9f9 100755
--- a/lib/common_test/src/ct_config_xml.erl
+++ b/lib/common_test/src/ct_config_xml.erl
@@ -24,6 +24,9 @@
-module(ct_config_xml).
-export([read_config/1, check_parameter/1]).
+% DEBUG ONLY
+-export([list_to_term/1]).
+
% read config file
read_config(ConfigFile) ->
case catch do_read_xml_config(ConfigFile) of
@@ -44,11 +47,14 @@ check_parameter(File)->
% actual reading of the config
do_read_xml_config(ConfigFile)->
- {ok, EntityList, _}=
- xmerl_sax_parser:file(ConfigFile,
+ case catch xmerl_sax_parser:file(ConfigFile,
[{event_fun, fun event/3},
- {event_state, []}]),
- {ok, transform_entity_list(EntityList)}.
+ {event_state, []}]) of
+ {ok, EntityList, _}->
+ {ok, lists:reverse(transform_entity_list(EntityList))};
+ Oops->
+ {error, parsing_failed, Oops}
+ end.
% event callback for xmerl_sax_parser
event(Event, _LineNo, State) ->
@@ -95,7 +101,7 @@ transform_entity_list(EntityList)->
% transform entity from {list(), list()} to {atom(), term()}
transform_entity({Tag, [Value|Rest]}) when
is_tuple(Value)->
- {list_to_atom(Tag), transform_entity_list([Value|Rest])};
+ {list_to_atom(Tag), transform_entity_list(lists:reverse([Value|Rest]))};
transform_entity({Tag, String})->
case list_to_term(String) of
{ok, Value}->
@@ -108,7 +114,7 @@ transform_entity({Tag, String})->
% stolen from trapexit.org :-)
list_to_term(String) ->
{ok, T, _} = erl_scan:string(String++"."),
- case erl_parse:parse_term(T) of
+ case catch erl_parse:parse_term(T) of
{ok, Term} ->
{ok, Term};
Error ->