From 6088c2c426d71a21874673ca6ddf93aa9e2ed4ab Mon Sep 17 00:00:00 2001 From: Lars Thorsen Date: Tue, 13 Dec 2011 13:58:53 +0100 Subject: [xmerl] Remove trailing blanks OTP-9821 --- lib/xmerl/src/xmerl_scan.erl | 336 +++++++++++++++++++++---------------------- 1 file changed, 168 insertions(+), 168 deletions(-) diff --git a/lib/xmerl/src/xmerl_scan.erl b/lib/xmerl/src/xmerl_scan.erl index 48951b6723..05431a5fd2 100644 --- a/lib/xmerl/src/xmerl_scan.erl +++ b/lib/xmerl/src/xmerl_scan.erl @@ -20,8 +20,8 @@ %% Description : Simgle-pass XML scanner. See xmerl.hrl for data defs. %% @doc This module is the interface to the XML parser, it handles XML 1.0. -%% The XML parser is activated through -%% xmerl_scan:string/[1,2] or +%% The XML parser is activated through +%% xmerl_scan:string/[1,2] or %% xmerl_scan:file/[1,2]. %% It returns records of the type defined in xmerl.hrl. %% See also tutorial on customization @@ -79,15 +79,15 @@ %%
{validation, Flag}
%%
Controls whether to process as a validating XML parser: %% 'off' (default) no validation, or validation 'dtd' by DTD or 'schema' -%% by XML Schema. 'false' and 'true' options are obsolete -%% (i.e. they may be removed in a future release), if used 'false' +%% by XML Schema. 'false' and 'true' options are obsolete +%% (i.e. they may be removed in a future release), if used 'false' %% equals 'off' and 'true' equals 'dtd'.
%%
{schemaLocation, [{Namespace,Link}|...]}
-%%
Tells explicitly which XML Schema documents to use to validate -%% the XML document. Used together with the +%%
Tells explicitly which XML Schema documents to use to validate +%% the XML document. Used together with the %% {validation,schema} option.
%%
{quiet, Flag}
-%%
Set to 'true' if xmerl should behave quietly and not output any +%%
Set to 'true' if xmerl should behave quietly and not output any %% information to standard output (default 'false').
%%
{doctype_DTD, DTD}
%%
Allows to specify DTD name when it isn't available in the XML @@ -275,7 +275,7 @@ int_file_decl(F, Options,_ExtCharset) -> %% @spec string(Text::list()) -> {xmlElement(),Rest} %% Rest = list() %% @equiv string(Test, []) -string(Str) -> +string(Str) -> string(Str, []). %% @spec string(Text::list(),Options::option_list()) -> {document(),Rest} @@ -306,7 +306,7 @@ int_string(Str, Options, XMLBase, FileName) -> scan_document(Str2, S#xmerl_scanner{encoding="iso-10646-utf-1"}); {undefined,undefined,Str2} -> %% no auto detection scan_document(Str2, S); - {external,ExtCharset,Str2} -> + {external,ExtCharset,Str2} -> %% no auto detection, ExtCharset is an explicitly provided %% 7 bit,8 bit or utf-8 encoding scan_document(Str2, S#xmerl_scanner{encoding=atom_to_list(ExtCharset)}) @@ -325,7 +325,7 @@ int_string_decl(Str, Options, XMLBase, FileName) -> {external,ExtCharset,Str2} -> scan_decl(Str2, S#xmerl_scanner{encoding=atom_to_list(ExtCharset)}) end. - + initial_state0(Options,XMLBase) -> @@ -386,7 +386,7 @@ initial_state([{line, L}|T], S) -> initial_state(T, S#xmerl_scanner{line = L}); initial_state([{namespace_conformant, F}|T], S) when F==true; F==false -> initial_state(T, S#xmerl_scanner{namespace_conformant = F}); -initial_state([{validation, F}|T], S) +initial_state([{validation, F}|T], S) when F==off; F==dtd; F==schema; F==true; F==false -> initial_state(T, S#xmerl_scanner{validation = validation_value(F)}); initial_state([{schemaLocation, SL}|T], S) when is_list(SL) -> @@ -422,7 +422,7 @@ validation_value(false) -> validation_value(F) -> F. -%% Used for compacting (some) indentations. +%% Used for compacting (some) indentations. %% See also fast_accumulate_whitespace(). common_data() -> {comdata(lists:duplicate(60, $\s), []), @@ -465,7 +465,7 @@ event(_X, S) -> %% where Pos' can be derived from X#xmlElement.pos, X#xmlText.pos, or %% X#xmlAttribute.pos (whichever is the current object type.) %% The acc/3 function is not allowed to redefine the type of object -%% being defined, but _is_ allowed to either ignore it or split it +%% being defined, but _is_ allowed to either ignore it or split it %% into multiple objects (in which case {Acc',Pos',S'} should be returned.) %% If {Acc',S'} is returned, Pos will be incremented by 1 by default. %% Below is an example of an acceptable operation @@ -488,10 +488,10 @@ fetch_URI(URI, S) -> %% assume URI is a filename Split = filename:split(URI), Filename = fun([])->[];(X)->lists:last(X) end (Split), - Fullname = + Fullname = case Split of %% how about Windows systems? ["file:"|Name]-> %% absolute path, see RFC2396 sect 3 - %% file:/dtd_name + %% file:/dtd_name filename:join(["/"|Name]); ["/"|Rest] when Rest /= [] -> %% absolute path name @@ -544,9 +544,9 @@ scan_document(Str0, S=#xmerl_scanner{event_fun = Event, line = L, col = C, data = document}, S), - + %% Transform to given character set. - %% Note that if another character set is given in the encoding + %% Note that if another character set is given in the encoding %% attribute in a XML declaration that one will be used later Str=if Charset == "utf-8" -> @@ -573,7 +573,7 @@ scan_document(Str0, S=#xmerl_scanner{event_fun = Event, {Misc, _Pos1, Tail, S4}=scan_misc(T3, S3, Pos + 1), %% M5 = erlang:memory(), %% io:format("Memory status after misc: ~p~n",[M5]), - + S5 = #xmerl_scanner{} = Event(#xmerl_event{event = ended, line = S4#xmerl_scanner.line, col = S4#xmerl_scanner.col, @@ -636,7 +636,7 @@ scan_decl(Str, S=#xmerl_scanner{event_fun = Event, line = L, col = C, data = document}, S), - + case scan_prolog(Str, S1, _StartPos = 1) of {_,_,T2="<"++_, S2} -> {{S2#xmerl_scanner.user_state,T2},[],S2}; @@ -665,14 +665,14 @@ scan_prolog(" {Charset, T3, S3} = if - Col==1,L==1,S0#xmerl_scanner.text_decl==true -> + Col==1,L==1,S0#xmerl_scanner.text_decl==true -> ?dbg("prolog(\" + Col==1,L==1 -> ?dbg("prolog(\" ?dbg("prolog(\"<\")~n", []), - + %% Check for Comments, PI before possible DOCTYPE declaration ?bump_col(1), %% If no known character set assume it is UTF-8 @@ -759,7 +759,7 @@ scan_prolog2(Str = " {Acc, Pos, T, S1}; scan_prolog2(Str, S0 = #xmerl_scanner{user_state=_US},Pos,Acc) -> ?dbg("prolog(\"<\")~n", []), - + %% Here we consider the DTD provided by doctype_DTD option, S1 = case S0 of @@ -793,7 +793,7 @@ scan_misc("";Tok=="/>"-> [Tok|Stack]; pe_push(_,Stack,_S) -> @@ -3841,10 +3841,10 @@ scan_comment(Str,S=#xmerl_scanner{col=C,event_fun=Event}, Pos, Parents, Lang) -> col = C, pos = Pos, data = Comment}, S), - + scan_comment1(Str, S1, Pos, Comment, _Acc = []). -scan_comment1([], S=#xmerl_scanner{continuation_fun = F}, +scan_comment1([], S=#xmerl_scanner{continuation_fun = F}, Pos, Comment, Acc) -> ?dbg("cont()...~n", []), F(fun(MoreBytes, S1) -> scan_comment1(MoreBytes, S1, Pos, Comment, Acc) end, @@ -3852,7 +3852,7 @@ scan_comment1([], S=#xmerl_scanner{continuation_fun = F}, S); scan_comment1("-->" ++ T, S0 = #xmerl_scanner{col = C, event_fun = Event, - hook_fun = Hook}, + hook_fun = Hook}, _Pos, Comment, Acc) -> ?bump_col(3), Comment1 = Comment#xmlComment{value = lists:reverse(Acc)}, @@ -3960,9 +3960,9 @@ normalize(T,S,IsNorm) -> end. -%% Optimization: +%% Optimization: %% - avoid building list of spaces or tabs; -%% - avoid reverse; +%% - avoid reverse; %% - compact two common indentation patterns. %% Note: only to be called when a \n was found. fast_accumulate_whitespace(" " ++ T, S, _) -> @@ -3974,7 +3974,7 @@ fast_accumulate_whitespace("<"++_=R, S, _T) -> {done, {element(3, CD), R, S#xmerl_scanner{col = 1, line = Line + 1}}}; fast_accumulate_whitespace(_, S, T) -> accumulate_whitespace(T, S, []). - + fast_acc_spaces(" " ++ T, S, N) -> fast_acc_spaces(T, S, N + 1); fast_acc_spaces(T, S, N) -> @@ -3988,18 +3988,18 @@ fast_acc_tabs(T, S, N) -> fast_acc_end(T, S, N, Col, C, CD_I) -> #xmerl_scanner{common_data = CD, line = Line0} = S, Line = Line0 + 1, - try + try $< = hd(T), - {done,{element(N, element(CD_I, CD)), T, + {done,{element(N, element(CD_I, CD)), T, S#xmerl_scanner{col = Col, line = Line}}} - catch _:_ -> + catch _:_ -> accumulate_whitespace(T, S, Line, Col, lists:duplicate(N, C)++"\n") end. - + %%% @spec accumulate_whitespace(T::string(),S::global_state(), %%% atom(),Acc::string()) -> {Acc, T1, S1} -%%% +%%% %%% @doc Function to accumulate and normalize whitespace. accumulate_whitespace(T, S, preserve, Acc) -> accumulate_whitespace(T, S, Acc); @@ -4058,19 +4058,19 @@ schemaLocations(El,#xmerl_scanner{schemaLocation=SL}) -> schemaLocations(El) end. -schemaLocations(#xmlElement{attributes=Atts,xmlbase=_Base}) -> +schemaLocations(#xmlElement{attributes=Atts,xmlbase=_Base}) -> Pred = fun(#xmlAttribute{name=schemaLocation}) -> false; (#xmlAttribute{nsinfo={_,"schemaLocation"}}) -> false; (_) -> true end, case lists:dropwhile(Pred,Atts) of [#xmlAttribute{value=Paths}|_] -> - + case string:tokens(Paths," \n\t\r") of L when length(L) > 0 -> case length(L) rem 2 of 0 -> - PairList = + PairList = fun([],_Fun) -> []; ([SLNS,SLLoc|Rest],Fun) -> @@ -4140,7 +4140,7 @@ to_ucs(Encoding, Chars) when Encoding=="utf-8"; Encoding == undefined -> utf8_2_ucs(Chars); to_ucs(_,[C|Rest]) -> {C,Rest}. - + utf8_2_ucs([A,B,C,D|Rest]) when A band 16#f8 =:= 16#f0, B band 16#c0 =:= 16#80, C band 16#c0 =:= 16#80, @@ -4229,7 +4229,7 @@ string_to_char_set(_,Str) -> %% {{_,{_,Tot}},Tot110} when Tot > Tot110 -> %% io:format("From ~p to ~p, total memory: ~p (~p)~n",[OldLine,Line,Tot,OldTot]), %% Tot; -%% {{_,{_,Tot}},_} -> +%% {{_,{_,Tot}},_} -> %% Tot %% end, %% put_total({NewTot,Line}). -- cgit v1.2.3