The test suite can be run in some cross-compilation setups (say, MinGW
on Linux). Howerver CTest's add_test command does not add the .exe
suffix on its own, as a result `make test' fails. Let's help add_test a bit.

TeX Live 2012 seems to dislike files produces by doxygen (1.8.x.y).
In particular, makeindex(1) program creates invalid index entries like

\hyperpage{NNN_}

(note the trailing underscore in the page number). This breaks automatic
builds and is very annoying. This patch works around the problem by
post-processing the generated *.ind file. This hack is a bit crude, however
it gets the job done (a proper fix is welcome, though).

6 If a template, a member template or the member of a class template
is explicitly specialized then that specialization shall be declared
before the first use of that specialization that would cause an implicit
instantiation to take place, in every translation unit in which such a
use occurs; no diagnostic is required. If the program does not provide
a definition for an explicit specialization and either the specialization
is used in a way that would cause an implicit instantiation to take place
or the member is a virtual member function, the program is ill-formed,
no diagnostic required. An implicit instantiation is never generated for
an explicit specialization that is declared but not defined.

Apparently we are breaking this rule (presumably since the commit 99901bd5c742
`Parser can now read GiNaC lists (lst) defined by braces.'). In particular,
parser.cpp does not include lst.h (neither directly nor indirectly) which
contains explicit specialization of lst::info(). However, parser.cpp
(indirectly) includes both container.h and registar.h, so the GiNaC::lst type
is declared (and is complete) before the first usage. Thus lst::info() gets
implicitly instantiated (using the general definition provided in container.h)
when compiling the parser.cpp file, and libginac fails to link properly due
to mutliply defined symbols:

When using GCC 4.6 the configure script fails to find libreadline and
libdl, although both libraries are definitely installed. See
http://www.ginac.de/pipermail/ginac-list/2012-January/001868.html for
more details.

Reason:

Apparently GCC 4.6 dislikes the -R/the/path switch (libtool way to say
-Wl,-rpath,/the/path in a cross platform manner). Previous versions of
GCC used to ignore the -R switch, however, GCC 4.6 errors out instead.
Thus the configure script fails to detect readline and dlopen.

Solution:

Set the rpath (for linking with CLN) using the compiler friendly syntax
(i.e. -Wl,-rpath -Wl,/the/path instead of -R/the/path).

Quick and dirty bug fix for the parser to read GiNaC::lst again.
The parser only accepts lst in the form lst(...) not {...}, though.
Function prototype can now have a argument size of 0 to indicate
functions with an arbitrary number of arguments (like lst).

Care about refcounts when reclaiming memory allocated for static objects.

With commit aff357309f6 we started freeing numeric flyweights when the library
usage count drops to zero. But that triggers assertions in basic::~basic
when compiled with -DDO_GINAC_ASSERT because these flyweights are still being
used by their matching ex objects (their refcount is still 1). Instead of
removing that assertion, let's just call the ex::~ex manually and let it do
the freeing.

This patch fixes a bug on machines where char is unsigned by default, by
extending the type of clifford_max_label to include all 257 possible
return values. Thanks to Martin Guy for the bug report and patch.

Changed naming convention for the library. Now, it is only libginac.so
without the release version included (instead of libginac-1.5.so, for
example). Since the previous commit broke the ABI, we are free to
implement this long planned change now.

The patch improves the run time at the expense of using more RAM in some
situations. Please note: it doesn't improve the actual algorithm
(iteration over all permutations). Thanks to Alexei Sheplyakov.

But the ability to do so is important for a lot of practical uses. So soon
after the C++98 standard was approved, a language defect report was filed
on this topic, see
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#195
The result is that compilers will be allowed to support reinterpret_cast
conversions of function pointers to other (pointers) types, and vice a versa.
Such conversions work with *current* compilers (GCC 4.x), but don't work
with older ones, hence this patch.

Commit 8bf0597dde55e4c94a2ff39f1d8130902e3d7a9b (titled as 'Fixed the parser
such that it can read in user defined classes again.') made the parser a bit
slower, especially if the input contains many terms of user-defined type.
The reason for that is quite simple: we throw and catch an exception every
time we construct an object of user-defined type:

Commit 3d09388a (titled as `[bugfix] chinrem_gcd: handle polynomials over
rationals properly.') broke extract_integer_content: now it always returns 1.
The check for rational `integer_contnent' introduced by that commit is wrong
(since integers is a subset of rationals). Rewrite the check proprerly.

The method in question is const, therefore one should use const_iterator
to access indices. Some compilers (for instance, msvc) are very strict
about this, and won't accept (invalid) code using non-const iterator.

* extract_integer_content():
integer_content() can also return a rational number, e.g if the expression
is a polynomial over rationals (in this case expr/content is polynomial
over integers with integer content being 1). Therefore check if
integer_content() is really an integer (and if it's not just return 1,
GCD for polynomials over a field is defined up to arbitrary element of
the field).

This fixes possible segfault when computing GCD of polynomials over
rationals (this is not theoretical, see the added test case).

* extract_integer_content():
integer_content() can also return a rational number, e.g if the expression
is a polynomial over rationals (in this case expr/content is polynomial
over integers with integer content being 1). Therefore check if
integer_content() is really an integer (and if it's not just return 1,
GCD for polynomials over a field is defined up to arbitrary element of
the field).

This fixes possible segfault when computing GCD of polynomials over
rationals (this is not theoretical, see the added test case).

However, the size of arrays (`vectors' in STL speak) passed to this
function is seq.size(), which is nops() - 1 for any mul object. Thus
algebraic_match_mul_with_mul() accesses beyond the arrays limit. Usually
it's not a problem, since any reasonable implementation of std::vector<bool>
packs booleans into ints (or longs). However, some STL implementations
(in particular, the one shipped with msvc) are more picky, and access
beyond the vector<bool> limits results in a segfault. Therefore let's
play safe and allocate proper number of elements (that is, nops()) for
those arrays (subsed and currsubsed).
(cherry picked from commit cbb93fadabbd56ba006902967b15b2b2aebb037c)

However, the size of arrays (`vectors' in STL speak) passed to this
function is seq.size(), which is nops() - 1 for any mul object. Thus
algebraic_match_mul_with_mul() accesses beyond the arrays limit. Usually
it's not a problem, since any reasonable implementation of std::vector<bool>
packs booleans into ints (or longs). However, some STL implementations
(in particular, the one shipped with msvc) are more picky, and access
beyond the vector<bool> limits results in a segfault. Therefore let's
play safe and allocate proper number of elements (that is, nops()) for
those arrays (subsed and currsubsed).

symbol::read_archive(): explicitly set status_flags::evaluated (and
status_flags::expanded) on object being unarchived. These flags get
reset by basic::operator=(const basic&) for realsymbol and possymbol,
and nothing sets (except symbol ctor), so automatic evaluation never
terminates (or rather, terminates due to a stack overflow). Therefore
it's necessary need to set status_flags::evaluated explicitly.

symbol::read_archive(): explicitly set status_flags::evaluated (and
status_flags::expanded) on object being unarchived. These flags get
reset by basic::operator=(const basic&) for realsymbol and possymbol,
and nothing sets (except symbol ctor), so automatic evaluation never
terminates (or rather, terminates due to a stack overflow). Therefore
it's necessary need to set status_flags::evaluated explicitly.

Apparently, add::eval() assumed that none of the elements of its epvector
has a numeric rest. However, nothing guarantees that -- in particular
evalchildren() doesn't (and actually cannot) do so. Since there are many
places where a new add is constructed directly from an epvector, enforcing
this doesn't make sense either. One example where it did fail was found by
Burgin Erocal: real_part(1+2*(sqrt(2)+1)*(sqrt(2)-1)) returned 1+2*1, not 3.

Apparently, add::eval() assumed that none of the elements of its epvector
has a numeric rest. However, nothing guarantees that -- in particular
evalchildren() doesn't (and actually cannot) do so. Since there are many
places where a new add is constructed directly from an epvector, enforcing
this doesn't make sense either. One example where it did fail was found by
Burgin Erocal: real_part(1+2*(sqrt(2)+1)*(sqrt(2)-1)) returned 1+2*1, not 3.

Substituting x==log(x) in exp(x) erroneously returned log(x) because of a
final subst(x==log(x)) after having eval'ed exp(log(x)) -> x. This final
substitution is wrong in the general case. On the other hand, the intent
is to syntactically substitute functions of a given kind etc. This patch
suppresses the final top-level substitution unless the intermediate result
is a container.

Thanks to Burcin Erocal for reporting this bug (originally described by
Kees van Schaik on sage-support@googlegroops.com).

Substituting x==log(x) in exp(x) erroneously returned log(x) because of a
final subst(x==log(x)) after having eval'ed exp(log(x)) -> x. This final
substitution is wrong in the general case. On the other hand, the intent
is to syntactically substitute functions of a given kind etc. This patch
suppresses the final top-level substitution unless the intermediate result
is a container.

Thanks to Burcin Erocal for reporting this bug (originally described by
Kees van Schaik on sage-support@googlegroops.com).

Apparently, autoconf doesn't like the angle brackets in the bug-report
argument any more. It comlains "not a literal: <ginac-list@ginac.de>".
So let's remove it. And while at it, also provide tarname and url
arguments.

Apparently, autoconf doesn't like the angle brackets in the bug-report
argument any more. It comlains "not a literal: <ginac-list@ginac.de>".
So let's remove it. And while at it, also provide tarname and url
arguments.

In general, ex_to is unsafe, and should be used only after proper checks.
evalf() may return non-numeric expression for various reasons (bad
convergence, floating point over- or underflow, out of memory, etc).
So let's add missing checks.