Remove unreachable duplicate (?#...) parsing code from S_reg()

I believe that this code was rendered unreachable when perl 5.001 added
code to S_nextchar() to skip over embedded comments. Adrian Enache noted
this in March 2003, and proposed a patch which removed it. See
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2003-03/msg00840.html

The patch wasn't applied at that time, and when he sent it again August,
he omitted that hunk. See
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2003-08/msg01820.html

That version was applied as commit e994fd663a4d8acc.
Perl_sv_uni_display() needs to be aware of RX_WRAPPED()

Commit 8d919b0a35f2b57a changed the storage location of the string in
SVt_REGEXP. It updated most code to deal with this, but missed the use of
SvPVX_const() in Perl_sv_uni_display(). This breaks dumping regular
expressions which have the UTF-8 flag set.
Test that S_grok_bslash_N() copes if S_reg() restarts the sizing parse.

S_reg() can discover midway through parsing the pattern to determine its
size, that the pattern will actually need to be encoded as UTF-8. If
calculations so far have been done in terms of bytes, then the macro
REQUIRE_UTF8 is used to restart the parse, so that sizes can be calculated
correctly for UTF-8.

It is possible to trigger this restart when processing multi-character
charnames interpolated into the pattern using \N{}. Test that this is
handled correctly.
Test that UTF-8 in the look-ahead of (?(?=...)...) restarts the sizing parse.

S_reg() recurses to itself to parse various constructions used as the
conditionals in conditional matching. Look-aheads and look-behinds can turn
out to need to be sized as UTF-8, which can cause the inner S_reg() to use
the macro REQUIRE_UTF8 is used to restart the parse. Test that this is
handled correctly.
Return orig_emit from S_regclass() when ret_invlist is true.

The return value isn't used (yet). Previously the code was returning END,
which is a macro for the regnode number for "End of program" which happens to
be 0. It happens that 0 is valid C for a NULL pointer, but using it in this
way makes the intent unclear. Not only is orig_emit a valid type, it's
semantically the correct thing to return, as it's most recently added node.
Document when and why S_reg{,branch,piece,atom,class}() return NULL.

As documented in pod/perlreguts.pod, the call graph for regex parsing
involves several levels of functions in regcomp.c, sometimes recursing more
than once.

The top level compiling function, S_reg(), calls S_regbranch() to parse each
single branch of an alternation. In turn, that calls S_regpiece() to parse
a simple pattern followed by quantifier, which calls S_regatom() to parse
that simple pattern. S_regatom() can call S_regclass() to handle classes,
but can also recurse into S_reg() to handle subpatterns and some other
constructions. Some other routines call call S_reg(), sometimes using an
alternative pattern that they generate dynamically to represent their input.

These routines all return a pointer to a regnode structure, and take a
pointer to an integer that holds flags, which is also used to return
information.

Historically, it has not been clear when and why they return NULL, and
whether the return value can be ignored. In particular, "Jumbo regexp patch"
(commit c277df42229d99fe, from Nov 1997), added code with two calls from
S_reg() to S_regbranch(), one of which checks the return value and generates
a LONGJMP node if it returns NULL, the other of which is called in void
context, and so both ignores any return value, or the possibility that it is
NULL.

After some analysis I have untangled the possible return values from these
5 functions (and related functions which call S_reg()).

Starting from the top:
S_reg() will return NULL and set the flags to TRYAGAIN at the end of pragma-
like constructions that it handles. Otherwise, historically it would return
NULL if S_regbranch() returned NULL. In turn, S_regbranch() would return
NULL if S_regpiece() returned NULL without setting TRYAGAIN. If S_regpiece()
returns TRYAGAIN, S_regbranch() loops, and ultimately will not return NULL.

S_regpiece() returns NULL with TRYAGAIN if S_regatom() returns NULL with
TRYAGAIN, but (historically) if S_regatom() returns NULL without setting
the flags to TRYAGAIN, S_regpiece() would to. Where S_regatom() calls
S_reg() it has similar behaviour when passing back return values, although
often it is able to loop instead on getting a TRYAGAIN.

Which gets us back to S_reg(), which can only *generate* NULL in conjunction
with TRYAGAIN. NULL without TRYAGAIN could only be returned if a routine it
called generated it. All other functions that these call that return regnode
structures cannot return NULL. Hence

1) in the loop of functions called, there is no source for a return value of
   NULL without the TRYAGAIN flag being set
2) a return value of NULL with TRYAGAIN set from an inner function does not
   propagate out past S_regbranch()

Hence the only return values that most functions can generate are non-NULL,
or NULL with TRYAGAIN set, and as S_regbranch() catches these, it cannot
return NULL. The longest sequence of functions that can return NULL (with
TRYAGAIN set) is S_reg() -> S_regatom() -> S_regpiece() -> S_regbranch().
Rapidly returning right round the loop back to S_reg() is not possible.

Hence code added by commit c277df42229d99fe to handle a NULL return from
S_regbranch(), along with some other code is dead.

I have replaced all unreachable code with FAIL()s that panic.
In S_regclass(), create listsv as a mortal, claiming a reference if needed.

The SV listsv is sometimes stored in an array generated near the end of
S_regclass(). In other cases it is not used, and it needs to be freed if
any of the warnings that S_regclass() can trigger turn out to be fatal.

The simplest solution to this problem is to declare it from the start as a
mortal, and claim a (new) reference to it if it is *not* to be freed. This
permits the removal of all other code related to ensuring that it is freed
at the right time, but not freed prematurely if a call to a warning returns.
Add a flag RESTART_UTF8 to the reg*() routines in regcomp.c

Add a flag RESTART_UTF8 along with infrastructure to the reg*() routines to
permit the parse to be restarted without using longjmp(). However, it's not
used yet.
Move the longjmp() that implements REQUIRE_UTF8 up to Perl_re_op_compile().

With longjmp() and setjmp() now in the same function (and all tests passing),
it becomes easy to replace the pair with a goto. Still evil, but "the lesser
of two evils".
Replace the longjmp()s in Perl_re_op_compile() with goto.

The regex parse needs to be restarted if it turns out that it should be done
as UTF-8, not bytes. Using setjmp()/longjmp() complicates compilation
considerably, causing warnings about missing use of volatile, and hitting
code generation errors from clang's ASAN. Using goto is much clearer.
In Perl_re_op_compile(), tidy up after removing setjmp().

Remove volatile qualifiers. Remove the variable jump_ret. Move the
initialisation of restudied back to the declaration. This reverts several of
the changes made by commits 5d51ce98fae3de07 and bbd61b5ffb7621c2.

However, I can't see a cleaner way to avoid code duplication when restarting
the parse than to approach I've taken here - the label redo_first_pass is
now inside an if (0) block, which is clear but ugly.
Revert "PATCH: regex longjmp flaws"

This reverts commit 595598ee1f247e72e06e4cfbe0f98406015df5cc.

The netbsd - 5.0.2 compiler pointed out that the recent changes to add
longjmps to speed up some regex compilations can result in clobbering a
few values.  These depend on the compiled code, and so didn't show up in
other compiler's warnings.  This patch reinitializes them after a
longjmp.

[With a lot of hand editing in regcomp.c, to propagate the changes through
subsequent commits.]
Document the uses of NULL returns in the regex parsing code.