~ubuntu-branches/ubuntu/trusty/erlang/trusty

« back to all changes in this revision

Viewing changes to lib/syntax_tools/src/erl_recomment.erl

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2011-05-05 15:48:43 UTC
  • mfrom: (3.5.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110505154843-0om6ekzg6m7ugj27
Tags: 1:14.b.2-dfsg-3ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Drop libwxgtk2.8-dev build dependency. Wx isn't in main, and not
    supposed to.
  - Drop erlang-wx binary.
  - Drop erlang-wx dependency from -megaco, -common-test, and -reltool, they
    do not really need wx. Also drop it from -debugger; the GUI needs wx,
    but it apparently has CLI bits as well, and is also needed by -megaco,
    so let's keep the package for now.
  - debian/patches/series: Do what I meant, and enable build-options.patch
    instead.
* Additional changes:
  - Drop erlang-wx from -et
* Dropped Changes:
  - patches/pcre-crash.patch: CVE-2008-2371: outer level option with
    alternatives caused crash. (Applied Upstream)
  - fix for ssl certificate verification in newSSL: 
    ssl_cacertfile_fix.patch (Applied Upstream)
  - debian/patches/series: Enable native.patch again, to get stripped beam
    files and reduce the package size again. (build-options is what
    actually accomplished this)
  - Remove build-options.patch on advice from upstream and because it caused
    odd build failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
%% comments. Comments within function definitions or declarations
48
48
%% ("forms") are simply ignored.
49
49
 
 
50
-spec quick_recomment_forms(erl_syntax:forms(), [erl_comment_scan:comment()]) ->
 
51
        erl_syntax:syntaxTree().
 
52
 
50
53
quick_recomment_forms(Tree, Cs) ->
51
54
    recomment_forms(Tree, Cs, false).
52
55
 
109
112
%% @see recomment_tree/2
110
113
%% @see quick_recomment_forms/2
111
114
 
 
115
-spec recomment_forms(erl_syntax:forms(), [erl_comment_scan:comment()]) ->
 
116
        erl_syntax:syntaxTree().
 
117
 
112
118
recomment_forms(Tree, Cs) ->
113
119
    recomment_forms(Tree, Cs, true).
114
120
 
209
215
%% the source file itself, but have been included by preprocessing. This
210
216
%% way, comments will not be inserted into such parts by mistake.
211
217
 
212
 
-record(filter, {file = undefined, line = 0}).
 
218
-record(filter, {file = undefined :: file:filename() | 'undefined',
 
219
                 line = 0         :: integer()}).
213
220
 
214
221
filter_forms(Fs) ->
215
222
    filter_forms(Fs, false, #filter{}).
330
337
%%
331
338
%% @see recomment_forms/2
332
339
 
 
340
-spec recomment_tree(erl_syntax:syntaxTree(), [erl_comment_scan:comment()]) ->
 
341
        {erl_syntax:syntaxTree(), [erl_comment_scan:comment()]}.
 
342
 
333
343
recomment_tree(Tree, Cs) ->
334
344
    {Tree1, Cs1} = insert_comments(Cs, build_tree(Tree)),
335
345
    {revert_tree(Tree1), Cs1}.
477
487
            
478
488
            %% Include L, while preserving Min =< Max.
479
489
            tree_node(minpos(L, Min),
480
 
                      max(L, Max),
 
490
                      erlang:max(L, Max),
481
491
                      erl_syntax:type(Node),
482
492
                      erl_syntax:get_attrs(Node),
483
493
                      Subtrees)
498
508
build_list([T | Ts], Min, Max, Ack) ->
499
509
    Node = build_tree(T),
500
510
    Min1 = minpos(node_min(Node), Min),
501
 
    Max1 = max(node_max(Node), Max),
 
511
    Max1 = erlang:max(node_max(Node), Max),
502
512
    build_list(Ts, Min1, Max1, [Node | Ack]);
503
513
build_list([], Min, Max, Ack) ->
504
514
    list_node(Min, Max, lists:reverse(Ack)).
509
519
build_list_list([L | Ls], Min, Max, Ack) ->
510
520
    Node = build_list(L),
511
521
    Min1 = minpos(node_min(Node), Min),
512
 
    Max1 = max(node_max(Node), Max),
 
522
    Max1 = erlang:max(node_max(Node), Max),
513
523
    build_list_list(Ls, Min1, Max1, [Node | Ack]);
514
524
build_list_list([], Min, Max, Ack) ->
515
525
    {lists:reverse(Ack), Min, Max}.
592
602
%% syntax tree for any such tree that can have no subtrees, i.e., such
593
603
%% that `erl_syntax:is_leaf' yields `true'.
594
604
 
595
 
-record(leaf, {min = 0,
596
 
               max = 0,
597
 
               precomments = [],
598
 
               postcomments = [],
599
 
               value}).
600
 
 
601
 
-record(tree, {min = 0,
602
 
               max = 0,
603
 
               type,
604
 
               attrs,
605
 
               precomments = [],
606
 
               postcomments = [],
607
 
               subtrees = []}).
608
 
 
609
 
-record(list, {min = 0,
610
 
               max = 0,
611
 
               subtrees = []}).
 
605
-record(leaf, {min = 0           :: integer(),
 
606
               max = 0           :: integer(),
 
607
               precomments  = [] :: [erl_syntax:syntaxTree()],
 
608
               postcomments = [] :: [erl_syntax:syntaxTree()],
 
609
               value             :: erl_syntax:syntaxTree()}).
 
610
 
 
611
-record(tree, {min = 0           :: integer(),
 
612
               max = 0           :: integer(),
 
613
               type              :: atom(),
 
614
               attrs             :: erl_syntax:syntaxTreeAttributes(),
 
615
               precomments  = [] :: [erl_syntax:syntaxTree()],
 
616
               postcomments = [] :: [erl_syntax:syntaxTree()],
 
617
               subtrees     = [] :: [erl_syntax:syntaxTree()]}).
 
618
 
 
619
-record(list, {min = 0           :: integer(),
 
620
               max = 0           :: integer(),
 
621
               subtrees = []     :: [erl_syntax:syntaxTree()]}).
612
622
 
613
623
leaf_node(Min, Max, Value) ->
614
624
    #leaf{min = Min,
712
722
%% =====================================================================
713
723
%% General utility functions
714
724
 
715
 
%% Just the generic "maximum" function
716
 
 
717
 
max(X, Y) when X > Y -> X;
718
 
max(_, Y) -> Y.
719
 
 
720
725
%% Return the least positive integer of X and Y, or zero if none of them
721
726
%% are positive. (This is necessary for computing minimum source line
722
727
%% numbers, since zero (or negative) numbers may occur, but they