Fix crash in mnesia_controller due to a function_clause exception from is_tab_blocked/1

If mnesia_controller:block_table/1 is called twice for same table,
the new stored value of {Tab, where_to_commit} will be {blocked, {blocked,List}}.
This will result in an exception when calling is_tab_blocked/1.
mnesia_conttoller:block_table/1 should check if the table is already blocked.
Make ssh_cli.erl handle <CTRL>+C

Dear all,

I've found that ssh_cli.erl does not scan the input received from the
remote for occurrences of <CTRL>+C to signal the user's interrupt
requests to the group_leader of the CLI session. The patch attached to
this e-mail fixes the issue.

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 f1d056ed1bf419677098cdc57bc7ce8a327e6b43 Mon Sep 17 00:00:00 2001
From: Stefan Zegenhagen <stefan.zegenhagen@arcutronix.com>
Date: Mon, 6 May 2013 14:29:45 +0200
Subject: [PATCH] [SSH-CLI] properly handle <CTRL>+C as shell interrupt

In ssh_cli.erl, check for the presence of <CTRL>+C in data received from
the remote. If detected, use the established mechanism (send an
'interrupt' exit signal to the group_leader) to signal an interrupt to
the shell.
make edlin understand a few important control keys

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).
Added primary bootstrap
Limit maximum line length in interactive shells

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).
Fix I/O-protocol error handling in eunit

ex_unit:io_request reuturns wrong value when it receive getopts or
get_geometry request
Restrict inlining of local fun references

Local fun references look like plain old variables in the Core Erlang
AST and should not be treated as such. Inlining of such expressions is
now restricted to application contexts as a local fun reference should
never occur in a guard.

This is not perfect as it forbids inlining in some safe situations, but
that is still better than a compiler crash.
Fix reverting of implicit funs

Implicit funs parts in plain AST are no longer in concrete form since
Erlang/OTP R15.
Fix transformation of implicit funs in igor

Function erl_syntax_lib:analyze_implicit_fun/1 should not be called on
implicit external funs, as their parts can contain variables instead of
atoms and integers.
Remove a useless function clause in erl_syntax_lib
Small fix to to_erl

Dear all,

we've stumbled across a small problem.

One of our devices does not like 'to_erl' to be run over a serial port.
When to_erl is started, we see "Attaching to /tm<0xFF>" being printed
and the device then refuses to accept any input. Occasionally, we have
seen a linux kernel error message "serial8250: too much work for irq16"
simultaneously. After some debugging we found out that cause is a call
to tcsetattr() by to_erl, immediately preceeded by some printf().

The UART in our device doesn't like hardware parameters to be changed
while output is concurrently active. In fact, the GNU libc manual also
mentions that it might be dangerous to change UART hardware parameters
when a transmission is ongoing.

The patch attached to this e-mail changes the behaviour of to_erl to use
TCSADRAIN instead of TCSANOW when changing terminal parameters. This
makes the serial driver wait for the output queues to be empty before
applying the terminal parameter change.

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 1f84b4ebd46da83e317cb15a37ef7d12206687df Mon Sep 17 00:00:00 2001
From: Stefan Zegenhagen <stefan.zegenhagen@arcutronix.com>
Date: Wed, 29 May 2013 16:22:34 +0200
Subject: [PATCH] Fix changing terminal parameters in to_erl

to_erl is changing quite a number of terminal parameters that might
affect the underlying serial port hardware. The UART, however, may
dislike this parameter change when output is concurrently active, so use
TCSADRAIN instead of TCSANOW for changing the terminal parameters.
Added an initial implementation of having erl_tidy print to screen instead of writing to the file provided. The reason for this is that you may want to have an intermediary step between saving the tidied file and using the output. Use-case personally is wanting to integrate erl_tidy into emacs and tidy buffers, overwriting the current file is generally not how this works in emacs with source code tidiers.
Changed function call for print_module

Changed the function call for print module to the one which matches
the actual function is.
Added documenation for the new option describing what it does.
Fix no return of io functions when self() used as Iodevice

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.
Fix variable usage tracking in erl_lint

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 does not correctly follow this behaviour.

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
Primary bootstrap
Silence a misleading warning with some comprehensions

When compiling comprehensions with generators which are foldable to
'true', a misleading warning is emitted by sys_core_fold because a
clause resulting from the compilation of the comprehension to Core
Erlang is not marked as generated by the compiler.

An example of such a comprehension is [ true || true ].
Bootstrap
Wrap eunit macros into begin ... end blocks

This makes typos such as missing commas between two assertions
(e.g. ?assert(true) ?assert(true)) syntax errors instead of silently
compiling and failing with a badfun error at runtime.

This won't break any existing code as parenthesed expressions and blocks
have the same precedence and none of these macros can be used as patterns.