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

« back to all changes in this revision

Viewing changes to lib/stdlib/src/edlin.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:
1
1
%%
2
2
%% %CopyrightBegin%
3
 
%% 
4
 
%% Copyright Ericsson AB 1996-2009. All Rights Reserved.
5
 
%% 
 
3
%%
 
4
%% Copyright Ericsson AB 1996-2010. All Rights Reserved.
 
5
%%
6
6
%% The contents of this file are subject to the Erlang Public License,
7
7
%% Version 1.1, (the "License"); you may not use this file except in
8
8
%% compliance with the License. You should have received a copy of the
9
9
%% Erlang Public License along with this software. If not, it can be
10
10
%% retrieved online at http://www.erlang.org/.
11
 
%% 
 
11
%%
12
12
%% Software distributed under the License is distributed on an "AS IS"
13
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
14
%% the License for the specific language governing rights and limitations
15
15
%% under the License.
16
 
%% 
 
16
%%
17
17
%% %CopyrightEnd%
18
18
%%
19
19
-module(edlin).
24
24
-export([init/0,start/1,edit_line/2,prefix_arg/1]).
25
25
-export([erase_line/1,erase_inp/1,redraw_line/1]).
26
26
-export([length_before/1,length_after/1,prompt/1]).
 
27
-export([current_line/1]).
27
28
%%-export([expand/1]).
28
29
 
29
30
-export([edit_line1/2]).
30
31
 
31
32
-import(lists, [reverse/1, reverse/2]).
32
33
 
33
 
%-import([nthtail/2, keysearch/3, prefix/2]).
34
 
 
35
34
-export([over_word/3]).
36
35
 
37
36
 
281
280
%%  Step over word/non-word characters pushing the stepped over ones on
282
281
%%  the stack.
283
282
 
284
 
over_word([C|Cs], Stack, N) ->
 
283
 
 
284
over_word(Cs, Stack, N) ->
 
285
    L = length([1 || $\' <- Cs]),
 
286
    case L rem 2 of
 
287
        0 ->
 
288
            over_word1(Cs, Stack, N);
 
289
        1 ->
 
290
            until_quote(Cs, Stack, N)
 
291
    end.
 
292
 
 
293
until_quote([$\'|Cs], Stack, N) ->
 
294
    {Cs, [$\'|Stack], N+1};
 
295
until_quote([C|Cs], Stack, N) ->
 
296
    until_quote(Cs, [C|Stack], N+1).
 
297
 
 
298
over_word1([$\'=C|Cs], Stack, N) ->
 
299
    until_quote(Cs, [C|Stack], N+1);
 
300
over_word1(Cs, Stack, N) ->
 
301
    over_word2(Cs, Stack, N).
 
302
 
 
303
over_word2([C|Cs], Stack, N) ->
285
304
    case word_char(C) of
286
 
        true -> over_word(Cs, [C|Stack], N+1);
 
305
        true -> over_word2(Cs, [C|Stack], N+1);
287
306
        false -> {[C|Cs],Stack,N}
288
307
    end;
289
 
over_word([], Stack, N) when is_integer(N) ->
 
308
over_word2([], Stack, N) when is_integer(N) ->
290
309
    {[],Stack,N}.
291
310
 
292
311
over_non_word([C|Cs], Stack, N) ->
403
422
%% length_before(Line)
404
423
%% length_after(Line)
405
424
%% prompt(Line)
 
425
%% current_line(Line)
406
426
%%  Various functions for accessing bits of a line.
407
427
 
408
428
erase_line({line,Pbs,{Bef,Aft},_}) ->
429
449
prompt({line,Pbs,_,_}) ->
430
450
    Pbs.
431
451
 
 
452
current_line({line,_,{Bef, Aft},_}) ->
 
453
    reverse(Bef, Aft ++ "\n").
 
454
 
432
455
%% %% expand(CurrentBefore) ->
433
456
%% %%   {yes,Expansion} | no
434
457
%% %%  Try to expand the word before as either a module name or a function
456
479
%%     case erlang:module_loaded(Mod) of
457
480
%%      true ->
458
481
%%          L = apply(Mod, module_info, []),
459
 
%%          case keysearch(exports, 1, L) of
460
 
%%              {value, {_, Exports}} ->
 
482
%%          case lists:keyfind(exports, 1, L) of
 
483
%%              {_, Exports} ->
461
484
%%                  match(FuncPrefix, Exports, "(");
462
485
%%              _ ->
463
486
%%                  no
473
496
%%          print_matches(Matches),
474
497
%%          no;
475
498
%%      {partial, Str} ->
476
 
%%          case nthtail(length(Prefix), Str) of
 
499
%%          case lists:nthtail(length(Prefix), Str) of
477
500
%%              [] ->
478
501
%%                  print_matches(Matches),
479
502
%%                  {yes, []};
481
504
%%                  {yes, Remain}
482
505
%%          end;
483
506
%%      {complete, Str} ->
484
 
%%          {yes, nthtail(length(Prefix), Str) ++ Extra};
 
507
%%          {yes, lists:nthtail(length(Prefix), Str) ++ Extra};
485
508
%%      no ->
486
509
%%          no
487
510
%%     end.