summaryrefslogtreecommitdiff
path: root/lib/stdlib/src
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'nox/fix-erl_lint-variable-usage' into puFredrik Gustafsson2013-08-011-19/+25
|\
| * Fix variable usage tracking in some record errorsAnthony Ramine2013-07-311-1/+1
| | | | | | | | | | When reporting a field redefinition in a record, erl_lint can forget about some old unused variables.
| * Fix unsafe variable tracking in try expressionsAnthony Ramine2013-07-221-1/+1
| | | | | | | | | | | | | | | | | | Variables used in the body of a try expression were marked as unsafe *and* used, which makes no sense as an unsafe variable can't be used. Function vtsubtract/2 is used to forget usage of such unsafe variables. Reported-by: Paul Davis
| * Fix variable usage tracking in erl_lintAnthony Ramine2013-07-011-18/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When analyzing complex expressions (i.e. comprehensions, cases, tries, ifs and receives), erl_lint does not forget about old unused variables when returning the updated variable table. This causes a bug where old unused variables are not recorded as such: t(X, Y) -> #r{a=[ K || K <- Y ],b=[ K || K <- Y ]}. As erl_lint uses vtmerge_pat/2 to merge the results of the analysis of the two list comprehensions, X is marked as used and the warning is not emitted. The function vtmerge_pat/2 is used instead of the similar vtmerge/2 which does not mark multiple occurrences of a variable as usage to handle cases like the following one: t(X, Y) -> #r{a=A=X,b=A=Y}. Other simpler expressions like conses, tuples and external fun references do not correctly follow this behaviour, e.g. A is not marked as used in the following code: t(X, Y) -> {A=X,A=Y}. This commit fixes both issues and makes erl_lint not return old unused variables in updated tables and makes all compound expressions use vtmerge_pat/2. Reported-by: Anders Ramsell
* | Merge branch 'epa/fix_io_noreturn_with_self_pid' into puFredrik Gustafsson2013-08-011-0/+2
|\ \
| * | Fix no return of io functions when self() used as Iodevicecrownedgrouse2013-06-031-0/+2
| | | | | | | | | | | | | | | | | | | | | When self() is used as Iodevice in io functions, this was resulting in an infinite wait of function return. This patch add a guard in request and replace self() by the current group_leader.
* | | Merge branch 'sze/limit_max_length_int_shell' into puFredrik Gustafsson2013-08-011-1/+3
|\ \ \
| * | | Limit maximum line length in interactive shellsStefan Zegenhagen2013-05-081-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Dear all, it seems as if I sent around the wrong version of the patch. Please find the correct version attached to this e-mail. Kind regards, > one of our testers found out that he could reliably reboot our > erlang-based device by just sending tons of 'A' characters to an > interactive shell. > > It appears that the I/O server of the interactive shell (in group.erl) > is always reading a full line before doing any end-of-input processing, > so that by sending bytes without a newline in between, it slowly eats up > all available memory. > > The patch attached to this e-mail fixes that by introducing a new > io:setopt() option in group.erl named 'max_length' that is used to check > whether the current line length exceeds this maximum whenever the line > is edited. If an overlong line is detected, max_length bytes are > returned immediately (without the actual stop condition being fulfilled, > though, allowing I/O clients to detect this situation). > > max_length is allowed to be an integer() > 0 or 'unlimited'. The default > is 'unlimited' to have the old behaviour by default. > > > > Kind regards, > > _______________________________________________ > erlang-patches mailing list > erlang-patches@erlang.org > http://erlang.org/mailman/listinfo/erlang-patches -- Dr. Stefan Zegenhagen arcutronix GmbH Garbsener Landstr. 10 30419 Hannover Germany Tel: +49 511 277-2734 Fax: +49 511 277-2709 Email: stefan.zegenhagen@arcutronix.com Web: www.arcutronix.com *Synchronize the Ethernet* General Managers: Dipl. Ing. Juergen Schroeder, Dr. Josef Gfrerer - Legal Form: GmbH, Registered office: Hannover, HRB 202442, Amtsgericht Hannover; Ust-Id: DE257551767. Please consider the environment before printing this message. >From b8b904f4ca1e0b418f8e758c9aa5e43b6469c3b4 Mon Sep 17 00:00:00 2001 From: Stefan Zegenhagen <stefan.zegenhagen@arcutronix.com> Date: Tue, 7 May 2013 14:14:50 +0200 Subject: [PATCH] limit line length in interactive shells Since the I/O server in group.erl was always collecting full lines before doing any further end-of-input processing, it was possible to crash any erlang system by just sending tons of characters without any newline to an interactive shell. Fix that by allowing to specify a maximum input length. Whenever new characters are received from the input device, check whether the new input exceeds the maximum line length and if so, return the data that was read so far (up to the maximum line length characters).
* | | | Merge branch 'sze/edlin_understand_keys' into puFredrik Gustafsson2013-08-011-0/+30
|\ \ \ \
| * | | | make edlin understand a few important control keysStefan Zegenhagen2013-05-061-0/+30
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Dear all, the patch attached to this e-mail teaches edlin.erl a few more important control keys that many users might have become *VERY* accustomed to. The control keys are: - <CTRL>+W : backward kill word - <CTRL>+U : backward kill line - <HOME> : goto start of line - <END> : goto end of line - <CTRL>+<LEFT> : backward word - <CTRL>+<RIGHT> : forward word With this patch in place, command line editing in erlang's own shell as well as in any input using io:get_line() comes a little closer to that in many contemporary shells. Kind regards, -- Dr. Stefan Zegenhagen arcutronix GmbH Garbsener Landstr. 10 30419 Hannover Germany Tel: +49 511 277-2734 Fax: +49 511 277-2709 Email: stefan.zegenhagen@arcutronix.com Web: www.arcutronix.com *Synchronize the Ethernet* General Managers: Dipl. Ing. Juergen Schroeder, Dr. Josef Gfrerer - Legal Form: GmbH, Registered office: Hannover, HRB 202442, Amtsgericht Hannover; Ust-Id: DE257551767. Please consider the environment before printing this message. >From 39f497adec90fc397f366da275fd5a7ca748cc5f Mon Sep 17 00:00:00 2001 From: Stefan Zegenhagen <stefan.zegenhagen@arcutronix.com> Date: Mon, 6 May 2013 14:39:07 +0200 Subject: [PATCH] [EDLIN] support a few more control keys Add support for the following control keys that many users have become accustomed to: - <CTRL>+W : backward kill word - <CTRL>+U : backward kill line - <HOME> : goto start of line - <END> : goto end of line - <CTRL>+<LEFT> : backward word - <CTRL>+<RIGHT> : forward word It seems that the <CTRL>+<LEFT|RIGHT> control key sequences are different between terminal emulators, therefore a few possible combinations were added (similar to how libreadline is configured).
* | | | Merge branch 'jv/update-io_prompt-type/OTP-11208' into maintBjörn-Egil Dahlberg2013-07-241-1/+1
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | * jv/update-io_prompt-type/OTP-11208: Update io:prompt() type
| * | | | Update io:prompt() typeJosé Valim2013-07-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Functions that expect an io:prompt() also accept binaries and iolists as arguments. Therefore its type has been updated to reflect the same types accepted by other io functions.
* | | | | Update filelib.erl typespecsJosé Valim2013-07-211-10/+13
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most functions in filelib support binaries as arguments but that was not reflected in the typespecs. The types filename_all() and dirname_all() were introduced to mimic file:name_all().
* | | | Merge branch 'genrich/stdlib/gen_server_typo/OTP-11200' into maintFredrik Gustafsson2013-07-091-1/+1
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | * genrich/stdlib/gen_server_typo/OTP-11200: handle_info Info type possible typo
| * | | | handle_info Info type possible typogenrich2013-06-081-1/+1
| | | | | | | | | | | | | | | Should it be 'timeout' instead of timeout(), as in doc: http://www.erlang.org/doc/man/gen_server.html#Module:handle_info-2?
* | | | | Update copyright yearsBjörn-Egil Dahlberg2013-06-128-8/+8
|/ / / /
* | | | Merge branch 'jv/erl_lint-default_types/OTP-11143' into maintFredrik Gustafsson2013-06-051-71/+66
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * jv/erl_lint-default_types/OTP-11143: Updated primary bootstrap stdlib: re-factored erl_lint.erl Improve erl_lint performance
| * | | | stdlib: re-factored erl_lint.erlFredrik Gustafsson2013-05-281-1/+4
| | | | |
| * | | | Improve erl_lint performanceJosé Valim2013-05-281-71/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The default_types() in erl_lint returned a dictionary with all default types. However, calculating this dict was expensive and we actually didn't use the default values in this dictionary. This patch replaces the dictionary use for one function that checks if the type is a default type or not, and remove the bits that checked explicitly for those default types when iterating the dictionary.
* | | | | Merge branch 'nox/erl_pp-callback/OTP-11140' into maintFredrik Gustafsson2013-06-041-3/+5
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * nox/erl_pp-callback/OTP-11140: Update primary bootstrap Support callback attributes in erl_pp
| * | | | | Support callback attributes in erl_ppAnthony Ramine2013-05-281-3/+5
| |/ / / /
* | | | | beam_lib: Correct wrong type specificationBjörn Gustavsson2013-06-041-1/+1
| | | | | | | | | | | | | | | | | | | | The function was updated in 5805b576, but not the type specificatin.
* | | | | Merge branch 'bmk/snmp/snmp424_integration/r16' into maintMicael Karlberg2013-06-031-1/+3
|\ \ \ \ \
| * \ \ \ \ Merge branch 'bmk/snmp/agent/mib_storage_behaviour/OTP-11107' into ↵Micael Karlberg2013-05-281-1/+3
| |\ \ \ \ \ | | |/ / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | bmk/snmp/snmp424_integration/r16 Conflicts: lib/snmp/doc/src/notes.xml
| | * | | | [stdlib] Updated for snmp deprecationsMicael Karlberg2013-05-281-1/+3
| | | | | |
* | | | | | Merge branch 'nox/erl_eval-receive/OTP-11137' into maintFredrik Gustafsson2013-06-031-53/+11
|\ \ \ \ \ \ | |_|_|_|/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * nox/erl_eval-receive/OTP-11137: Updated primary bootstrap for erl_eval Added preloaded prim_eval Fix receive support in erl_eval with a BEAM module
| * | | | | Fix receive support in erl_eval with a BEAM moduleAnthony Ramine2013-05-281-53/+11
| |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using the low-level BEAM instructions, we can loop over each message in the process queue and removes the first message that matches, without receiving them all to later send them back to itself. The function prim_eval:'receive'/2 is equivalent to the following pseudo-code: 'receive'(F, T) -> RESET MESSAGE QUEUE POINTER, LOOP: case PEEK CURRENT MESSAGE WITH TIMEOUT T of {ok,Msg} -> case F(Msg) of nomatch -> DECREMENT TIMEOUT T, ADVANCE MESSAGE QUEUE POINTER, GOTO LOOP; Result -> RESET MESSAGE QUEUE POINTER, Result end; timeout -> RESET MESSAGE QUEUE POINTER, timeout end. To not break Dialyzer and other tools, we use a stub Erlang module which abstract code is forcefully inserted into prim_inet.erl afterwards compilation.
* | | | | Merge branch 'bjorn/stdlib/improve-ls/OTP-11108' into maintBjörn Gustavsson2013-05-291-2/+4
|\ \ \ \ \ | |/ / / / |/| | | | | | | | | | | | | | * bjorn/stdlib/improve-ls/OTP-11108: Teach c:ls/1 to show non-directory files
| * | | | Teach c:ls/1 to show non-directory filesBjörn Gustavsson2013-05-221-2/+4
| | |_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In an email to erlang-questions, Bengt Kleberg wrote: When I use c:ls/1 it reminds me so much of Unix "ls" that I expect c:ls("filename") to work. The resulting error surprises me every time (not the same day). While teaching c:ls/1 to show non-directory files, update the error handling to make use of the POSIX error codes from file:list_dir/1 and file:format_error/1 (which had not been invented when the c module was first implemented). Suggested-by: Bengt Kleberg Test-suite-by: Bengt Kleberg
* | | | beam_lib, compile: Replace use of deprecated crypto functionsBjörn Gustavsson2013-05-201-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since both the STDLIB and compiler applications turn warnings into errors, we must stop using the old deprecated crypto functions. While we are at it, generalize the format of the key tuple returned by beam_lib:make_crypto_key/2 to facilitate introducing new crypto methods in the future. Change the format to: {Type,Key,IV,BlockSize} where Type, Key, and IV are the first three arguments for either crypto:block_encrypt4/ or crypto:block_decrypt/4, and BlockSize is the block size for the crypto algorithm (it is needed to properly pad the plaintext blocks before encryption).
* | | | crypto: Correct deprecated informationIngela Anderton Andin2013-05-201-14/+58
|/ / /
* | | [stdlib] Fix pretty printing of invalid formsHans Bolinder2013-05-161-16/+17
| | | | | | | | | | | | Thanks to Tomáš Janoušek.
* | | ssl & crypto: Generalize the remaining crypto APIIngela Anderton Andin2013-05-081-1/+1
| | |
* | | crypto: New API for ciphersIngela Anderton Andin2013-05-081-0/+61
| | |
* | | crypto: Deprecate functions, update doc and specsIngela Anderton Andin2013-05-081-0/+72
| |/ |/|
* | Merge branch 'nox/fix-epp-file-attrs/OTP-11079' into maintFredrik Gustafsson2013-05-031-1/+1
|\ \ | | | | | | | | | | | | * nox/fix-epp-file-attrs/OTP-11079: Fix an inconsistent state in epp
| * | Fix an inconsistent state in eppAnthony Ramine2013-04-261-1/+1
| |/ | | | | | | | | | | When entering a new file, epp doesn't properly set #epp.name2 like it does on initialisation, generating a malformed file attribute when it leaves the file.
* | Rename and document lists:zf/2 as lists:filtermap/2Anthony Ramine2013-04-301-7/+17
|/ | | | | | This function is used all over the place in OTP itself and people sometimes want that functionality, they may as well not reimplement it themselves.
* fix excessive CPU consumption of timer_serverAliaksey Kandratsenka2013-04-191-2/+2
| | | | | | | | | | | | | | | | | | | | I've found stdlib's timer to burn CPU without good reason. Here's what happens. The problem is that it sleeps in milliseconds but computes time in microseconds. And there is bug in code to compute milliseconds to sleep. It computes microseconds difference between now and nearest timer event and then does _truncating_ division by 1000. So on average it sleeps 500 microseconds _less than needed_. On wakeup its checks do I have timer tick that already occurred? No. Ok how much I need to sleep ? It does that bad computation again and gets 0 milliseconds. So next gen_server timeout happens right away only to find we're still before closest timer tick and to decide to sleep 0 milliseconds again. And again and again. This commit changes division to pick ceiling of ratio rather than floor. So that we always sleep not less then difference between now and closest event time.
* Merge branch 'jaf/fix-supervisor-multi-restart/OTP-11042' into maintFredrik Gustafsson2013-04-151-5/+22
|\
| * Fix rest_for_one and one_for_all restarting a child not terminatedJames Fish2013-04-041-5/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In rest_for_one and one_for_all supervisors one child dying can cause multiple children to be restarted. Previously if the child that caused the restart is started successfully but another child fails to start, the supervisor would not terminate this child with the other successfully restarted children as no record of the pid was kept. Thus the supervisor would try to start this child again. This could lead to multiples of the same child or if the child is registered cause repeated attempts at starting this child - until the max restart threshold was reached. Now the child that failed to start becomes the restarting child, instead of staying with the same child, for the next restart attempt. This has the following side effects: 1) In one_for_all the new version of the child that original died is terminated before a restart attempt is made. 2) In rest_for_one all succesfully restarted children are not terminated and restarting continues from the child that failed to start.
* | Merge branch 'lh/demonitor-flush/OTP-11039' into maintFredrik Gustafsson2013-04-154-28/+8
|\ \ | | | | | | | | | | | | * lh/demonitor-flush/OTP-11039: Use erlang:demonitor(Ref, [flush]) where applicable
| * | Use erlang:demonitor(Ref, [flush]) where applicableLoïc Hoguin2013-04-054-28/+8
| | |
* | | Merge branch 'lh/otp-optims/OTP-11035' into maintFredrik Gustafsson2013-04-111-15/+16
|\ \ \ | |/ / |/| | | | | | | | | | | * lh/otp-optims/OTP-11035: Use erlang:demonitor's flush option on timeout Don't lookup the node unless required in gen:call/{3,4}
| * | Use erlang:demonitor's flush option on timeoutLoïc Hoguin2013-04-011-5/+1
| | | | | | | | | | | | It is equivalent to the few lines removed, except more efficient.
| * | Don't lookup the node unless required in gen:call/{3,4}Loïc Hoguin2013-04-011-10/+15
| | | | | | | | | | | | | | | | | | Move some operations that aren't required for the happy path. The operations were small, so they shouldn't show a big difference in benchmarks except for systems with many active gen processes.
* | | Merge branch 'sv/stdlib/sys-get-state/OTP-11013' into maintFredrik Gustafsson2013-04-044-0/+68
|\ \ \ | |_|/ |/| | | | | | | | | | | | | | * sv/stdlib/sys-get-state/OTP-11013: Removed ?line macro add sys:get_state/1,2 and sys:replace_state/2,3 update sys:get_status/2,3 documentation for gen_event
| * | add sys:get_state/1,2 and sys:replace_state/2,3Steve Vinoski2013-04-024-0/+68
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At Erlang Factory 2013 there was discussion during one of the talks about the sys:get_status functions and how useful they were for debugging. Geoff Cant mentioned it would be very useful if the sys module also provided functions to use while debugging to get just the state of a process and also to be able to replace the state of a process, and many others in the audience appeared to agree. The sys:get_state/1,2 functions return the state of a gen_server, gen_fsm, or gen_event process. The return value varies depending on the process type: process state for a gen_server, state name and state data for a gen_fsm, and handler module, handler id, and handler state for each handler registered in a gen_event process. The sys:replace_state/2,3 functions allow the state of a gen_server, gen_fsm, or gen_event process to be replaced with a new state. These functions take a function argument that updates or replaces the process state; using a function to change the state eliminates the race condition of first reading the state via sys:get_state/1 or sys:get_state/2, using its return value to create a new state, and then replacing the old state with the new state, since during that time the process might have received other calls or messages that could have changed its state. * For a gen_server process, the state replacement function takes the process state as an argument and returns a new state. * For a gen_fsm process, the state replacement function gets a tuple of {StateName, StateData} and returns a similar tuple that specifies a new state name, new state data, or both. * For a gen_event process, the state replacement function is called for each registered event handler. It gets a tuple {Module, Id, HandlerState} and returns a similar tuple that specifies the same Module and Id values but may specify a different value for HandlerState. If the state replacement function crashes or results in an error, the original state of a gen_server or gen_fsm process is maintained; if such a crash occurs for a gen_event process, the original state of the event handler for which the state replacement function was called is maintained, but the states of other event handlers of the same gen_event process may still be updated if no errors or crashes occur while replacing their states. Add documentation for sys:get_state/1,2 and sys:replace_state/2,3. The documentation explicitly notes that the functions are intended for use during debugging. Add new tests for these functions to gen_server_SUITE, gen_fsm_SUITE, and gen_event_SUITE.
* | Document erl_parse:abstract/2Hans Bolinder2013-03-291-0/+1
| | | | | | | | | | | | A bug has been fixed: when given the option {encoding,utf8} a list of floating point numbers (in the correct interval) was mistakenly returned as a string.
* | Fix a bug in the Erlang scannerHans Bolinder2013-03-281-0/+1
|/ | | | | The scanner did not crash when a floating point number was encountered in the input string.