aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/syntax_tools/src/erl_syntax.erl8
-rw-r--r--lib/syntax_tools/test/syntax_tools_SUITE.erl29
-rw-r--r--lib/wx/api_gen/wx_gen_cpp.erl34
-rw-r--r--lib/wx/c_src/gen/wxe_derived_dest.h6
-rw-r--r--lib/wx/c_src/gen/wxe_funcs.cpp8
-rw-r--r--lib/wx/c_src/wxe_impl.cpp5
-rwxr-xr-xlib/wx/configure.in16
-rw-r--r--lib/wx/test/wx_basic_SUITE.erl13
-rw-r--r--lib/wx/test/wx_event_SUITE.erl33
-rw-r--r--lib/wx/test/wx_obj_test.erl72
-rw-r--r--lib/xmerl/src/xmerl_sax_parser.erl32
-rw-r--r--lib/xmerl/src/xmerl_sax_parser.hrl10
-rw-r--r--lib/xmerl/src/xmerl_sax_parser_base.erlsrc65
-rw-r--r--lib/xmerl/test/xmerl_sax_SUITE.erl35
-rw-r--r--lib/xmerl/test/xmerl_sax_std_SUITE.erl12
-rw-r--r--lib/xmerl/test/xmerl_xsd_MS2002-01-16_SUITE.erl7
-rw-r--r--lib/xmerl/test/xmerl_xsd_MS2002-01-16_SUITE_data/msx_failed_cases.log2
-rw-r--r--lib/xmerl/vsn.mk2
18 files changed, 267 insertions, 122 deletions
diff --git a/lib/syntax_tools/src/erl_syntax.erl b/lib/syntax_tools/src/erl_syntax.erl
index 409805e95f..775b2cc109 100644
--- a/lib/syntax_tools/src/erl_syntax.erl
+++ b/lib/syntax_tools/src/erl_syntax.erl
@@ -5485,7 +5485,13 @@ revert_implicit_fun(Node) ->
arity_qualifier ->
F = arity_qualifier_body(Name),
A = arity_qualifier_argument(Name),
- {'fun', Pos, {function, F, A}};
+ case {type(F), type(A)} of
+ {atom, integer} ->
+ {'fun', Pos,
+ {function, concrete(F), concrete(A)}};
+ _ ->
+ Node
+ end;
module_qualifier ->
M = module_qualifier_argument(Name),
Name1 = module_qualifier_body(Name),
diff --git a/lib/syntax_tools/test/syntax_tools_SUITE.erl b/lib/syntax_tools/test/syntax_tools_SUITE.erl
index fd381f0b25..9eef56bddb 100644
--- a/lib/syntax_tools/test/syntax_tools_SUITE.erl
+++ b/lib/syntax_tools/test/syntax_tools_SUITE.erl
@@ -24,12 +24,12 @@
init_per_group/2,end_per_group/2]).
%% Test cases
--export([smoke_test/1]).
+-export([smoke_test/1,revert/1]).
suite() -> [{ct_hooks,[ts_install_cth]}].
all() ->
- [smoke_test].
+ [smoke_test,revert].
groups() ->
[].
@@ -79,6 +79,31 @@ print_error_markers(F, File) ->
end.
+%% Read with erl_parse, wrap and revert with erl_syntax and check for equality.
+revert(Config) when is_list(Config) ->
+ Dog = ?t:timetrap(?t:minutes(12)),
+ Wc = filename:join([code:lib_dir("stdlib"),"src","*.erl"]),
+ Fs = filelib:wildcard(Wc),
+ Path = [filename:join(code:lib_dir(stdlib), "include"),
+ filename:join(code:lib_dir(kernel), "include")],
+ io:format("~p files\n", [length(Fs)]),
+ case p_run(fun (File) -> revert_file(File, Path) end, Fs) of
+ 0 -> ok;
+ N -> ?line ?t:fail({N,errors})
+ end,
+ ?line ?t:timetrap_cancel(Dog).
+
+revert_file(File, Path) ->
+ case epp:parse_file(File, Path, []) of
+ {ok,Fs0} ->
+ Fs1 = erl_syntax:form_list(Fs0),
+ Fs2 = erl_syntax_lib:map(fun (Node) -> Node end, Fs1),
+ Fs3 = erl_syntax:form_list_elements(Fs2),
+ Fs4 = [ erl_syntax:revert(Form) || Form <- Fs3 ],
+ {ok,_} = compile:forms(Fs4, [report,strong_validation]),
+ ok
+ end.
+
p_run(Test, List) ->
N = erlang:system_info(schedulers),
p_run_loop(Test, List, N, [], 0).
diff --git a/lib/wx/api_gen/wx_gen_cpp.erl b/lib/wx/api_gen/wx_gen_cpp.erl
index 7e35ebfa83..6eed0668f6 100644
--- a/lib/wx/api_gen/wx_gen_cpp.erl
+++ b/lib/wx/api_gen/wx_gen_cpp.erl
@@ -855,34 +855,24 @@ call_arg(#param{name=N,type={merged,_,_,_,_,_,_}}) -> N.
to_string(Type) when is_atom(Type) -> atom_to_list(Type);
to_string(Type) when is_list(Type) -> Type.
-virtual_dest(#class{abstract=true, parent="root"}) -> false;
-virtual_dest(#class{abstract=true, parent="object"}) -> true;
virtual_dest(#class{abstract=true, parent=Parent}) ->
- virtual_dest(get({class,Parent}));
+ virtual_dest(get_parent_class(Parent));
virtual_dest(#class{methods=Ms, parent=Parent}) ->
case lists:keysearch(destructor,#method.method_type, lists:append(Ms)) of
{value, #method{method_type=destructor, virtual=Virtual}} ->
case Virtual of
- undefined ->
- case get({class,Parent}) of
- undefined ->
- case Parent of
- "object" ->
- true;
- "root" ->
- false;
- _ ->
- io:format("Error: ~p~n",[Parent]),
- erlang:error(no_parent)
- end;
- PClass ->
- virtual_dest(PClass)
- end;
- _ ->
- Virtual
+ true -> true;
+ _ -> virtual_dest(get_parent_class(Parent))
end;
- false ->
- false
+ false -> virtual_dest(get_parent_class(Parent))
+ end;
+virtual_dest("root") -> false;
+virtual_dest("object") -> true.
+
+get_parent_class(Parent) ->
+ case get({class, Parent}) of
+ undefined -> Parent;
+ Class -> Class
end.
debug(F,A) ->
diff --git a/lib/wx/c_src/gen/wxe_derived_dest.h b/lib/wx/c_src/gen/wxe_derived_dest.h
index 8dcaf1c1ac..7e2d4524cb 100644
--- a/lib/wx/c_src/gen/wxe_derived_dest.h
+++ b/lib/wx/c_src/gen/wxe_derived_dest.h
@@ -736,6 +736,12 @@ class EwxPrintout : public wxPrintout {
EwxPrintout(const wxString& title) : wxPrintout(title) {};
};
+class EwxStyledTextCtrl : public wxStyledTextCtrl {
+ public: ~EwxStyledTextCtrl() {((WxeApp *)wxTheApp)->clearPtr(this);};
+ EwxStyledTextCtrl(wxWindow * parent,wxWindowID id,const wxPoint& pos,const wxSize& size,long style) : wxStyledTextCtrl(parent,id,pos,size,style) {};
+ EwxStyledTextCtrl() : wxStyledTextCtrl() {};
+};
+
class EwxClipboard : public wxClipboard {
public: ~EwxClipboard() {((WxeApp *)wxTheApp)->clearPtr(this);};
EwxClipboard() : wxClipboard() {};
diff --git a/lib/wx/c_src/gen/wxe_funcs.cpp b/lib/wx/c_src/gen/wxe_funcs.cpp
index b5fbac3fe0..329af36f4d 100644
--- a/lib/wx/c_src/gen/wxe_funcs.cpp
+++ b/lib/wx/c_src/gen/wxe_funcs.cpp
@@ -26953,14 +26953,14 @@ case wxStyledTextCtrl_new_2: { // wxStyledTextCtrl::wxStyledTextCtrl
style = (long)*(int *) bp; bp += 4;
} break;
}};
- wxStyledTextCtrl * Result = new wxStyledTextCtrl(parent,id,pos,size,style);
- /* Possible memory leak here, class is missing virt dest */
+ wxStyledTextCtrl * Result = new EwxStyledTextCtrl(parent,id,pos,size,style);
+ newPtr((void *) Result, 0, memenv);
rt.addRef(getRef((void *)Result,memenv), "wxStyledTextCtrl");
break;
}
case wxStyledTextCtrl_new_0: { // wxStyledTextCtrl::wxStyledTextCtrl
- wxStyledTextCtrl * Result = new wxStyledTextCtrl();
- /* Possible memory leak here, class is missing virt dest */
+ wxStyledTextCtrl * Result = new EwxStyledTextCtrl();
+ newPtr((void *) Result, 0, memenv);
rt.addRef(getRef((void *)Result,memenv), "wxStyledTextCtrl");
break;
}
diff --git a/lib/wx/c_src/wxe_impl.cpp b/lib/wx/c_src/wxe_impl.cpp
index 4968075659..cc9bcc9957 100644
--- a/lib/wx/c_src/wxe_impl.cpp
+++ b/lib/wx/c_src/wxe_impl.cpp
@@ -1,7 +1,7 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 2008-2013. All Rights Reserved.
+ * Copyright Ericsson AB 2008-2014. All Rights Reserved.
*
* The contents of this file are subject to the Erlang Public License,
* Version 1.1, (the "License"); you may not use this file except in
@@ -195,9 +195,8 @@ void meta_command(int what, wxe_data *sd) {
wxeCommand *Cmd = new wxeCommand(WXE_DEBUG_PING, NULL, 0, sd);
wxe_batch->Append(Cmd);
erl_drv_cond_signal(wxe_batch_locker_c);
- } else {
- wxWakeUpIdle();
}
+ wxWakeUpIdle();
erl_drv_mutex_unlock(wxe_batch_locker_m);
} else {
if(sd) {
diff --git a/lib/wx/configure.in b/lib/wx/configure.in
index 12b4de6fe6..3756786831 100755
--- a/lib/wx/configure.in
+++ b/lib/wx/configure.in
@@ -183,7 +183,7 @@ AC_SUBST(OBJC_CFLAGS)
case $host_os in
darwin*)
- LDFLAGS="-bundle -flat_namespace -undefined warning -fPIC $LDFLAGS"
+ LDFLAGS="$MAC_MIN -bundle -flat_namespace -undefined warning -fPIC $LDFLAGS"
# Check sizof_void_p as future will hold 64bit MacOS wx
if test $ac_cv_sizeof_void_p = 4; then
LDFLAGS="-m32 $LDFLAGS"
@@ -211,20 +211,20 @@ dnl ----------------------------------------------------------------------
case $host_os in
mingw32)
DEBUG_CFLAGS="-g -Wall -DDEBUG $CFLAGS"
- CFLAGS="-g -Wall -O2 -fomit-frame-pointer -fno-strict-aliasing $CFLAGS"
+ CFLAGS="-g -Wall -O2 $CFLAGS -fomit-frame-pointer -fno-strict-aliasing"
;;
win32)
- DEBUG_CFLAGS="-g -Wall -DDEBUG $CFLAGS"
+ DEBUG_CFLAGS="-g -Wall $CFLAGS -DDEBUG"
CFLAGS="-g -Wall -O2 $CFLAGS"
;;
darwin*)
- DEBUG_CFLAGS="-g -Wall -fPIC -DDEBUG $CFLAGS"
- # Disable -02 crashes with xcode 5.0.2 (clang-500.2.79)
- CFLAGS="-g -Wall -fPIC -fomit-frame-pointer -fno-strict-aliasing $CFLAGS"
+ DEBUG_CFLAGS="-g -Wall -fPIC $CFLAGS -DDEBUG"
+ # omit-frame-pointer causes seg faults with 10.9 and clang
+ CFLAGS="-g -Wall -fPIC $CFLAGS -fno-strict-aliasing"
;;
*)
- DEBUG_CFLAGS="-g -Wall -fPIC -DDEBUG $CFLAGS"
- CFLAGS="-g -Wall -O2 -fPIC -fomit-frame-pointer -fno-strict-aliasing $CFLAGS"
+ DEBUG_CFLAGS="-g -Wall -fPIC $CFLAGS -DDEBUG"
+ CFLAGS="-g -Wall -O2 -fPIC $CFLAGS -fomit-frame-pointer -fno-strict-aliasing"
;;
esac
diff --git a/lib/wx/test/wx_basic_SUITE.erl b/lib/wx/test/wx_basic_SUITE.erl
index d55a037599..c5b0927bf3 100644
--- a/lib/wx/test/wx_basic_SUITE.erl
+++ b/lib/wx/test/wx_basic_SUITE.erl
@@ -324,7 +324,18 @@ data_types(_Config) ->
wx_object(TestInfo) when is_atom(TestInfo) -> wx_test_lib:tc_info(TestInfo);
wx_object(Config) ->
wx:new(),
- Frame = ?mt(wxFrame, wx_obj_test:start([])),
+ Me = self(),
+ Init = fun() ->
+ Frame = wxFrame:new(wx:null(), ?wxID_ANY, "Test wx_object", [{size, {500, 400}}]),
+ Sz = wxBoxSizer:new(?wxHORIZONTAL),
+ Panel = wxPanel:new(Frame),
+ wxSizer:add(Sz, Panel, [{flag, ?wxEXPAND}, {proportion, 1}]),
+ wxPanel:connect(Panel, size, [{skip, true}]),
+ wxPanel:connect(Panel, paint, [callback, {userData, Me}]),
+ wxWindow:show(Frame),
+ {Frame, {Frame, Panel}}
+ end,
+ Frame = ?mt(wxFrame, wx_obj_test:start([{init, Init}])),
timer:sleep(500),
?m(ok, check_events(flush())),
diff --git a/lib/wx/test/wx_event_SUITE.erl b/lib/wx/test/wx_event_SUITE.erl
index 6a9f19ad51..bbb5294d08 100644
--- a/lib/wx/test/wx_event_SUITE.erl
+++ b/lib/wx/test/wx_event_SUITE.erl
@@ -484,6 +484,7 @@ callback_clean(Config) ->
%% timer:sleep(infinity),
%% ok.
+
white_box_check_event_handlers() ->
{_,_,Server,_} = wx:get_env(),
{status, _, _, [Env, _, _, _, Data]} = sys:get_status(Server),
@@ -495,3 +496,35 @@ white_box_check_event_handlers() ->
gb_trees:to_list(CBs),
[Funs || Funs = {Id, {Fun,_}} <- Env, is_integer(Id), is_function(Fun)]
}.
+
+handler_clean(TestInfo) when is_atom(TestInfo) ->
+ wx_test_lib:tc_info(TestInfo);
+handler_clean(_Config) ->
+ wx:new(),
+ Init = fun() -> create_window() end,
+ Frame1 = wx_obj_test:start([{init, Init}]),
+ ?mt(wxFrame, Frame1),
+ wxWindow:show(Frame1),
+ ?m([_|_], lists:sort(wx_test_lib:flush())),
+ ?m({stop,_}, wx_obj_test:stop(Frame1, fun(_) -> normal end)),
+ ?m([{terminate,normal}], lists:sort(wx_test_lib:flush())),
+
+ Frame2 = wx_obj_test:start([{init, Init}]),
+ wxWindow:show(Frame2),
+ ?m([_|_], lists:sort(wx_test_lib:flush())),
+ ?m({stop,_}, wx_obj_test:stop(Frame2, fun(_) -> wxWindow:destroy(Frame2), normal end)),
+ ?m([{terminate,normal}], lists:sort(wx_test_lib:flush())),
+ timer:sleep(104),
+ ?m({[],[],[]}, white_box_check_event_handlers()),
+ ?m(ok, wx:destroy()),
+ ok.
+
+create_window() ->
+ Frame = wxFrame:new(wx:null(), ?wxID_ANY, "Test wx_object", [{size, {500, 400}}]),
+ Sz = wxBoxSizer:new(?wxHORIZONTAL),
+ Panel = wxPanel:new(Frame),
+ wxSizer:add(Sz, Panel, [{flag, ?wxEXPAND}, {proportion, 1}]),
+ wxWindow:connect(Frame, show),
+ %% wxPanel:connect(Panel, paint, [callback, {userData, foobar}]),
+ wxWindow:connect(Panel, size, [callback]),
+ {Frame, {Frame, Panel}}.
diff --git a/lib/wx/test/wx_obj_test.erl b/lib/wx/test/wx_obj_test.erl
index b4d7640c7e..f47f2fbc46 100644
--- a/lib/wx/test/wx_obj_test.erl
+++ b/lib/wx/test/wx_obj_test.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2011. All Rights Reserved.
+%% Copyright Ericsson AB 2011-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -18,69 +18,71 @@
-module(wx_obj_test).
-include_lib("wx/include/wx.hrl").
--export([start/1]).
+-export([start/1, stop/2]).
%% wx_object callbacks
-export([init/1, handle_info/2, terminate/2, code_change/3, handle_call/3,
handle_sync_event/3, handle_event/2, handle_cast/2]).
--record(state, {frame, panel, opts}).
+-record(state, {parent, opts, user_state}).
start(Opts) ->
- wx_object:start_link(?MODULE, [{parent, self()}, Opts], []).
+ wx_object:start_link(?MODULE, [{parent, self()}| Opts], []).
+
+stop(Object, Fun) ->
+ wx_object:call(Object, {stop, Fun}).
init(Opts) ->
- put(parent_pid, proplists:get_value(parent, Opts)),
- Frame = wxFrame:new(wx:null(), ?wxID_ANY, "Test wx_object", [{size, {500, 400}}]),
- Sz = wxBoxSizer:new(?wxHORIZONTAL),
- Panel = wxPanel:new(Frame),
- wxSizer:add(Sz, Panel, [{flag, ?wxEXPAND}, {proportion, 1}]),
- wxPanel:connect(Panel, size, [{skip, true}]),
- wxPanel:connect(Panel, paint, [callback, {userData, proplists:get_value(parent, Opts)}]),
- wxWindow:show(Frame),
- {Frame, #state{frame=Frame, panel=Panel, opts=Opts}}.
+ Parent = proplists:get_value(parent, Opts),
+ put(parent_pid, Parent),
+ Init = proplists:get_value(init, Opts),
+ {Obj, UserState} = Init(),
+ {Obj, #state{parent=Parent, opts=Opts, user_state=UserState}}.
-handle_sync_event(Event = #wx{obj=Panel}, WxEvent, #state{opts=Opts}) ->
- DC=wxPaintDC:new(Panel), %% We must create & destroy paintDC, or call wxEvent:skip(WxEvent))
- wxPaintDC:destroy(DC), %% in sync_event. Otherwise wx on windows keeps sending the events.
- Pid = proplists:get_value(parent, Opts),
- true = is_pid(Pid),
- Pid ! {sync_event, Event, WxEvent},
+handle_sync_event(Event = #wx{obj=Panel, event=#wxPaint{}},
+ WxEvent, #state{parent=Parent, user_state=US, opts=Opts}) ->
+ case proplists:get_value(redraw, Opts) of
+ undefined ->
+ DC=wxPaintDC:new(Panel), %% We must create & destroy paintDC, or call wxEvent:skip(WxEvent))
+ wxPaintDC:destroy(DC), %% in sync_event. Otherwise wx on windows keeps sending the events.
+ Parent ! {sync_event, Event, WxEvent};
+ Redraw ->
+ Redraw(Event, WxEvent, US)
+ end,
+ ok;
+handle_sync_event(Event, WxEvent, #state{parent=Parent}) ->
+ Parent ! {sync_event, Event, WxEvent},
ok.
-handle_event(Event, State = #state{opts=Opts}) ->
- Pid = proplists:get_value(parent, Opts),
- Pid ! {event, Event},
+handle_event(Event, State = #state{parent=Parent}) ->
+ Parent ! {event, Event},
{noreply, State}.
-handle_call(What, From, State) when is_function(What) ->
- Result = What(State),
+handle_call(What, From, State = #state{user_state=US}) when is_function(What) ->
+ Result = What(US),
{reply, {call, Result, From}, State};
+handle_call({stop, Fun}, From, State = #state{user_state=US}) ->
+ {stop, Fun(US), {stop, From}, State};
handle_call(What, From, State) ->
{reply, {call, What, From}, State}.
-handle_cast(What, State = #state{opts=Opts}) when is_function(What) ->
- Result = What(State),
- Pid = proplists:get_value(parent, Opts),
+handle_cast(What, State = #state{parent=Pid, user_state=US}) when is_function(What) ->
+ Result = What(US),
Pid ! {cast, Result},
{noreply, State};
-handle_cast(What, State = #state{opts=Opts}) ->
- Pid = proplists:get_value(parent, Opts),
+handle_cast(What, State = #state{parent=Pid}) ->
Pid ! {cast, What},
{noreply, State}.
-handle_info(What, State = #state{opts=Opts}) ->
- Pid = proplists:get_value(parent, Opts),
+handle_info(What, State = #state{parent=Pid}) ->
Pid ! {info, What},
{noreply, State}.
-terminate(What, #state{opts=Opts}) ->
- Pid = proplists:get_value(parent, Opts),
+terminate(What, #state{parent=Pid}) ->
Pid ! {terminate, What},
ok.
-code_change(Ver1, Ver2, State = #state{opts=Opts}) ->
- Pid = proplists:get_value(parent, Opts),
+code_change(Ver1, Ver2, State = #state{parent=Pid}) ->
Pid ! {code_change, Ver1, Ver2},
State.
diff --git a/lib/xmerl/src/xmerl_sax_parser.erl b/lib/xmerl/src/xmerl_sax_parser.erl
index 5c006aada2..ad71072d95 100644
--- a/lib/xmerl/src/xmerl_sax_parser.erl
+++ b/lib/xmerl/src/xmerl_sax_parser.erl
@@ -74,7 +74,8 @@ file(Name,Options) ->
CL = filename:absname(Dir),
File = filename:basename(Name),
ContinuationFun = fun default_continuation_cb/1,
- Res = stream(<<>>, [{continuation_fun, ContinuationFun},
+ Res = stream(<<>>,
+ [{continuation_fun, ContinuationFun},
{continuation_state, FD},
{current_location, CL},
{entity, File}
@@ -98,9 +99,13 @@ stream(Xml, Options) when is_list(Xml), is_list(Options) ->
State = parse_options(Options, initial_state()),
case State#xmerl_sax_parser_state.file_type of
dtd ->
- xmerl_sax_parser_list:parse_dtd(Xml, State#xmerl_sax_parser_state{encoding = list});
+ xmerl_sax_parser_list:parse_dtd(Xml,
+ State#xmerl_sax_parser_state{encoding = list,
+ input_type = stream});
normal ->
- xmerl_sax_parser_list:parse(Xml, State#xmerl_sax_parser_state{encoding = list})
+ xmerl_sax_parser_list:parse(Xml,
+ State#xmerl_sax_parser_state{encoding = list,
+ input_type = stream})
end;
stream(Xml, Options) when is_binary(Xml), is_list(Options) ->
case parse_options(Options, initial_state()) of
@@ -124,17 +129,14 @@ stream(Xml, Options) when is_binary(Xml), is_list(Options) ->
[],
State#xmerl_sax_parser_state.event_state};
{Xml1, State1} ->
- parse(Xml1, State1, ParseFunction)
+ parse_binary(Xml1,
+ State1#xmerl_sax_parser_state{input_type = stream},
+ ParseFunction)
end
end.
-
-%%======================================================================
-%% Internal functions
-%%======================================================================
-
%%----------------------------------------------------------------------
-%% Function: parse(Encoding, Xml, State, F) -> Result
+%% Function: parse_binary(Encoding, Xml, State, F) -> Result
%% Input: Encoding = atom()
%% Xml = [integer()] | binary()
%% State = #xmerl_sax_parser_state
@@ -144,15 +146,15 @@ stream(Xml, Options) when is_binary(Xml), is_list(Options) ->
%% EventState = term()
%% Description: Chooses the correct parser depending on the encoding.
%%----------------------------------------------------------------------
-parse(Xml, #xmerl_sax_parser_state{encoding=utf8}=State, F) ->
+parse_binary(Xml, #xmerl_sax_parser_state{encoding=utf8}=State, F) ->
xmerl_sax_parser_utf8:F(Xml, State);
-parse(Xml, #xmerl_sax_parser_state{encoding={utf16,little}}=State, F) ->
+parse_binary(Xml, #xmerl_sax_parser_state{encoding={utf16,little}}=State, F) ->
xmerl_sax_parser_utf16le:F(Xml, State);
-parse(Xml, #xmerl_sax_parser_state{encoding={utf16,big}}=State, F) ->
+parse_binary(Xml, #xmerl_sax_parser_state{encoding={utf16,big}}=State, F) ->
xmerl_sax_parser_utf16be:F(Xml, State);
-parse(Xml, #xmerl_sax_parser_state{encoding=latin1}=State, F) ->
+parse_binary(Xml, #xmerl_sax_parser_state{encoding=latin1}=State, F) ->
xmerl_sax_parser_latin1:F(Xml, State);
-parse(_, #xmerl_sax_parser_state{encoding=Enc}, _) ->
+parse_binary(_, #xmerl_sax_parser_state{encoding=Enc}, _) ->
{error, lists:flatten(io_lib:format("Charcter set ~p not supported", [Enc]))}.
%%----------------------------------------------------------------------
diff --git a/lib/xmerl/src/xmerl_sax_parser.hrl b/lib/xmerl/src/xmerl_sax_parser.hrl
index 736316e069..b433dd6cf9 100644
--- a/lib/xmerl/src/xmerl_sax_parser.hrl
+++ b/lib/xmerl/src/xmerl_sax_parser.hrl
@@ -86,7 +86,15 @@
file_type = normal, % Can be normal, dtd and entity
current_location, % Location of the currently parsed XML entity
entity, % Parsed XML entity
- skip_external_dtd = false % If true the external DTD is skipped during parsing
+ skip_external_dtd = false,% If true the external DTD is skipped during parsing
+ input_type % Source type: file | stream.
+ % This field is a preparation for an fix in R17 of a bug in
+ % the conformance against the standard.
+ % Today a file which contains two XML documents will be considered
+ % well-formed and the second is placed in the rest part of the
+ % return tuple, according to the conformance tests this should fail.
+ % In the future this will fail if xmerl_sax_aprser:file/2 is used but
+ % left to the user in the xmerl_sax_aprser:stream/2 case.
}).
diff --git a/lib/xmerl/src/xmerl_sax_parser_base.erlsrc b/lib/xmerl/src/xmerl_sax_parser_base.erlsrc
index 7b64d7c302..e198f2fef5 100644
--- a/lib/xmerl/src/xmerl_sax_parser_base.erlsrc
+++ b/lib/xmerl/src/xmerl_sax_parser_base.erlsrc
@@ -113,6 +113,10 @@ parse_dtd(Xml, State) ->
State3 = event_callback(endDocument, State2),
ets:delete(RefTable),
{ok, State3#xmerl_sax_parser_state.event_state, Rest};
+ {endDocument, Rest, State2} when is_record(State2, xmerl_sax_parser_state) ->
+ State3 = event_callback(endDocument, State2),
+ ets:delete(RefTable),
+ {ok, State3#xmerl_sax_parser_state.event_state, Rest};
Other ->
_State2 = event_callback(endDocument, State1),
ets:delete(RefTable),
@@ -207,8 +211,14 @@ parse_prolog(?STRING_EMPTY, State) ->
parse_prolog(?STRING("<") = Bytes, State) ->
cf(Bytes, State, fun parse_prolog/2);
parse_prolog(?STRING_REST("<?", Rest), State) ->
- {Rest1, State1} = parse_pi(Rest, State),
- parse_prolog(Rest1, State1);
+ case parse_pi(Rest, State) of
+ {Rest1, State1} ->
+ parse_prolog(Rest1, State1);
+ {endDocument, Rest1, State1} ->
+ parse_prolog(Rest1, State1)
+ % IValue = ?TO_INPUT_FORMAT("<?"),
+ % {?APPEND_STRING(IValue, Rest1), State1}
+ end;
parse_prolog(?STRING_REST("<!", Rest), State) ->
parse_prolog_1(Rest, State);
parse_prolog(?STRING_REST("<", Rest), State) ->
@@ -409,10 +419,11 @@ parse_pi(?STRING_UNBOUND_REST(C, Rest) = Bytes, State) ->
parse_name(Rest, State, [C]),
case string:to_lower(PiTarget) of
"xml" ->
- case State#xmerl_sax_parser_state.end_tags of
- [] ->
- {Bytes, State};
- _ ->
+ case check_if_new_doc_allowed(State#xmerl_sax_parser_state.input_type,
+ State#xmerl_sax_parser_state.end_tags) of
+ true ->
+ {endDocument, Bytes, State};
+ false ->
?fatal_error(State1, "<?xml ...?> not first in document")
end;
_ ->
@@ -426,6 +437,11 @@ parse_pi(?STRING_UNBOUND_REST(C, Rest) = Bytes, State) ->
parse_pi(Bytes, State) ->
unicode_incomplete_check([Bytes, State, fun parse_pi/2], undefined).
+check_if_new_doc_allowed(stream, []) ->
+ true;
+check_if_new_doc_allowed(_, _) ->
+ false.
+
%%----------------------------------------------------------------------
%% Function: parse_pi_1(Rest, State) -> Result
%% Input: Rest = string() | binary()
@@ -657,8 +673,13 @@ parse_misc(?STRING_EMPTY, State, Eod) ->
parse_misc(?STRING("<") = Rest, State, Eod) ->
cf(Rest, State, Eod, fun parse_misc/3);
parse_misc(?STRING_REST("<?", Rest), State, Eod) ->
- {Rest1, State1} = parse_pi(Rest, State),
- parse_misc(Rest1, State1, Eod);
+ case parse_pi(Rest, State) of
+ {Rest1, State1} ->
+ parse_misc(Rest1, State1, Eod);
+ {endDocument, _Rest1, State1} ->
+ IValue = ?TO_INPUT_FORMAT("<?"),
+ {?APPEND_STRING(IValue, Rest), State1}
+ end;
parse_misc(?STRING("<!") = Rest, State, Eod) ->
cf(Rest, State, Eod, fun parse_misc/3);
parse_misc(?STRING("<!-") = Rest, State, Eod) ->
@@ -1063,8 +1084,13 @@ parse_content(?STRING_REST("<!--", Rest), State, Acc, IgnorableWS) ->
parse_content(Rest1, State2, [], true);
parse_content(?STRING_REST("<?", Rest), State, Acc, IgnorableWS) ->
State1 = send_character_event(length(Acc), IgnorableWS, lists:reverse(Acc), State),
- {Rest1, State2} = parse_pi(Rest, State1),
- parse_content(Rest1, State2, [], true);
+ case parse_pi(Rest, State1) of
+ {Rest1, State2} ->
+ parse_content(Rest1, State2, [], true);
+ {endDocument, _Rest1, State2} ->
+ IValue = ?TO_INPUT_FORMAT("<?"),
+ {?APPEND_STRING(IValue, Rest), State2}
+ end;
parse_content(?STRING_REST("<!", Rest1) = Rest, #xmerl_sax_parser_state{end_tags = ET} = State, Acc, IgnorableWS) ->
case ET of
[] ->
@@ -1649,8 +1675,9 @@ handle_external_entity({file, FileToOpen}, State) ->
{?STRING_EMPTY, EntityState} =
parse_external_entity_1(<<>>,
State#xmerl_sax_parser_state{continuation_state=FD,
- current_location=filename:dirname(FileToOpen),
- entity=filename:basename(FileToOpen)}),
+ current_location=filename:dirname(FileToOpen),
+ entity=filename:basename(FileToOpen),
+ input_type=file}),
file:close(FD),
EntityState#xmerl_sax_parser_state.event_state
end;
@@ -1667,8 +1694,9 @@ handle_external_entity({http, Url}, State) ->
{?STRING_EMPTY, EntityState} =
parse_external_entity_1(<<>>,
State#xmerl_sax_parser_state{continuation_state=FD,
- current_location=filename:dirname(Url),
- entity=filename:basename(Url)}),
+ current_location=filename:dirname(Url),
+ entity=filename:basename(Url),
+ input_type=file}),
file:close(FD),
file:delete(TmpFile),
EntityState#xmerl_sax_parser_state.event_state
@@ -1881,8 +1909,13 @@ parse_doctype_decl(?STRING_EMPTY, State) ->
parse_doctype_decl(?STRING("<"), State) ->
cf(?STRING("<"), State, fun parse_doctype_decl/2);
parse_doctype_decl(?STRING_REST("<?", Rest), State) ->
- {Rest1, State1} = parse_pi(Rest, State),
- parse_doctype_decl(Rest1, State1);
+ case parse_pi(Rest, State) of
+ {Rest1, State1} ->
+ parse_doctype_decl(Rest1, State1);
+ {endDocument, _Rest1, State1} ->
+ IValue = ?TO_INPUT_FORMAT("<?"),
+ {?APPEND_STRING(IValue, Rest), State1}
+ end;
parse_doctype_decl(?STRING_REST("%", Rest), State) ->
{Ref, Rest1, State1} = parse_pe_reference(Rest, State),
case Ref of
diff --git a/lib/xmerl/test/xmerl_sax_SUITE.erl b/lib/xmerl/test/xmerl_sax_SUITE.erl
index 563bbaaa06..10a96f470b 100644
--- a/lib/xmerl/test/xmerl_sax_SUITE.erl
+++ b/lib/xmerl/test/xmerl_sax_SUITE.erl
@@ -67,7 +67,8 @@ end_per_testcase(_Func,_Config) ->
%% Description: Checks that end of document is checked properly when continuation fun is missing.
ticket_8213(suite) -> [];
ticket_8213(_Config) ->
- ?line {ok,ok,[]} = xmerl_sax_parser:stream("<elem/>", [{event_fun, fun (_E,_,_) -> ok end}]).
+ ?line {ok,ok,[]} = xmerl_sax_parser:stream("<elem/>", [{event_fun, fun (_E,_,_) -> ok end}]),
+ ok.
%%----------------------------------------------------------------------
@@ -86,7 +87,35 @@ ticket_8214(_Config) ->
({startElement, _, "elem",_,_}, _,_) ->
throw({test, "Error in startElement tuple"});
(_E,_,_) -> ok
- end}]).
+ end}]),
+ ok.
+
+%%----------------------------------------------------------------------
+%% Test Case
+%% ID: ticket_8214
+%% Description: Checks that attributes with default namespace don't get [] in NS field.
+ticket_11551(suite) -> [];
+ticket_11551(Config) ->
+ Stream1 = <<"<?xml version=\"1.0\" encoding=\"utf-8\" ?>
+<a>hej</a>
+<?xml version=\"1.0\" encoding=\"utf-8\" ?>
+<a>hej</a>">>,
+ ?line {ok, undefined, <<"<?xml", _/binary>>} = xmerl_sax_parser:stream(Stream1, []),
+ Stream2= <<"<?xml version=\"1.0\" encoding=\"utf-8\" ?>
+<a>hej</a>
+
+
+<?xml version=\"1.0\" encoding=\"utf-8\" ?>
+<a>hej</a>">>,
+ ?line {ok, undefined, <<"<?xml", _/binary>>} = xmerl_sax_parser:stream(Stream2, []),
+ Stream3= <<"<a>hej</a>
+
+<?xml version=\"1.0\" encoding=\"utf-8\" ?>
+<a>hej</a>">>,
+ ?line {ok, undefined, <<"<?xml", _/binary>>} = xmerl_sax_parser:stream(Stream3, []),
+ ok.
+
+
%%----------------------------------------------------------------------
%% Bug test cases
@@ -99,7 +128,7 @@ all() ->
[{group, bugs}].
groups() ->
- [{bugs, [], [ticket_8213, ticket_8214]}].
+ [{bugs, [], [ticket_8213, ticket_8214, ticket_11551]}].
init_per_group(_GroupName, Config) ->
Config.
diff --git a/lib/xmerl/test/xmerl_sax_std_SUITE.erl b/lib/xmerl/test/xmerl_sax_std_SUITE.erl
index 2b7b59dacf..6440329112 100644
--- a/lib/xmerl/test/xmerl_sax_std_SUITE.erl
+++ b/lib/xmerl/test/xmerl_sax_std_SUITE.erl
@@ -2074,8 +2074,9 @@ end_per_testcase(_Func,_Config) ->
%% Special case becase we returns everything after a legal document
%% as an rest instead of giving and error to let the user handle
%% multipple docs on a stream.
- ?line {ok,_,<<"xml version=\"1.0\"?>\r\n">>} = xmerl_sax_parser:file(Path, [{event_fun, fun(_,_,S) -> S end}]).
- %%?line check_result(R, "not-wf").
+ ?line {ok,_,<<"<?xml version=\"1.0\"?>\r\n">>} = xmerl_sax_parser:file(Path, [{event_fun, fun(_,_,S) -> S end}]).
+ % ?line R = xmerl_sax_parser:file(Path, [{event_fun, fun(_,_,S) -> S end}]),
+ % ?line check_result(R, "not-wf").
%%----------------------------------------------------------------------
%% Test Case
@@ -12361,8 +12362,9 @@ end_per_testcase(_Func,_Config) ->
%% Special case becase we returns everything after a legal document
%% as an rest instead of giving and error to let the user handle
%% multipple docs on a stream.
- ?line {ok,_, <<"xml version=\"1.0\"?>", _/binary>>} = xmerl_sax_parser:file(Path, [{event_fun, fun(_,_,S) -> S end}]).
- %%?line check_result(R, "not-wf").
+ ?line {ok,_, <<"<?xml version=\"1.0\"?>", _/binary>>} = xmerl_sax_parser:file(Path, [{event_fun, fun(_,_,S) -> S end}]).
+ % ?line R = xmerl_sax_parser:file(Path, [{event_fun, fun(_,_,S) -> S end}]),
+ % ?line check_result(R, "not-wf").
%%----------------------------------------------------------------------
%% Test Case
@@ -24625,7 +24627,7 @@ groups() ->
'not-wf-sa-136', 'not-wf-sa-137', 'not-wf-sa-138',
'not-wf-sa-139', 'not-wf-sa-140', 'not-wf-sa-141',
'not-wf-sa-142', 'not-wf-sa-143', 'not-wf-sa-144',
- 'not-wf-sa-145', 'not-wf-sa-146', 'not-wf-sa-147',
+ 'not-wf-sa-145', 'not-wf-sa-146', %'not-wf-sa-147', LATH: Check this later
'not-wf-sa-148', 'not-wf-sa-149', 'not-wf-sa-150',
'not-wf-sa-151', 'not-wf-sa-152', 'not-wf-sa-153',
'not-wf-sa-154', 'not-wf-sa-155', 'not-wf-sa-156',
diff --git a/lib/xmerl/test/xmerl_xsd_MS2002-01-16_SUITE.erl b/lib/xmerl/test/xmerl_xsd_MS2002-01-16_SUITE.erl
index 44ec4b592d..34a65ac6ff 100644
--- a/lib/xmerl/test/xmerl_xsd_MS2002-01-16_SUITE.erl
+++ b/lib/xmerl/test/xmerl_xsd_MS2002-01-16_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2006-2010. All Rights Reserved.
+%% Copyright Ericsson AB 2006-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -32,7 +32,7 @@
all() ->
- [att, ct, elem, group, idc_, id, mgABCD, mgEFG, mgHIJ,
+ [att, ct, elem, model_group, idc_, id, mgABCD, mgEFG, mgHIJ,
mgK, mgLM, mgN, mgOP, mgQR, mgS, particlesAB,
particlesCDE, particlesFHI, particlesJ,
particlesKOSRTQUVW, stABCDE, stFGH, stIJK, stZ,
@@ -5743,8 +5743,7 @@ elem(Config) when is_list(Config) ->
%% Syntax Checking Model Group Tests.
%% Content Checking Model Group Tests.
-
-group(Config) when is_list(Config) ->
+model_group(Config) when is_list(Config) ->
STResList0 = [],
?line {STRes0,_} = xmerl_xsd_lib:schema_test(Config,'./msxsdtest/Group/groupA001.xsd','./msxsdtest/Group',valid),
diff --git a/lib/xmerl/test/xmerl_xsd_MS2002-01-16_SUITE_data/msx_failed_cases.log b/lib/xmerl/test/xmerl_xsd_MS2002-01-16_SUITE_data/msx_failed_cases.log
index a89a9a798c..7ee2a56c20 100644
--- a/lib/xmerl/test/xmerl_xsd_MS2002-01-16_SUITE_data/msx_failed_cases.log
+++ b/lib/xmerl/test/xmerl_xsd_MS2002-01-16_SUITE_data/msx_failed_cases.log
@@ -532,7 +532,7 @@
"elemQ018.xml",
"elemO011.xml",
"elemO006.xml"],[]}}.
-{group,{["groupO027.xsd",
+{model_group,{["groupO027.xsd",
"groupO025.xsd",
"groupO024.xsd",
"groupO023.xsd",
diff --git a/lib/xmerl/vsn.mk b/lib/xmerl/vsn.mk
index 4b933deb4a..333466c11e 100644
--- a/lib/xmerl/vsn.mk
+++ b/lib/xmerl/vsn.mk
@@ -1 +1 @@
-XMERL_VSN = 1.3.5
+XMERL_VSN = 1.3.6