This reverts commit 6568096a.
Reverting fixes the following bug:
Using the END key (or whatever equivalent defined) does show the
last page, but the TOC is not scrolled to the number if the number
is outside the current TOC scroll window. It scrolls somewhere near
if the UP key is pressed afterwards. An annoying additional space
is shown beyond the last entry if you scroll down to the last position
using the slider.

As sec_sscanf's arguments cannot be checked by gcc for correctness,
and the code gets less wasteful, shorter and IMHO more readable,
replace easily replaceable invocations with more manual implementations.

This should fix http://bugs.debian.org/627471
Bernhard R. Link finally found the bug (excellent job!). He
describes the bug as follows:
ps.c is using some sec_sscanf (from secscanf.c) instead of
regular sscanf or instead of doing some proper parsing.
As sec_sscanf differs from regular sscanf about it variadic
arguments gcc cannot test if the arguments given match the
format string, especially it is lost about sec_sscanf
wanting a 'char *' and a 'size_t' for ever '%s' or '%256s'
it gets. Thus when ps.c does
sec_sscanf(line+lenght("%%BoundingBox:), "%256s", text);
the size of text field is not given, so some random value
is returned by the 'va_arg(ap, size_t)' in secscanf.c
If that random value is smaller than the length of "(atend)"
then this will be copied incompletely and thus
not be recognized.

Errno will usually be a macro nowadays (to make use of thread local
storage), so defining it as
extern int errno;
is made by the preprocessor to:
extern int (*__errno_location ());
which luckily currently still works, but shows that is really not
what should be done, so remove the definitions. (Which also silences
a compiler warning).

As numpages and nummedia are usually compared to int
and assigned to them, the bigger unsigned values cannot
be used anway, so make them int to avoid all kind of warnings.
Also remove some casts no longer necessary due to that.

* Markus Steinborn <gnugv_maintainer@yahoo.de> [110506 13:28]:
> Hello Bernhard,
>
> I've applied the other three patches.
>
> Bernhard R. Link schrieb:
>> With fallback styles enabled (currently default), gv_spartan.dat and
>> gv_widgetless.dat are always replaced with compiled in versions,
>> so do not install those files to not confuse users with installing
>> files that have no effect if changed.
>> ---
>>
> On my system, GNU gv 3.7.2 installs the following files within
> /usr/share/gv/
>
> /usr/share/gv/GV
that is stored in appdefaultsdir (which by default might be the same,
but can thus be installed in a way that it is used.
> /usr/share/gv/gv_class.ad
> /usr/share/gv/gv_copyright.dat
> /usr/share/gv/gv_spartan.dat
> /usr/share/gv/gv_system.ad
> /usr/share/gv/gv_user.ad
> /usr/share/gv/gv_user_res.dat
> /usr/share/gv/gv_widgetless.dat
>
> Except "/usr/share/gv/gv_system.ad" none is read iff fallback styles are
> enabled. I do not see any reason to handle gv_spartan.dat and
> gv_widgetless.dat different from the raiming gv_*-files (except
> gv_system.ad).
I did not realize that. I only saw that those two are used with fallback
styles and not without. What about the following then?
>From 6540ff7072006cc84768704c1e0ceef80544be13 Mon Sep 17 00:00:00 2001
From: Bernhard R. Link <brlink@debian.org>
Date: Thu, 28 Apr 2011 16:24:16 +0200
Subject: [PATCH] don't install .ad files not used
Only install files gv actually reads. Having other files around
is confusing as changing them has no effect.
With fallback styles enabled (currently default), gv_spartan.dat and
gv_widgetless.dat are always replaced with compiled in versions,
so only install them if fallback styles are disabled.

file_translateTildeInPath currently translates the first ~ it finds.
This is different from shell which only translates it if it is the
first character of a word and not if other letters follow.
As file_translateTildeInPath is always called with a single filename,
only replace it if this string is "~" or starts with "~/".
Additionally add an size argument to the function, so that no string
buffers can overrun and do not access a NULL pointer if HOME is not set.

The current search path is current directory, home directory,
and then GV_LIBDIR (but no /) prepended.
As GV_LIBDIR without the slash cannot have worked for anyone
yet and looking into the current directory is quite some security
risk (in case anyone actually used that option), reject filenames
not being absolute.

Make distcheck fails because a gv-i18n.h file is left over
after building and dist-cleaning.
To avoid this make gv-i18n.h not depend on the nls/ directory
(causing rebuilds of this file), but list the languages
to include in a nls/LANGUAGES files.
Additionally move it from EXTRA_DIST to gv_SOURCES proper.
Version 2 of this patch should fix some problems when building
directly from git and documents the replacement of .lnk files