aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stdlib')
-rw-r--r--lib/stdlib/doc/src/epp.xml26
-rw-r--r--lib/stdlib/doc/src/erl_lint.xml8
-rw-r--r--lib/stdlib/doc/src/erl_parse.xml26
-rw-r--r--lib/stdlib/doc/src/file_sorter.xml14
-rw-r--r--lib/stdlib/doc/src/gb_sets.xml8
-rw-r--r--lib/stdlib/doc/src/gb_trees.xml8
-rw-r--r--lib/stdlib/doc/src/io.xml2
-rw-r--r--lib/stdlib/doc/src/lists.xml17
-rw-r--r--lib/stdlib/doc/src/proplists.xml9
-rw-r--r--lib/stdlib/doc/src/re.xml2
-rw-r--r--lib/stdlib/doc/src/shell.xml41
-rw-r--r--lib/stdlib/doc/src/sofs.xml17
-rw-r--r--lib/stdlib/doc/src/stdlib_app.xml34
-rw-r--r--lib/stdlib/doc/src/supervisor.xml44
-rw-r--r--lib/stdlib/src/Makefile3
-rw-r--r--lib/stdlib/src/dets_v8.erl40
-rw-r--r--lib/stdlib/src/edlin.erl10
-rw-r--r--lib/stdlib/src/epp.erl265
-rw-r--r--lib/stdlib/src/erl_lint.erl114
-rw-r--r--lib/stdlib/src/escript.erl71
-rw-r--r--lib/stdlib/src/file_sorter.erl34
-rw-r--r--lib/stdlib/src/filelib.erl22
-rw-r--r--lib/stdlib/src/io_lib.erl14
-rw-r--r--lib/stdlib/src/qlc.erl159
-rw-r--r--lib/stdlib/src/qlc_pt.erl32
-rw-r--r--lib/stdlib/src/shell.erl104
-rw-r--r--lib/stdlib/src/shell_default.erl11
-rw-r--r--lib/stdlib/src/supervisor.erl59
-rw-r--r--lib/stdlib/test/Makefile2
-rw-r--r--lib/stdlib/test/calendar_SUITE.erl26
-rw-r--r--lib/stdlib/test/epp_SUITE.erl143
-rw-r--r--lib/stdlib/test/erl_lint_SUITE.erl12
-rw-r--r--lib/stdlib/test/ets_tough_SUITE.erl18
-rw-r--r--lib/stdlib/test/filelib_SUITE.erl30
-rw-r--r--lib/stdlib/test/fixtable_SUITE.erl26
-rw-r--r--lib/stdlib/test/format_SUITE.erl12
-rw-r--r--lib/stdlib/test/gen_event_SUITE.erl30
-rw-r--r--lib/stdlib/test/io_proto_SUITE.erl50
-rw-r--r--lib/stdlib/test/ms_transform_SUITE.erl36
-rw-r--r--lib/stdlib/test/queue_SUITE.erl22
-rw-r--r--lib/stdlib/test/re_SUITE.erl10
-rw-r--r--lib/stdlib/test/re_testoutput1_replacement_test.erl11
-rw-r--r--lib/stdlib/test/re_testoutput1_split_test.erl11
-rw-r--r--lib/stdlib/test/run_pcre_tests.erl2
-rw-r--r--lib/stdlib/test/select_SUITE.erl16
-rw-r--r--lib/stdlib/test/shell_SUITE.erl115
-rw-r--r--lib/stdlib/test/slave_SUITE.erl18
-rw-r--r--lib/stdlib/test/sofs_SUITE.erl132
-rw-r--r--lib/stdlib/test/supervisor_SUITE.erl243
-rw-r--r--lib/stdlib/test/tar_SUITE.erl18
-rw-r--r--lib/stdlib/test/timer_SUITE.erl12
-rw-r--r--lib/stdlib/test/unicode_SUITE.erl82
-rw-r--r--lib/stdlib/test/win32reg_SUITE.erl14
-rw-r--r--lib/stdlib/test/zip_SUITE.erl20
54 files changed, 1474 insertions, 831 deletions
diff --git a/lib/stdlib/doc/src/epp.xml b/lib/stdlib/doc/src/epp.xml
index 455d9dc124..e6b48b270a 100644
--- a/lib/stdlib/doc/src/epp.xml
+++ b/lib/stdlib/doc/src/epp.xml
@@ -4,23 +4,21 @@
<erlref>
<header>
<copyright>
- <year>1996</year>
- <year>2007</year>
- <holder>Ericsson AB, All Rights Reserved</holder>
+ <year>1996</year><year>2010</year>
+ <holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
- The contents of this file are subject to the Erlang Public License,
- Version 1.1, (the "License"); you may not use this file except in
- compliance with the License. You should have received a copy of the
- Erlang Public License along with this software. If not, it can be
- retrieved online at http://www.erlang.org/.
+ The contents of this file are subject to the Erlang Public License,
+ Version 1.1, (the "License"); you may not use this file except in
+ compliance with the License. You should have received a copy of the
+ Erlang Public License along with this software. If not, it can be
+ retrieved online at http://www.erlang.org/.
- Software distributed under the License is distributed on an "AS IS"
- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- the License for the specific language governing rights and limitations
- under the License.
+ Software distributed under the License is distributed on an "AS IS"
+ basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ the License for the specific language governing rights and limitations
+ under the License.
- The Initial Developer of the Original Code is Ericsson AB.
</legalnotice>
<title>epp</title>
@@ -112,7 +110,7 @@
<p>A string which describes the error is obtained with the following call:
</p>
<code type="none">
-apply(Module, format_error, ErrorDescriptor) </code>
+ Module:format_error(ErrorDescriptor) </code>
</section>
<section>
diff --git a/lib/stdlib/doc/src/erl_lint.xml b/lib/stdlib/doc/src/erl_lint.xml
index e339f484cc..6a7d37765c 100644
--- a/lib/stdlib/doc/src/erl_lint.xml
+++ b/lib/stdlib/doc/src/erl_lint.xml
@@ -4,7 +4,7 @@
<erlref>
<header>
<copyright>
- <year>1996</year><year>2009</year>
+ <year>1996</year><year>2010</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -13,12 +13,12 @@
compliance with the License. You should have received a copy of the
Erlang Public License along with this software. If not, it can be
retrieved online at http://www.erlang.org/.
-
+
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
the License for the specific language governing rights and limitations
under the License.
-
+
</legalnotice>
<title>erl_lint</title>
@@ -147,7 +147,7 @@
<p>A string which describes the error is obtained with the following call:
</p>
<code type="none">
-apply(Module, format_error, ErrorDescriptor) </code>
+ Module:format_error(ErrorDescriptor) </code>
</section>
<section>
diff --git a/lib/stdlib/doc/src/erl_parse.xml b/lib/stdlib/doc/src/erl_parse.xml
index 739fde7a40..ae8a8afd5c 100644
--- a/lib/stdlib/doc/src/erl_parse.xml
+++ b/lib/stdlib/doc/src/erl_parse.xml
@@ -4,23 +4,21 @@
<erlref>
<header>
<copyright>
- <year>1996</year>
- <year>2007</year>
- <holder>Ericsson AB, All Rights Reserved</holder>
+ <year>1996</year><year>2010</year>
+ <holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
- The contents of this file are subject to the Erlang Public License,
- Version 1.1, (the "License"); you may not use this file except in
- compliance with the License. You should have received a copy of the
- Erlang Public License along with this software. If not, it can be
- retrieved online at http://www.erlang.org/.
+ The contents of this file are subject to the Erlang Public License,
+ Version 1.1, (the "License"); you may not use this file except in
+ compliance with the License. You should have received a copy of the
+ Erlang Public License along with this software. If not, it can be
+ retrieved online at http://www.erlang.org/.
- Software distributed under the License is distributed on an "AS IS"
- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- the License for the specific language governing rights and limitations
- under the License.
+ Software distributed under the License is distributed on an "AS IS"
+ basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ the License for the specific language governing rights and limitations
+ under the License.
- The Initial Developer of the Original Code is Ericsson AB.
</legalnotice>
<title>erl_parse</title>
@@ -188,7 +186,7 @@
<p>A string which describes the error is obtained with the following call:
</p>
<code type="none">
-apply(Module, format_error, ErrorDescriptor) </code>
+ Module:format_error(ErrorDescriptor) </code>
</section>
<section>
diff --git a/lib/stdlib/doc/src/file_sorter.xml b/lib/stdlib/doc/src/file_sorter.xml
index b3f4da294c..ccb32659a0 100644
--- a/lib/stdlib/doc/src/file_sorter.xml
+++ b/lib/stdlib/doc/src/file_sorter.xml
@@ -4,7 +4,7 @@
<erlref>
<header>
<copyright>
- <year>2001</year><year>2009</year>
+ <year>2001</year><year>2010</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -13,12 +13,12 @@
compliance with the License. You should have received a copy of the
Erlang Public License along with this software. If not, it can be
retrieved online at http://www.erlang.org/.
-
+
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
the License for the specific language governing rights and limitations
under the License.
-
+
</legalnotice>
<title>file_sorter</title>
@@ -83,13 +83,15 @@
An ordering function is antisymmetric, transitive and total.
<c>Fun(A,&nbsp;B)</c> should return <c>true</c> if <c>A</c>
comes before <c>B</c> in the ordering, <c>false</c> otherwise.
+ An example of a typical ordering function is less than or equal
+ to, <c>=&lt;/2</c>.
Using an ordering function will slow down the sort
considerably. The <c>keysort</c>, <c>keymerge</c> and
<c>keycheck</c> functions do not accept ordering functions.
</item>
<item><c>{unique, bool()}</c>. When sorting or merging files,
- only the first of a sequence of terms that compare equal is
- output if this option is set to <c>true</c>. The default
+ only the first of a sequence of terms that compare equal (<c>==</c>)
+ is output if this option is set to <c>true</c>. The default
value is <c>false</c> which implies that all terms that
compare equal are output. When checking files for
sortedness, a check that no pair of consecutive terms
@@ -301,7 +303,7 @@ Value = Term</pre>
<desc>
<p>Sorts tuples on files. The sort is performed on the
element(s) mentioned in <c>KeyPos</c>. If two tuples
- compare equal on one element, next element according to
+ compare equal (<c>==</c>) on one element, next element according to
<c>KeyPos</c> is compared. The sort is stable.
</p>
<p><c>keysort(N, FileName)</c> is equivalent to
diff --git a/lib/stdlib/doc/src/gb_sets.xml b/lib/stdlib/doc/src/gb_sets.xml
index accec623b9..60d8bcbfa3 100644
--- a/lib/stdlib/doc/src/gb_sets.xml
+++ b/lib/stdlib/doc/src/gb_sets.xml
@@ -4,7 +4,7 @@
<erlref>
<header>
<copyright>
- <year>2001</year><year>2009</year>
+ <year>2001</year><year>2010</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -13,12 +13,12 @@
compliance with the License. You should have received a copy of the
Erlang Public License along with this software. If not, it can be
retrieved online at http://www.erlang.org/.
-
+
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
the License for the specific language governing rights and limitations
under the License.
-
+
</legalnotice>
<title>gb_sets</title>
@@ -34,6 +34,8 @@
General Balanced Trees. This can be much more efficient than
using ordered lists, for larger sets, but depends on the
application.</p>
+ <p>This module considers two elements as different if and only if
+ they do not compare equal (<c>==</c>).</p>
</description>
<section>
diff --git a/lib/stdlib/doc/src/gb_trees.xml b/lib/stdlib/doc/src/gb_trees.xml
index 2bf18138c0..94f40c28bd 100644
--- a/lib/stdlib/doc/src/gb_trees.xml
+++ b/lib/stdlib/doc/src/gb_trees.xml
@@ -4,7 +4,7 @@
<erlref>
<header>
<copyright>
- <year>2001</year><year>2009</year>
+ <year>2001</year><year>2010</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -13,12 +13,12 @@
compliance with the License. You should have received a copy of the
Erlang Public License along with this software. If not, it can be
retrieved online at http://www.erlang.org/.
-
+
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
the License for the specific language governing rights and limitations
under the License.
-
+
</legalnotice>
<title>gb_trees</title>
@@ -34,6 +34,8 @@
Balanced Trees. These have no storage overhead compared to
unbalanced binary trees, and their performance is in general
better than AVL trees.</p>
+ <p>This module considers two keys as different if and only if
+ they do not compare equal (<c>==</c>).</p>
</description>
<section>
diff --git a/lib/stdlib/doc/src/io.xml b/lib/stdlib/doc/src/io.xml
index 6f9d979c9a..efbb1fc078 100644
--- a/lib/stdlib/doc/src/io.xml
+++ b/lib/stdlib/doc/src/io.xml
@@ -1021,7 +1021,7 @@ Error: error 11</pre>
<p>A string which describes the error is obtained with the following
call:</p>
<code type="none">
-apply(Module, format_error, ErrorDescriptor)</code>
+Module:format_error(ErrorDescriptor)</code>
</section>
</erlref>
diff --git a/lib/stdlib/doc/src/lists.xml b/lib/stdlib/doc/src/lists.xml
index 39fc05420d..855a7e0244 100644
--- a/lib/stdlib/doc/src/lists.xml
+++ b/lib/stdlib/doc/src/lists.xml
@@ -4,7 +4,7 @@
<erlref>
<header>
<copyright>
- <year>1996</year><year>2009</year>
+ <year>1996</year><year>2010</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -13,12 +13,12 @@
compliance with the License. You should have received a copy of the
Erlang Public License along with this software. If not, it can be
retrieved online at http://www.erlang.org/.
-
+
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
the License for the specific language governing rights and limitations
under the License.
-
+
</legalnotice>
<title>lists</title>
@@ -30,15 +30,16 @@
<module>lists</module>
<modulesummary>List Processing Functions</modulesummary>
<description>
- <p>This module contains functions for list processing. The functions
- are organized in two groups: those in the first group perform a
- particular operation on one or more lists, whereas those in the
- second group are higher-order functions, using a fun as argument
- to perform an operation on one list.</p>
+ <p>This module contains functions for list processing.</p>
+
<p>Unless otherwise stated, all functions assume that position
numbering starts at 1. That is, the first element of a list is at
position 1.</p>
+ <p>Two terms <c>T1</c> and <c>T2</c> compare equal if
+ <c>T1&nbsp;==&nbsp;T2</c> evaluates to <c>true</c>. They match
+ if <c>T1&nbsp;=:=&nbsp;T2</c> evaluates to <c>true</c>.</p>
+
<p>Whenever an <marker
id="ordering_function"></marker><em>ordering function</em>
<c>F</c> is expected as argument, it is assumed that the
diff --git a/lib/stdlib/doc/src/proplists.xml b/lib/stdlib/doc/src/proplists.xml
index a218dcf1fe..9f1c5b24ad 100644
--- a/lib/stdlib/doc/src/proplists.xml
+++ b/lib/stdlib/doc/src/proplists.xml
@@ -4,7 +4,7 @@
<erlref>
<header>
<copyright>
- <year>2002</year><year>2009</year>
+ <year>2002</year><year>2010</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -13,12 +13,12 @@
compliance with the License. You should have received a copy of the
Erlang Public License along with this software. If not, it can be
retrieved online at http://www.erlang.org/.
-
+
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
the License for the specific language governing rights and limitations
under the License.
-
+
</legalnotice>
<title>proplists</title>
@@ -44,6 +44,9 @@
such as options passed to a function where a user may specify options
overriding the default settings, object properties, annotations,
etc.</p>
+ <p>Two keys are considered equal if they match (<c>=:=</c>). In other
+ words, numbers are compared literally rather than by value, so that,
+ for instance, <c>1</c> and <c>1.0</c> are different keys.</p>
</description>
<funcs>
<func>
diff --git a/lib/stdlib/doc/src/re.xml b/lib/stdlib/doc/src/re.xml
index e9a32a59d4..4d2a0e0995 100644
--- a/lib/stdlib/doc/src/re.xml
+++ b/lib/stdlib/doc/src/re.xml
@@ -592,7 +592,7 @@ This option makes it possible to include comments inside complicated patterns. N
<v>NLSpec = cr | crlf | lf | anycrlf | any </v>
<v>SplitList = [ RetData ] | [ GroupedRetData ]</v>
<v>GroupedRetData = [ RetData ]</v>
- <v>RetData = iodata() charlist() | binary() | list()</v>
+ <v>RetData = iodata() | charlist() | binary() | list()</v>
</type>
<desc>
<p>This function splits the input into parts by finding tokens
diff --git a/lib/stdlib/doc/src/shell.xml b/lib/stdlib/doc/src/shell.xml
index b8fc64f45e..73cc1b33bd 100644
--- a/lib/stdlib/doc/src/shell.xml
+++ b/lib/stdlib/doc/src/shell.xml
@@ -4,7 +4,7 @@
<erlref>
<header>
<copyright>
- <year>1996</year><year>2009</year>
+ <year>1996</year><year>2010</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -13,12 +13,12 @@
compliance with the License. You should have received a copy of the
Erlang Public License along with this software. If not, it can be
retrieved online at http://www.erlang.org/.
-
+
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
the License for the specific language governing rights and limitations
under the License.
-
+
</legalnotice>
<title>shell</title>
@@ -739,6 +739,28 @@ loop(N) ->
returns <c>{error,Reason}</c>.</item>
</list>
</section>
+
+ <section>
+ <title>Prompting</title>
+ <p>The default shell prompt function displays the name of the node
+ (if the node can be part of a distributed system) and the
+ current command number. The user can customize the prompt
+ function by calling
+ <c>shell:prompt_func/1</c> or by setting the application
+ configuration parameter <c>shell_prompt_func</c> for the
+ application STDLIB.</p>
+ <p>A customized prompt function is stated as a tuple
+ <c>{Mod,&nbsp;Func}</c>. The function is called as
+ <c>Mod:Func(L)</c>, where <c>L</c> is a list of key-value pairs
+ created by the shell. Currently there is only one pair:
+ <c>{history, N}</c>, where N is the current command number. The
+ function should return a list of characters or an atom. This
+ constraint is due to the Erlang I/O-protocol. Unicode characters
+ beyond codepoint 255 are allowed in the list. Note
+ that in restricted mode the call <c>Mod:Func(L)</c> must be
+ allowed or the default shell prompt function will be called.</p>
+ </section>
+
<funcs>
<func>
<name>history(N) -> integer()</name>
@@ -782,6 +804,19 @@ loop(N) ->
</desc>
</func>
<func>
+ <name>prompt_func(PromptFunc) -> prompt_func()</name>
+ <fsummary>Sets the shell prompt</fsummary>
+ <type>
+ <v>PromptFunc = prompt_func()</v>
+ <v>prompt_func() = default | {Mod, Func}</v>
+ <v>Mod = Func = atom()</v>
+ </type>
+ <desc>
+ <p>Sets the shell prompt function to <c>PromptFunc</c>. The
+ previous prompt function is returned.</p>
+ </desc>
+ </func>
+ <func>
<name>start_restricted(Module) -> ok | {error, Reason}</name>
<fsummary>Exits a normal shell and starts a restricted shell.</fsummary>
<type>
diff --git a/lib/stdlib/doc/src/sofs.xml b/lib/stdlib/doc/src/sofs.xml
index ac434ec5b7..8c8ae51262 100644
--- a/lib/stdlib/doc/src/sofs.xml
+++ b/lib/stdlib/doc/src/sofs.xml
@@ -4,7 +4,7 @@
<erlref>
<header>
<copyright>
- <year>2001</year><year>2009</year>
+ <year>2001</year><year>2010</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -13,12 +13,12 @@
compliance with the License. You should have received a copy of the
Erlang Public License along with this software. If not, it can be
retrieved online at http://www.erlang.org/.
-
+
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
the License for the specific language governing rights and limitations
under the License.
-
+
</legalnotice>
<title>sofs</title>
@@ -311,7 +311,7 @@
applying Fun to the type of the given set), and that Fun does
nothing but selecting, duplicating or rearranging parts of the
elements. Specifying a SetFun as an integer I is equivalent to
- specifying <c>{external, fun(X)&nbsp;-> element(I,&nbsp;X)}</c>,
+ specifying <c>{external, fun(X)&nbsp;-> element(I,&nbsp;X)&nbsp;end}</c>,
but is to be preferred since it makes it possible to handle this
case even more efficiently. Examples of SetFuns:</p>
<pre>
@@ -336,6 +336,7 @@ fun(S) -> sofs:partition(1, S) end
<c>badarg</c>, <c>bad_function</c>, or <c>type_mismatch</c>
message when given badly formed arguments or sets the types of
which are not compatible.</p>
+ <p>When comparing external sets the operator <c>==/2</c> is used.</p>
<p><em>Types</em></p>
<pre>
anyset() = -&nbsp;an unordered, ordered or atomic set&nbsp;-
@@ -1108,7 +1109,13 @@ type() = -&nbsp;a type&nbsp;- </pre>
<desc>
<p>Returns <c>true</c> if the AnySet1 and AnySet2
are <seealso marker="#equal">equal</seealso>, <c>false</c>
- otherwise.</p>
+ otherwise. This example shows that <c>==/2</c> is used when
+ comparing sets for equality:</p>
+ <pre>
+1> <input>S1 = sofs:set([1.0]),</input>
+<input>S2 = sofs:set([1]),</input>
+<input>sofs:is_equal(S1, S2).</input>
+true</pre>
</desc>
</func>
<func>
diff --git a/lib/stdlib/doc/src/stdlib_app.xml b/lib/stdlib/doc/src/stdlib_app.xml
index da046b8a8d..a615c1bf88 100644
--- a/lib/stdlib/doc/src/stdlib_app.xml
+++ b/lib/stdlib/doc/src/stdlib_app.xml
@@ -4,23 +4,21 @@
<appref>
<header>
<copyright>
- <year>2005</year>
- <year>2007</year>
- <holder>Ericsson AB, All Rights Reserved</holder>
+ <year>2005</year><year>2010</year>
+ <holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
- The contents of this file are subject to the Erlang Public License,
- Version 1.1, (the "License"); you may not use this file except in
- compliance with the License. You should have received a copy of the
- Erlang Public License along with this software. If not, it can be
- retrieved online at http://www.erlang.org/.
+ The contents of this file are subject to the Erlang Public License,
+ Version 1.1, (the "License"); you may not use this file except in
+ compliance with the License. You should have received a copy of the
+ Erlang Public License along with this software. If not, it can be
+ retrieved online at http://www.erlang.org/.
- Software distributed under the License is distributed on an "AS IS"
- basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- the License for the specific language governing rights and limitations
- under the License.
+ Software distributed under the License is distributed on an "AS IS"
+ basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+ the License for the specific language governing rights and limitations
+ under the License.
- The Initial Developer of the Original Code is Ericsson AB.
</legalnotice>
<title>STDLIB</title>
@@ -63,6 +61,16 @@
<p>This parameter can be used to determine how many
commands are saved by the Erlang shell.</p>
</item>
+ <tag><c>shell_prompt_func = {Mod, Func} | default</c></tag>
+ <item>
+ <p>where</p>
+ <list type="bulleted">
+ <item><c>Mod = atom()</c></item>
+ <item><c>Func = atom()</c></item>
+ </list>
+ <p>This parameter can be used to set a customized
+ Erlang shell prompt function.</p>
+ </item>
<tag><c>shell_saved_results = integer() >= 0</c></tag>
<item>
<p>This parameter can be used to determine how many
diff --git a/lib/stdlib/doc/src/supervisor.xml b/lib/stdlib/doc/src/supervisor.xml
index adf9d24eae..c696434d49 100644
--- a/lib/stdlib/doc/src/supervisor.xml
+++ b/lib/stdlib/doc/src/supervisor.xml
@@ -4,7 +4,7 @@
<erlref>
<header>
<copyright>
- <year>1996</year><year>2009</year>
+ <year>1996</year><year>2010</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -13,12 +13,12 @@
compliance with the License. You should have received a copy of the
Erlang Public License along with this software. If not, it can be
retrieved online at http://www.erlang.org/.
-
+
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
the License for the specific language governing rights and limitations
under the License.
-
+
</legalnotice>
<title>supervisor</title>
@@ -402,9 +402,12 @@ child_spec() = {Id,StartFunc,Restart,Shutdown,Type,Modules}
<v>&nbsp;Module = atom()</v>
</type>
<desc>
- <p>Returns a list with information about all child
+ <p>Returns a newly created list with information about all child
specifications and child processes belonging to
the supervisor <c>SupRef</c>.</p>
+ <p>Note that calling this function when supervising a large
+ number of children under low memory conditions can cause an
+ out of memory exception.</p>
<p>See <c>start_child/2</c> for a description of <c>SupRef</c>.</p>
<p>The information given for each child specification/process
is:</p>
@@ -428,6 +431,39 @@ child_spec() = {Id,StartFunc,Restart,Shutdown,Type,Modules}
</desc>
</func>
<func>
+ <name>count_children(SupRef) -> PropListOfCounts</name>
+ <fsummary>Return counts for the number of childspecs, active children, supervisors and workers.</fsummary>
+ <type>
+ <v>SupRef = Name | {Name,Node} | {global,Name} | pid()</v>
+ <v>&nbsp;Name = Node = atom()</v>
+ <v>PropListOfCounts = [{specs, ChildSpecCount}, {active, ActiveProcessCount}, {supervisors, ChildSupervisorCount}, {workers, ChildWorkerCount}]</v>
+ </type>
+ <desc>
+ <p>Returns a property list (see <c>proplists</c>) containing the
+ counts for each of the following elements of the supervisor's
+ child specifications and managed processes:</p>
+ <list type="bulleted">
+ <item>
+ <p><c>specs</c> - the total count of children, dead or alive.</p>
+ </item>
+ <item>
+ <p><c>active</c> - the count of all actively running child processes
+ managed by this supervisor.</p>
+ </item>
+ <item>
+ <p><c>supervisors</c> - the count of all children marked as
+ child_type = supervisor in the spec list, whether or not the
+ child process is still alive.</p>
+ </item>
+ <item>
+ <p><c>workers</c> - the count of all children marked as
+ child_type = worker in the spec list, whether or not the child
+ process is still alive.</p>
+ </item>
+ </list>
+ </desc>
+ </func>
+ <func>
<name>check_childspecs([ChildSpec]) -> Result</name>
<fsummary>Check if children specifications are syntactically correct.</fsummary>
<type>
diff --git a/lib/stdlib/src/Makefile b/lib/stdlib/src/Makefile
index 37c836a254..237818c08b 100644
--- a/lib/stdlib/src/Makefile
+++ b/lib/stdlib/src/Makefile
@@ -146,6 +146,9 @@ APPUP_TARGET= $(EBIN)/$(APPUP_FILE)
# FLAGS
# ----------------------------------------------------
+ifeq ($(NATIVE_LIBS_ENABLED),yes)
+ERL_COMPILE_FLAGS += +native
+endif
ERL_COMPILE_FLAGS += -I../include -I../../kernel/include
# ----------------------------------------------------
diff --git a/lib/stdlib/src/dets_v8.erl b/lib/stdlib/src/dets_v8.erl
index b24df02882..1f9f84cd27 100644
--- a/lib/stdlib/src/dets_v8.erl
+++ b/lib/stdlib/src/dets_v8.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2001-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 2001-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(dets_v8).
@@ -1053,14 +1053,14 @@ wl([{_Seq, {insert, Object}} | Cs], Type, _Del, Lookup, _I, _Objs)
wl(Cs, Type, delete, Lookup, 1, [{Object,-1}]);
wl([{_Seq, {insert, Object}} | Cs], Type, Del, Lookup, _I, Objs) ->
NObjs =
- case lists:keysearch(Object, 1, Objs) of
- {value, {_, 0}} ->
+ case lists:keyfind(Object, 1, Objs) of
+ {_, 0} ->
lists:keyreplace(Object, 1, Objs, {Object,-1});
- {value, {_, _C}} when Type =:= bag -> % C =:= 1; C =:= -1
+ {_, _C} when Type =:= bag -> % C =:= 1; C =:= -1
Objs;
- {value, {_, C}} when C < 0 -> % when Type =:= duplicate_bag
+ {_, C} when C < 0 -> % when Type =:= duplicate_bag
lists:keyreplace(Object, 1, Objs, {Object,C-1});
- {value, {_, C}} -> % when C > 0, Type =:= duplicate_bag
+ {_, C} -> % when C > 0, Type =:= duplicate_bag
lists:keyreplace(Object, 1, Objs, {Object,C+1});
false when Del =:= delete ->
[{Object, -1} | Objs];
@@ -1258,8 +1258,8 @@ eval_slot(Head, TrySize, Pos, WLs, L, LU) ->
find_key(Head, Pos, NextPos, Size, Term, Key, WLs, L, LU).
find_key(Head, Pos, NextPos, Size, Term, Key, WLs, L, LU) ->
- case lists:keysearch(Key, 1, WLs) of
- {value, {_, {Delete, LookUp, Objects}} = WL} ->
+ case lists:keyfind(Key, 1, WLs) of
+ {_, {Delete, LookUp, Objects}} = WL ->
NWLs = lists:delete(WL, WLs),
{NewObjects, NL, LUK} = eval_object(Size, Term, Delete, LookUp,
Objects, Head, Pos, L, []),
@@ -1297,30 +1297,30 @@ eval_key(Key, Delete, LookUp, Objects, Head, Pos, WLs, L, LU, LUK) ->
%% All objects in Objects have the key Key.
eval_object(Size, Term, Delete, LookUp, Objects, Head, Pos, L, LU) ->
Type = Head#head.type,
- case lists:keysearch(Term, 1, Objects) of
- {value, {_Object, N}} when N =:= 0 ->
+ case lists:keyfind(Term, 1, Objects) of
+ {_Object, N} when N =:= 0 ->
L1 = [{delete,Pos,Size} | L],
{Objects, L1, LU};
- {value, {_Object, N}} when N < 0, Type =:= set ->
+ {_Object, N} when N < 0, Type =:= set ->
L1 = [{old,Pos} | L],
wl_lookup(LookUp, Objects, Term, L1, LU);
- {value, {Object, _N}} when Type =:= bag -> % when N =:= 1; N =:= -1
+ {Object, _N} when Type =:= bag -> % when N =:= 1; N =:= -1
L1 = [{old,Pos} | L],
Objects1 = lists:keydelete(Object, 1, Objects),
wl_lookup(LookUp, Objects1, Term, L1, LU);
- {value, {Object, N}} when N < 0, Type =:= duplicate_bag ->
+ {Object, N} when N < 0, Type =:= duplicate_bag ->
L1 = [{old,Pos} | L],
Objects1 = lists:keyreplace(Object, 1, Objects, {Object,N+1}),
wl_lookup(LookUp, Objects1, Term, L1, LU);
- {value, {_Object, N}} when N > 0, Type =:= duplicate_bag ->
+ {_Object, N} when N > 0, Type =:= duplicate_bag ->
L1 = [{old,Pos} | L],
wl_lookup(LookUp, Objects, Term, L1, LU);
false when Type =:= set, Delete =:= delete ->
- case lists:keysearch(-1, 2, Objects) of
+ case lists:keyfind(-1, 2, Objects) of
false -> % no inserted object, perhaps deleted objects
L1 = [{delete,Pos,Size} | L],
{[], L1, LU};
- {value, {Term2,-1}} ->
+ {Term2, -1} ->
Bin2 = term_to_binary(Term2),
NSize = byte_size(Bin2),
Overwrite =
diff --git a/lib/stdlib/src/edlin.erl b/lib/stdlib/src/edlin.erl
index 0e98bbaa06..6cb441dbed 100644
--- a/lib/stdlib/src/edlin.erl
+++ b/lib/stdlib/src/edlin.erl
@@ -30,8 +30,6 @@
-import(lists, [reverse/1, reverse/2]).
-%-import([nthtail/2, keysearch/3, prefix/2]).
-
-export([over_word/3]).
@@ -476,8 +474,8 @@ prompt({line,Pbs,_,_}) ->
%% case erlang:module_loaded(Mod) of
%% true ->
%% L = apply(Mod, module_info, []),
-%% case keysearch(exports, 1, L) of
-%% {value, {_, Exports}} ->
+%% case lists:keyfind(exports, 1, L) of
+%% {_, Exports} ->
%% match(FuncPrefix, Exports, "(");
%% _ ->
%% no
@@ -493,7 +491,7 @@ prompt({line,Pbs,_,_}) ->
%% print_matches(Matches),
%% no;
%% {partial, Str} ->
-%% case nthtail(length(Prefix), Str) of
+%% case lists:nthtail(length(Prefix), Str) of
%% [] ->
%% print_matches(Matches),
%% {yes, []};
@@ -501,7 +499,7 @@ prompt({line,Pbs,_,_}) ->
%% {yes, Remain}
%% end;
%% {complete, Str} ->
-%% {yes, nthtail(length(Prefix), Str) ++ Extra};
+%% {yes, lists:nthtail(length(Prefix), Str) ++ Extra};
%% no ->
%% no
%% end.
diff --git a/lib/stdlib/src/epp.erl b/lib/stdlib/src/epp.erl
index 8b702c005b..424aed3d2e 100644
--- a/lib/stdlib/src/epp.erl
+++ b/lib/stdlib/src/epp.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1996-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1996-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
-module(epp).
@@ -111,18 +111,24 @@ format_error({bad,W}) ->
io_lib:format("badly formed '~s'", [W]);
format_error({call,What}) ->
io_lib:format("illegal macro call '~s'",[What]);
-format_error({undefined,M}) ->
- io_lib:format("undefined macro '~w'", [M]);
+format_error({undefined,M,none}) ->
+ io_lib:format("undefined macro '~s'", [M]);
+format_error({undefined,M,A}) ->
+ io_lib:format("undefined macro '~s/~p'", [M,A]);
format_error({depth,What}) ->
io_lib:format("~s too deep",[What]);
format_error({mismatch,M}) ->
- io_lib:format("argument mismatch for macro '~w'", [M]);
+ io_lib:format("argument mismatch for macro '~s'", [M]);
format_error({arg_error,M}) ->
- io_lib:format("badly formed argument for macro '~w'", [M]);
+ io_lib:format("badly formed argument for macro '~s'", [M]);
format_error({redefine,M}) ->
- io_lib:format("redefining macro '~w'", [M]);
-format_error({circular,M}) ->
- io_lib:format("circular macro '~w'", [M]);
+ io_lib:format("redefining macro '~s'", [M]);
+format_error({redefine_predef,M}) ->
+ io_lib:format("redefining predefined macro '~s'", [M]);
+format_error({circular,M,none}) ->
+ io_lib:format("circular macro '~s'", [M]);
+format_error({circular,M,A}) ->
+ io_lib:format("circular macro '~s/~p'", [M,A]);
format_error({include,W,F}) ->
io_lib:format("can't find include ~s \"~s\"", [W,F]);
format_error({illegal,How,What}) ->
@@ -258,18 +264,23 @@ user_predef([{M,Val,redefine}|Pdm], Ms) when is_atom(M) ->
user_predef(Pdm, dict:store({atom,M}, {none,Exp}, Ms));
user_predef([{M,Val}|Pdm], Ms) when is_atom(M) ->
case dict:find({atom,M}, Ms) of
- {ok,_Def} ->
+ {ok,_Defs} when is_list(_Defs) -> %% User defined macros
{error,{redefine,M}};
+ {ok,_Def} -> %% Predefined macros
+ {error,{redefine_predef,M}};
error ->
Exp = erl_parse:tokens(erl_parse:abstract(Val)),
- user_predef(Pdm, dict:store({atom,M}, {none,Exp}, Ms))
+ user_predef(Pdm, dict:store({atom,M}, [{none, {none,Exp}}], Ms))
end;
user_predef([M|Pdm], Ms) when is_atom(M) ->
case dict:find({atom,M}, Ms) of
- {ok,_Def} ->
+ {ok,_Defs} when is_list(_Defs) -> %% User defined macros
{error,{redefine,M}};
+ {ok,_Def} -> %% Predefined macros
+ {error,{redefine_predef,M}};
error ->
- user_predef(Pdm, dict:store({atom,M}, {none,[{atom,1,true}]}, Ms))
+ user_predef(Pdm,
+ dict:store({atom,M}, [{none, {none,[{atom,1,true}]}}], Ms))
end;
user_predef([Md|_Pdm], _Ms) -> {error,{bad,Md}};
user_predef([], Ms) -> {ok,Ms}.
@@ -476,57 +487,56 @@ scan_extends(_Ts, _As, Ms) -> Ms.
%% scan_define(Tokens, DefineToken, From, EppState)
-scan_define([{'(',_Lp},{atom,_Lm,M}=Mac,{',',_Lc}|Toks], _Def, From, St) ->
+scan_define([{'(',_Lp},{Type,_Lm,M}=Mac,{',',_Lc}|Toks], _Def, From, St)
+ when Type =:= atom; Type =:= var ->
case dict:find({atom,M}, St#epp.macs) of
- {ok,_OldDef} ->
- epp_reply(From, {error,{loc(Mac),epp,{redefine,M}}}),
- wait_req_scan(St);
- error ->
- scan_define_cont(From, St,
- {atom, M},
- {none,macro_expansion(Toks)})
- end;
-scan_define([{'(',_Lp},{atom,_Lm,M}=Mac,{'(',_Lc}|Toks], Def, From, St) ->
- case dict:find({atom,M}, St#epp.macs) of
- {ok,_Def} ->
- epp_reply(From, {error,{loc(Mac),epp,{redefine,M}}}),
- wait_req_scan(St);
- error ->
- case catch macro_pars(Toks, []) of
- {ok, {As, Me}} ->
- scan_define_cont(From, St,
- {atom, M},
- {As, Me});
- _ ->
- epp_reply(From, {error,{loc(Def),epp,{bad,define}}}),
- wait_req_scan(St)
- end
- end;
-scan_define([{'(',_Lp},{var,_Lm,M}=Mac,{',',_Lc}|Toks], _Def, From, St) ->
- case dict:find({atom,M}, St#epp.macs) of
- {ok,_OldDef} ->
- epp_reply(From, {error,{loc(Mac),epp,{redefine,M}}}),
- wait_req_scan(St);
- error ->
- scan_define_cont(From, St,
- {atom, M},
- {none,macro_expansion(Toks)})
+ {ok, Defs} when is_list(Defs) ->
+ %% User defined macros: can be overloaded
+ case proplists:is_defined(none, Defs) of
+ true ->
+ epp_reply(From, {error,{loc(Mac),epp,{redefine,M}}}),
+ wait_req_scan(St);
+ false ->
+ scan_define_cont(From, St,
+ {atom, M},
+ {none, {none,macro_expansion(Toks)}})
+ end;
+ {ok, _PreDef} ->
+ %% Predefined macros: cannot be overloaded
+ epp_reply(From, {error,{loc(Mac),epp,{redefine_predef,M}}}),
+ wait_req_scan(St);
+ error ->
+ scan_define_cont(From, St,
+ {atom, M},
+ {none, {none,macro_expansion(Toks)}})
end;
-scan_define([{'(',_Lp},{var,_Lm,M}=Mac,{'(',_Lc}|Toks], Def, From, St) ->
- case dict:find({atom,M}, St#epp.macs) of
- {ok,_Def} ->
- epp_reply(From, {error,{loc(Mac),epp,{redefine,M}}}),
- wait_req_scan(St);
- error ->
- case catch macro_pars(Toks, []) of
- {ok, {As, Me}} ->
- scan_define_cont(From, St,
- {atom, M},
- {As, Me});
- _ ->
- epp_reply(From, {error,{loc(Def),epp,{bad,define}}}),
- wait_req_scan(St)
- end
+scan_define([{'(',_Lp},{Type,_Lm,M}=Mac,{'(',_Lc}|Toks], Def, From, St)
+ when Type =:= atom; Type =:= var ->
+ case catch macro_pars(Toks, []) of
+ {ok, {As,Me}} ->
+ Len = length(As),
+ case dict:find({atom,M}, St#epp.macs) of
+ {ok, Defs} when is_list(Defs) ->
+ %% User defined macros: can be overloaded
+ case proplists:is_defined(Len, Defs) of
+ true ->
+ epp_reply(From,{error,{loc(Mac),epp,{redefine,M}}}),
+ wait_req_scan(St);
+ false ->
+ scan_define_cont(From, St, {atom, M},
+ {Len, {As, Me}})
+ end;
+ {ok, _PreDef} ->
+ %% Predefined macros: cannot be overloaded
+ %% (There are currently no predefined F(...) macros.)
+ epp_reply(From, {error,{loc(Mac),epp,{redefine_predef,M}}}),
+ wait_req_scan(St);
+ error ->
+ scan_define_cont(From, St, {atom, M}, {Len, {As, Me}})
+ end;
+ _ ->
+ epp_reply(From, {error,{loc(Def),epp,{bad,define}}}),
+ wait_req_scan(St)
end;
scan_define(_Toks, Def, From, St) ->
epp_reply(From, {error,{loc(Def),epp,{bad,define}}}),
@@ -541,13 +551,17 @@ scan_define(_Toks, Def, From, St) ->
%%% the information from St#epp.uses is traversed, and if a circularity
%%% is detected, an error message is thrown.
-scan_define_cont(F, St, M, Def) ->
- Ms = dict:store(M, Def, St#epp.macs),
- U = dict:store(M, macro_uses(Def), St#epp.uses),
- scan_toks(F, St#epp{uses=U, macs=Ms}).
+scan_define_cont(F, St, M, {Arity, Def}) ->
+ Ms = dict:append_list(M, [{Arity, Def}], St#epp.macs),
+ try dict:append_list(M, [{Arity, macro_uses(Def)}], St#epp.uses) of
+ U ->
+ scan_toks(F, St#epp{uses=U, macs=Ms})
+ catch
+ {error, Line, Reason} ->
+ epp_reply(F, {error,{Line,epp,Reason}}),
+ wait_req_scan(St)
+ end.
-macro_uses(undefined) ->
- undefined;
macro_uses({_Args, Tokens}) ->
Uses0 = macro_ref(Tokens),
lists:usort(Uses0).
@@ -556,31 +570,25 @@ macro_ref([]) ->
[];
macro_ref([{'?', _}, {'?', _} | Rest]) ->
macro_ref(Rest);
-macro_ref([{'?', _}, {atom, _, A} | Rest]) ->
- [{atom, A} | macro_ref(Rest)];
-macro_ref([{'?', _}, {var, _, A} | Rest]) ->
- [{atom, A} | macro_ref(Rest)];
+macro_ref([{'?', _}, {atom, Lm, A} | Rest]) ->
+ Arity = count_args(Rest, Lm, A),
+ [{{atom, A}, Arity} | macro_ref(Rest)];
+macro_ref([{'?', _}, {var, Lm, A} | Rest]) ->
+ Arity = count_args(Rest, Lm, A),
+ [{{atom, A}, Arity} | macro_ref(Rest)];
macro_ref([_Token | Rest]) ->
macro_ref(Rest).
-all_macro_uses(D0) ->
- L = dict:to_list(D0),
- D = dict:new(),
- add_macro_uses(L, D).
-
-add_macro_uses([], D) ->
- D;
-add_macro_uses([{Key, Def} | Rest], D0) ->
- add_macro_uses(Rest, dict:store(Key, macro_uses(Def), D0)).
-
%% scan_undef(Tokens, UndefToken, From, EppState)
scan_undef([{'(',_Llp},{atom,_Lm,M},{')',_Lrp},{dot,_Ld}], _Undef, From, St) ->
- scan_toks(From, St#epp{macs=dict:erase({atom,M}, St#epp.macs),
- uses=all_macro_uses(St#epp.macs)});
+ Macs = dict:erase({atom,M}, St#epp.macs),
+ Uses = dict:erase({atom,M}, St#epp.uses),
+ scan_toks(From, St#epp{macs=Macs, uses=Uses});
scan_undef([{'(',_Llp},{var,_Lm,M},{')',_Lrp},{dot,_Ld}], _Undef, From,St) ->
- scan_toks(From, St#epp{macs=dict:erase({atom,M}, St#epp.macs),
- uses=all_macro_uses(St#epp.macs)});
+ Macs = dict:erase({atom,M}, St#epp.macs),
+ Uses = dict:erase({atom,M}, St#epp.uses),
+ scan_toks(From, St#epp{macs=Macs, uses=Uses});
scan_undef(_Toks, Undef, From, St) ->
epp_reply(From, {error,{loc(Undef),epp,{bad,undef}}}),
wait_req_scan(St).
@@ -819,42 +827,57 @@ expand_macros(Type, MacT, M, Toks, Ms0) ->
%% (Type will always be 'atom')
{Ms, U} = Ms0,
Lm = loc(MacT),
- check_uses([{Type,M}], [], U, Lm),
Tinfo = element(2, MacT),
- case dict:find({Type,M}, Ms) of
+ case expand_macro1(Type, Lm, M, Toks, Ms) of
{ok,{none,Exp}} ->
- expand_macros(expand_macro(Exp, Tinfo, Toks, dict:new()), Ms0);
+ check_uses([{{Type,M}, none}], [], U, Lm),
+ Toks1 = expand_macros(expand_macro(Exp, Tinfo, [], dict:new()), Ms0),
+ expand_macros(Toks1++Toks, Ms0);
{ok,{As,Exp}} ->
+ check_uses([{{Type,M}, length(As)}], [], U, Lm),
{Bs,Toks1} = bind_args(Toks, Lm, M, As, dict:new()),
- %%io:format("Bound arguments to macro ~w (~w)~n", [M,Bs]),
- expand_macros(expand_macro(Exp, Tinfo, Toks1, Bs), Ms0);
- {ok,undefined} ->
- throw({error,Lm,{undefined,M}});
- error ->
- throw({error,Lm,{undefined,M}})
+ expand_macros(expand_macro(Exp, Tinfo, Toks1, Bs), Ms0)
+ end.
+
+expand_macro1(Type, Lm, M, Toks, Ms) ->
+ Arity = count_args(Toks, Lm, M),
+ case dict:find({Type,M}, Ms) of
+ error -> %% macro not found
+ throw({error,Lm,{undefined,M,Arity}});
+ {ok, undefined} -> %% Predefined macro without definition
+ throw({error,Lm,{undefined,M,Arity}});
+ {ok, [{none, Def}]} ->
+ {ok, Def};
+ {ok, Defs} when is_list(Defs) ->
+ case proplists:get_value(Arity, Defs) of
+ undefined ->
+ throw({error,Lm,{mismatch,M}});
+ Def ->
+ {ok, Def}
+ end;
+ {ok, PreDef} -> %% Predefined macro
+ {ok, PreDef}
end.
-check_uses(undefined, _Anc, _U, _Lm) ->
- ok;
check_uses([], _Anc, _U, _Lm) ->
ok;
check_uses([M|Rest], Anc, U, Lm) ->
case lists:member(M, Anc) of
true ->
- {_, Name} = M,
- throw({error,Lm,{circular,Name}});
+ {{_, Name},Arity} = M,
+ throw({error,Lm,{circular,Name,Arity}});
false ->
L = get_macro_uses(M, U),
check_uses(L, [M|Anc], U, Lm),
check_uses(Rest, Anc, U, Lm)
end.
-
-get_macro_uses(M, U) ->
+
+get_macro_uses({M,Arity}, U) ->
case dict:find(M, U) of
error ->
[];
{ok, L} ->
- L
+ proplists:get_value(Arity, L, proplists:get_value(none, L, []))
end.
%% Macro expansion
@@ -882,7 +905,7 @@ expand_macros([T|Ts], Ms) ->
expand_macros([], _Ms) -> [].
%% bind_args(Tokens, MacroLocation, MacroName, ArgumentVars, Bindings)
-%% Collect the arguments to a macro call and check for correct number.
+%% Collect the arguments to a macro call.
bind_args([{'(',_Llp},{')',_Lrp}|Toks], _Lm, _M, [], Bs) ->
{Bs,Toks};
@@ -890,7 +913,7 @@ bind_args([{'(',_Llp}|Toks0], Lm, M, [A|As], Bs) ->
{Arg,Toks1} = macro_arg(Toks0, [], []),
macro_args(Toks1, Lm, M, As, store_arg(Lm, M, A, Arg, Bs));
bind_args(_Toks, Lm, M, _As, _Bs) ->
- throw({error,Lm,{mismatch,M}}).
+ throw({error,Lm,{mismatch,M}}). % Cannot happen.
macro_args([{')',_Lrp}|Toks], _Lm, _M, [], Bs) ->
{Bs,Toks};
@@ -898,15 +921,39 @@ macro_args([{',',_Lc}|Toks0], Lm, M, [A|As], Bs) ->
{Arg,Toks1} = macro_arg(Toks0, [], []),
macro_args(Toks1, Lm, M, As, store_arg(Lm, M, A, Arg, Bs));
macro_args([], Lm, M, _As, _Bs) ->
- throw({error,Lm,{arg_error,M}});
+ throw({error,Lm,{arg_error,M}}); % Cannot happen.
macro_args(_Toks, Lm, M, _As, _Bs) ->
- throw({error,Lm,{mismatch,M}}).
+ throw({error,Lm,{mismatch,M}}). % Cannot happen.
store_arg(L, M, _A, [], _Bs) ->
throw({error,L,{mismatch,M}});
store_arg(_L, _M, A, Arg, Bs) ->
dict:store(A, Arg, Bs).
+%% count_args(Tokens, MacroLine, MacroName)
+%% Count the number of arguments in a macro call.
+count_args([{'(', _Llp},{')',_Lrp}|_Toks], _Lm, _M) ->
+ 0;
+count_args([{'(', _Llp},{',',_Lc}|_Toks], Lm, M) ->
+ throw({error,Lm,{arg_error,M}});
+count_args([{'(',_Llp}|Toks0], Lm, M) ->
+ {_Arg,Toks1} = macro_arg(Toks0, [], []),
+ count_args(Toks1, Lm, M, 1);
+count_args(_Toks, _Lm, _M) ->
+ none.
+
+count_args([{')',_Lrp}|_Toks], _Lm, _M, NbArgs) ->
+ NbArgs;
+count_args([{',',_Lc},{')',_Lrp}|_Toks], Lm, M, _NbArgs) ->
+ throw({error,Lm,{arg_error,M}});
+count_args([{',',_Lc}|Toks0], Lm, M, NbArgs) ->
+ {_Arg,Toks1} = macro_arg(Toks0, [], []),
+ count_args(Toks1, Lm, M, NbArgs+1);
+count_args([], Lm, M, _NbArgs) ->
+ throw({error,Lm,{arg_error,M}});
+count_args(_Toks, Lm, M, _NbArgs) ->
+ throw({error,Lm,{mismatch,M}}). % Cannot happen.
+
%% macro_arg([Tok], [ClosePar], [ArgTok]) -> {[ArgTok],[RestTok]}.
%% Collect argument tokens until we hit a ',' or a ')'. We know a
%% enough about syntax to recognise "open parentheses" and keep
diff --git a/lib/stdlib/src/erl_lint.erl b/lib/stdlib/src/erl_lint.erl
index 156d68554e..91f7641af7 100644
--- a/lib/stdlib/src/erl_lint.erl
+++ b/lib/stdlib/src/erl_lint.erl
@@ -1,20 +1,20 @@
%% -*- erlang-indent-level: 4 -*-
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1996-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1996-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
%% Do necessary checking of Erlang code.
@@ -78,7 +78,7 @@ value_option(Flag, Default, On, OnVal, Off, OffVal, Opts) ->
calls = dict:new(), %Who calls who
imported = [], %Actually imported functions
used_records=sets:new() :: set(), %Used record definitions
- used_types = sets:new() :: set() %Used type definitions
+ used_types = dict:new() :: dict() %Used type definitions
}).
%% Define the lint state record.
@@ -277,6 +277,8 @@ format_error({conflicting_behaviours,{Name,Arity},B,FirstL,FirstB}) ->
format_error({undefined_behaviour_func, {Func,Arity}, Behaviour}) ->
io_lib:format("undefined callback function ~w/~w (behaviour '~w')",
[Func,Arity,Behaviour]);
+format_error({undefined_behaviour_func, {Func,Arity,_Spec}, Behaviour}) ->
+ format_error({undefined_behaviour_func, {Func,Arity}, Behaviour});
format_error({undefined_behaviour,Behaviour}) ->
io_lib:format("behaviour ~w undefined", [Behaviour]);
format_error({undefined_behaviour_callbacks,Behaviour}) ->
@@ -288,7 +290,7 @@ format_error({ill_defined_behaviour_callbacks,Behaviour}) ->
%% --- types and specs ---
format_error({singleton_typevar, Name}) ->
io_lib:format("type variable ~w is only used once (is unbound)", [Name]);
-format_error({type_ref, {TypeName, Arity}}) ->
+format_error({undefined_type, {TypeName, Arity}}) ->
io_lib:format("type ~w~s undefined", [TypeName, gen_type_paren(Arity)]);
format_error({unused_type, {TypeName, Arity}}) ->
io_lib:format("type ~w~s is unused", [TypeName, gen_type_paren(Arity)]);
@@ -757,10 +759,11 @@ post_traversal_check(Forms, St0) ->
St7 = check_bif_clashes(Forms, St6),
St8 = check_specs_without_function(St7),
St9 = check_functions_without_spec(Forms, St8),
- StA = check_unused_types(Forms, St9),
- StB = check_untyped_records(Forms, StA),
- StC = check_on_load(StB),
- check_unused_records(Forms, StC).
+ StA = check_undefined_types(St9),
+ StB = check_unused_types(Forms, StA),
+ StC = check_untyped_records(Forms, StB),
+ StD = check_on_load(StC),
+ check_unused_records(Forms, StD).
%% check_behaviour(State0) -> State
%% Check that the behaviour attribute is valid.
@@ -786,13 +789,20 @@ behaviour_callbacks(Line, B, St0) ->
Funcs when is_list(Funcs) ->
All = all(fun({FuncName, Arity}) ->
is_atom(FuncName) andalso is_integer(Arity);
+ ({FuncName, Arity, Spec}) ->
+ is_atom(FuncName) andalso is_integer(Arity)
+ andalso is_list(Spec);
(_Other) ->
false
end,
Funcs),
+ MaybeRemoveSpec = fun({_F,_A}=FA) -> FA;
+ ({F,A,_S}) -> {F,A};
+ (Other) -> Other
+ end,
if
All =:= true ->
- {Funcs, St0};
+ {[MaybeRemoveSpec(F) || F <- Funcs], St0};
true ->
St1 = add_warning(Line,
{ill_defined_behaviour_callbacks,B},
@@ -970,6 +980,16 @@ check_undefined_functions(#lint{called=Called0,defined=Def0}=St0) ->
add_error(L, {undefined_function,NA}, St)
end, St0, Undef).
+%% check_undefined_types(State0) -> State
+
+check_undefined_types(#lint{usage=Usage,types=Def}=St0) ->
+ Used = Usage#usage.used_types,
+ UTAs = dict:fetch_keys(Used),
+ Undef = [{TA,dict:fetch(TA, Used)} || TA <- UTAs, not dict:is_key(TA, Def)],
+ foldl(fun ({TA,L}, St) ->
+ add_error(L, {undefined_type,TA}, St)
+ end, St0, Undef).
+
%% check_bif_clashes(Forms, State0) -> State
check_bif_clashes(Forms, St0) ->
@@ -1427,20 +1447,11 @@ is_pattern_expr_1({tuple,_Line,Es}) ->
all(fun is_pattern_expr/1, Es);
is_pattern_expr_1({nil,_Line}) -> true;
is_pattern_expr_1({cons,_Line,H,T}) ->
- case is_pattern_expr_1(H) of
- true -> is_pattern_expr_1(T);
- false -> false
- end;
+ is_pattern_expr_1(H) andalso is_pattern_expr_1(T);
is_pattern_expr_1({op,_Line,Op,A}) ->
- case erl_internal:arith_op(Op, 1) of
- true -> is_pattern_expr_1(A);
- false -> false
- end;
+ erl_internal:arith_op(Op, 1) andalso is_pattern_expr_1(A);
is_pattern_expr_1({op,_Line,Op,A1,A2}) ->
- case erl_internal:arith_op(Op, 2) of
- true -> all(fun is_pattern_expr/1, [A1,A2]);
- false -> false
- end;
+ erl_internal:arith_op(Op, 2) andalso all(fun is_pattern_expr/1, [A1,A2]);
is_pattern_expr_1(_Other) -> false.
%% pattern_bin([Element], VarTable, Old, BinVarTable, State) ->
@@ -1817,28 +1828,17 @@ is_gexpr({bin,_L,Fs}, RDs) ->
end, Fs);
is_gexpr({call,_L,{atom,_Lf,F},As}, RDs) ->
A = length(As),
- case erl_internal:guard_bif(F, A) of
- true -> is_gexpr_list(As, RDs);
- false -> false
- end;
+ erl_internal:guard_bif(F, A) andalso is_gexpr_list(As, RDs);
is_gexpr({call,_L,{remote,_Lr,{atom,_Lm,erlang},{atom,_Lf,F}},As}, RDs) ->
A = length(As),
- case erl_internal:guard_bif(F, A) orelse is_gexpr_op(F, A) of
- true -> is_gexpr_list(As, RDs);
- false -> false
- end;
+ (erl_internal:guard_bif(F, A) orelse is_gexpr_op(F, A))
+ andalso is_gexpr_list(As, RDs);
is_gexpr({call,L,{tuple,Lt,[{atom,Lm,erlang},{atom,Lf,F}]},As}, RDs) ->
is_gexpr({call,L,{remote,Lt,{atom,Lm,erlang},{atom,Lf,F}},As}, RDs);
is_gexpr({op,_L,Op,A}, RDs) ->
- case is_gexpr_op(Op, 1) of
- true -> is_gexpr(A, RDs);
- false -> false
- end;
+ is_gexpr_op(Op, 1) andalso is_gexpr(A, RDs);
is_gexpr({op,_L,Op,A1,A2}, RDs) ->
- case is_gexpr_op(Op, 2) of
- true -> is_gexpr_list([A1,A2], RDs);
- false -> false
- end;
+ is_gexpr_op(Op, 2) andalso is_gexpr_list([A1,A2], RDs);
is_gexpr(_Other, _RDs) -> false.
is_gexpr_op('andalso', 2) -> true;
@@ -2388,7 +2388,7 @@ check_type(Types, St) ->
{SeenVars, St1} = check_type(Types, dict:new(), St),
dict:fold(fun(Var, {seen_once, Line}, AccSt) ->
case atom_to_list(Var) of
- [$_|_] -> AccSt;
+ "_"++_ -> AccSt;
_ -> add_error(Line, {singleton_typevar, Var}, AccSt)
end;
(_Var, seen_multiple, AccSt) ->
@@ -2400,7 +2400,7 @@ check_type({ann_type, _L, [_Var, Type]}, SeenVars, St) ->
check_type({paren_type, _L, [Type]}, SeenVars, St) ->
check_type(Type, SeenVars, St);
check_type({remote_type, L, [{atom, _, Mod}, {atom, _, Name}, Args]},
- SeenVars, St = #lint{module=CurrentMod}) ->
+ SeenVars, #lint{module=CurrentMod} = St) ->
St1 =
case (dict:is_key({Name, length(Args)}, default_types())
orelse is_var_arity_type(Name)) of
@@ -2463,21 +2463,15 @@ check_type({type, _L, product, Args}, SeenVars, St) ->
lists:foldl(fun(T, {AccSeenVars, AccSt}) ->
check_type(T, AccSeenVars, AccSt)
end, {SeenVars, St}, Args);
-check_type({type, La, TypeName, Args}, SeenVars,
- St = #lint{types=Defs, usage=Usage}) ->
+check_type({type, La, TypeName, Args}, SeenVars, #lint{usage=Usage} = St) ->
Arity = length(Args),
- St1 =
- case dict:is_key({TypeName, Arity}, Defs) of
- true ->
- UsedTypes1 = Usage#usage.used_types,
- UsedTypes2 = sets:add_element({TypeName, Arity}, UsedTypes1),
- St#lint{usage=Usage#usage{used_types=UsedTypes2}};
- false ->
- case is_var_arity_type(TypeName) of
- true -> St;
- false -> add_error(La, {type_ref, {TypeName, Arity}}, St)
- end
- end,
+ St1 = case is_var_arity_type(TypeName) of
+ true -> St;
+ false ->
+ OldUsed = Usage#usage.used_types,
+ UsedTypes = dict:store({TypeName, Arity}, La, OldUsed),
+ St#lint{usage=Usage#usage{used_types=UsedTypes}}
+ end,
check_type({type, -1, product, Args}, SeenVars, St1).
check_record_types(Line, Name, Fields, SeenVars, St) ->
@@ -2636,7 +2630,7 @@ check_specs([FunType|Left], Arity, St0) ->
check_specs([], _Arity, St) ->
St.
-check_specs_without_function(St = #lint{module=Mod, defined=Funcs}) ->
+check_specs_without_function(#lint{module=Mod,defined=Funcs,specs=Specs}=St) ->
Fun = fun({M, F, A} = MFA, Line, AccSt) when M =:= Mod ->
case gb_sets:is_element({F, A}, Funcs) of
true -> AccSt;
@@ -2644,7 +2638,7 @@ check_specs_without_function(St = #lint{module=Mod, defined=Funcs}) ->
end;
({_M, _F, _A}, _Line, AccSt) -> AccSt
end,
- dict:fold(Fun, St, St#lint.specs).
+ dict:fold(Fun, St, Specs).
%% This generates warnings for functions without specs; if the user has
%% specified both options, we do not generate the same warnings twice.
@@ -2688,7 +2682,7 @@ check_unused_types(Forms, St = #lint{usage=Usage, types=Types}) ->
(Type, FileLine, AccSt) ->
case loc(FileLine) of
{FirstFile, _} ->
- case sets:is_element(Type, UsedTypes) of
+ case dict:is_key(Type, UsedTypes) of
true -> AccSt;
false ->
add_warning(FileLine,
@@ -3009,7 +3003,7 @@ check_old_unused_vars(Vt, Vt0, St0) ->
unused_vars(Vt, Vt0, _St0) ->
U0 = orddict:filter(fun (V, {_State,unused,_Ls}) ->
case atom_to_list(V) of
- [$_|_] -> false;
+ "_"++_ -> false;
_ -> true
end;
(_V, _How) -> false
diff --git a/lib/stdlib/src/escript.erl b/lib/stdlib/src/escript.erl
index c0f71fb3f5..b2562c6169 100644
--- a/lib/stdlib/src/escript.erl
+++ b/lib/stdlib/src/escript.erl
@@ -139,7 +139,8 @@ start(EscriptOptions) ->
parse_and_run(File, Args, Options) ->
CheckOnly = lists:member("s", Options),
- {Source, Module, FormsOrBin, Mode} = parse_file(File, CheckOnly),
+ {Source, Module, FormsOrBin, HasRecs, Mode} =
+ parse_file(File, CheckOnly),
Mode2 =
case lists:member("d", Options) of
true ->
@@ -159,7 +160,7 @@ parse_and_run(File, Args, Options) ->
is_list(FormsOrBin) ->
case Mode2 of
interpret ->
- interpret(FormsOrBin, File, Args);
+ interpret(FormsOrBin, HasRecs, File, Args);
compile ->
case compile:forms(FormsOrBin, [report]) of
{ok, Module, BeamBin} ->
@@ -246,7 +247,8 @@ parse_file(File, CheckOnly) ->
#state{mode = Mode,
source = Source,
module = Module,
- forms_or_bin = FormsOrBin} =
+ forms_or_bin = FormsOrBin,
+ has_records = HasRecs} =
case ScriptType of
archive ->
%% Archive file
@@ -260,7 +262,7 @@ parse_file(File, CheckOnly) ->
%% Source code
parse_source(S, File, Fd, StartLine, HeaderSz, CheckOnly)
end,
- {Source, Module, FormsOrBin, Mode}.
+ {Source, Module, FormsOrBin, HasRecs, Mode}.
%% Skip header and make a heuristic guess about the script type
skip_header(P, LineNo) ->
@@ -421,8 +423,7 @@ check_source(S, CheckOnly) ->
case S of
#state{n_errors = Nerrs} when Nerrs =/= 0 ->
fatal("There were compilation errors.");
- #state{exports_main = ExpMain,
- has_records = HasRecs,
+ #state{exports_main = ExpMain,
forms_or_bin = [FileForm2, ModForm2 | Forms]} ->
%% Optionally add export of main/1
Forms2 =
@@ -433,36 +434,15 @@ check_source(S, CheckOnly) ->
Forms3 = [FileForm2, ModForm2 | Forms2],
case CheckOnly of
true ->
- %% Optionally expand records
- Forms4 =
- case HasRecs of
- false -> Forms3;
- true -> erl_expand_records:module(Forms3, [])
- end,
%% Strong validation and halt
- case compile:forms(Forms4, [report,strong_validation]) of
+ case compile:forms(Forms3, [report,strong_validation]) of
{ok,_} ->
my_halt(0);
_Other ->
fatal("There were compilation errors.")
end;
false ->
- %% Basic validation before execution
- case erl_lint:module(Forms3) of
- {ok,Ws} ->
- report_warnings(Ws);
- {error,Es,Ws} ->
- report_errors(Es),
- report_warnings(Ws),
- fatal("There were compilation errors.")
- end,
- %% Optionally expand records
- Forms4 =
- case HasRecs of
- false -> Forms3;
- true -> erl_expand_records:module(Forms3, [])
- end,
- S#state{forms_or_bin = Forms4}
+ S#state{forms_or_bin = Forms3}
end
end.
@@ -495,17 +475,9 @@ epp_parse_file2(Epp, S, Forms, Parsed) ->
case Parsed of
{ok, Form} ->
case Form of
- {attribute,Ln,record,{Record,Fields}} ->
- S2 = S#state{has_records = true},
- case epp:normalize_typed_record_fields(Fields) of
- {typed, NewFields} ->
- epp_parse_file(Epp, S2,
- [{attribute, Ln, record, {Record, NewFields}},
- {attribute, Ln, type,
- {{record, Record}, Fields, []}} | Forms]);
- not_typed ->
- epp_parse_file(Epp, S2, [Form | Forms])
- end;
+ {attribute,_,record, _} ->
+ S2 = S#state{has_records = true},
+ epp_parse_file(Epp, S2, [Form | Forms]);
{attribute,Ln,mode,NewMode} ->
S2 = S#state{mode = NewMode},
if
@@ -564,8 +536,23 @@ run(Module, Args) ->
fatal(format_exception(Class, Reason))
end.
-interpret(Forms, File, Args) ->
- Dict = parse_to_dict(Forms),
+interpret(Forms, HasRecs, File, Args) ->
+ %% Basic validation before execution
+ case erl_lint:module(Forms) of
+ {ok,Ws} ->
+ report_warnings(Ws);
+ {error,Es,Ws} ->
+ report_errors(Es),
+ report_warnings(Ws),
+ fatal("There were compilation errors.")
+ end,
+ %% Optionally expand records
+ Forms2 =
+ case HasRecs of
+ false -> Forms;
+ true -> erl_expand_records:module(Forms, [])
+ end,
+ Dict = parse_to_dict(Forms2),
ArgsA = erl_parse:abstract(Args, 0),
Call = {call,0,{atom,0,main},[ArgsA]},
try
diff --git a/lib/stdlib/src/file_sorter.erl b/lib/stdlib/src/file_sorter.erl
index de9e628e22..e21a0c88f3 100644
--- a/lib/stdlib/src/file_sorter.erl
+++ b/lib/stdlib/src/file_sorter.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2001-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 2001-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(file_sorter).
@@ -186,7 +186,7 @@ options(Option) ->
options([{format, Format} | L], Opts) when Format =:= binary;
Format =:= term;
is_function(Format),
- is_function(Format, 1) ->
+ is_function(Format, 1) ->
options(L, Opts#opts{format = Format});
options([{format, binary_term} | L], Opts) ->
options(L, Opts#opts{format = binary_term_fun()});
@@ -419,9 +419,9 @@ culprit_found(IFun, F, FNs, W, L, I, [_Size | BT]) ->
IFun(close),
check_files(FNs, W, [{F,I,binary_to_term(BT)} | L]).
-files(_I, L, _LSz, #w{seq = 1}=W, []) ->
+files(_I, L, _LSz, #w{seq = 1, out = Out}=W, []) ->
%% No temporary files created, everything in L.
- case W#w.out of
+ case Out of
Fun when is_function(Fun) ->
SL = internal_sort(L, W),
W1 = outfun(binterm_objects(SL, []), W),
@@ -462,8 +462,8 @@ fun_run(I, L, LSz, W, []) ->
{cont, NW, Objs} ->
fun_run(I, L, LSz, NW, Objs)
end;
-fun_run(I, L, LSz, W, Objs) when LSz < W#w.runsize ->
- {NI, NObjs, NL, NLSz} = fun_objs(Objs, L, LSz, W#w.runsize, I, W),
+fun_run(I, L, LSz, #w{runsize = Runsize}=W, Objs) when LSz < Runsize ->
+ {NI, NObjs, NL, NLSz} = fun_objs(Objs, L, LSz, Runsize, I, W),
fun_run(NI, NL, NLSz, W, NObjs);
fun_run(I, L, _LSz, W, Objs) ->
NW = write_run(L, W),
@@ -1201,11 +1201,11 @@ infun(W) ->
erlang:raise(Class, Reason, erlang:get_stacktrace())
end.
-outfun(A, W) when W#w.inout_value =/= no_value ->
+outfun(A, #w{inout_value = Val} = W) when Val =/= no_value ->
W1 = W#w{inout_value = no_value},
W2 = if
W1#w.fun_out ->
- outfun(W#w.inout_value, W1);
+ outfun(Val, W1);
true -> W1
end,
outfun(A, W2);
@@ -1372,19 +1372,19 @@ cleanup(W) ->
end,
lists:foreach(F, W1#w.temp).
-close_input(W) when is_function(W#w.in) ->
- catch (W#w.in)(close),
+close_input(#w{in = In}=W) when is_function(In) ->
+ catch In(close),
W#w{in = undefined};
close_input(#w{in = undefined}=W) ->
W.
-close_out(W) when is_function(W#w.out) ->
- catch (W#w.out)(close);
+close_out(#w{out = Out}) when is_function(Out) ->
+ catch Out(close);
close_out(_) ->
ok.
close_file(Fd, W) ->
- {value, {Fd, FileName}} = lists:keysearch(Fd, 1, W#w.temp),
+ {Fd, FileName} = lists:keyfind(Fd, 1, W#w.temp),
?DEBUG("closing ~p~n", [FileName]),
file:close(Fd),
W#w{temp = [FileName | lists:keydelete(Fd, 1, W#w.temp)]}.
diff --git a/lib/stdlib/src/filelib.erl b/lib/stdlib/src/filelib.erl
index d65588f0d1..74c5172137 100644
--- a/lib/stdlib/src/filelib.erl
+++ b/lib/stdlib/src/filelib.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1997-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
-module(filelib).
@@ -228,7 +228,17 @@ ensure_dir(F) ->
ok;
false ->
ensure_dir(Dir),
- file:make_dir(Dir)
+ case file:make_dir(Dir) of
+ {error,eexist}=EExist ->
+ case do_is_dir(Dir, file) of
+ true ->
+ ok;
+ false ->
+ EExist
+ end;
+ Err ->
+ Err
+ end
end.
diff --git a/lib/stdlib/src/io_lib.erl b/lib/stdlib/src/io_lib.erl
index 2d3c86e4ea..26f6ec8931 100644
--- a/lib/stdlib/src/io_lib.erl
+++ b/lib/stdlib/src/io_lib.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1996-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1996-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
@@ -139,9 +139,9 @@ format_prompt({format,Format,Args}) ->
format_prompt(Format,Args);
format_prompt(Prompt)
when is_list(Prompt); is_atom(Prompt); is_binary(Prompt) ->
- format_prompt("~s", [Prompt]);
+ format_prompt("~ts", [Prompt]);
format_prompt(Prompt) ->
- format_prompt("~p", [Prompt]).
+ format_prompt("~tp", [Prompt]).
format_prompt(Format, Args) ->
case catch io_lib:format(Format, Args) of
diff --git a/lib/stdlib/src/qlc.erl b/lib/stdlib/src/qlc.erl
index ef142e1c8a..6e48d95973 100644
--- a/lib/stdlib/src/qlc.erl
+++ b/lib/stdlib/src/qlc.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2004-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 2004-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(qlc).
@@ -528,122 +528,111 @@ options(Options0, [Key | Keys], L) when is_list(Options0) ->
false ->
Options0
end,
- V = case lists:keysearch(Key, 1, Options) of
- {value, {format_fun, U=undefined}} ->
+ V = case lists:keyfind(Key, 1, Options) of
+ {format_fun, U=undefined} ->
{ok, U};
- {value, {info_fun, U=undefined}} ->
+ {info_fun, U=undefined} ->
{ok, U};
- {value, {lookup_fun, U=undefined}} ->
+ {lookup_fun, U=undefined} ->
{ok, U};
- {value, {parent_fun, U=undefined}} ->
+ {parent_fun, U=undefined} ->
{ok, U};
- {value, {post_fun, U=undefined}} ->
+ {post_fun, U=undefined} ->
{ok, U};
- {value, {pre_fun, U=undefined}} ->
+ {pre_fun, U=undefined} ->
{ok, U};
- {value, {info_fun, Fun}} when is_function(Fun),
- is_function(Fun, 1) ->
+ {info_fun, Fun} when is_function(Fun), is_function(Fun, 1) ->
{ok, Fun};
- {value, {pre_fun, Fun}} when is_function(Fun),
- is_function(Fun, 1) ->
+ {pre_fun, Fun} when is_function(Fun), is_function(Fun, 1) ->
{ok, Fun};
- {value, {post_fun, Fun}} when is_function(Fun),
- is_function(Fun, 0) ->
+ {post_fun, Fun} when is_function(Fun), is_function(Fun, 0) ->
{ok, Fun};
- {value, {lookup_fun, Fun}} when is_function(Fun),
- is_function(Fun, 2) ->
+ {lookup_fun, Fun} when is_function(Fun), is_function(Fun, 2) ->
{ok, Fun};
- {value, {max_lookup, Max}} when is_integer(Max), Max >= 0 ->
+ {max_lookup, Max} when is_integer(Max), Max >= 0 ->
{ok, Max};
- {value, {max_lookup, infinity}} ->
+ {max_lookup, infinity} ->
{ok, -1};
- {value, {format_fun, Fun}} when is_function(Fun),
- is_function(Fun, 1) ->
+ {format_fun, Fun} when is_function(Fun), is_function(Fun, 1) ->
{ok, Fun};
- {value, {parent_fun, Fun}} when is_function(Fun),
- is_function(Fun, 0) ->
+ {parent_fun, Fun} when is_function(Fun), is_function(Fun, 0) ->
{ok, Fun};
- {value, {key_equality, KE='=='}}->
+ {key_equality, KE='=='} ->
{ok, KE};
- {value, {key_equality, KE='=:='}}->
+ {key_equality, KE='=:='} ->
{ok, KE};
- {value, {join, J=any}} ->
+ {join, J=any} ->
{ok, J};
- {value, {join, J=nested_loop}} ->
+ {join, J=nested_loop} ->
{ok, J};
- {value, {join, J=merge}} ->
+ {join, J=merge} ->
{ok, J};
- {value, {join, J=lookup}} ->
+ {join, J=lookup} ->
{ok, J};
- {value, {lookup, LookUp}} when LookUp;
- not LookUp;
- LookUp =:= any ->
+ {lookup, LookUp} when is_boolean(LookUp); LookUp =:= any ->
{ok, LookUp};
- {value, {max_list_size, Max}} when is_integer(Max), Max >= 0 ->
+ {max_list_size, Max} when is_integer(Max), Max >= 0 ->
{ok, Max};
- {value, {tmpdir_usage, TmpUsage}} when TmpUsage =:= allowed;
- TmpUsage =:= not_allowed;
- TmpUsage =:= info_msg;
- TmpUsage =:= warning_msg;
- TmpUsage =:= error_msg ->
+ {tmpdir_usage, TmpUsage} when TmpUsage =:= allowed;
+ TmpUsage =:= not_allowed;
+ TmpUsage =:= info_msg;
+ TmpUsage =:= warning_msg;
+ TmpUsage =:= error_msg ->
{ok, TmpUsage};
- {value, {unique, Unique}} when Unique; not Unique ->
+ {unique, Unique} when is_boolean(Unique) ->
{ok, Unique};
- {value, {cache, Cache}} when Cache; not Cache; Cache =:= list ->
+ {cache, Cache} when is_boolean(Cache); Cache =:= list ->
{ok, Cache};
- {value, {cache, ets}} ->
+ {cache, ets} ->
{ok, true};
- {value, {cache, no}} ->
+ {cache, no} ->
{ok, false};
- {value, {unique_all, UniqueAll}} when UniqueAll; not UniqueAll ->
+ {unique_all, UniqueAll} when is_boolean(UniqueAll) ->
{ok, UniqueAll};
- {value, {cache_all, CacheAll}} when CacheAll;
- not CacheAll;
- CacheAll =:= list ->
+ {cache_all, CacheAll} when is_boolean(CacheAll);
+ CacheAll =:= list ->
{ok, CacheAll};
- {value, {cache_all, ets}} ->
+ {cache_all, ets} ->
{ok, true};
- {value, {cache_all, no}} ->
+ {cache_all, no} ->
{ok, false};
- {value, {spawn_options, default}} ->
+ {spawn_options, default} ->
{ok, default};
- {value, {spawn_options, SpawnOptions}} ->
+ {spawn_options, SpawnOptions} ->
case is_proper_list(SpawnOptions) of
true ->
{ok, SpawnOptions};
false ->
badarg
end;
- {value, {flat, Flat}} when Flat; not Flat ->
+ {flat, Flat} when is_boolean(Flat) ->
{ok, Flat};
- {value, {format, Format}} when Format =:= string;
- Format =:= abstract_code;
- Format =:= debug ->
+ {format, Format} when Format =:= string;
+ Format =:= abstract_code;
+ Format =:= debug ->
{ok, Format};
- {value, {n_elements, NElements}} when NElements =:= infinity;
- is_integer(NElements),
- NElements > 0 ->
+ {n_elements, NElements} when NElements =:= infinity;
+ is_integer(NElements),
+ NElements > 0 ->
{ok, NElements};
- {value, {depth, Depth}} when Depth =:= infinity;
- is_integer(Depth), Depth >= 0 ->
+ {depth, Depth} when Depth =:= infinity;
+ is_integer(Depth), Depth >= 0 ->
{ok, Depth};
- {value, {order, Order}} when is_function(Order),
- is_function(Order, 2);
- (Order =:= ascending);
- (Order =:= descending) ->
+ {order, Order} when is_function(Order), is_function(Order, 2);
+ (Order =:= ascending);
+ (Order =:= descending) ->
{ok, Order};
- {value, {compressed, Comp}} when Comp ->
+ {compressed, Comp} when Comp ->
{ok, [compressed]};
- {value, {compressed, Comp}} when not Comp ->
+ {compressed, Comp} when not Comp ->
{ok, []};
- {value, {tmpdir, T}} ->
+ {tmpdir, T} ->
{ok, T};
- {value, {size, Size}} when is_integer(Size), Size > 0 ->
+ {size, Size} when is_integer(Size), Size > 0 ->
{ok, Size};
- {value, {no_files, NoFiles}} when is_integer(NoFiles),
- NoFiles > 1 ->
+ {no_files, NoFiles} when is_integer(NoFiles), NoFiles > 1 ->
{ok, NoFiles};
- {value, {Key, _}} ->
+ {Key, _} ->
badarg;
false ->
Default = default_option(Key),
@@ -1457,7 +1446,7 @@ prep_qlc_lc({qlc_v1, QFun, CodeF, Qdata0, QOpt}, Opt, GOpt, _H) ->
{?qual_data(QNum, GoI, SI, {gen, Prep}), ModGens}
end,
{Qdata, ModGens} = lists:mapfoldl(F, [], Qdata0),
- SomeLookUp = lists:keymember(true, 2, ModGens) =/= false,
+ SomeLookUp = lists:keymember(true, 2, ModGens),
check_lookup_option(Opt, SomeLookUp),
case ModGens of
[{_QNum, _LookUp, all, OnePrep}] ->
@@ -1503,7 +1492,7 @@ pos_fun('==', QOpt, QNum) ->
prep_gen(#qlc_table{lu_vals = LuV0, ms = MS0, trav_MS = TravMS,
info_fun = IF, lookup_fun = LU_fun,
- key_equality = KeyEquality}=LE0,
+ key_equality = KeyEquality}=LE0,
Prep0, PosFun0, {MS, Fs}, Opt) ->
PosFun = PosFun0(KeyEquality),
{LuV, {STag,SkipFils}} = find_const_positions(IF, LU_fun, PosFun, Opt),
@@ -1998,8 +1987,8 @@ no_cache_of_first_generator(Optz, 1) ->
Optz#optz{cache = false}.
maybe_sort(LE, QNum, DoSort, Opt) ->
- case lists:keysearch(QNum, 1, DoSort) of
- {value, {QNum, Col}} ->
+ case lists:keyfind(QNum, 1, DoSort) of
+ {QNum, Col} ->
#qlc_opt{tmpdir = TmpDir, tmpdir_usage = TmpUsage} = Opt,
SortOpts = [{tmpdir,Dir} || Dir <- [TmpDir], Dir =/= ""],
Sort = #qlc_sort{h = LE, keypos = {keysort, Col}, unique = false,
@@ -2025,7 +2014,7 @@ skip_lookup_filters(Qdata0, LU_SkipFs) ->
%% specification it must be applied _after_ the lookup join (the
%% filter must not be skipped!).
activate_join_lookup_filter(QNum, Qdata) ->
- {value, {_,GoI2,SI2,{gen,Prep2}}} = lists:keysearch(QNum, 1, Qdata),
+ {_,GoI2,SI2,{gen,Prep2}} = lists:keyfind(QNum, 1, Qdata),
Table2 = Prep2#prepared.qh,
NPrep2 = Prep2#prepared{qh = Table2#qlc_table{ms = no_match_spec}},
%% Table2#qlc_table.ms has been reset; the filter will be run.
@@ -2059,7 +2048,7 @@ opt_join(Join, JoinOption, Qdata, Opt, LU_SkipQuals) ->
opt_join_lu([{{_Q1,_C1,Q2,_C2}=J,[{lookup_join,_KEols,JKE,Skip0} | _]} | LJ],
Qdata, LU_SkipQuals) ->
- {value, {Q2,_,_,{gen,Prep2}}} = lists:keysearch(Q2, 1, Qdata),
+ {Q2,_,_,{gen,Prep2}} = lists:keyfind(Q2, 1, Qdata),
#qlc_table{ms = MS, key_equality = KE,
lookup_fun = LU_fun} = Prep2#prepared.qh,
%% If there is no filter to skip (the match spec was derived
@@ -2670,8 +2659,8 @@ sort_list_output(L) ->
%% Don't use the file_sorter unless it is known that objects will be
%% put on a temporary file (optimization).
sort_handle(H, ListFun, FileFun, SortOptions, Post, LocalPost, TmpUsageM) ->
- Size = case lists:keysearch(size, 1, SortOptions) of
- {value, {size, Size0}} -> Size0;
+ Size = case lists:keyfind(size, 1, SortOptions) of
+ {size, Size0} -> Size0;
false -> default_option(size)
end,
sort_cache(H, [], Size, {ListFun, FileFun, Post, LocalPost, TmpUsageM}).
@@ -2891,8 +2880,8 @@ ucache_recall(UTab, MTab, SeqNo) ->
Object = case ets:lookup(UTab, Hash) of
[{Hash, SeqNo, Object0}] -> Object0;
HashSeqObjects ->
- {value, {Hash, SeqNo, Object0}} =
- lists:keysearch(SeqNo, 2, HashSeqObjects),
+ {Hash, SeqNo, Object0} =
+ lists:keyfind(SeqNo, 2, HashSeqObjects),
Object0
end,
[Object | fun() -> ucache_recall(UTab, MTab, SeqNo + 1) end]
@@ -3403,8 +3392,8 @@ merge_join_id() ->
tmp_merge_file(MergeId) ->
TmpFiles = get(?MERGE_JOIN_FILE),
- case lists:keysearch(MergeId, 1, TmpFiles) of
- {value, {MergeId, Fd, FileName}} ->
+ case lists:keyfind(MergeId, 1, TmpFiles) of
+ {MergeId, Fd, FileName} ->
{Fd, FileName};
false ->
none
diff --git a/lib/stdlib/src/qlc_pt.erl b/lib/stdlib/src/qlc_pt.erl
index 2d7874d99f..24378a0698 100644
--- a/lib/stdlib/src/qlc_pt.erl
+++ b/lib/stdlib/src/qlc_pt.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2004-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 2004-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(qlc_pt).
@@ -845,8 +845,8 @@ join_handle(AP, L, [F, H, O, C], Constants) ->
join_handle_constants(QId, ExtraConstants) ->
IdNo = QId#qid.no,
- case lists:keysearch(IdNo, 1, ExtraConstants) of
- {value, {IdNo, ConstOps}} ->
+ case lists:keyfind(IdNo, 1, ExtraConstants) of
+ {IdNo, ConstOps} ->
ConstOps;
false ->
[]
@@ -1231,9 +1231,9 @@ lu_skip(ColConstants, FilterData, PatternFrame, PatternVars,
%% The filter can only be skipped if all constants
%% are looked up.
LookedUpConstants =
- case lists:keysearch(Column, 1, ColConstants) of
+ case lists:keyfind(Column, 1, ColConstants) of
false -> [];
- {value, {Column,LUCs}} -> LUCs
+ {Column, LUCs} -> LUCs
end,
%% Don't try to handle filters that compare several
%% values equal. See also frames_to_columns().
@@ -1279,8 +1279,8 @@ join_gens(Cs0, Qs, Skip) ->
join_gens2(lists:filter(fun(C) -> length(C) > 2 end, Cs), FD, Skip)}.
join_gens2(Cs0, FilterData, Skip) ->
- [{J, skip_tag(case lists:keysearch(J, 1, Skip) of
- {value, {J,FilL}} ->
+ [{J, skip_tag(case lists:keyfind(J, 1, Skip) of
+ {J, FilL} ->
FilL;
false ->
[]
@@ -1296,8 +1296,8 @@ skip_tag(FilList, FilterData) ->
end, FilList}.
skip_tag(Col, ColFils, FilterData) ->
- case lists:keysearch(Col, 1, ColFils) of
- {value, {Col, FilL}} ->
+ case lists:keyfind(Col, 1, ColFils) of
+ {Col, FilL} ->
Tag = if
length(FilterData) =:= length(FilL) ->
all;
@@ -1415,7 +1415,7 @@ sel_gf([], _N, _Deps, _RDs, _Gens, _Gens1) ->
sel_gf([{#qid{no = N}=Id,{fil,F}}=Fil | FData], N, Deps, RDs, Gens, Gens1) ->
case erl_lint:is_guard_test(F, RDs) of
true ->
- {value, {Id,GIds}} = lists:keysearch(Id, 1, Deps),
+ {Id,GIds} = lists:keyfind(Id, 1, Deps),
case length(GIds) =< 1 of
true ->
case generators_in_scope(GIds, Gens1) of
@@ -2572,8 +2572,8 @@ nos_pattern([P0 | Ps0], S0, PVs0) ->
{[P | Ps], S, PVs};
nos_pattern({var,L,V}, {LI,Vs0,UV,A,Sg}, PVs0) when V =/= '_' ->
{Name, Vs, PVs} =
- case lists:keysearch(V, 1, PVs0) of
- {value, {V,VN}} ->
+ case lists:keyfind(V, 1, PVs0) of
+ {V, VN} ->
_ = used_var(V, Vs0, UV),
{VN, Vs0, PVs0};
false ->
diff --git a/lib/stdlib/src/shell.erl b/lib/stdlib/src/shell.erl
index a8d31b4e6b..ebb221c151 100644
--- a/lib/stdlib/src/shell.erl
+++ b/lib/stdlib/src/shell.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1996-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1996-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(shell).
@@ -22,12 +22,14 @@
-export([whereis_evaluator/0, whereis_evaluator/1]).
-export([start_restricted/1, stop_restricted/0]).
-export([local_allowed/3, non_local_allowed/3]).
+-export([prompt_func/1]).
-define(LINEMAX, 30).
-define(CHAR_MAX, 60).
-define(DEF_HISTORY, 20).
-define(DEF_RESULTS, 20).
-define(DEF_CATCH_EXCEPTION, false).
+-define(DEF_PROMPT_FUNC, default).
-define(RECORDS, shell_records).
@@ -235,14 +237,15 @@ server(StartSync) ->
{History,Results} = check_and_get_history_and_results(),
server_loop(0, start_eval(Bs, RT, []), Bs, RT, [], History, Results).
-server_loop(N0, Eval_0, Bs0, RT, Ds0, History0, Results0) ->
+server_loop(N0, Eval_0, Bs00, RT, Ds00, History0, Results0) ->
N = N0 + 1,
- {Res, Eval0} = get_command(prompt(N), Eval_0, Bs0, RT, Ds0),
+ {Eval_1,Bs0,Ds0,Prompt} = prompt(N, Eval_0, Bs00, RT, Ds00),
+ {Res,Eval0} = get_command(Prompt, Eval_1, Bs0, RT, Ds0),
case Res of
{ok,Es0,_EndLine} ->
case expand_hist(Es0, N) of
{ok,Es} ->
- {V,Eval,Bs,Ds} = shell_cmd(Es, Eval0, Bs0, RT, Ds0),
+ {V,Eval,Bs,Ds} = shell_cmd(Es, Eval0, Bs0, RT, Ds0, cmd),
{History,Results} = check_and_get_history_and_results(),
add_cmd(N, Es, V),
HB1 = del_cmd(command, N - History, N - History0, false),
@@ -301,7 +304,42 @@ get_command1(Pid, Eval, Bs, RT, Ds) ->
get_command1(Pid, start_eval(Bs, RT, Ds), Bs, RT, Ds)
end.
-prompt(N) ->
+prompt(N, Eval0, Bs0, RT, Ds0) ->
+ case get_prompt_func() of
+ {M,F} ->
+ L = [{history,N}],
+ C = {call,1,{remote,1,{atom,1,M},{atom,1,F}},[{value,1,L}]},
+ {V,Eval,Bs,Ds} = shell_cmd([C], Eval0, Bs0, RT, Ds0, pmt),
+ {Eval,Bs,Ds,case V of
+ {pmt,Val} ->
+ Val;
+ _ ->
+ bad_prompt_func({M,F}),
+ default_prompt(N)
+ end};
+ default ->
+ {Eval0,Bs0,Ds0,default_prompt(N)}
+ end.
+
+get_prompt_func() ->
+ case application:get_env(stdlib, shell_prompt_func) of
+ {ok,{M,F}=PromptFunc} when is_atom(M), is_atom(F) ->
+ PromptFunc;
+ {ok,default=Default} ->
+ Default;
+ {ok,Term} ->
+ bad_prompt_func(Term),
+ default;
+ undefined ->
+ default
+ end.
+
+bad_prompt_func(M) ->
+ fwrite_severity(benign, <<"Bad prompt function: ~p">>, [M]).
+
+default_prompt(N) ->
+ %% Don't bother flattening the list irrespective of what the
+ %% I/O-protocol states.
case is_alive() of
true -> io_lib:format(<<"(~s)~w> ">>, [node(), N]);
false -> io_lib:format(<<"~w> ">>, [N])
@@ -461,14 +499,16 @@ has_bin(T, I) ->
has_bin(element(I, T)),
has_bin(T, I - 1).
-%% shell_cmd(Sequence, Evaluator, Bindings, RecordTable, Dictionary)
+%% shell_cmd(Sequence, Evaluator, Bindings, RecordTable, Dictionary, What)
%% shell_rep(Evaluator, Bindings, RecordTable, Dictionary) ->
%% {Value,Evaluator,Bindings,Dictionary}
%% Send a command to the evaluator and wait for the reply. Start a new
%% evaluator if necessary.
+%% What = pmt | cmd. When evaluating a prompt ('pmt') the evaluated value
+%% must not be displayed, and it has to be returned.
-shell_cmd(Es, Eval, Bs, RT, Ds) ->
- Eval ! {shell_cmd,self(),{eval,Es}},
+shell_cmd(Es, Eval, Bs, RT, Ds, W) ->
+ Eval ! {shell_cmd,self(),{eval,Es}, W},
shell_rep(Eval, Bs, RT, Ds).
shell_rep(Ev, Bs0, RT, Ds0) ->
@@ -559,26 +599,26 @@ evaluator(Shell, Bs, RT, Ds) ->
eval_loop(Shell, Bs0, RT) ->
receive
- {shell_cmd,Shell,{eval,Es}} ->
+ {shell_cmd,Shell,{eval,Es},W} ->
Ef = {value,
fun(MForFun, As) -> apply_fun(MForFun, As, Shell) end},
Lf = local_func_handler(Shell, RT, Ef),
- Bs = eval_exprs(Es, Shell, Bs0, RT, Lf, Ef),
+ Bs = eval_exprs(Es, Shell, Bs0, RT, Lf, Ef, W),
eval_loop(Shell, Bs, RT)
end.
restricted_eval_loop(Shell, Bs0, RT, RShMod) ->
receive
- {shell_cmd,Shell,{eval,Es}} ->
+ {shell_cmd,Shell,{eval,Es}, W} ->
{LFH,NLFH} = restrict_handlers(RShMod, Shell, RT),
put(restricted_expr_state, []),
- Bs = eval_exprs(Es, Shell, Bs0, RT, {eval,LFH}, {value,NLFH}),
+ Bs = eval_exprs(Es, Shell, Bs0, RT, {eval,LFH}, {value,NLFH}, W),
restricted_eval_loop(Shell, Bs, RT, RShMod)
end.
-eval_exprs(Es, Shell, Bs0, RT, Lf, Ef) ->
+eval_exprs(Es, Shell, Bs0, RT, Lf, Ef, W) ->
try
- {R,Bs2} = exprs(Es, Bs0, RT, Lf, Ef),
+ {R,Bs2} = exprs(Es, Bs0, RT, Lf, Ef, W),
Shell ! {shell_rep,self(),R},
Bs2
catch
@@ -614,10 +654,10 @@ do_catch(_Class, _Reason) ->
false
end.
-exprs(Es, Bs0, RT, Lf, Ef) ->
- exprs(Es, Bs0, RT, Lf, Ef, Bs0).
+exprs(Es, Bs0, RT, Lf, Ef, W) ->
+ exprs(Es, Bs0, RT, Lf, Ef, Bs0, W).
-exprs([E0|Es], Bs1, RT, Lf, Ef, Bs0) ->
+exprs([E0|Es], Bs1, RT, Lf, Ef, Bs0, W) ->
UsedRecords = used_record_defs(E0, RT),
RBs = record_bindings(UsedRecords, Bs1),
case check_command(prep_check([E0]), RBs) of
@@ -629,16 +669,20 @@ exprs([E0|Es], Bs1, RT, Lf, Ef, Bs0) ->
if
Es =:= [] ->
VS = pp(V0, 1, RT),
- io:requests([{put_chars, VS}, nl]),
+ [io:requests([{put_chars, VS}, nl]) || W =:= cmd],
%% Don't send the result back if it will be
%% discarded anyway.
- V = case result_will_be_saved() of
- true -> V0;
- false -> ignored
+ V = if
+ W =:= pmt ->
+ {W,V0};
+ true -> case result_will_be_saved() of
+ true -> V0;
+ false -> ignored
+ end
end,
{{value,V,Bs,get()},Bs};
true ->
- exprs(Es, Bs, RT, Lf, Ef, Bs0)
+ exprs(Es, Bs, RT, Lf, Ef, Bs0, W)
end;
{error,Error} ->
{{command_error,Error},Bs0}
@@ -1383,7 +1427,7 @@ pp(V, I, RT) ->
columns() ->
case io:columns() of
- {ok,N} -> N;
+ {ok,N} -> N;
_ -> 80
end.
@@ -1438,3 +1482,9 @@ results(L) when is_integer(L), L >= 0 ->
catch_exception(Bool) ->
set_env(stdlib, shell_catch_exception, Bool, ?DEF_CATCH_EXCEPTION).
+
+-type prompt_func() :: 'default' | {module(),atom()}.
+-spec prompt_func(prompt_func()) -> prompt_func().
+
+prompt_func(String) ->
+ set_env(stdlib, shell_prompt_func, String, ?DEF_PROMPT_FUNC).
diff --git a/lib/stdlib/src/shell_default.erl b/lib/stdlib/src/shell_default.erl
index 670f8cdb44..3fe359af0e 100644
--- a/lib/stdlib/src/shell_default.erl
+++ b/lib/stdlib/src/shell_default.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1996-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1996-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
@@ -45,6 +45,7 @@ help() ->
format("h() -- history\n"),
format("history(N) -- set how many previous commands to keep\n"),
format("results(N) -- set how many previous command results to keep\n"),
+ format("catch_exception(B) -- how exceptions are handled\n"),
format("v(N) -- use the value of query <N>\n"),
format("rd(R,D) -- define a record\n"),
format("rf() -- remove all record information\n"),
diff --git a/lib/stdlib/src/supervisor.erl b/lib/stdlib/src/supervisor.erl
index fb1303d1eb..22269a8d1b 100644
--- a/lib/stdlib/src/supervisor.erl
+++ b/lib/stdlib/src/supervisor.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1996-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1996-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(supervisor).
@@ -24,7 +24,7 @@
-export([start_link/2,start_link/3,
start_child/2, restart_child/2,
delete_child/2, terminate_child/2,
- which_children/1,
+ which_children/1, count_children/1,
check_childspecs/1]).
-export([behaviour_info/1]).
@@ -95,6 +95,9 @@ terminate_child(Supervisor, Name) ->
which_children(Supervisor) ->
call(Supervisor, which_children).
+count_children(Supervisor) ->
+ call(Supervisor, count_children).
+
call(Supervisor, Req) ->
gen_server:call(Supervisor, Req, infinity).
@@ -297,7 +300,49 @@ handle_call(which_children, _From, State) ->
{Name, Pid, ChildType, Mods}
end,
State#state.children),
- {reply, Resp, State}.
+ {reply, Resp, State};
+
+handle_call(count_children, _From, State) when ?is_simple(State) ->
+ [#child{child_type = CT}] = State#state.children,
+ {Active, Count} =
+ ?DICT:fold(fun(Pid, _Val, {Alive, Tot}) ->
+ if is_pid(Pid) -> {Alive+1, Tot +1};
+ true -> {Alive, Tot + 1} end
+ end, {0, 0}, State#state.dynamics),
+ Reply = case CT of
+ supervisor -> [{specs, 1}, {active, Active},
+ {supervisors, Count}, {workers, 0}];
+ worker -> [{specs, 1}, {active, Active},
+ {supervisors, 0}, {workers, Count}]
+ end,
+ {reply, Reply, State};
+
+handle_call(count_children, _From, State) ->
+
+ %% Specs and children are together on the children list...
+ {Specs, Active, Supers, Workers} =
+ lists:foldl(fun(Child, Counts) ->
+ count_child(Child, Counts)
+ end, {0,0,0,0}, State#state.children),
+
+ %% Reformat counts to a property list.
+ Reply = [{specs, Specs}, {active, Active},
+ {supervisors, Supers}, {workers, Workers}],
+ {reply, Reply, State}.
+
+
+count_child(#child{pid = Pid, child_type = worker},
+ {Specs, Active, Supers, Workers}) ->
+ case is_pid(Pid) andalso is_process_alive(Pid) of
+ true -> {Specs+1, Active+1, Supers, Workers+1};
+ false -> {Specs+1, Active, Supers, Workers+1}
+ end;
+count_child(#child{pid = Pid, child_type = supervisor},
+ {Specs, Active, Supers, Workers}) ->
+ case is_pid(Pid) andalso is_process_alive(Pid) of
+ true -> {Specs+1, Active+1, Supers+1, Workers};
+ false -> {Specs+1, Active, Supers+1, Workers}
+ end.
%%% Hopefully cause a function-clause as there is no API function
diff --git a/lib/stdlib/test/Makefile b/lib/stdlib/test/Makefile
index ac8cbba375..9beac93eb8 100644
--- a/lib/stdlib/test/Makefile
+++ b/lib/stdlib/test/Makefile
@@ -110,7 +110,7 @@ COVERFILE=stdlib.cover
make_emakefile:
$(ERL_TOP)/make/make_emakefile $(ERL_COMPILE_FLAGS) -o$(EBIN) $(MODULES) \
- >> $(EMAKEFILE)
+ > $(EMAKEFILE)
tests debug opt: make_emakefile
erl $(ERL_MAKE_FLAGS) -make
diff --git a/lib/stdlib/test/calendar_SUITE.erl b/lib/stdlib/test/calendar_SUITE.erl
index ea81bb99a9..10fb72c1b1 100644
--- a/lib/stdlib/test/calendar_SUITE.erl
+++ b/lib/stdlib/test/calendar_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1997-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(calendar_SUITE).
@@ -48,7 +48,7 @@ gregorian_days(doc) ->
"At the same time valid_date is tested.";
gregorian_days(suite) ->
[];
-gregorian_days(Config) when list(Config) ->
+gregorian_days(Config) when is_list(Config) ->
?line Days = calendar:date_to_gregorian_days({?START_YEAR, 1, 1}),
?line MaxDays = calendar:date_to_gregorian_days({?END_YEAR, 1, 1}),
?line check_gregorian_days(Days, MaxDays).
@@ -60,7 +60,7 @@ gregorian_seconds(doc) ->
"every 2 days + 1 second.";
gregorian_seconds(suite) ->
[];
-gregorian_seconds(Config) when list(Config) ->
+gregorian_seconds(Config) when is_list(Config) ->
?line Secs = calendar:datetime_to_gregorian_seconds({{?START_YEAR, 1, 1},
{0, 0, 0}}),
?line MaxSecs = calendar:datetime_to_gregorian_seconds({{?END_YEAR, 1, 1},
@@ -72,7 +72,7 @@ day_of_the_week(doc) ->
"year ?START_YEAR up to ?END_YEAR.";
day_of_the_week(suite) ->
[];
-day_of_the_week(Config) when list(Config) ->
+day_of_the_week(Config) when is_list(Config) ->
?line Days = calendar:date_to_gregorian_days({?START_YEAR, 1, 1}),
?line MaxDays = calendar:date_to_gregorian_days({?END_YEAR, 1, 1}),
?line DayNumber = calendar:day_of_the_week({?START_YEAR, 1, 1}),
@@ -82,7 +82,7 @@ day_of_the_week_calibrate(doc) ->
"Tests that day_of_the_week for 1997-11-11 is Tuesday (2)";
day_of_the_week_calibrate(suite) ->
[];
-day_of_the_week_calibrate(Config) when list(Config) ->
+day_of_the_week_calibrate(Config) when is_list(Config) ->
?line 2 = calendar:day_of_the_week({1997, 11, 11}).
leap_years(doc) ->
@@ -90,7 +90,7 @@ leap_years(doc) ->
"year ?START_YEAR up to ?END_YEAR.";
leap_years(suite) ->
[];
-leap_years(Config) when list(Config) ->
+leap_years(Config) when is_list(Config) ->
?line check_leap_years(?START_YEAR, ?END_YEAR).
last_day_of_the_month(doc) ->
@@ -98,14 +98,14 @@ last_day_of_the_month(doc) ->
"year ?START_YEAR up to ?END_YEAR.";
last_day_of_the_month(suite) ->
[];
-last_day_of_the_month(Config) when list(Config) ->
+last_day_of_the_month(Config) when is_list(Config) ->
?line check_last_day_of_the_month({?START_YEAR, 1}, {?END_YEAR, 1}).
local_time_to_universal_time_dst(doc) ->
"Tests local_time_to_universal_time_dst for MET";
local_time_to_universal_time_dst(suite) ->
[];
-local_time_to_universal_time_dst(Config) when list(Config) ->
+local_time_to_universal_time_dst(Config) when is_list(Config) ->
case os:type() of
{unix,_} ->
case os:cmd("date '+%Z'") of
@@ -117,7 +117,7 @@ local_time_to_universal_time_dst(Config) when list(Config) ->
_ ->
local_time_to_universal_time_dst_x(Config)
end.
-local_time_to_universal_time_dst_x(Config) when list(Config) ->
+local_time_to_universal_time_dst_x(Config) when is_list(Config) ->
%% Assumes MET (UTC+1 / UTC+2(dst)
?line LtW = {{2003,01,15},{14,00,00}}, % Winter
?line UtW = {{2003,01,15},{13,00,00}}, %
diff --git a/lib/stdlib/test/epp_SUITE.erl b/lib/stdlib/test/epp_SUITE.erl
index 67e20fd2e1..9a3ae0baf5 100644
--- a/lib/stdlib/test/epp_SUITE.erl
+++ b/lib/stdlib/test/epp_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1998-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1998-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
-module(epp_SUITE).
@@ -23,7 +23,7 @@
upcase_mac/1, upcase_mac_1/1, upcase_mac_2/1,
variable/1, variable_1/1, otp_4870/1, otp_4871/1, otp_5362/1,
pmod/1, not_circular/1, skip_header/1, otp_6277/1, otp_7702/1,
- otp_8130/1]).
+ otp_8130/1, overload_mac/1, otp_8388/1]).
-export([epp_parse_erl_form/2]).
@@ -61,8 +61,9 @@ fin_per_testcase(_, Config) ->
all(doc) ->
["Test cases for epp."];
all(suite) ->
- [rec_1, upcase_mac, predef_mac, variable, otp_4870, otp_4871, otp_5362,
- pmod, not_circular, skip_header, otp_6277, otp_7702, otp_8130].
+ [rec_1, upcase_mac, predef_mac, variable, otp_4870, otp_4871, otp_5362,
+ pmod, not_circular, skip_header, otp_6277, otp_7702, otp_8130,
+ overload_mac, otp_8388].
rec_1(doc) ->
["Recursive macros hang or crash epp (OTP-1398)."];
@@ -466,7 +467,7 @@ otp_6277(Config) when is_list(Config) ->
-define(ASSERT, ?MODULE).
?ASSERT().">>,
- [{error,{{4,16},epp,{undefined,'MODULE'}}}]}],
+ [{error,{{4,16},epp,{undefined,'MODULE', none}}}]}],
?line [] = check(Config, Ts),
ok.
@@ -673,7 +674,7 @@ otp_8130(Config) when is_list(Config) ->
{otp_8130_c7,
<<"\nt() -> ?A.\n">>,
- {errors,[{{2,9},epp,{undefined,'A'}}],[]}},
+ {errors,[{{2,9},epp,{undefined,'A', none}}],[]}},
{otp_8130_c8,
<<"\n-include_lib(\"$apa/foo.hrl\").\n">>,
@@ -683,7 +684,7 @@ otp_8130(Config) when is_list(Config) ->
{otp_8130_c9,
<<"-define(S, ?S).\n"
"t() -> ?S.\n">>,
- {errors,[{{2,9},epp,{circular,'S'}}],[]}},
+ {errors,[{{2,9},epp,{circular,'S', none}}],[]}},
{otp_8130_c10,
<<"\n-file.">>,
@@ -718,22 +719,22 @@ otp_8130(Config) when is_list(Config) ->
{otp_8130_c17,
<<"\n-define(A(B), B).\n"
"-define(A, 1).\n">>,
- {errors,[{{3,9},epp,{redefine,'A'}}],[]}},
+ []},
{otp_8130_c18,
<<"\n-define(A, 1).\n"
"-define(A(B), B).\n">>,
- {errors,[{{3,9},epp,{redefine,'A'}}],[]}},
+ []},
{otp_8130_c19,
<<"\n-define(a(B), B).\n"
"-define(a, 1).\n">>,
- {errors,[{{3,9},epp,{redefine,a}}],[]}},
+ []},
{otp_8130_c20,
<<"\n-define(a, 1).\n"
"-define(a(B), B).\n">>,
- {errors,[{{3,9},epp,{redefine,a}}],[]}},
+ []},
{otp_8130_c21,
<<"\n-define(A(B, B), B).\n">>,
@@ -745,7 +746,7 @@ otp_8130(Config) when is_list(Config) ->
{otp_8130_c23,
<<"\n-file(?b, 3).\n">>,
- {errors,[{{2,8},epp,{undefined,b}}],[]}},
+ {errors,[{{2,8},epp,{undefined,b, none}}],[]}},
{otp_8130_c24,
<<"\n-include(\"no such file.erl\").\n">>,
@@ -821,7 +822,8 @@ macs(Epp) ->
macro(Epp, N) ->
case lists:keyfind({atom,N}, 1, epp:macro_defs(Epp)) of
false -> false;
- {{atom,N},{_,V}} -> V
+ {{atom,N},{_,V}} -> V;
+ {{atom,N},Defs} -> lists:append([V || {_,{_,V}} <- Defs])
end.
ifdef(Config) ->
@@ -1030,6 +1032,113 @@ ifdef(Config) ->
],
?line [] = run(Config, Ts).
+
+
+overload_mac(doc) ->
+ ["Advanced test on overloading macros."];
+overload_mac(suite) ->
+ [];
+overload_mac(Config) when is_list(Config) ->
+ Cs = [
+ %% '-undef' removes all definitions of a macro
+ {overload_mac_c1,
+ <<"-define(A, a).\n"
+ "-define(A(X), X).\n"
+ "-undef(A).\n"
+ "t1() -> ?A.\n",
+ "t2() -> ?A(1).">>,
+ {errors,[{{4,9},epp,{undefined,'A', none}},
+ {{5,9},epp,{undefined,'A', 1}}],[]}},
+
+ %% cannot overload predefined macros
+ {overload_mac_c2,
+ <<"-define(MODULE(X), X).">>,
+ {errors,[{{1,9},epp,{redefine_predef,'MODULE'}}],[]}},
+
+ %% cannot overload macros with same arity
+ {overload_mac_c3,
+ <<"-define(A(X), X).\n"
+ "-define(A(Y), Y).">>,
+ {errors,[{{2,9},epp,{redefine,'A'}}],[]}},
+
+ {overload_mac_c4,
+ <<"-define(A, a).\n"
+ "-define(A(X,Y), {X,Y}).\n"
+ "a(X) -> X.\n"
+ "t() -> ?A(1).">>,
+ {errors,[{{4,9},epp,{mismatch,'A'}}],[]}}
+ ],
+ ?line [] = compile(Config, Cs),
+
+ Ts = [
+ {overload_mac_r1,
+ <<"-define(A, 1).\n"
+ "-define(A(X), X).\n"
+ "-define(A(X, Y), {X, Y}).\n"
+ "t() -> {?A, ?A(2), ?A(3, 4)}.">>,
+ {1, 2, {3, 4}}},
+
+ {overload_mac_r2,
+ <<"-define(A, 1).\n"
+ "-define(A(X), X).\n"
+ "t() -> ?A(?A).">>,
+ 1},
+
+ {overload_mac_r3,
+ <<"-define(A, ?B).\n"
+ "-define(B, a).\n"
+ "-define(B(X), {b,X}).\n"
+ "a(X) -> X.\n"
+ "t() -> ?A(1).">>,
+ 1}
+ ],
+ ?line [] = run(Config, Ts).
+
+
+otp_8388(doc) ->
+ ["OTP-8388. More tests on overloaded macros."];
+otp_8388(suite) ->
+ [];
+otp_8388(Config) when is_list(Config) ->
+ Dir = ?config(priv_dir, Config),
+ ?line File = filename:join(Dir, "otp_8388.erl"),
+ ?line ok = file:write_file(File, <<"-module(otp_8388)."
+ "-define(LINE, a).">>),
+ fun() ->
+ PreDefMacros = [{'LINE', a}],
+ ?line {error,{redefine_predef,'LINE'}} =
+ epp:open(File, [], PreDefMacros)
+ end(),
+
+ fun() ->
+ PreDefMacros = ['LINE'],
+ ?line {error,{redefine_predef,'LINE'}} =
+ epp:open(File, [], PreDefMacros)
+ end(),
+
+ Ts = [
+ {macro_1,
+ <<"-define(m(A), A).\n"
+ "t() -> ?m(,).\n">>,
+ {errors,[{{2,11},epp,{arg_error,m}}],[]}},
+ {macro_2,
+ <<"-define(m(A), A).\n"
+ "t() -> ?m(a,).\n">>,
+ {errors,[{{2,12},epp,{arg_error,m}}],[]}},
+ {macro_3,
+ <<"-define(LINE, a).\n">>,
+ {errors,[{{1,9},epp,{redefine_predef,'LINE'}}],[]}},
+ {macro_4,
+ <<"-define(A(B, C, D), {B,C,D}).\n"
+ "t() -> ?A(a,,3).\n">>,
+ {errors,[{{2,8},epp,{mismatch,'A'}}],[]}},
+ {macro_5,
+ <<"-define(Q, {?F0(), ?F1(,,4)}).\n">>,
+ {errors,[{{1,24},epp,{arg_error,'F1'}}],[]}}
+ ],
+ ?line [] = compile(Config, Ts),
+ ok.
+
check(Config, Tests) ->
eval_tests(Config, fun check_test/2, Tests).
diff --git a/lib/stdlib/test/erl_lint_SUITE.erl b/lib/stdlib/test/erl_lint_SUITE.erl
index bfbd7b3dc1..8581b496aa 100644
--- a/lib/stdlib/test/erl_lint_SUITE.erl
+++ b/lib/stdlib/test/erl_lint_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1999-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1999-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(erl_lint_SUITE).
@@ -2597,7 +2597,7 @@ otp_8051(Config) when is_list(Config) ->
<<"-opaque foo() :: bar().
">>,
[],
- {error,[{1,erl_lint,{type_ref,{bar,0}}}],
+ {error,[{1,erl_lint,{undefined_type,{bar,0}}}],
[{1,erl_lint,{unused_type,{foo,0}}}]}}],
?line [] = run(Config, Ts),
ok.
diff --git a/lib/stdlib/test/ets_tough_SUITE.erl b/lib/stdlib/test/ets_tough_SUITE.erl
index e3d44d00b9..4c8d941f13 100644
--- a/lib/stdlib/test/ets_tough_SUITE.erl
+++ b/lib/stdlib/test/ets_tough_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1996-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1996-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(ets_tough_SUITE).
@@ -40,7 +40,7 @@ fin_per_testcase(_Func, Config) ->
ets:delete(?GLOBAL_PARAMS).
-ex1(Config) when list(Config) ->
+ex1(Config) when is_list(Config) ->
?line ets:new(?GLOBAL_PARAMS,[named_table,public]),
?line ets:insert(?GLOBAL_PARAMS,{a,set}),
?line ets:insert(?GLOBAL_PARAMS,{b,set}),
@@ -269,7 +269,7 @@ show_entries(Fd) ->
start(DbName) ->
case gen_server:start_link(ets_tough_SUITE,{DbName,no_dump_dir},[]) of
- {ok,Pid} when pid(Pid) ->
+ {ok,Pid} when is_pid(Pid) ->
{ok, Pid};
Other ->
Other
@@ -283,7 +283,7 @@ start(DbName) ->
start(DbName,DumpDir) ->
case gen_server:start_link(ets_tough_SUITE,
{DbName,{dump_dir,DumpDir}},[]) of
- {ok,Pid} when pid(Pid) ->
+ {ok,Pid} when is_pid(Pid) ->
{ok, Pid};
Other ->
Other
@@ -1075,7 +1075,7 @@ phys_read_len(Fd) ->
phys_read_entry(Fd,Len) ->
case io:get_chars(Fd,'',Len) of
- L when list(L), length(L) == Len ->
+ L when is_list(L), length(L) == Len ->
{ok,binary_to_term(list_to_binary(L))};
Other ->
{error,{read_term,Other}}
diff --git a/lib/stdlib/test/filelib_SUITE.erl b/lib/stdlib/test/filelib_SUITE.erl
index c9c6054f7b..d54741051f 100644
--- a/lib/stdlib/test/filelib_SUITE.erl
+++ b/lib/stdlib/test/filelib_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2005-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 2005-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
@@ -21,7 +21,7 @@
-export([all/1,init_per_testcase/2,fin_per_testcase/2,
wildcard_one/1,wildcard_two/1,wildcard_errors/1,
- fold_files/1,otp_5960/1]).
+ fold_files/1,otp_5960/1,ensure_dir_eexist/1]).
-import(lists, [foreach/2]).
@@ -38,7 +38,8 @@ fin_per_testcase(_Case, Config) ->
ok.
all(suite) ->
- [wildcard_one,wildcard_two,wildcard_errors,fold_files,otp_5960].
+ [wildcard_one,wildcard_two,wildcard_errors,fold_files,otp_5960,
+ ensure_dir_eexist].
wildcard_one(Config) when is_list(Config) ->
?line {ok,OldCwd} = file:get_cwd(),
@@ -223,7 +224,9 @@ otp_5960(Config) when is_list(Config) ->
?line Name1 = filename:join(Dir, name1),
?line Name2 = filename:join(Dir, name2),
?line ok = filelib:ensure_dir(Name1), % parent is created
+ ?line ok = filelib:ensure_dir(Name1), % repeating it should be OK
?line ok = filelib:ensure_dir(Name2), % parent already exists
+ ?line ok = filelib:ensure_dir(Name2), % repeating it should be OK
?line Name3 = filename:join(Name1, name3),
?line {ok, FileInfo} = file:read_file_info(Dir),
case os:type() of
@@ -239,3 +242,16 @@ otp_5960(Config) when is_list(Config) ->
?line ok = file:write_file_info(Dir, #file_info{mode=Mode}),
ok
end.
+
+ensure_dir_eexist(Config) when is_list(Config) ->
+ ?line PrivDir = ?config(priv_dir, Config),
+ ?line Dir = filename:join(PrivDir, ensure_dir_eexist),
+ ?line Name = filename:join(Dir, "same_name_as_file_and_dir"),
+ ?line ok = filelib:ensure_dir(Name),
+ ?line ok = file:write_file(Name, <<"some string\n">>),
+
+ %% There already is a file with the name of the directory
+ %% we want to create.
+ ?line NeedFile = filename:join(Name, "file"),
+ ?line {error, eexist} = filelib:ensure_dir(NeedFile),
+ ok.
diff --git a/lib/stdlib/test/fixtable_SUITE.erl b/lib/stdlib/test/fixtable_SUITE.erl
index 9f21308ad4..1940ee147e 100644
--- a/lib/stdlib/test/fixtable_SUITE.erl
+++ b/lib/stdlib/test/fixtable_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1999-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1999-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
%%%----------------------------------------------------------------------
@@ -83,7 +83,7 @@ fixbag(doc) ->
"incorrect lookups"];
fixbag(suite) ->
[];
-fixbag(Config) when list(Config) ->
+fixbag(Config) when is_list(Config) ->
?line T = ets:new(x,[bag]),
?line ets:insert(T,{a,1}),
?line ets:insert(T,{a,2}),
@@ -101,7 +101,7 @@ insert_same_key(doc) ->
["Check correct behaviour if a key is deleted and reinserted during fixation."];
insert_same_key(suite) ->
[];
-insert_same_key(Config) when list(Config) ->
+insert_same_key(Config) when is_list(Config) ->
?line {ok,Dets1} = dets:open_file(?DETS_TMP1,
[{file, dets_filename(?DETS_TMP1,Config)}]),
?line Ets1 = ets:new(ets,[]),
@@ -180,7 +180,7 @@ owner_dies(doc) ->
["Check correct behaviour if the table owner dies."];
owner_dies(suite) ->
[];
-owner_dies(Config) when list(Config) ->
+owner_dies(Config) when is_list(Config) ->
?line P1 = start_commander(),
?line Ets1 = command(P1,{ets,new,[ets,[]]}),
?line command(P1,{ets,safe_fixtable,[Ets1,true]}),
@@ -236,7 +236,7 @@ other_process_closes(doc) ->
other_process_closes(suite) ->
[];
-other_process_closes(Config) when list(Config) ->
+other_process_closes(Config) when is_list(Config) ->
?line {ok,Dets} = dets:open_file(?DETS_TMP1,
[{file, dets_filename(tmp1,Config)}]),
?line P2 = start_commander(),
@@ -265,7 +265,7 @@ other_process_deletes(doc) ->
"deletes an ets table"];
other_process_deletes(suite) ->
[];
-other_process_deletes(Config) when list(Config) ->
+other_process_deletes(Config) when is_list(Config) ->
?line Ets = ets:new(ets,[public]),
?line P = start_commander(),
?line ets:safe_fixtable(Ets,true),
@@ -282,7 +282,7 @@ multiple_fixes(doc) ->
["Check that multiple safe_fixtable keeps the reference counter."];
multiple_fixes(suite) ->
[];
-multiple_fixes(Config) when list(Config) ->
+multiple_fixes(Config) when is_list(Config) ->
?line {ok,Dets} = dets:open_file(?DETS_TMP1,
[{file, dets_filename(?DETS_TMP1,Config)}]),
?line Ets = ets:new(ets,[]),
@@ -317,7 +317,7 @@ multiple_processes(doc) ->
"counted OK"];
multiple_processes(suite) ->
[];
-multiple_processes(Config) when list(Config) ->
+multiple_processes(Config) when is_list(Config) ->
?line {ok,Dets} = dets:open_file(?DETS_TMP1,[{file,
dets_filename(?DETS_TMP1,
Config)}]),
@@ -370,7 +370,7 @@ multiple_processes(Tab, Mod) ->
%%% Helpers
-dets_filename(Base, Config) when atom(Base) ->
+dets_filename(Base, Config) when is_atom(Base) ->
dets_filename(atom_to_list(Base) ++ ".dat", Config);
dets_filename(Basename, Config) ->
PrivDir = ?config(priv_dir,Config),
diff --git a/lib/stdlib/test/format_SUITE.erl b/lib/stdlib/test/format_SUITE.erl
index 2c415894f4..1c9e953003 100644
--- a/lib/stdlib/test/format_SUITE.erl
+++ b/lib/stdlib/test/format_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1998-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1998-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(format_SUITE).
@@ -45,7 +45,7 @@ hang_1(doc) ->
["Bad args can hang (OTP-2400)"];
hang_1(suite) ->
[];
-hang_1(Config) when list(Config) ->
+hang_1(Config) when is_list(Config) ->
?line _ = (catch io:format(a, "", [])),
?line _ = (catch io:format({}, "", [])),
ok.
diff --git a/lib/stdlib/test/gen_event_SUITE.erl b/lib/stdlib/test/gen_event_SUITE.erl
index dc5ddebf53..8cbffaca56 100644
--- a/lib/stdlib/test/gen_event_SUITE.erl
+++ b/lib/stdlib/test/gen_event_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1996-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1996-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(gen_event_SUITE).
@@ -33,7 +33,7 @@ all(suite) -> {req, [stdlib], [start, test_all, hibernate]}.
start(doc) -> [];
start(suite) -> [];
-start(Config) when list(Config) ->
+start(Config) when is_list(Config) ->
OldFl = process_flag(trap_exit, true),
?line {ok, Pid0} = gen_event:start(), %anonymous
@@ -175,7 +175,7 @@ test_all(suite) -> [add_handler, add_sup_handler, delete_handler,
add_handler(doc) -> [];
add_handler(suite) -> [];
-add_handler(Config) when list(Config) ->
+add_handler(Config) when is_list(Config) ->
?line {ok,_} = gen_event:start({local, my_dummy_handler}),
?line {error, my_error} =
gen_event:add_handler(my_dummy_handler, dummy_h, make_error),
@@ -196,7 +196,7 @@ add_handler(Config) when list(Config) ->
add_sup_handler(doc) -> [];
add_sup_handler(suite) -> [];
-add_sup_handler(Config) when list(Config) ->
+add_sup_handler(Config) when is_list(Config) ->
?line {ok,Pid} = gen_event:start({local, my_dummy_handler}),
?line {error, my_error} =
gen_event:add_sup_handler(my_dummy_handler, dummy_h, make_error),
@@ -238,7 +238,7 @@ add_sup_handler(Config) when list(Config) ->
delete_handler(doc) -> [];
delete_handler(suite) -> [];
-delete_handler(Config) when list(Config) ->
+delete_handler(Config) when is_list(Config) ->
?line {ok,_} = gen_event:start({local, my_dummy_handler}),
?line ok = gen_event:add_handler(my_dummy_handler, dummy_h, [self()]),
?line {error, module_not_found} =
@@ -270,7 +270,7 @@ delete_handler(Config) when list(Config) ->
swap_handler(doc) -> [];
swap_handler(suite) -> [];
-swap_handler(Config) when list(Config) ->
+swap_handler(Config) when is_list(Config) ->
?line {ok,_} = gen_event:start({local, my_dummy_handler}),
?line ok = gen_event:add_handler(my_dummy_handler, dummy_h, [self()]),
?line {error, non_existing} =
@@ -299,7 +299,7 @@ swap_handler(Config) when list(Config) ->
swap_sup_handler(doc) -> [];
swap_sup_handler(suite) -> [];
-swap_sup_handler(Config) when list(Config) ->
+swap_sup_handler(Config) when is_list(Config) ->
?line {ok,_} = gen_event:start({local, my_dummy_handler}),
?line ok = gen_event:add_sup_handler(my_dummy_handler, dummy_h, [self()]),
?line {error, non_existing} =
@@ -341,7 +341,7 @@ swap_sup_handler(Config) when list(Config) ->
notify(doc) -> [];
notify(suite) -> [];
-notify(Config) when list(Config) ->
+notify(Config) when is_list(Config) ->
?line {ok,_} = gen_event:start({local, my_dummy_handler}),
?line ok = gen_event:add_handler(my_dummy_handler, dummy_h, [self()]),
Event = {event, self()},
@@ -457,7 +457,7 @@ notify(Config) when list(Config) ->
sync_notify(doc) -> [];
sync_notify(suite) -> [];
-sync_notify(Config) when list(Config) ->
+sync_notify(Config) when is_list(Config) ->
?line {ok,_} = gen_event:start({local, my_dummy_handler}),
?line ok = gen_event:add_handler(my_dummy_handler, dummy_h, [self()]),
Event = {event, self()},
@@ -576,7 +576,7 @@ sync_notify(Config) when list(Config) ->
call(doc) -> [];
call(suite) -> [];
-call(Config) when list(Config) ->
+call(Config) when is_list(Config) ->
?line {ok,_} = gen_event:start({local, my_dummy_handler}),
?line ok = gen_event:add_handler(my_dummy_handler, dummy_h, [self()]),
?line ok = gen_event:add_handler(my_dummy_handler, {dummy_h, 1}, [self()]),
@@ -718,7 +718,7 @@ flush() ->
info(doc) -> [];
info(suite) -> [];
-info(Config) when list(Config) ->
+info(Config) when is_list(Config) ->
?line {ok,_} = gen_event:start({local, my_dummy_handler}),
?line ok = gen_event:add_handler(my_dummy_handler, dummy_h, [self()]),
Info = {info, self()},
diff --git a/lib/stdlib/test/io_proto_SUITE.erl b/lib/stdlib/test/io_proto_SUITE.erl
index 59aa175c73..93159fbd5b 100644
--- a/lib/stdlib/test/io_proto_SUITE.erl
+++ b/lib/stdlib/test/io_proto_SUITE.erl
@@ -23,7 +23,7 @@
-export([init_per_testcase/2, fin_per_testcase/2]).
-export([setopts_getopts/1,unicode_options/1,unicode_options_gen/1, binary_options/1, bc_with_r12/1,
- bc_with_r12_gl/1, read_modes_gl/1,bc_with_r12_ogl/1, read_modes_ogl/1, broken_unicode/1,eof_on_pipe/1]).
+ bc_with_r12_gl/1, read_modes_gl/1,bc_with_r12_ogl/1, read_modes_ogl/1, broken_unicode/1,eof_on_pipe/1,unicode_prompt/1]).
-export([io_server_proxy/1,start_io_server_proxy/0, proxy_getall/1, proxy_setnext/2, proxy_quit/1]).
@@ -31,6 +31,8 @@
-export([toerl_server/3,hold_the_line/3,answering_machine1/3,
answering_machine2/3]).
+-export([uprompt/1]).
+
%-define(without_test_server, true).
-ifdef(without_test_server).
@@ -43,7 +45,7 @@
-define(privdir(Conf), ?config(priv_dir, Conf)).
-endif.
-%-define(debug, true).
+-define(debug, true).
-ifdef(debug).
-define(format(S, A), io:format(S, A)).
@@ -82,7 +84,7 @@ all(doc) ->
all(suite) ->
[setopts_getopts, unicode_options, unicode_options_gen, binary_options, bc_with_r12,
bc_with_r12_gl,bc_with_r12_ogl, read_modes_gl, read_modes_ogl,
- broken_unicode,eof_on_pipe].
+ broken_unicode,eof_on_pipe,unicode_prompt].
-record(state, {
@@ -91,6 +93,48 @@ all(suite) ->
mode = list
}).
+uprompt(_L) ->
+ [1050,1072,1082,1074,1086,32,1077,32,85,110,105,99,111,100,101,32,63].
+
+unicode_prompt(suite) ->
+ [];
+unicode_prompt(doc) ->
+ ["Test that an Unicode prompt does not crash the shell"];
+unicode_prompt(Config) when is_list(Config) ->
+ ?line PA = filename:dirname(code:which(?MODULE)),
+ ?line rtnode([{putline,""},
+ {putline, "2."},
+ {getline, "2"},
+ {putline, "shell:prompt_func({io_proto_SUITE,uprompt})."},
+ {getline, "default"},
+ {putline, "io:get_line('')."},
+ {putline, "hej"},
+ {getline, "\"hej\\n\""},
+ {putline, "io:setopts([{binary,true}])."},
+ {getline, "ok"},
+ {putline, "io:get_line('')."},
+ {putline, "hej"},
+ {getline, "<<\"hej\\n\">>"}
+ ],[],[],"-pa "++ PA),
+ %% And one with oldshell
+ ?line rtnode([{putline,""},
+ {putline, "2."},
+ {getline_re, ".*2."},
+ {getline, "2"},
+ {putline, "shell:prompt_func({io_proto_SUITE,uprompt})."},
+ {getline_re, ".*default"},
+ {putline, "io:get_line('')."},
+ {putline, "hej"},
+ {getline_re, ".*\"hej\\\\n\""},
+ {putline, "io:setopts([{binary,true}])."},
+ {getline_re, ".*ok"},
+ {putline, "io:get_line('')."},
+ {putline, "hej"},
+ {getline_re, ".*<<\"hej\\\\n\">>"}
+ ],[],[],"-oldshell -pa "++PA),
+ ok.
+
+
setopts_getopts(suite) ->
[];
setopts_getopts(doc) ->
diff --git a/lib/stdlib/test/ms_transform_SUITE.erl b/lib/stdlib/test/ms_transform_SUITE.erl
index cf0926b7fa..79a0a9af89 100644
--- a/lib/stdlib/test/ms_transform_SUITE.erl
+++ b/lib/stdlib/test/ms_transform_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2003-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 2003-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(ms_transform_SUITE).
@@ -56,7 +56,7 @@ andalso_orelse(suite) ->
[];
andalso_orelse(doc) ->
["Tests that andalso and orelse are allowed in guards."];
-andalso_orelse(Config) when list(Config) ->
+andalso_orelse(Config) when is_list(Config) ->
?line setup(Config),
?line [{{'$1','$2'},
[{'and',{is_integer,'$1'},{'>',{'+','$1',5},'$2'}}],
@@ -93,7 +93,7 @@ bitsyntax(suite) ->
[];
bitsyntax(doc) ->
["Tests that bitsyntax works and does not work where appropriate"];
-bitsyntax(Config) when list(Config) ->
+bitsyntax(Config) when is_list(Config) ->
?line setup(Config),
?line [{'_',[],
[<<0,27,0,27>>]}] =
@@ -131,7 +131,7 @@ record_defaults(suite) ->
[];
record_defaults(doc) ->
["Tests that record defaults works"];
-record_defaults(Config) when list(Config) ->
+record_defaults(Config) when is_list(Config) ->
?line setup(Config),
?line [{{<<27>>,{a,5,'$1',hej,hej}},
[],
@@ -146,7 +146,7 @@ basic_ets(suite) ->
[];
basic_ets(doc) ->
["Tests basic ets:fun2ms"];
-basic_ets(Config) when list(Config) ->
+basic_ets(Config) when is_list(Config) ->
?line setup(Config),
?line [{{a,b},[],[true]}] = compile_and_run(
<<"ets:fun2ms(fun({a,b}) -> true end)">>),
@@ -167,7 +167,7 @@ basic_dbg(suite) ->
[];
basic_dbg(doc) ->
["Tests basic ets:fun2ms"];
-basic_dbg(Config) when list(Config) ->
+basic_dbg(Config) when is_list(Config) ->
?line setup(Config),
?line [{[a,b],[],[{message,banan},{return_trace}]}] =
compile_and_run(<<"dbg:fun2ms(fun([a,b]) -> message(banan), ",
@@ -186,7 +186,7 @@ from_shell(suite) ->
[];
from_shell(doc) ->
["Test calling of ets/dbg:fun2ms from the shell"];
-from_shell(Config) when list(Config) ->
+from_shell(Config) when is_list(Config) ->
?line setup(Config),
?line Fun = do_eval("fun({a,b}) -> true end"),
?line [{{a,b},[],[true]}] = apply(ets,fun2ms,[Fun]),
@@ -203,7 +203,7 @@ records(suite) ->
[];
records(doc) ->
["Tests expansion of records in fun2ms"];
-records(Config) when list(Config) ->
+records(Config) when is_list(Config) ->
?line setup(Config),
?line RD = <<"-record(t, {"
"t1 = [],"
@@ -253,7 +253,7 @@ record_index(suite) ->
[];
record_index(doc) ->
["Tests expansion of records in fun2ms, part 2"];
-record_index(Config) when list(Config) ->
+record_index(Config) when is_list(Config) ->
?line setup(Config),
?line RD = <<"-record(a,{a,b}).">>,
?line [{{2},[],[true]}] = compile_and_run(RD,
@@ -268,7 +268,7 @@ top_match(suite) ->
[];
top_match(doc) ->
["Tests matching on top level in head to give alias for object()"];
-top_match(Config) when list(Config) ->
+top_match(Config) when is_list(Config) ->
?line setup(Config),
?line RD = <<"-record(a,{a,b}).">>,
?line [{{a,3,'_'},[],['$_']}] =
@@ -295,7 +295,7 @@ multipass(suite) ->
[];
multipass(doc) ->
["Tests that multi-defined fields in records give errors."];
-multipass(Config) when list(Config) ->
+multipass(Config) when is_list(Config) ->
?line setup(Config),
?line RD = <<"-record(a,{a,b}).">>,
?line expect_failure(RD,<<"ets:fun2ms(fun(A) -> #a{a=2,a=3} end)">>),
@@ -319,7 +319,7 @@ old_guards(suite) ->
[];
old_guards(doc) ->
["Tests that old type tests in guards are translated"];
-old_guards(Config) when list(Config) ->
+old_guards(Config) when is_list(Config) ->
?line setup(Config),
Tests = [
{atom,is_atom},
@@ -382,7 +382,7 @@ autoimported(suite) ->
autoimported(doc) ->
["Tests use of autoimported bif's used like erlang:'+'(A,B) in guards"
" and body."];
-autoimported(Config) when list(Config) ->
+autoimported(Config) when is_list(Config) ->
?line setup(Config),
Allowed = [
{abs,1},
@@ -582,7 +582,7 @@ float_1_function(suite) ->
[];
float_1_function(doc) ->
["OTP-5297. The function float/1."];
-float_1_function(Config) when list(Config) ->
+float_1_function(Config) when is_list(Config) ->
?line setup(Config),
RunMS = fun(L, MS) ->
ets:match_spec_run(L, ets:match_spec_compile(MS))
diff --git a/lib/stdlib/test/queue_SUITE.erl b/lib/stdlib/test/queue_SUITE.erl
index ec3080baa0..2cd6b52311 100644
--- a/lib/stdlib/test/queue_SUITE.erl
+++ b/lib/stdlib/test/queue_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1999-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1999-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(queue_SUITE).
@@ -45,7 +45,7 @@ do(doc) ->
[""];
do(suite) ->
[];
-do(Config) when list(Config) ->
+do(Config) when is_list(Config) ->
?line L = [{in, 1},
{in, 2},
{out, {value, 1}},
@@ -66,7 +66,7 @@ to_list(doc) ->
["OTP-2701"];
to_list(suite) ->
[];
-to_list(Config) when list(Config) ->
+to_list(Config) when is_list(Config) ->
?line E = queue:new(),
?line Q = do_queue(E, [{in, 1},
{in, 2},
@@ -104,7 +104,7 @@ io_test(doc) ->
"Test input and output";
io_test(suite) ->
[];
-io_test(Config) when list(Config) ->
+io_test(Config) when is_list(Config) ->
E = queue:new(),
do_io_test(E),
ok.
@@ -284,7 +284,7 @@ op_test(doc) ->
"Test operations on whole queues";
op_test(suite) ->
[];
-op_test(Config) when list(Config) ->
+op_test(Config) when is_list(Config) ->
do_op_test(fun id/1),
ok.
@@ -382,7 +382,7 @@ error(doc) ->
"Test queue errors";
error(suite) ->
[];
-error(Config) when list(Config) ->
+error(Config) when is_list(Config) ->
do_error(fun id/1, illegal_queue),
do_error(fun id/1, {[],illegal_queue}),
do_error(fun id/1, {illegal_queue,[17]}),
@@ -449,7 +449,7 @@ oops(doc) ->
"Test queue errors";
oops(suite) ->
[];
-oops(Config) when list(Config) ->
+oops(Config) when is_list(Config) ->
?line N = 3142,
?line Optab = optab(),
?line Seed0 = random:seed0(),
diff --git a/lib/stdlib/test/re_SUITE.erl b/lib/stdlib/test/re_SUITE.erl
index fa50ba3b7a..02683f9f1a 100644
--- a/lib/stdlib/test/re_SUITE.erl
+++ b/lib/stdlib/test/re_SUITE.erl
@@ -18,12 +18,12 @@
%%
-module(re_SUITE).
--export([all/1, pcre/1,compile_options/1,run_options/1,combined_options/1,replace_autogen/1,global_capture/1,replace_input_types/1,replace_return/1,split_autogen/1,split_options/1,split_specials/1,error_handling/1]).
+-export([all/1, pcre/1,compile_options/1,run_options/1,combined_options/1,replace_autogen/1,global_capture/1,replace_input_types/1,replace_return/1,split_autogen/1,split_options/1,split_specials/1,error_handling/1,pcre_cve_2008_2371/1]).
-include("test_server.hrl").
-include_lib("kernel/include/file.hrl").
-all(suite) -> [pcre,compile_options,run_options,combined_options,replace_autogen,global_capture,replace_input_types,replace_return,split_autogen,split_options,split_specials,error_handling].
+all(suite) -> [pcre,compile_options,run_options,combined_options,replace_autogen,global_capture,replace_input_types,replace_return,split_autogen,split_options,split_specials,error_handling,pcre_cve_2008_2371].
pcre(doc) ->
["Run all applicable tests from the PCRE testsuites."];
@@ -538,3 +538,9 @@ error_handling(Config) when is_list(Config) ->
?t:timetrap_cancel(Dog),
ok.
+pcre_cve_2008_2371(doc) ->
+ "Fix as in http://vcs.pcre.org/viewvc?revision=360&view=revision";
+pcre_cve_2008_2371(Config) when is_list(Config) ->
+ %% Make sure it doesn't crash the emulator.
+ re:compile(<<"(?i)[\xc3\xa9\xc3\xbd]|[\xc3\xa9\xc3\xbdA]">>, [unicode]),
+ ok.
diff --git a/lib/stdlib/test/re_testoutput1_replacement_test.erl b/lib/stdlib/test/re_testoutput1_replacement_test.erl
index b20db3f9c3..69cb140e0d 100644
--- a/lib/stdlib/test/re_testoutput1_replacement_test.erl
+++ b/lib/stdlib/test/re_testoutput1_replacement_test.erl
@@ -1,23 +1,24 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2008-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 2008-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(re_testoutput1_replacement_test).
-compile(export_all).
+-compile(no_native).
-include("test_server.hrl").
%% This file is generated by running run_pcre_tests:gen_repl_test("re_SUITE_data/testoutput1")
run() ->
diff --git a/lib/stdlib/test/re_testoutput1_split_test.erl b/lib/stdlib/test/re_testoutput1_split_test.erl
index 7e2d3f79ec..e86a04b008 100644
--- a/lib/stdlib/test/re_testoutput1_split_test.erl
+++ b/lib/stdlib/test/re_testoutput1_split_test.erl
@@ -1,23 +1,24 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2008-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 2008-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(re_testoutput1_split_test).
-compile(export_all).
+-compile(no_native).
-include("test_server.hrl").
%% This file is generated by running run_pcre_tests:gen_split_test("re_SUITE_data/testoutput1")
join([]) -> [];
diff --git a/lib/stdlib/test/run_pcre_tests.erl b/lib/stdlib/test/run_pcre_tests.erl
index 8c6424e708..78b4803fc8 100644
--- a/lib/stdlib/test/run_pcre_tests.erl
+++ b/lib/stdlib/test/run_pcre_tests.erl
@@ -987,6 +987,7 @@ gen_split_test(OneFile) ->
{ok,F}= file:open(ErlFileName,[write]),
io:format(F,"-module(~s).~n",[ErlModule]),
io:format(F,"-compile(export_all).~n",[]),
+ io:format(F,"-compile(no_native).~n",[]),
io:format(F,"-include(\"test_server.hrl\").~n",[]),
%io:format(F,"-define(line,erlang:display(?LINE),).~n",[]),
io:format(F,"%% This file is generated by running ~w:gen_split_test(~p)~n",
@@ -1068,6 +1069,7 @@ gen_repl_test(OneFile) ->
{ok,F}= file:open(ErlFileName,[write]),
io:format(F,"-module(~s).~n",[ErlModule]),
io:format(F,"-compile(export_all).~n",[]),
+ io:format(F,"-compile(no_native).~n",[]),
io:format(F,"-include(\"test_server.hrl\").~n",[]),
io:format(F,"%% This file is generated by running ~w:gen_repl_test(~p)~n",
[?MODULE,OneFile]),
diff --git a/lib/stdlib/test/select_SUITE.erl b/lib/stdlib/test/select_SUITE.erl
index 54664fbb00..6900f1a8f5 100644
--- a/lib/stdlib/test/select_SUITE.erl
+++ b/lib/stdlib/test/select_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2000-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 2000-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
@@ -79,14 +79,14 @@ select_test(suite) ->
[];
select_test(doc) ->
["Tests select in numerous ways"];
-select_test(Config) when list(Config) ->
+select_test(Config) when is_list(Config) ->
do_test(Config).
return_values(suite) ->
[];
return_values(doc) ->
["Tests return values in specific situations for select/3 and select/1"];
-return_values(Config) when list(Config) ->
+return_values(Config) when is_list(Config) ->
do_return_values().
-endif.
@@ -279,7 +279,7 @@ cmp_ms_to_fun({Mod,Tab}, MS, Fun1, Fun2, ChunkSize) ->
MSRes = lists:sort(chunked_select(Mod,Tab,MS,ChunkSize)),
FunRes0 = table_foldl(Fun1,[],{Mod,Tab}),
FunRes = case Fun2 of
- F when function(F) ->
+ F when is_function(F) ->
FunRes1 = table_foldl(F,[],{Mod,Tab}),
lists:merge(FunRes0,FunRes1);
[] ->
diff --git a/lib/stdlib/test/shell_SUITE.erl b/lib/stdlib/test/shell_SUITE.erl
index 5827d5f332..588342d46a 100644
--- a/lib/stdlib/test/shell_SUITE.erl
+++ b/lib/stdlib/test/shell_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2004-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 2004-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(shell_SUITE).
@@ -28,13 +28,14 @@
progex/1, progex_bit_syntax/1, progex_records/1,
progex_lc/1, progex_funs/1,
tickets/1, otp_5990/1, otp_6166/1, otp_6554/1, otp_6785/1,
- otp_7184/1, otp_7232/1]).
+ otp_7184/1, otp_7232/1, otp_8393/1]).
-export([restricted/1, start_restricted_from_shell/1,
start_restricted_on_command_line/1,restricted_local/1]).
%% Internal export.
--export([otp_5435_2/0]).
+-export([otp_5435_2/0, prompt1/1, prompt2/1, prompt3/1, prompt4/1,
+ prompt5/1]).
%%
%% Define to run outside of test server
@@ -2256,7 +2257,7 @@ progex_funs(Config) when is_list(Config) ->
ok.
tickets(suite) ->
- [otp_5990, otp_6166, otp_6554, otp_6785, otp_7184, otp_7232].
+ [otp_5990, otp_6166, otp_6554, otp_6785, otp_7184, otp_7232, otp_8393].
otp_5990(doc) ->
"OTP-5990. {erlang,is_record}.";
@@ -2598,6 +2599,93 @@ otp_7232(Config) when is_list(Config) ->
" end}])" = evaluate(Info, []),
ok.
+otp_8393(doc) ->
+ "OTP-8393. Prompt string.";
+otp_8393(suite) -> [];
+otp_8393(Config) when is_list(Config) ->
+ ?line _ = shell:prompt_func(default),
+ ?line "Bad prompt function: '> '" =
+ prompt_err(<<"shell:prompt_func('> ').">>),
+
+ ?line _ = shell:prompt_func(default),
+ ?line "exception error: bad argument in an arithmetic expression"++_ =
+ prompt_err(<<"shell:prompt_func({shell_SUITE,prompt4}).">>),
+
+ ?line _ = shell:prompt_func(default),
+ ?line "default.\n" =
+ t(<<"shell:prompt_func({shell_SUITE,prompt2}).">>),
+
+ ?line _ = shell:prompt_func(default),
+ ?line "default\nl.\n" =
+ t(<<"shell:prompt_func({shell_SUITE,prompt3}). l.">>),
+
+ %%
+ %% Although this tests that you can set a unicode prompt function
+ %% it does not really test that it does work with the io-servers.
+ %% That is instead tested in the io_proto_SUITE, which has
+ %% the right infrastructure in place for such tests. /PaN
+ %%
+ ?line _ = shell:prompt_func(default),
+ ?line "default\nl.\n" =
+ t(<<"shell:prompt_func({shell_SUITE,prompt5}). l.">>),
+
+ %% Restricted shell.
+ Contents = <<"-module(test_restricted_shell).
+ -export([local_allowed/3, non_local_allowed/3]).
+ local_allowed(_,_,State) ->
+ {false,State}.
+
+ non_local_allowed({shell,stop_restricted},[],State) ->
+ {true,State};
+ non_local_allowed({shell,prompt_func},[_L],State) ->
+ {true,State};
+ non_local_allowed({shell_SUITE,prompt1},[_L],State) ->
+ {true,State};
+ non_local_allowed(_,_,State) ->
+ {false,State}.
+ ">>,
+ ?line Test = filename:join(?config(priv_dir, Config),
+ "test_restricted_shell.erl"),
+ ?line ok = compile_file(Config, Test, Contents, []),
+ ?line _ = shell:prompt_func(default),
+ ?line "exception exit: restricted shell starts now" =
+ comm_err(<<"begin shell:start_restricted("
+ "test_restricted_shell) end.">>),
+ ?line "default.\n"++_ =
+ t(<<"shell:prompt_func({shell_SUITE,prompt1}).">>),
+ ?line "exception exit: restricted shell does not allow apple(" ++ _ =
+ comm_err(<<"apple(1).">>),
+ ?line "{shell_SUITE,prompt1}.\n" =
+ t(<<"shell:prompt_func(default).">>),
+ ?line "exception exit: restricted shell stopped"=
+ comm_err(<<"begin shell:stop_restricted() end.">>),
+ ?line undefined =
+ application:get_env(stdlib, restricted_shell),
+
+ ?line NR = shell:results(20),
+ ?line "default\n20.\n" =
+ t(<<"shell:prompt_func({shell_SUITE,prompt3}). results(0).">>),
+
+ ?line _ = shell:prompt_func(default),
+ ?line 0 = shell:results(NR),
+ ok.
+
+prompt1(_L) ->
+ "prompt> ".
+
+prompt2(_L) ->
+ {'EXIT', []}.
+
+prompt3(L) ->
+ N = proplists:get_value(history, L),
+ integer_to_list(N).
+
+prompt4(_L) ->
+ erlang:apply({erlang,'/'}, [1,0]).
+
+prompt5(_L) ->
+ [1050,1072,1082,1074,1086,32,1077,32,85,110,105,99,111,100,101,32,63].
+
-ifdef(not_used).
exit_term(B) ->
"** exception exit:" ++ Reply = t(B),
@@ -2627,7 +2715,16 @@ comm_err(B) ->
Reply = t(B),
S0 = string:left(Reply, string:chr(Reply, $\n)-1),
S1 = string:strip(S0, left, $*),
- S2 = string:strip(S1, both, $ ),
+ S2 = string:strip(S1, both, $ ),
+ S = string:strip(S2, both, $"),
+ string:strip(S, right, $.).
+
+prompt_err(B) ->
+ Reply = t(B),
+ S00 = string:sub_string(Reply, string:chr(Reply, $\n)+1),
+ S0 = string:left(S00, string:chr(S00, $\n)-1),
+ S1 = string:strip(S0, left, $*),
+ S2 = string:strip(S1, both, $ ),
S = string:strip(S2, both, $"),
string:strip(S, right, $.).
diff --git a/lib/stdlib/test/slave_SUITE.erl b/lib/stdlib/test/slave_SUITE.erl
index 3b737af64d..5c1282fe9b 100644
--- a/lib/stdlib/test/slave_SUITE.erl
+++ b/lib/stdlib/test/slave_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1997-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(slave_SUITE).
@@ -31,7 +31,7 @@ all(suite) ->
[t_start_link, start_link_nodedown, t_start, errors].
t_start_link(suite) -> [];
-t_start_link(Config) when list(Config) ->
+t_start_link(Config) when is_list(Config) ->
?line Dog = test_server:timetrap(test_server:seconds(20)),
%% Define useful variables.
@@ -81,7 +81,7 @@ t_start_link(Config) when list(Config) ->
%% Test that slave:start_link() works when the master exits.
start_link_nodedown(suite) -> [];
-start_link_nodedown(Config) when list(Config) ->
+start_link_nodedown(Config) when is_list(Config) ->
?line Dog = test_server:timetrap(test_server:seconds(20)),
%% Define useful variables.
@@ -109,7 +109,7 @@ start_a_slave(ReplyTo, Host, Name) ->
%% Test slave:start().
t_start(suite) -> [];
-t_start(Config) when list(Config) ->
+t_start(Config) when is_list(Config) ->
?line Dog = test_server:timetrap(test_server:seconds(20)),
%% Define useful variables.
@@ -160,7 +160,7 @@ t_start(Config) when list(Config) ->
%% in slave is 32 seconds).
errors(suite) -> [];
-errors(Config) when list(Config) ->
+errors(Config) when is_list(Config) ->
?line Dog = test_server:timetrap(test_server:seconds(50)),
?line process_flag(trap_exit, true),
diff --git a/lib/stdlib/test/sofs_SUITE.erl b/lib/stdlib/test/sofs_SUITE.erl
index 0849e0f59c..d60cfc6895 100644
--- a/lib/stdlib/test/sofs_SUITE.erl
+++ b/lib/stdlib/test/sofs_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2001-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 2001-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(sofs_SUITE).
@@ -115,7 +115,7 @@ sofs(suite) ->
from_term_1(suite) -> [];
from_term_1(doc) -> [""];
-from_term_1(Conf) when list(Conf) ->
+from_term_1(Conf) when is_list(Conf) ->
%% would go wrong: projection(1,from_term([{2,b},{1,a,b}])),
?line {'EXIT', {badarg, _}} = (catch from_term([], {atom,'_',atom})),
@@ -203,7 +203,7 @@ from_term_1(Conf) when list(Conf) ->
set_1(suite) -> [];
set_1(doc) -> [""];
-set_1(Conf) when list(Conf) ->
+set_1(Conf) when is_list(Conf) ->
%% set/1
?line {'EXIT', {badarg, _}} = (catch set(a)),
?line {'EXIT', {badarg, _}} = (catch set({a})),
@@ -235,7 +235,7 @@ set_1(Conf) when list(Conf) ->
from_sets_1(suite) -> [];
from_sets_1(doc) -> [""];
-from_sets_1(Conf) when list(Conf) ->
+from_sets_1(Conf) when is_list(Conf) ->
?line E = empty_set(),
%% unordered
@@ -272,7 +272,7 @@ from_sets_1(Conf) when list(Conf) ->
relation_1(suite) -> [];
relation_1(doc) -> [""];
-relation_1(Conf) when list(Conf) ->
+relation_1(Conf) when is_list(Conf) ->
%% relation/1
?line eval(relation([]), from_term([], [{atom,atom}])),
?line eval(from_term([{a}]), relation([{a}])),
@@ -305,7 +305,7 @@ relation_1(Conf) when list(Conf) ->
a_function_1(suite) -> [];
a_function_1(doc) -> [""];
-a_function_1(Conf) when list(Conf) ->
+a_function_1(Conf) when is_list(Conf) ->
%% a_function/1
?line eval(a_function([]), from_term([], [{atom,atom}])),
?line eval(a_function([{a,b},{a,b},{b,c}]), from_term([{a,b},{b,c}])),
@@ -352,7 +352,7 @@ a_function_1(Conf) when list(Conf) ->
family_1(suite) -> [];
family_1(doc) -> [""];
-family_1(Conf) when list(Conf) ->
+family_1(Conf) when is_list(Conf) ->
%% family/1
?line eval(family([]), from_term([],[{atom,[atom]}])),
?line {'EXIT', {badarg, _}} = (catch family(a)),
@@ -413,7 +413,7 @@ family_1(Conf) when list(Conf) ->
projection(suite) -> [];
projection(doc) -> [""];
-projection(Conf) when list(Conf) ->
+projection(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line ER = relation([]),
@@ -535,7 +535,7 @@ projection(Conf) when list(Conf) ->
substitution(suite) -> [];
substitution(doc) -> [""];
-substitution(Conf) when list(Conf) ->
+substitution(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line ER = relation([]),
@@ -633,7 +633,7 @@ substitution(Conf) when list(Conf) ->
restriction(suite) -> [];
restriction(doc) -> [""];
-restriction(Conf) when list(Conf) ->
+restriction(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line ER = relation([], 2),
@@ -752,7 +752,7 @@ restriction(Conf) when list(Conf) ->
drestriction(suite) -> [];
drestriction(doc) -> [""];
-drestriction(Conf) when list(Conf) ->
+drestriction(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line ER = relation([], 2),
@@ -869,7 +869,7 @@ drestriction(Conf) when list(Conf) ->
strict_relation_1(suite) -> [];
strict_relation_1(doc) -> [""];
-strict_relation_1(Conf) when list(Conf) ->
+strict_relation_1(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line ER = relation([], 2),
?line eval(strict_relation(E), E),
@@ -890,7 +890,7 @@ strict_relation_1(Conf) when list(Conf) ->
extension(suite) -> [];
extension(doc) -> [""];
-extension(Conf) when list(Conf) ->
+extension(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line ER = relation([], 2),
?line EF = family([]),
@@ -933,7 +933,7 @@ lextension(R, S, C) ->
weak_relation_1(suite) -> [];
weak_relation_1(doc) -> [""];
-weak_relation_1(Conf) when list(Conf) ->
+weak_relation_1(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line ER = relation([], 2),
?line eval(weak_relation(E), E),
@@ -966,7 +966,7 @@ weak_relation_1(Conf) when list(Conf) ->
to_sets_1(suite) -> [];
to_sets_1(doc) -> [""];
-to_sets_1(Conf) when list(Conf) ->
+to_sets_1(Conf) when is_list(Conf) ->
?line {'EXIT', {badarg, _}} = (catch to_sets(from_term(a))),
?line {'EXIT', {function_clause, _}} = (catch to_sets(a)),
%% unordered
@@ -988,8 +988,8 @@ to_sets_1(Conf) when list(Conf) ->
specification(suite) -> [];
specification(doc) -> [""];
-specification(Conf) when list(Conf) ->
- Fun = {external, fun(I) when integer(I) -> true; (_) -> false end},
+specification(Conf) when is_list(Conf) ->
+ Fun = {external, fun(I) when is_integer(I) -> true; (_) -> false end},
?line [1,2,3] = to_external(specification(Fun, set([a,1,b,2,c,3]))),
Fun2 = fun(S) -> is_subset(S, set([1,3,5,7,9])) end,
@@ -1014,7 +1014,7 @@ specification(Conf) when list(Conf) ->
union_1(suite) -> [];
union_1(doc) -> [""];
-union_1(Conf) when list(Conf) ->
+union_1(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line ER = relation([], 2),
?line {'EXIT', {badarg, _}} = (catch union(ER)),
@@ -1044,7 +1044,7 @@ union_1(Conf) when list(Conf) ->
intersection_1(suite) -> [];
intersection_1(doc) -> [""];
-intersection_1(Conf) when list(Conf) ->
+intersection_1(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line {'EXIT', {badarg, _}} = (catch intersection(from_term([a,b]))),
?line {'EXIT', {badarg, _}} = (catch intersection(E)),
@@ -1068,7 +1068,7 @@ intersection_1(Conf) when list(Conf) ->
difference(suite) -> [];
difference(doc) -> [""];
-difference(Conf) when list(Conf) ->
+difference(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line {'EXIT', {type_mismatch, _}} =
(catch difference(relation([{a,b}]), relation([{a,b,c}]))),
@@ -1089,7 +1089,7 @@ difference(Conf) when list(Conf) ->
symdiff(suite) -> [];
symdiff(doc) -> [""];
-symdiff(Conf) when list(Conf) ->
+symdiff(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line {'EXIT', {type_mismatch, _}} =
(catch symdiff(relation([{a,b}]), relation([{a,b,c}]))),
@@ -1114,7 +1114,7 @@ symdiff(Conf) when list(Conf) ->
symmetric_partition(suite) -> [];
symmetric_partition(doc) -> [""];
-symmetric_partition(Conf) when list(Conf) ->
+symmetric_partition(Conf) when is_list(Conf) ->
?line E = set([]),
?line S1 = set([1,2,3,4]),
?line S2 = set([3,4,5,6]),
@@ -1148,7 +1148,7 @@ symmetric_partition(Conf) when list(Conf) ->
is_sofs_set_1(suite) -> [];
is_sofs_set_1(doc) -> [""];
-is_sofs_set_1(Conf) when list(Conf) ->
+is_sofs_set_1(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line true = is_sofs_set(E),
?line true = is_sofs_set(from_term([a])),
@@ -1159,7 +1159,7 @@ is_sofs_set_1(Conf) when list(Conf) ->
is_set_1(suite) -> [];
is_set_1(doc) -> [""];
-is_set_1(Conf) when list(Conf) ->
+is_set_1(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line true = is_set(E),
?line true = is_set(from_term([a])),
@@ -1177,7 +1177,7 @@ is_set_1(Conf) when list(Conf) ->
is_equal(suite) -> [];
is_equal(doc) -> [""];
-is_equal(Conf) when list(Conf) ->
+is_equal(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line true = is_equal(E, E),
?line false = is_equal(from_term([a]), E),
@@ -1212,7 +1212,7 @@ is_equal(Conf) when list(Conf) ->
is_subset(suite) -> [];
is_subset(doc) -> [""];
-is_subset(Conf) when list(Conf) ->
+is_subset(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line true = is_subset(E, E),
?line true = is_subset(set([a,c,e]), set([a,b,c,d,e])),
@@ -1230,7 +1230,7 @@ is_subset(Conf) when list(Conf) ->
is_a_function_1(suite) -> [];
is_a_function_1(doc) -> [""];
-is_a_function_1(Conf) when list(Conf) ->
+is_a_function_1(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line ER = relation([], 2),
?line {'EXIT', {badarg, _}} = (catch is_a_function(set([a,b]))),
@@ -1254,7 +1254,7 @@ is_a_function_1(Conf) when list(Conf) ->
is_disjoint(suite) -> [];
is_disjoint(doc) -> [""];
-is_disjoint(Conf) when list(Conf) ->
+is_disjoint(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line {'EXIT', {type_mismatch, _}} =
(catch is_disjoint(relation([{a,1}]), set([a,b]))),
@@ -1268,7 +1268,7 @@ is_disjoint(Conf) when list(Conf) ->
join(suite) -> [];
join(doc) -> [""];
-join(Conf) when list(Conf) ->
+join(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line {'EXIT', {badarg, _}} = (catch join(relation([{a,1}]), 3, E, 5)),
@@ -1306,7 +1306,7 @@ join(Conf) when list(Conf) ->
canonical(suite) -> [];
canonical(doc) -> [""];
-canonical(Conf) when list(Conf) ->
+canonical(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line {'EXIT', {badarg, _}} =
(catch canonical_relation(set([a,b]))),
@@ -1318,7 +1318,7 @@ canonical(Conf) when list(Conf) ->
relation_to_family_1(suite) -> [];
relation_to_family_1(doc) -> [""];
-relation_to_family_1(Conf) when list(Conf) ->
+relation_to_family_1(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line EF = family([]),
?line eval(relation_to_family(E), E),
@@ -1333,7 +1333,7 @@ relation_to_family_1(Conf) when list(Conf) ->
domain_1(suite) -> [];
domain_1(doc) -> [""];
-domain_1(Conf) when list(Conf) ->
+domain_1(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line ER = relation([]),
?line {'EXIT', {badarg, _}} = (catch domain(relation([],3))),
@@ -1355,7 +1355,7 @@ domain_1(Conf) when list(Conf) ->
range_1(suite) -> [];
range_1(doc) -> [""];
-range_1(Conf) when list(Conf) ->
+range_1(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line ER = relation([]),
?line {'EXIT', {badarg, _}} = (catch range(relation([],3))),
@@ -1367,7 +1367,7 @@ range_1(Conf) when list(Conf) ->
inverse_1(suite) -> [];
inverse_1(doc) -> [""];
-inverse_1(Conf) when list(Conf) ->
+inverse_1(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line ER = relation([]),
?line {'EXIT', {badarg, _}} = (catch inverse(relation([],3))),
@@ -1391,7 +1391,7 @@ inverse_1(Conf) when list(Conf) ->
converse_1(suite) -> [];
converse_1(doc) -> [""];
-converse_1(Conf) when list(Conf) ->
+converse_1(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line ER = relation([]),
?line {'EXIT', {badarg, _}} = (catch converse(relation([],3))),
@@ -1407,7 +1407,7 @@ converse_1(Conf) when list(Conf) ->
no_elements_1(suite) -> [];
no_elements_1(doc) -> [""];
-no_elements_1(Conf) when list(Conf) ->
+no_elements_1(Conf) when is_list(Conf) ->
?line 0 = no_elements(empty_set()),
?line 0 = no_elements(set([])),
?line 1 = no_elements(from_term([a])),
@@ -1419,7 +1419,7 @@ no_elements_1(Conf) when list(Conf) ->
image(suite) -> [];
image(doc) -> [""];
-image(Conf) when list(Conf) ->
+image(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line ER = relation([]),
?line eval(image(E, E), E),
@@ -1441,7 +1441,7 @@ image(Conf) when list(Conf) ->
inverse_image(suite) -> [];
inverse_image(doc) -> [""];
-inverse_image(Conf) when list(Conf) ->
+inverse_image(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line ER = relation([]),
?line eval(inverse_image(E, E), E),
@@ -1468,7 +1468,7 @@ inverse_image(Conf) when list(Conf) ->
composite_1(suite) -> [];
composite_1(doc) -> [""];
-composite_1(Conf) when list(Conf) ->
+composite_1(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line EF = a_function([]),
?line eval(composite(E, E), E),
@@ -1520,7 +1520,7 @@ composite_1(Conf) when list(Conf) ->
relative_product_1(suite) -> [];
relative_product_1(doc) -> [""];
-relative_product_1(Conf) when list(Conf) ->
+relative_product_1(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line ER = relation([]),
?line eval(relative_product1(E, E), E),
@@ -1548,7 +1548,7 @@ relative_product_1(Conf) when list(Conf) ->
relative_product_2(suite) -> [];
relative_product_2(doc) -> [""];
-relative_product_2(Conf) when list(Conf) ->
+relative_product_2(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line ER = relation([]),
@@ -1597,7 +1597,7 @@ relative_product_2(Conf) when list(Conf) ->
product_1(suite) -> [];
product_1(doc) -> [""];
-product_1(Conf) when list(Conf) ->
+product_1(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line eval(product(E, E), E),
?line eval(product(relation([]), E), E),
@@ -1625,7 +1625,7 @@ product_1(Conf) when list(Conf) ->
partition_1(suite) -> [];
partition_1(doc) -> [""];
-partition_1(Conf) when list(Conf) ->
+partition_1(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line ER = relation([]),
?line Id = fun(A) -> A end,
@@ -1671,7 +1671,7 @@ partition_1(Conf) when list(Conf) ->
partition_3(suite) -> [];
partition_3(doc) -> [""];
-partition_3(Conf) when list(Conf) ->
+partition_3(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line ER = relation([]),
@@ -1818,7 +1818,7 @@ lpartition(F, S1, S2) ->
multiple_relative_product(suite) -> [];
multiple_relative_product(doc) -> [""];
-multiple_relative_product(Conf) when list(Conf) ->
+multiple_relative_product(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line ER = relation([]),
?line T = relation([{a,1},{a,11},{b,2},{c,3},{c,33},{d,4}]),
@@ -1842,7 +1842,7 @@ multiple_relative_product(Conf) when list(Conf) ->
digraph(suite) -> [];
digraph(doc) -> [""];
-digraph(Conf) when list(Conf) ->
+digraph(Conf) when is_list(Conf) ->
?line T0 = ets:all(),
?line E = empty_set(),
?line R = relation([{a,b},{b,c},{c,d},{d,a}]),
@@ -1901,7 +1901,7 @@ digraph(Conf) when list(Conf) ->
constant_function(suite) -> [];
constant_function(doc) -> [""];
-constant_function(Conf) when list(Conf) ->
+constant_function(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line C = from_term(3),
?line eval(constant_function(E, C), E),
@@ -1913,7 +1913,7 @@ constant_function(Conf) when list(Conf) ->
misc(suite) -> [];
misc(doc) -> [""];
-misc(Conf) when list(Conf) ->
+misc(Conf) when is_list(Conf) ->
% find "relational" part of relation:
?line S = relation([{a,b},{b,c},{b,d},{c,d}]),
Id = fun(A) -> A end,
@@ -1943,7 +1943,7 @@ sofs_family(suite) ->
family_specification(suite) -> [];
family_specification(doc) -> [""];
-family_specification(Conf) when list(Conf) ->
+family_specification(Conf) when is_list(Conf) ->
E = empty_set(),
%% internal
?line eval(family_specification({sofs, is_set}, E), E),
@@ -1963,7 +1963,7 @@ family_specification(Conf) when list(Conf) ->
(catch family_specification(Fun3, F3)),
%% external
- IsList = {external, fun(L) when list(L) -> true; (_) -> false end},
+ IsList = {external, fun(L) when is_list(L) -> true; (_) -> false end},
?line eval(family_specification(IsList, E), E),
?line eval(family_specification(IsList, F1), F1),
MF = {external, fun(L) -> lists:member(3, L) end},
@@ -1975,7 +1975,7 @@ family_specification(Conf) when list(Conf) ->
family_domain_1(suite) -> [];
family_domain_1(doc) -> [""];
-family_domain_1(Conf) when list(Conf) ->
+family_domain_1(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line ER = from_term([{a,[]},{b,[]}],[{atom,[{atom,atom}]}]),
?line EF = from_term([{a,[]},{b,[]}],[{atom,[atom]}]),
@@ -2001,7 +2001,7 @@ family_domain_1(Conf) when list(Conf) ->
family_range_1(suite) -> [];
family_range_1(doc) -> [""];
-family_range_1(Conf) when list(Conf) ->
+family_range_1(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line ER = from_term([{a,[]},{b,[]}],[{atom,[{atom,atom}]}]),
?line EF = from_term([{a,[]},{b,[]}],[{atom,[atom]}]),
@@ -2023,7 +2023,7 @@ family_range_1(Conf) when list(Conf) ->
family_to_relation_1(suite) -> [];
family_to_relation_1(doc) -> [""];
-family_to_relation_1(Conf) when list(Conf) ->
+family_to_relation_1(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line ER = relation([]),
?line EF = family([]),
@@ -2037,7 +2037,7 @@ family_to_relation_1(Conf) when list(Conf) ->
union_of_family_1(suite) -> [];
union_of_family_1(doc) -> [""];
-union_of_family_1(Conf) when list(Conf) ->
+union_of_family_1(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line EF = from_term([{a,[]},{b,[]}],[{atom,[atom]}]),
?line eval(union_of_family(E), E),
@@ -2052,7 +2052,7 @@ union_of_family_1(Conf) when list(Conf) ->
intersection_of_family_1(suite) -> [];
intersection_of_family_1(doc) -> [""];
-intersection_of_family_1(Conf) when list(Conf) ->
+intersection_of_family_1(Conf) when is_list(Conf) ->
?line EF = from_term([{a,[]},{b,[]}],[{atom,[atom]}]),
?line eval(intersection_of_family(EF), set([])),
?line FR = from_term([{a,[1,2,3]},{b,[2,3]},{c,[3,4,5]}]),
@@ -2066,7 +2066,7 @@ intersection_of_family_1(Conf) when list(Conf) ->
family_projection(suite) -> [];
family_projection(doc) -> [""];
-family_projection(Conf) when list(Conf) ->
+family_projection(Conf) when is_list(Conf) ->
SSType = [{atom,[[atom]]}],
SRType = [{atom,[{atom,atom}]}],
?line E = empty_set(),
@@ -2127,7 +2127,7 @@ family_projection(Conf) when list(Conf) ->
family_difference(suite) -> [];
family_difference(doc) -> [""];
-family_difference(Conf) when list(Conf) ->
+family_difference(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line EF = family([]),
?line F9 = from_term([{b,[b,c]}]),
@@ -2164,7 +2164,7 @@ family_difference(Conf) when list(Conf) ->
family_intersection_1(suite) -> [];
family_intersection_1(doc) -> [""];
-family_intersection_1(Conf) when list(Conf) ->
+family_intersection_1(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line EF = family([]),
?line ES = from_term([], [{atom,[[atom]]}]),
@@ -2184,7 +2184,7 @@ family_intersection_1(Conf) when list(Conf) ->
family_intersection_2(suite) -> [];
family_intersection_2(doc) -> [""];
-family_intersection_2(Conf) when list(Conf) ->
+family_intersection_2(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line EF = family([]),
?line F1 = from_term([{a,[1,2]},{b,[4,5]},{c,[7,8]},{d,[10,11]}]),
@@ -2215,7 +2215,7 @@ family_intersection_2(Conf) when list(Conf) ->
family_union_1(suite) -> [];
family_union_1(doc) -> [""];
-family_union_1(Conf) when list(Conf) ->
+family_union_1(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line EF = family([]),
?line ES = from_term([], [{atom,[[atom]]}]),
@@ -2230,7 +2230,7 @@ family_union_1(Conf) when list(Conf) ->
family_union_2(suite) -> [];
family_union_2(doc) -> [""];
-family_union_2(Conf) when list(Conf) ->
+family_union_2(Conf) when is_list(Conf) ->
?line E = empty_set(),
?line EF = family([]),
?line F1 = from_term([{a,[1,2]},{b,[4,5]},{c,[7,8]},{d,[10,11]}]),
@@ -2259,7 +2259,7 @@ family_union_2(Conf) when list(Conf) ->
partition_family(suite) -> [];
partition_family(doc) -> [""];
-partition_family(Conf) when list(Conf) ->
+partition_family(Conf) when is_list(Conf) ->
?line E = empty_set(),
%% set of ordered sets
diff --git a/lib/stdlib/test/supervisor_SUITE.erl b/lib/stdlib/test/supervisor_SUITE.erl
index b5d9ca44bf..039ea298c4 100644
--- a/lib/stdlib/test/supervisor_SUITE.erl
+++ b/lib/stdlib/test/supervisor_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1996-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1996-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
%% Description: Tests supervisor.erl
@@ -50,7 +50,7 @@
simple_one_for_one_extra/1]).
%% Misc tests
--export([child_unlink/1, tree/1]).
+-export([child_unlink/1, tree/1, count_children_memory/1]).
%-------------------------------------------------------------------------
@@ -60,7 +60,8 @@ all(suite) ->
child_adm_simple, extra_return, child_specs,
restart_one_for_one, restart_one_for_all,
restart_simple_one_for_one, restart_rest_for_one,
- normal_termination, abnormal_termination, child_unlink, tree]}.
+ normal_termination, abnormal_termination, child_unlink, tree,
+ count_children_memory]}.
start(InitResult) ->
@@ -72,6 +73,15 @@ init(fail) ->
init(InitResult) ->
InitResult.
+%% Respect proplist return of supervisor:count_children
+get_child_counts(Supervisor) ->
+ Counts = supervisor:count_children(Supervisor),
+ [proplists:get_value(specs, Counts),
+ proplists:get_value(active, Counts),
+ proplists:get_value(supervisors, Counts),
+ proplists:get_value(workers, Counts)].
+
+
%-------------------------------------------------------------------------
%
% Test cases starts here.
@@ -89,7 +99,7 @@ sup_start_normal(doc) ->
["Tests that the supervisor process starts correctly and that it "
"can be terminated gracefully."];
sup_start_normal(suite) -> [];
-sup_start_normal(Config) when list(Config) ->
+sup_start_normal(Config) when is_list(Config) ->
process_flag(trap_exit, true),
?line {ok, Pid} = start({ok, {{one_for_one, 2, 3600}, []}}),
?line exit(Pid, shutdown),
@@ -107,7 +117,7 @@ sup_start_normal(Config) when list(Config) ->
sup_start_ignore_init(doc) ->
["Tests what happens if init-callback returns ignore"];
sup_start_ignore_init(suite) -> [];
-sup_start_ignore_init(Config) when list(Config) ->
+sup_start_ignore_init(Config) when is_list(Config) ->
process_flag(trap_exit, true),
?line ignore = start(ignore),
@@ -127,7 +137,7 @@ sup_start_ignore_init(Config) when list(Config) ->
sup_start_ignore_child(doc) ->
["Tests what happens if init-callback returns ignore"];
sup_start_ignore_child(suite) -> [];
-sup_start_ignore_child(Config) when list(Config) ->
+sup_start_ignore_child(Config) when is_list(Config) ->
process_flag(trap_exit, true),
?line {ok, _Pid} = start({ok, {{one_for_one, 2, 3600}, []}}),
Child1 = {child1, {supervisor_1, start_child, [ignore]},
@@ -140,13 +150,15 @@ sup_start_ignore_child(Config) when list(Config) ->
?line [{child2, CPid2, worker, []},{child1, undefined, worker, []}]
= supervisor:which_children(sup_test),
+ ?line [2,1,0,2] = get_child_counts(sup_test),
+
ok.
%-------------------------------------------------------------------------
sup_start_error_return(doc) ->
["Tests what happens if init-callback returns a invalid value"];
sup_start_error_return(suite) -> [];
-sup_start_error_return(Config) when list(Config) ->
+sup_start_error_return(Config) when is_list(Config) ->
process_flag(trap_exit, true),
?line {error, Term} = start(invalid),
@@ -165,7 +177,7 @@ sup_start_error_return(Config) when list(Config) ->
sup_start_fail(doc) ->
["Tests what happens if init-callback fails"];
sup_start_fail(suite) -> [];
-sup_start_fail(Config) when list(Config) ->
+sup_start_fail(Config) when is_list(Config) ->
process_flag(trap_exit, true),
?line {error, Term} = start(fail),
@@ -192,7 +204,7 @@ sup_stop_infinity(doc) ->
"for children of type supervisor"];
sup_stop_infinity(suite) -> [];
-sup_stop_infinity(Config) when list(Config) ->
+sup_stop_infinity(Config) when is_list(Config) ->
process_flag(trap_exit, true),
?line {ok, Pid} = start({ok, {{one_for_one, 2, 3600}, []}}),
Child1 = {child1, {supervisor_1, start_child, []},
@@ -230,7 +242,7 @@ sup_stop_timeout(doc) ->
["See sup_stop/1 when Shutdown = 1000"];
sup_stop_timeout(suite) -> [];
-sup_stop_timeout(Config) when list(Config) ->
+sup_stop_timeout(Config) when is_list(Config) ->
process_flag(trap_exit, true),
?line {ok, Pid} = start({ok, {{one_for_one, 2, 3600}, []}}),
Child1 = {child1, {supervisor_1, start_child, []},
@@ -278,7 +290,7 @@ sup_stop_brutal_kill(doc) ->
["See sup_stop/1 when Shutdown = brutal_kill"];
sup_stop_brutal_kill(suite) -> [];
-sup_stop_brutal_kill(Config) when list(Config) ->
+sup_stop_brutal_kill(Config) when is_list(Config) ->
process_flag(trap_exit, true),
?line {ok, Pid} = start({ok, {{one_for_one, 2, 3600}, []}}),
Child1 = {child1, {supervisor_1, start_child, []},
@@ -327,7 +339,7 @@ extra_return(doc) ->
"and restart_child/2"];
extra_return(suite) -> [];
-extra_return(Config) when list(Config) ->
+extra_return(Config) when is_list(Config) ->
process_flag(trap_exit, true),
Child = {child1, {supervisor_1, start_child, [extra_return]},
permanent, 1000,
@@ -341,6 +353,8 @@ extra_return(Config) when list(Config) ->
?line {error, running} = supervisor:delete_child(sup_test, child1),
?line {error, running} = supervisor:restart_child(sup_test, child1),
?line [{child1, CPid, worker, []}] = supervisor:which_children(sup_test),
+ ?line [1,1,0,1] = get_child_counts(sup_test),
+
?line ok = supervisor:terminate_child(sup_test, child1),
receive
{'EXIT', CPid, shutdown} -> ok;
@@ -350,29 +364,39 @@ extra_return(Config) when list(Config) ->
?line test_server:fail(no_child_termination)
end,
?line [{child1,undefined,worker,[]}] = supervisor:which_children(sup_test),
+ ?line [1,0,0,1] = get_child_counts(sup_test),
+
?line {ok, CPid2,extra_return} =
supervisor:restart_child(sup_test, child1),
?line [{child1, CPid2, worker, []}] = supervisor:which_children(sup_test),
+ ?line [1,1,0,1] = get_child_counts(sup_test),
+
?line ok = supervisor:terminate_child(sup_test, child1),
?line ok = supervisor:terminate_child(sup_test, child1),
?line ok = supervisor:delete_child(sup_test, child1),
?line {error, not_found} = supervisor:restart_child(sup_test, child1),
?line [] = supervisor:which_children(sup_test),
+ ?line [0,0,0,0] = get_child_counts(sup_test),
+
?line {ok, CPid3, extra_return} = supervisor:start_child(sup_test, Child),
?line [{child1, CPid3, worker, []}] = supervisor:which_children(sup_test),
+ ?line [1,1,0,1] = get_child_counts(sup_test),
+
ok.
%-------------------------------------------------------------------------
child_adm(doc)->
["Test API functions start_child/2, terminate_child/2, delete_child/2 "
- "restart_child/2, which_children/1. Only correct childspecs are used, "
- "handling of incorrect childspecs is tested in child_specs/1"];
+ "restart_child/2, which_children/1, count_children/1. Only correct "
+ "childspecs are used, handling of incorrect childspecs is tested in "
+ "child_specs/1"];
child_adm(suite) -> [];
-child_adm(Config) when list(Config) ->
+child_adm(Config) when is_list(Config) ->
process_flag(trap_exit, true),
Child = {child1, {supervisor_1, start_child, []}, permanent, 1000,
worker, []},
?line {ok, _Pid} = start({ok, {{one_for_one, 2, 3600}, [Child]}}),
?line [{child1, CPid, worker, []}] = supervisor:which_children(sup_test),
+ ?line [1,1,0,1] = get_child_counts(sup_test),
link(CPid),
%% Start of an already runnig process
@@ -392,6 +416,7 @@ child_adm(Config) when list(Config) ->
?line test_server:fail(no_child_termination)
end,
?line [{child1,undefined,worker,[]}] = supervisor:which_children(sup_test),
+ ?line [1,0,0,1] = get_child_counts(sup_test),
%% Like deleting something that does not exist, it will succeed!
?line ok = supervisor:terminate_child(sup_test, child1),
@@ -402,6 +427,7 @@ child_adm(Config) when list(Config) ->
%% Restart
?line {ok, CPid2} = supervisor:restart_child(sup_test, child1),
?line [{child1, CPid2, worker, []}] = supervisor:which_children(sup_test),
+ ?line [1,1,0,1] = get_child_counts(sup_test),
?line {error, running} = supervisor:restart_child(sup_test, child1),
?line {error, not_found} = supervisor:restart_child(sup_test, child2),
@@ -414,15 +440,19 @@ child_adm(Config) when list(Config) ->
?line ok = supervisor:delete_child(sup_test, child1),
?line {error, not_found} = supervisor:restart_child(sup_test, child1),
?line [] = supervisor:which_children(sup_test),
+ ?line [0,0,0,0] = get_child_counts(sup_test),
%% Start
?line {'EXIT',{noproc,{gen_server,call, _}}} =
(catch supervisor:start_child(foo, Child)),
?line {ok, CPid3} = supervisor:start_child(sup_test, Child),
?line [{child1, CPid3, worker, []}] = supervisor:which_children(sup_test),
+ ?line [1,1,0,1] = get_child_counts(sup_test),
?line {'EXIT',{noproc,{gen_server,call,[foo,which_children,infinity]}}}
= (catch supervisor:which_children(foo)),
+ ?line {'EXIT',{noproc,{gen_server,call,[foo,count_children,infinity]}}}
+ = (catch supervisor:count_children(foo)),
ok.
%-------------------------------------------------------------------------
child_adm_simple(doc) ->
@@ -430,12 +460,13 @@ child_adm_simple(doc) ->
"restart_child/2 are not valid for a simple_one_for_one supervisor "
"check that the correct error message is returned."];
child_adm_simple(suite) -> [];
-child_adm_simple(Config) when list(Config) ->
+child_adm_simple(Config) when is_list(Config) ->
Child = {child, {supervisor_1, start_child, []}, permanent, 1000,
worker, []},
?line {ok, _Pid} = start({ok, {{simple_one_for_one, 2, 3600}, [Child]}}),
%% In simple_one_for_one all children are added dynamically
?line [] = supervisor:which_children(sup_test),
+ ?line [1,0,0,0] = get_child_counts(sup_test),
%% Start
?line {'EXIT',{noproc,{gen_server,call, _}}} =
@@ -443,12 +474,14 @@ child_adm_simple(Config) when list(Config) ->
?line {ok, CPid1} = supervisor:start_child(sup_test, []),
?line [{undefined, CPid1, worker, []}] =
supervisor:which_children(sup_test),
+ ?line [1,1,0,1] = get_child_counts(sup_test),
?line {ok, CPid2} = supervisor:start_child(sup_test, []),
?line Children = supervisor:which_children(sup_test),
?line 2 = length(Children),
?line true = lists:member({undefined, CPid2, worker, []}, Children),
?line true = lists:member({undefined, CPid1, worker, []}, Children),
+ ?line [1,2,0,2] = get_child_counts(sup_test),
%% Termination
?line {error, simple_one_for_one} =
@@ -467,7 +500,7 @@ child_adm_simple(Config) when list(Config) ->
child_specs(doc) ->
["Tests child specs, invalid formats should be rejected."];
child_specs(suite) -> [];
-child_specs(Config) when list(Config) ->
+child_specs(Config) when is_list(Config) ->
process_flag(trap_exit, true),
?line {ok, _Pid} = start({ok, {{one_for_one, 2, 3600}, []}}),
?line {error, _} = supervisor:start_child(sup_test, hej),
@@ -526,7 +559,7 @@ normal_termination(suite) ->
permanent_normal(doc) ->
["A permanent child should always be restarted"];
permanent_normal(suite) -> [];
-permanent_normal(Config) when list(Config) ->
+permanent_normal(Config) when is_list(Config) ->
?line {ok, _SupPid} = start({ok, {{one_for_one, 2, 3600}, []}}),
Child1 = {child1, {supervisor_1, start_child, []}, permanent, 1000,
worker, []},
@@ -541,14 +574,16 @@ permanent_normal(Config) when list(Config) ->
ok;
false ->
?line test_server:fail({permanent_child_not_restarted, Child1})
- end.
+ end,
+ ?line [1,1,0,1] = get_child_counts(sup_test),
+ ok.
%-------------------------------------------------------------------------
transient_normal(doc) ->
["A transient child should not be restarted if it exits with "
"reason normal"];
transient_normal(suite) -> [];
-transient_normal(Config) when list(Config) ->
+transient_normal(Config) when is_list(Config) ->
?line {ok, _SupPid} = start({ok, {{one_for_one, 2, 3600}, []}}),
Child1 = {child1, {supervisor_1, start_child, []}, transient, 1000,
worker, []},
@@ -558,13 +593,15 @@ transient_normal(Config) when list(Config) ->
CPid1 ! stop,
test_server:sleep(100),
- ?line [{child1,undefined,worker,[]}] = supervisor:which_children(sup_test).
+ ?line [{child1,undefined,worker,[]}] = supervisor:which_children(sup_test),
+ ?line [1,0,0,1] = get_child_counts(sup_test),
+ ok.
%-------------------------------------------------------------------------
temporary_normal(doc) ->
["A temporary process should never be restarted"];
temporary_normal(suite) -> [];
-temporary_normal(Config) when list(Config) ->
+temporary_normal(Config) when is_list(Config) ->
?line {ok, _SupPid} = start({ok, {{one_for_one, 2, 3600}, []}}),
Child1 = {child1, {supervisor_1, start_child, []}, temporary, 1000,
worker, []},
@@ -574,8 +611,10 @@ temporary_normal(Config) when list(Config) ->
CPid1 ! stop,
test_server:sleep(100),
- ?line [{child1,undefined,worker,[]}] = supervisor:which_children(sup_test).
+ ?line [{child1,undefined,worker,[]}] = supervisor:which_children(sup_test),
+ ?line [1,0,0,1] = get_child_counts(sup_test),
+ ok.
%-------------------------------------------------------------------------
abnormal_termination(doc) ->
["Testes the supervisors behaviour if a child dies with reason abnormal"];
@@ -586,7 +625,7 @@ abnormal_termination(suite) ->
permanent_abnormal(doc) ->
["A permanent child should always be restarted"];
permanent_abnormal(suite) -> [];
-permanent_abnormal(Config) when list(Config) ->
+permanent_abnormal(Config) when is_list(Config) ->
?line {ok, _SupPid} = start({ok, {{one_for_one, 2, 3600}, []}}),
Child1 = {child1, {supervisor_1, start_child, []}, permanent, 1000,
worker, []},
@@ -601,14 +640,16 @@ permanent_abnormal(Config) when list(Config) ->
ok;
false ->
?line test_server:fail({permanent_child_not_restarted, Child1})
- end.
+ end,
+ ?line [1,1,0,1] = get_child_counts(sup_test),
+ ok.
%-------------------------------------------------------------------------
transient_abnormal(doc) ->
["A transient child should be restarted if it exits with "
"reason abnormal"];
transient_abnormal(suite) -> [];
-transient_abnormal(Config) when list(Config) ->
+transient_abnormal(Config) when is_list(Config) ->
?line {ok, _SupPid} = start({ok, {{one_for_one, 2, 3600}, []}}),
Child1 = {child1, {supervisor_1, start_child, []}, transient, 1000,
worker, []},
@@ -624,14 +665,15 @@ transient_abnormal(Config) when list(Config) ->
ok;
false ->
?line test_server:fail({transient_child_not_restarted, Child1})
- end.
-
+ end,
+ ?line [1,1,0,1] = get_child_counts(sup_test),
+ ok.
%-------------------------------------------------------------------------
temporary_abnormal(doc) ->
["A temporary process should never be restarted"];
temporary_abnormal(suite) -> [];
-temporary_abnormal(Config) when list(Config) ->
+temporary_abnormal(Config) when is_list(Config) ->
?line {ok, _SupPid} = start({ok, {{one_for_one, 2, 3600}, []}}),
Child1 = {child1, {supervisor_1, start_child, []}, temporary, 1000,
worker, []},
@@ -641,8 +683,10 @@ temporary_abnormal(Config) when list(Config) ->
CPid1 ! die,
test_server:sleep(100),
- ?line [{child1,undefined,worker,[]}] = supervisor:which_children(sup_test).
+ ?line [{child1,undefined,worker,[]}] = supervisor:which_children(sup_test),
+ ?line [1,0,0,1] = get_child_counts(sup_test),
+ ok.
%-------------------------------------------------------------------------
restart_one_for_one(doc) ->
["Test that the one_for_one strategy works."];
@@ -653,7 +697,7 @@ restart_one_for_one(suite) -> [one_for_one, one_for_one_escalation].
one_for_one(doc) ->
["Test the one_for_one base case."];
one_for_one(suite) -> [];
-one_for_one(Config) when list(Config) ->
+one_for_one(Config) when is_list(Config) ->
process_flag(trap_exit, true),
Child1 = {child1, {supervisor_1, start_child, []}, permanent, 1000,
worker, []},
@@ -679,6 +723,7 @@ one_for_one(Config) when list(Config) ->
end;
true -> ?line test_server:fail({bad_child_list, Children})
end,
+ ?line [2,2,0,2] = get_child_counts(sup_test),
%% Test restart frequency property
CPid2 ! die,
@@ -697,7 +742,7 @@ one_for_one(Config) when list(Config) ->
one_for_one_escalation(doc) ->
["Test restart escalation on a one_for_one supervisor."];
one_for_one_escalation(suite) -> [];
-one_for_one_escalation(Config) when list(Config) ->
+one_for_one_escalation(Config) when is_list(Config) ->
process_flag(trap_exit, true),
Child1 = {child1, {supervisor_1, start_child, [error]},
permanent, 1000,
@@ -737,7 +782,7 @@ restart_one_for_all(suite) ->
one_for_all(doc) ->
["Test the one_for_all base case."];
one_for_all(suite) -> [];
-one_for_all(Config) when list(Config) ->
+one_for_all(Config) when is_list(Config) ->
process_flag(trap_exit, true),
Child1 = {child1, {supervisor_1, start_child, []}, permanent, 1000,
worker, []},
@@ -772,6 +817,8 @@ one_for_all(Config) when list(Config) ->
true -> ?line test_server:fail(bad_child);
false -> ok
end,
+ ?line [2,2,0,2] = get_child_counts(sup_test),
+
%%% Test restart frequency property
[{_, Pid3, _, _}|_] = supervisor:which_children(sup_test),
Pid3 ! die,
@@ -788,7 +835,7 @@ one_for_all(Config) when list(Config) ->
one_for_all_escalation(doc) ->
["Test restart escalation on a one_for_all supervisor."];
one_for_all_escalation(suite) -> [];
-one_for_all_escalation(Config) when list(Config) ->
+one_for_all_escalation(Config) when is_list(Config) ->
process_flag(trap_exit, true),
Child1 = {child1, {supervisor_1, start_child, []}, permanent, 1000,
worker, []},
@@ -830,7 +877,7 @@ restart_simple_one_for_one(suite) ->
simple_one_for_one(doc) ->
["Test the simple_one_for_one base case."];
simple_one_for_one(suite) -> [];
-simple_one_for_one(Config) when list(Config) ->
+simple_one_for_one(Config) when is_list(Config) ->
process_flag(trap_exit, true),
Child = {child, {supervisor_1, start_child, []}, permanent, 1000,
worker, []},
@@ -854,6 +901,8 @@ simple_one_for_one(Config) when list(Config) ->
end;
true -> ?line test_server:fail({bad_child_list, Children})
end,
+ ?line [1,2,0,2] = get_child_counts(sup_test),
+
%% Test restart frequency property
CPid2 ! die,
receive
@@ -872,7 +921,7 @@ simple_one_for_one_extra(doc) ->
["Tests automatic restart of children "
"who's start function return extra info."];
simple_one_for_one_extra(suite) -> [];
-simple_one_for_one_extra(Config) when list(Config) ->
+simple_one_for_one_extra(Config) when is_list(Config) ->
process_flag(trap_exit, true),
Child = {child, {supervisor_1, start_child, [extra_info]},
permanent, 1000, worker, []},
@@ -896,6 +945,8 @@ simple_one_for_one_extra(Config) when list(Config) ->
end;
true -> ?line test_server:fail({bad_child_list, Children})
end,
+ ?line [1,2,0,2] = get_child_counts(sup_test),
+
CPid2 ! die,
receive
{'EXIT', CPid2, _} -> ok
@@ -912,7 +963,7 @@ simple_one_for_one_extra(Config) when list(Config) ->
simple_one_for_one_escalation(doc) ->
["Test restart escalation on a simple_one_for_one supervisor."];
simple_one_for_one_escalation(suite) -> [];
-simple_one_for_one_escalation(Config) when list(Config) ->
+simple_one_for_one_escalation(Config) when is_list(Config) ->
process_flag(trap_exit, true),
Child = {child, {supervisor_1, start_child, []}, permanent, 1000,
worker, []},
@@ -947,7 +998,7 @@ restart_rest_for_one(suite) -> [rest_for_one, rest_for_one_escalation].
rest_for_one(doc) ->
["Test the rest_for_one base case."];
rest_for_one(suite) -> [];
-rest_for_one(Config) when list(Config) ->
+rest_for_one(Config) when is_list(Config) ->
process_flag(trap_exit, true),
Child1 = {child1, {supervisor_1, start_child, []}, permanent, 1000,
worker, []},
@@ -962,6 +1013,8 @@ rest_for_one(Config) when list(Config) ->
link(CPid2),
?line {ok, CPid3} = supervisor:start_child(sup_test, Child3),
link(CPid3),
+ ?line [3,3,0,3] = get_child_counts(sup_test),
+
CPid2 ! die,
receive
{'EXIT', CPid2, died} -> ok;
@@ -987,6 +1040,8 @@ rest_for_one(Config) when list(Config) ->
if length(Children) == 3 -> ok;
true -> ?line test_server:fail({bad_child_list, Children})
end,
+ ?line [3,3,0,3] = get_child_counts(sup_test),
+
%% Test that no old children is still alive
SCh = lists:map(fun({_,P,_,_}) -> P end, Children),
case lists:member(CPid1, SCh) of
@@ -1018,7 +1073,7 @@ rest_for_one(Config) when list(Config) ->
rest_for_one_escalation(doc) ->
["Test restart escalation on a rest_for_one supervisor."];
rest_for_one_escalation(suite) -> [];
-rest_for_one_escalation(Config) when list(Config) ->
+rest_for_one_escalation(Config) when is_list(Config) ->
process_flag(trap_exit, true),
Child1 = {child1, {supervisor_1, start_child, []}, permanent, 1000,
worker, []},
@@ -1052,7 +1107,7 @@ rest_for_one_escalation(Config) when list(Config) ->
child_unlink(doc)-> ["Test that the supervisor does not hang forever if "
"the child unliks and then is terminated by the supervisor."];
child_unlink(suite) -> [];
-child_unlink(Config) when list(Config) ->
+child_unlink(Config) when is_list(Config) ->
?line {ok, SupPid} = start({ok, {{one_for_one, 2, 3600}, []}}),
@@ -1081,7 +1136,7 @@ tree(doc) ->
["Test a basic supervison tree."];
tree(suite) ->
[];
-tree(Config) when list(Config) ->
+tree(Config) when is_list(Config) ->
process_flag(trap_exit, true),
Child1 = {child1, {supervisor_1, start_child, []},
@@ -1114,15 +1169,19 @@ tree(Config) when list(Config) ->
%% Child supervisors
?line {ok, Sup1} = supervisor:start_child(Pid, ChildSup1),
?line {ok, Sup2} = supervisor:start_child(Pid, ChildSup2),
+ ?line [2,2,2,0] = get_child_counts(Pid),
%% Workers
-
?line [{_, CPid2, _, _},{_, CPid1, _, _}] =
supervisor:which_children(Sup1),
+ ?line [2,2,0,2] = get_child_counts(Sup1),
+ ?line [0,0,0,0] = get_child_counts(Sup2),
%% Dynamic children
?line {ok, CPid3} = supervisor:start_child(Sup2, Child3),
?line {ok, CPid4} = supervisor:start_child(Sup2, Child4),
+ ?line [2,2,0,2] = get_child_counts(Sup1),
+ ?line [2,2,0,2] = get_child_counts(Sup2),
link(Sup1),
link(Sup2),
@@ -1144,9 +1203,11 @@ tree(Config) when list(Config) ->
?line [{_, CPid2, _, _},{_, CPid1, _, _}] =
supervisor:which_children(Sup1),
+ ?line [2,2,0,2] = get_child_counts(Sup1),
?line [{_, NewCPid4, _, _},{_, CPid3, _, _}] =
supervisor:which_children(Sup2),
+ ?line [2,2,0,2] = get_child_counts(Sup2),
link(NewCPid4),
@@ -1195,9 +1256,99 @@ tree(Config) when list(Config) ->
?line [{supchild2, NewSup2, _, _},{supchild1, NewSup1, _, _}] =
supervisor:which_children(Pid),
+ ?line [2,2,2,0] = get_child_counts(Pid),
?line [{child2, _, _, _},{child1, _, _, _}] =
supervisor:which_children(NewSup1),
+ ?line [2,2,0,2] = get_child_counts(NewSup1),
+
?line [] = supervisor:which_children(NewSup2),
+ ?line [0,0,0,0] = get_child_counts(NewSup2),
ok.
+%-------------------------------------------------------------------------
+count_children_allocator_test(MemoryState) ->
+ Allocators = [temp_alloc, eheap_alloc, binary_alloc, ets_alloc,
+ driver_alloc, sl_alloc, ll_alloc, fix_alloc, std_alloc,
+ sys_alloc],
+ MemoryStateList = element(4, MemoryState),
+ AllocTypes = [lists:keyfind(Alloc, 1, MemoryStateList)
+ || Alloc <- Allocators],
+ AllocStates = [lists:keyfind(e, 1, AllocValue)
+ || {_Type, AllocValue} <- AllocTypes],
+ lists:all(fun(State) -> State == {e, true} end, AllocStates).
+
+count_children_memory(doc) ->
+ ["Test that which_children eats memory, but count_children does not."];
+count_children_memory(suite) ->
+ MemoryState = erlang:system_info(allocator),
+ case count_children_allocator_test(MemoryState) of
+ true -> [];
+ false ->
+ {skip, "+Meamin used during test; erlang:memory/1 not available"}
+ end;
+count_children_memory(Config) when is_list(Config) ->
+ process_flag(trap_exit, true),
+ Child = {child, {supervisor_1, start_child, []}, temporary, 1000,
+ worker, []},
+ ?line {ok, _Pid} = start({ok, {{simple_one_for_one, 2, 3600}, [Child]}}),
+ [supervisor:start_child(sup_test, []) || _Ignore <- lists:seq(1,1000)],
+
+ garbage_collect(),
+ _Size1 = erlang:memory(processes_used),
+ Children = supervisor:which_children(sup_test),
+ _Size2 = erlang:memory(processes_used),
+ ChildCount = get_child_counts(sup_test),
+ Size3 = erlang:memory(processes_used),
+
+ [supervisor:start_child(sup_test, []) || _Ignore2 <- lists:seq(1,1000)],
+
+ garbage_collect(),
+ Children2 = supervisor:which_children(sup_test),
+ Size4 = erlang:memory(processes_used),
+ ChildCount2 = get_child_counts(sup_test),
+ Size5 = erlang:memory(processes_used),
+
+ garbage_collect(),
+ Children3 = supervisor:which_children(sup_test),
+ Size6 = erlang:memory(processes_used),
+ ChildCount3 = get_child_counts(sup_test),
+ Size7 = erlang:memory(processes_used),
+
+ ?line 1000 = length(Children),
+ ?line [1,1000,0,1000] = ChildCount,
+ ?line 2000 = length(Children2),
+ ?line [1,2000,0,2000] = ChildCount2,
+ ?line Children3 = Children2,
+ ?line ChildCount3 = ChildCount2,
+
+ %% count_children consumes memory using an accumulator function,
+ %% but the space can be reclaimed incrementally, whereas
+ %% which_children generates a return list.
+ case (Size5 =< Size4) of
+ true -> ok;
+ false ->
+ ?line test_server:fail({count_children, used_more_memory})
+ end,
+ case Size7 =< Size6 of
+ true -> ok;
+ false ->
+ ?line test_server:fail({count_children, used_more_memory})
+ end,
+
+ case Size4 > Size3 of
+ true -> ok;
+ false ->
+ ?line test_server:fail({which_children, used_no_memory})
+ end,
+ case Size6 > Size5 of
+ true -> ok;
+ false ->
+ ?line test_server:fail({which_children, used_no_memory})
+ end,
+
+ [exit(Pid, kill) || {undefined, Pid, worker, _Modules} <- Children3],
+ test_server:sleep(100),
+ ?line [1,0,0,0] = get_child_counts(sup_test),
+
+ ok.
diff --git a/lib/stdlib/test/tar_SUITE.erl b/lib/stdlib/test/tar_SUITE.erl
index af687ed2e1..7646f4c249 100644
--- a/lib/stdlib/test/tar_SUITE.erl
+++ b/lib/stdlib/test/tar_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1997-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(tar_SUITE).
@@ -183,7 +183,7 @@ atomic(doc) ->
"and uncompressed archives."
"Also test the 'cooked' option."];
atomic(suite) -> [];
-atomic(Config) when list(Config) ->
+atomic(Config) when is_list(Config) ->
?line ok = file:set_cwd(?config(priv_dir, Config)),
?line DataFiles = data_files(),
?line Names = [Name || {Name,_,_} <- DataFiles],
@@ -369,7 +369,7 @@ try_bad(Name0, Reason, Config) ->
case catch erl_tar:format_error(Reason) of
{'EXIT', CrashReason} ->
test_server:fail({format_error, crashed, CrashReason});
- String when list(String) ->
+ String when is_list(String) ->
io:format("format_error(~p) -> ~s", [Reason, String]);
Other ->
test_server:fail({format_error, returned, Other})
@@ -413,7 +413,7 @@ try_error(M, F, A, Error) ->
case catch erl_tar:format_error(Error) of
{'EXIT', FReason} ->
test_server:fail({format_error, crashed, FReason});
- String when list(String) ->
+ String when is_list(String) ->
io:format("format_error(~p) -> ~s", [Error, String]);
Other ->
test_server:fail({format_error, returned, Other})
@@ -431,7 +431,7 @@ remove_prefix(_, Result) ->
extract_from_binary(doc) ->
"Test extracting a tar archive from a binary.";
-extract_from_binary(Config) when list(Config) ->
+extract_from_binary(Config) when is_list(Config) ->
?line DataDir = ?config(data_dir, Config),
?line PrivDir = ?config(priv_dir, Config),
?line Long = filename:join(DataDir, "no_fancy_stuff.tar"),
diff --git a/lib/stdlib/test/timer_SUITE.erl b/lib/stdlib/test/timer_SUITE.erl
index 86d8612b56..5f38c91c64 100644
--- a/lib/stdlib/test/timer_SUITE.erl
+++ b/lib/stdlib/test/timer_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1996-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1996-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(timer_SUITE).
@@ -271,7 +271,7 @@ collect(N, {E,A,B}, I) ->
print_report ->
print_report({E,A,B,I}),
collect(N,{E,A,B}, I);
- {Pid, get_report} when pid(Pid) ->
+ {Pid, get_report} when is_pid(Pid) ->
Pid ! {report, {E, A, B, I}},
collect(N,{E,A,B}, I);
reset ->
diff --git a/lib/stdlib/test/unicode_SUITE.erl b/lib/stdlib/test/unicode_SUITE.erl
index 706445005c..141ac64606 100644
--- a/lib/stdlib/test/unicode_SUITE.erl
+++ b/lib/stdlib/test/unicode_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2008-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 2008-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(unicode_SUITE).
@@ -276,7 +276,7 @@ ex_latin1(Config) when is_list(Config) ->
unicode:characters_to_list(make_unaligned(MissingLastByte),unicode),
?line DoubleSize16 = byte_size(DoubleUtf16),
- ?line DoubleUtf16_2 = erlang:concat_binary([DoubleUtf16,<<16#FFFFF/utf16-big>>]),
+ ?line DoubleUtf16_2 = list_to_binary([DoubleUtf16,<<16#FFFFF/utf16-big>>]),
?line DoubleSize16_2 = byte_size(DoubleUtf16_2),
?line AllBut1_16 = DoubleSize16 - 1,
?line AllBut2_16_2 = DoubleSize16_2 - 2,
@@ -884,15 +884,15 @@ utf8_to_list_bsyntax(<<C/utf8,R/binary>>) ->
list_to_utf8_bsyntax(List,unicode) ->
FList = flatx(List),
- erlang:concat_binary([ if
- is_binary(E) ->
- E;
- true ->
- <<E/utf8>>
- end || E <- FList ]);
+ list_to_binary([ if
+ is_binary(E) ->
+ E;
+ true ->
+ <<E/utf8>>
+ end || E <- FList ]);
list_to_utf8_bsyntax(List,latin1) ->
FList = flatb(List),
- erlang:concat_binary([ <<E/utf8>> || E <- FList ]).
+ list_to_binary([ <<E/utf8>> || E <- FList ]).
@@ -954,15 +954,15 @@ utf16_big_to_list_bsyntax(<<C/utf16-big,R/binary>>) ->
list_to_utf16_big_bsyntax(List,{utf16,big}) ->
FList = flatx(List),
- erlang:concat_binary([ if
- is_binary(E) ->
- E;
- true ->
- <<E/utf16-big>>
- end || E <- FList ]);
+ list_to_binary([ if
+ is_binary(E) ->
+ E;
+ true ->
+ <<E/utf16-big>>
+ end || E <- FList ]);
list_to_utf16_big_bsyntax(List,latin1) ->
FList = flatb(List),
- erlang:concat_binary([ <<E/utf16-big>> || E <- FList ]).
+ list_to_binary([ <<E/utf16-big>> || E <- FList ]).
utf16_little_to_list_bsyntax(<<>>) ->
@@ -972,15 +972,15 @@ utf16_little_to_list_bsyntax(<<C/utf16-little,R/binary>>) ->
list_to_utf16_little_bsyntax(List,{utf16,little}) ->
FList = flatx(List),
- erlang:concat_binary([ if
- is_binary(E) ->
- E;
- true ->
- <<E/utf16-little>>
- end || E <- FList ]);
+ list_to_binary([ if
+ is_binary(E) ->
+ E;
+ true ->
+ <<E/utf16-little>>
+ end || E <- FList ]);
list_to_utf16_little_bsyntax(List,latin1) ->
FList = flatb(List),
- erlang:concat_binary([ <<E/utf16-little>> || E <- FList ]).
+ list_to_binary([ <<E/utf16-little>> || E <- FList ]).
@@ -991,15 +991,15 @@ utf32_big_to_list_bsyntax(<<C/utf32-big,R/binary>>) ->
list_to_utf32_big_bsyntax(List,{utf32,big}) ->
FList = flatx(List),
- erlang:concat_binary([ if
- is_binary(E) ->
- E;
- true ->
- <<E/utf32-big>>
- end || E <- FList ]);
+ list_to_binary([ if
+ is_binary(E) ->
+ E;
+ true ->
+ <<E/utf32-big>>
+ end || E <- FList ]);
list_to_utf32_big_bsyntax(List,latin1) ->
FList = flatb(List),
- erlang:concat_binary([ <<E/utf32-big>> || E <- FList ]).
+ list_to_binary([ <<E/utf32-big>> || E <- FList ]).
utf32_little_to_list_bsyntax(<<>>) ->
@@ -1009,15 +1009,15 @@ utf32_little_to_list_bsyntax(<<C/utf32-little,R/binary>>) ->
list_to_utf32_little_bsyntax(List,{utf32,little}) ->
FList = flatx(List),
- erlang:concat_binary([ if
- is_binary(E) ->
- E;
- true ->
- <<E/utf32-little>>
- end || E <- FList ]);
+ list_to_binary([ if
+ is_binary(E) ->
+ E;
+ true ->
+ <<E/utf32-little>>
+ end || E <- FList ]);
list_to_utf32_little_bsyntax(List,latin1) ->
FList = flatb(List),
- erlang:concat_binary([ <<E/utf32-little>> || E <- FList ]).
+ list_to_binary([ <<E/utf32-little>> || E <- FList ]).
diff --git a/lib/stdlib/test/win32reg_SUITE.erl b/lib/stdlib/test/win32reg_SUITE.erl
index 3ad58eba03..c8cc82f61e 100644
--- a/lib/stdlib/test/win32reg_SUITE.erl
+++ b/lib/stdlib/test/win32reg_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 1997-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 1997-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(win32reg_SUITE).
@@ -37,7 +37,7 @@ fini(Config) when is_list(Config) ->
Config.
long(doc) -> "Test long keys and entries (OTP-3446).";
-long(Config) when list(Config) ->
+long(Config) when is_list(Config) ->
?line Dog = test_server:timetrap(test_server:seconds(10)),
?line LongKey = "software\\" ++
@@ -61,7 +61,7 @@ long(Config) when list(Config) ->
?line test_server:timetrap_cancel(Dog),
ok.
-evil_write(Config) when list(Config) ->
+evil_write(Config) when is_list(Config) ->
?line Dog = test_server:timetrap(test_server:seconds(10)),
?line Key = "Software\\Ericsson\\Erlang",
diff --git a/lib/stdlib/test/zip_SUITE.erl b/lib/stdlib/test/zip_SUITE.erl
index 55cbd277ef..12ca655000 100644
--- a/lib/stdlib/test/zip_SUITE.erl
+++ b/lib/stdlib/test/zip_SUITE.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2006-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 2006-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
-module(zip_SUITE).
@@ -181,7 +181,7 @@ atomic(doc) ->
["Test the 'atomic' operations: zip/unzip/list_dir, on archives."
"Also test the 'cooked' option."];
atomic(suite) -> [];
-atomic(Config) when list(Config) ->
+atomic(Config) when is_list(Config) ->
ok = file:set_cwd(?config(priv_dir, Config)),
DataFiles = data_files(),
Names = [Name || {Name,_,_} <- DataFiles],
@@ -209,7 +209,7 @@ openzip_api(doc) ->
["Test the openzip_open/2, openzip_get/1, openzip_get/2, openzip_close/1 "
"and openzip_list_dir/1 functions."];
openzip_api(suite) -> [];
-openzip_api(Config) when list(Config) ->
+openzip_api(Config) when is_list(Config) ->
ok = file:set_cwd(?config(priv_dir, Config)),
DataFiles = data_files(),
Names = [Name || {Name, _, _} <- DataFiles],
@@ -248,7 +248,7 @@ zip_api(doc) ->
["Test the zip_open/2, zip_get/1, zip_get/2, zip_close/1 "
"and zip_list_dir/1 functions."];
zip_api(suite) -> [];
-zip_api(Config) when list(Config) ->
+zip_api(Config) when is_list(Config) ->
ok = file:set_cwd(?config(priv_dir, Config)),
DataFiles = data_files(),
Names = [Name || {Name, _, _} <- DataFiles],
@@ -550,7 +550,7 @@ aliases(Config) when is_list(Config) ->
unzip_from_binary(doc) ->
["Test extracting a zip archive from a binary."];
-unzip_from_binary(Config) when list(Config) ->
+unzip_from_binary(Config) when is_list(Config) ->
DataDir = ?config(data_dir, Config),
PrivDir = ?config(priv_dir, Config),
ExtractDir = filename:join(PrivDir, "extract_from_binary"),
@@ -626,7 +626,7 @@ delete_all_in(Dir) ->
compress_control(doc) ->
["Test control of which files that should be compressed"];
compress_control(suite) -> [];
-compress_control(Config) when list(Config) ->
+compress_control(Config) when is_list(Config) ->
ok = file:set_cwd(?config(priv_dir, Config)),
Dir = "compress_control",
Files = [