Bug 694653: Watch for xref being NULL in pdf_xref_len

This can occur early on during xref repair.
Fix missing 'const' in fz_authenticate_password

The pdf_ versions were already correct. Probably just an
oversight that this was missed.
Bug 694565: Cope with negative xref counts when reading old trailers.

This was causing an infinite loop.
Bug 694557: Fix infinite loop in pdf_lex.

When we read a '>' during lexing, we try to read another char to see
if it's another '>'. If not, we warn that it's unexpected, put the char
back and retry.

Putting the char back fails if the '>' was the last char in the stream
as we will then have read EOF. We then loop and reread the '>' resulting
in an infinite loop. Simple fix is to check for EOF.
Bug 694566: Avoid locking up while seeking in deflated stream.

In streams that we cannot seek in (such as flate ones) we implement
seeking forward by skipping bytes. We failed to spot that we hit EOF,
and spent ages just looping. Fix is simply to spot that we hit EOF
and bale with a warning.
Android: fix missing fz_vars
iOS: use ObjC-level ref counting to control lifetime of fz_document

With the latest version if iOS, timing changes were causing crashes
during close down of a MuDocumentController. This change isolates
us from those changes.
iOS: add reflow mode
iOS: while adjusting reflow zoom, refresh only the visible page

At end of gesture all pages are refreshed so that newly-becoming-visible
pages appear at the correct zoom.
Android: while adjusting reflow zoom, refresh only the visible page

Also fix a race condition where an attempt to set the zoom might precede
the loading of html into the WebView
Fix typo in struct definition.

Thanks to Zaister for reporting this.
fix bug 694618

For Separation and DeviceN colorspaces, the initial color value is 1.0
for all components instead of 0.0 as for most other colorspaces. The
current initialization in pdf_set_colorspace initializes for CMYK which
happens to work for all non-tint colorspaces.
stop checking if the result of fz_read is negative

fz_read used to return a negative value on errors. With the
introduction of fz_try/fz_catch, it throws an error instead and
always returns non-negative values. This removes the pointless
checks.
preserve /Encrypt for documents with streamed xrefs

If /Encrypt is not present on an updated xref of an encrypted document,
that document can no longer be opened. This is required for incremental
saving.

Note: Streams aren't encrypted by pdf_write_document and can't thus
currently be appended to an encrypted document. In that case, saving
non-incrementally will produce a working (non-encrypted) document.
clip flate stream on data check error instead of rejecting it wholesale

This is required e.g. for 1798_-_zlib_incorrect_data_check.pdf .
don't reset the clipping rectangle for accumulated text

FZ_CMD_CLIP_TEXT behaves quite differently whether the accumulate flag
is set or not (see fz_list_clip_text). fz_run_display_list handles this
correctly but fz_append_display_node doesn't do so yet.
don't color transform RGB JPEG-in-TIFF images

TIFF images containing JPEG data only require color transformation for
CYMK data streams. For RGB streams, this could lead to unexpected
results.
tweak pdf_parse_action

* Destination names are a name and not a string
* Expose whether a /Launch action points to a path or a URI
fix some MSVC warnings

* unreachable code in fz_generate_transition
* signed/unsigned comparison in get_comp_index
* potential dataloss due to conversion from int to short in ucdn_mirror
add support for .tga output to mudraw

SumatraPDF's testsuite uses Targa images as output because they're
compressed while still far easier to compare than PNG and have better
tool support than PCL/PWG.