~clint-fewbar/ubuntu/precise/erlang/merge-15b

« back to all changes in this revision

Viewing changes to lib/stdlib/src/binary.erl

  • Committer: Package Import Robot
  • Author(s): Sergei Golovan
  • Date: 2011-12-15 19:20:10 UTC
  • mfrom: (1.1.18) (3.5.15 sid)
  • mto: (3.5.16 sid)
  • mto: This revision was merged to the branch mainline in revision 33.
  • Revision ID: package-import@ubuntu.com-20111215192010-jnxcfe3tbrpp0big
Tags: 1:15.b-dfsg-1
* New upstream release.
* Upload to experimental because this release breaks external drivers
  API along with ABI, so several applications are to be fixed.
* Removed SSL patch because the old SSL implementation is removed from
  the upstream distribution.
* Removed never used patch which added native code to erlang beam files.
* Removed the erlang-docbuilder binary package because the docbuilder
  application was dropped by upstream.
* Documented dropping ${erlang-docbuilder:Depends} substvar in
  erlang-depends(1) manpage.
* Made erlang-base and erlang-base-hipe provide virtual package
  erlang-abi-15.b (the number means the first erlang version, which
  provides current ABI).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
%%
2
2
%% %CopyrightBegin%
3
3
%%
4
 
%% Copyright Ericsson AB 2010. All Rights Reserved.
 
4
%% Copyright Ericsson AB 2010-2011. All Rights Reserved.
5
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
38
38
%% Implemented in this module:
39
39
-export([split/2,split/3,replace/3,replace/4]).
40
40
 
 
41
-opaque cp() :: tuple().
 
42
-type part() :: {Start :: non_neg_integer(), Length :: integer()}.
 
43
 
41
44
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42
45
%% split
43
46
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
47
 
 
48
-spec split(Subject, Pattern) -> Parts when
 
49
      Subject :: binary(),
 
50
      Pattern :: binary() | [binary()] | cp(),
 
51
      Parts :: [binary()].
 
52
 
44
53
split(H,N) ->
45
54
    split(H,N,[]).
 
55
 
 
56
-spec split(Subject, Pattern, Options) -> Parts when
 
57
      Subject :: binary(),
 
58
      Pattern :: binary() | [binary()] | cp(),
 
59
      Options :: [Option],
 
60
      Option :: {scope, part()} | trim | global,
 
61
      Parts :: [binary()].
 
62
 
46
63
split(Haystack,Needles,Options) ->
47
64
    try
48
65
        {Part,Global,Trim} = get_opts_split(Options,{no,false,false}),
89
106
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
90
107
%% replace
91
108
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
109
 
 
110
-spec replace(Subject, Pattern, Replacement) -> Result when
 
111
      Subject :: binary(),
 
112
      Pattern :: binary() | [ binary() ] | cp(),
 
113
      Replacement :: binary(),
 
114
      Result :: binary().
 
115
 
92
116
replace(H,N,R) ->
93
117
    replace(H,N,R,[]).
 
118
 
 
119
-spec replace(Subject, Pattern, Replacement, Options) -> Result when
 
120
      Subject :: binary(),
 
121
      Pattern :: binary() | [ binary() ] | cp(),
 
122
      Replacement :: binary(),
 
123
      Options :: [Option],
 
124
      Option :: global | {scope, part()} | {insert_replaced, InsPos},
 
125
      InsPos :: OnePos | [ OnePos ],
 
126
      OnePos :: non_neg_integer(),
 
127
      Result :: binary().
 
128
 
94
129
replace(Haystack,Needles,Replacement,Options) ->
95
130
    try
96
131
        true = is_binary(Replacement), % Make badarg instead of function clause