Fix typo in validate_manual_hostkey().

'p += strcspn' returns p always non-NULL and sometimes pointing at \0,
as opposed to 'p = strchr' which returns p sometimes non-NULL and
never pointing at \0. Test the pointer after the call accordingly.
Thanks, Coverity.
Clarify when ldisc->term may be NULL.

Namely, any ldisc that you send actual data through should have a
terminal attached, because the ldisc editing/echoing system is
designed entirely for use with a terminal. The only time you can have
an ldisc with no terminal is when it's only ever used by the backend
to report changes to the front end in edit/echo status, e.g. by Unix
Plink.

Coverity spotted an oddity in ldisc_send which after a while I decided
would never have actually caused a problem, but OTOH I agree that it
was confusing, so now hopefully it's less so.
Fix uninitialised variable in two Windows event loops.

If (Msg)WaitForMultipleObjects returns WAIT_TIMEOUT, we expect 'next'
to have been initialised. This can occur without having called
run_timers(), if a toplevel callback was pending, so we can't expect
run_timers to have reliably initialised 'next'.

I'm not actually convinced this could have come up in either of the
affected programs (Windows PSFTP and Plink), due to the list of things
toplevel callbacks are currently used for, but it certainly wants
fixing anyway for the future.

Spotted by Coverity.
Fix assorted memory leaks.

All spotted by Coverity.
Don't reject _and_ accept X forwarding requests!

If a sharing downstream asks for an auth method we don't understand,
we should send them CHANNEL_FAILURE *and then stop processing*. Ahem.

(Spotted while examining this code in the course of Coverity-related
fixes, but not itself a Coverity-found problem.)
Add some missing initialisations.

Spotted by valgrind, after I was testing all the Coverity bug fixes :-)
Merge branch 'pre-0.64'
Move echo/edit state change functionality out of ldisc_send.

I'm not actually sure why we've always had back ends notify ldisc of
changes to echo/edit settings by giving ldisc_send(ldisc,NULL,0,0) a
special meaning, instead of by having a separate dedicated notify
function with its own prototype and parameter set. Coverity's recent
observation that the two kinds of call don't even have the same
requirements on the ldisc (particularly, whether ldisc->term can be
NULL) makes me realise that it's really high time I separated the two
conceptually different operations into actually different functions.

While I'm here, I've renamed the confusing ldisc_update() function
which that special operation ends up feeding to, because it's not
actually a function applying to an ldisc - it applies to a front end.
So ldisc_send(ldisc,NULL,0,0) is now ldisc_echoedit_update(ldisc), and
that in turn figures out the current echo/edit settings before passing
them on to frontend_echoedit_update(). I think that should be clearer.
Consistently use &def for %makefile_extra pieces.

mkfiles.pl was giving a couple of annoying perl warnings, because some
makefile_extra strings were never set by Recipe. We already have the
&def function to convert undefs into "" for this reason, but weren't
using it everywhere. Now I think we are.
Another missing initialisation.

This one spotted in the old-fashioned way, by actually attempting a
Plink raw connection and wondering why it didn't seem to be reading
from standard input! Turns out 'bufsize' is uninitialised until the
first send, which can inhibit any stdin reading if it gets a large
enough nonsense value.
Stop referring to Plink as "PuTTY Link".

I don't think anyone has ever actually called it that, colloquially
_or_ formally, and if anyone ever did (in a bug report, say) I'd
probably have to stop and think to work out what they meant. It's
universally called Plink, and should be officially so as well :-)
Merge branch 'pre-0.64'
Repair GTK timer handling

The bug eventually makes PuTTY take 100% of a CPU.

timing.c:  This patch stops run_timers returning with a next timer
interval of zero ms. Which gets rid of the CPU spinning caused by other
parts of the code needing the timer to have passed.

unix/gtkwin.c: The code called from run_timers is likely to create a
new timer when it runs before timer_trigger adds the next timer that
run_timers returns. This would mean that two timers get scheduled
with gtk.

terminal.c: Make sure terminal.c doesn't waste CPU doing the text blink
timer when we don't have focus. Naturally the text blink and a blinking
cursor will resync when we regain focus.

NB: Windows calls 'term_set_focus' a lot .. Yes you still have focus
Repair GTK timer handling: Partial revert.

Something similar is now in SGT's base code.
Pango font performance update

This change improves the speed of the best case pango font
processing.  It removes multiple calls to pango_layout_set_text and
pango_layout_get_pixel_extents that were used to check that every prefix
string of a given draw_text is actually the correct size.

Instead the function now checks just once before painting the text
that the size of the whole region is correct. If it's not correct it
falls back to painting one character at a time immediatly rather than
optimistically trying lots of substrings; this normally improves the
draw time of complex screens and proportional fonts too.

If there are compensating layout issues within the string they won't
cause problems because terminal.c already has code to redraw any row
of text that was drawn as one operation if it's split.
Minimise, maximise, etc are as annoying as other terminal resize operations.

Note they ARE resize operations so treat them as such and disable them
if requested.
Add XTerm extensions for VTTEST and reverse BS

Codes to enable and disable the DECCOLM 132/80 column switching DEC
control and XTerm's reverse BS hack to 'pass' the vttest option 1.

This means that PuTTY uses the same modal hack as XTerm to pass the vttest
'end of line' test, (Actually the reverse part) and Thomas can stop lying
about PuTTY in the xterm FAQ.  The second part prevents the default xterm
'init' sequence from terminfo clearing the screen.

In addition most applications realise that terminal resizes are requests
and that you likely won't get what you ask for.  Programs (like vttest)
that use the sequence DECCOLM aren't so smart so the change is immediatly
enacted.
Adjust DEC-MCS character set.

U+2426 "␦" is defined as the substitution character in DEC-MCS

Note: dec_mcs is a 94 character set so 0xA0 and 0xFF are not defined in
a different way when it's mapped into GR.
Optimisation to delete windows code on unix

Changed is_dbcs_leadbyte to a macro on unix so the compiler knows
it's always zero.
Windows codepages do not have C1 controls

MS CP125X do NOT actually have any high control characters, the MS tables
show some of them but they are never interpreted by Microsoft software
and, as they have done before, MS will replace them by any new characters
that may be useful in the future.

Also eliminates as possible security risk where control characters are
not expected in Windows csets by host software.