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

« back to all changes in this revision

Viewing changes to lib/kernel/src/user.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(user).
26
26
 
27
27
-define(NAME, user).
28
28
 
29
 
%% Internal exports
30
 
-export([server/1, server/2]).
31
 
 
32
29
%% Defines for control ops
33
30
-define(CTRL_OP_GET_WINSIZE,100).
34
31
 
43
40
    %% Mod,Fun,Args should return a pid. That process is supposed to act
44
41
    %% as the io port.
45
42
    Pid = apply(Mod, Fun, Args),  % This better work!
46
 
    Id = spawn(?MODULE, server, [Pid]),
 
43
    Id = spawn(fun() -> server(Pid) end),
47
44
    register(?NAME, Id),
48
45
    Id.
49
46
 
52
49
    start_port([out,binary]).
53
50
 
54
51
start_port(PortSettings) ->
55
 
    Id = spawn(?MODULE,server,[{fd,0,1},PortSettings]),
56
 
    register(?NAME,Id),
 
52
    Id = spawn(fun() -> server({fd,0,1}, PortSettings) end),
 
53
    register(?NAME, Id),
57
54
    Id.
58
55
 
59
56
%% Return the pid of the shell process.
72
69
            []
73
70
    end.
74
71
 
75
 
 
76
72
server(Pid) when is_pid(Pid) ->
77
73
    process_flag(trap_exit, true),
78
74
    link(Pid),
104
100
        new_shell ->
105
101
            exit(Shell, kill),
106
102
            catch_loop(Port, start_new_shell());
107
 
        {unknown_exit,{Shell,Reason},_} ->                      % shell has exited
 
103
        {unknown_exit,{Shell,Reason},_} ->               % shell has exited
108
104
            case Reason of
109
105
                normal ->
110
106
                    put_chars("*** ", Port, []);
172
168
 
173
169
get_fd_geometry(Port) ->
174
170
    case (catch port_control(Port,?CTRL_OP_GET_WINSIZE,[])) of
175
 
        List when is_list(List), length(List) =:= 8 -> 
 
171
        List when length(List) =:= 8 ->
176
172
            <<W:32/native,H:32/native>> = list_to_binary(List),
177
173
            {W,H};
178
174
        _ ->
373
369
    end.
374
370
 
375
371
getopts(_Port,Q) ->
376
 
    Bin = {binary, case get(read_mode) of
377
 
                       binary ->
378
 
                           true;
379
 
                       _ ->
380
 
                           false
381
 
                   end},
 
372
    Bin = {binary, get(read_mode) =:= binary},
382
373
    Uni = {encoding, case get(unicode) of
383
374
                       true ->
384
375
                           unicode;
698
689
prompt(_Port, '') -> ok;
699
690
 
700
691
prompt(Port, Prompt) ->
701
 
    put_port(io_lib:format_prompt(Prompt), Port).
 
692
    put_port(wrap_characters_to_binary(io_lib:format_prompt(Prompt),unicode,
 
693
                                       case get(unicode) of 
 
694
                                           true -> unicode;
 
695
                                           _ -> latin1
 
696
                                       end), Port).
702
697
 
703
698
%% Convert error code to make it look as before
704
699
err_func(io_lib, get_until, {_,F,_}) ->