Avoid strerror_s on MinGW-w64 for compatibility with Windows XP.

runtime/mercury_runtime_util.c:
	As above.
Fix problems with the char module.

(1) The behaviour of digit_to_int/2 was inconsistent with that of is_digit/2.
The former succeeds for all of 0-9, a-z and A-Z while the latter succeeds only
for 0-9 (i.e. it was possible for digit_to_int/2 to succeed for non-decimal
characters, which is not what was intended in many of it uses).

(2) Predicates involving hexadecimal digits were inconsistently named, they
were "hex digits" in one predicate name, "hex chars" in another.

This change ensures that the following operations are supported for binary,
octal, decimal and hexadecimal digits and that we use a consistent naming
scheme for the predicates that implement them:
    - testing if a character is a digit of the given base
    - conversion to an int
    - conversion from an int

In addition, we also add predicates for supporting these operations for user
defined bases, ranging from 2-36.

library/char.m:
    Add the predicate is_decimal_digit/1, which is a synonym for is_digit/1.

    Add the predicate is_base_digit/2.

    Add the predicates int_to_{binary,octal,decimal,hex}_digit/2 and
    base_int_to_digit/3.

    Add the predicates {binary,octal,decimal,hex}_digit_to_int/2 and
    base_digit_to_int/3.

    Add det function versions of the above.

    Delete the function det_digit_to_int/1 that I added the other day.

    Mark the following as obsolete:
        - is_hex_digit/2
        - int_to_hex_char/2
        - int_to_digit/2
        - det_int_to_digit/1
        - det_int_to_digit/2

    Avoid redundant module qualification in the implementation.

    Mark some C foreign_procs as not modifying the trail.

    Re-order some declarations according to how the coding standard says they
    should be ordered.

library/bitmap.m:
library/integer.m:
library/parsing_utils.m:
library/string.m:
compiler/prog_rep_tables.m:
    Replace calls to obsolete predicates or functions.

NEWS:
    Announce the above changes.

    Add note advising users of digit_to_int/2 to check their code for the
    problem described above.

tests/hard_coded/Mmakefile:
tests/hard_coded/test_char_digits.m:
tests/hard_coded/test_char_digits.exp:
    Add a systematic test for the above predicates.
Fix some bugs with constrained polymorphic modes.

1. An inst variable from the head of the clause could be bound in the body.
The mode error in the call `P(X)' was not detected because the inst
variable I could be bound to ground.

	:- pred p(pred(T), T).
	:- mode p(pred(in(I =< ground)) is det, in) is det.

	p(P, X) :- P(X).

2. In David Overton's thesis, a get_subst function produces an inst
substitution from the callee's initial insts to the arguments' initial
insts, and the substitution is applied to all insts from the callee.
In the implementation we actually build the substitution while matching
the arguments' insts with the callee's insts, but we lost some precision
by not applying the incremental substitutions built as we match a list
of insts.

3. We rename apart the callee's inst variables from our own, but did not
keep the merged inst varset.  When a renamed inst variable appears in a
mode error it would be printed without its original name.
(could this avert more serious problems?)

4. inst_merge_3 was missing a case.

Some of these bugs may not be apparent due to the hack in
inst_matches_final_3 which allows a ground inst to match any bound inst.
A similar hack exists in inst_matches_binding_3.

compiler/inst_util.m:
	Handle in inst_merge_3 the case
	    InstA \= constrained_inst_var(_, _),
	    InstB = constrained_inst_var(_, _).

	Move InstA = not_reached case to inst_merge_2 to maintain
	inst_merge(not_reached, InstB @ constrained_inst_var(_, _)) = InstB

compiler/inst_match.m:
	Improve precision of inst var substitution computed in
	handle_inst_var_subs_2, following dmo's thesis.

compiler/mode_util.m:
compiler/modecheck_call.m:
	Keep the merged inst varsets after renaming.

compiler/mode_info.m:
	Add "head inst vars" in mode_info structure.

compiler/modecheck_util.m:
	Add get_constrained_inst_vars to extract constrained inst vars from a
	list of mode.

	Make modecheck_var_has_inst_list_* fail if the computed substitution
	would change the constraints of any head inst variables.

compiler/modes.m:
	Initialise mode_info with head inst variables.

compiler/pd_info.m:
compiler/pd_util.m:
	Conform to change in mode_info_init (not specifically tested).

compiler/prog_mode.m:
	Export inst_apply_substitution.

	Make rename_apart_inst_vars return the merged inst varset.

	Fix comments.

tests/invalid/Mmakefile:
tests/invalid/constrained_poly_insts2.err_exp:
tests/invalid/constrained_poly_insts2.m:
tests/valid/Mmakefile:
tests/valid/constrained_poly_multi.m:
	Add test cases.

NEWS:
	Announce fix.
Fix mantis bug 361.

compiler/table_gen.m:
    Fix the bug.

tests/valid/bug361.m:
    The test case.

tests/valid/Mmakefile:
    Enable the test case.

doc/reference_manual.texi:
    Document why, despite not crashing the compiler, the code of the test case,
    and similar code, won't do what it is intended to do.
Standardise formatting of float special values.

The string representation of float special values is currently dependent on the
target language and, for C grades, the underlying platform.  As a result,
values like NaN and Infinity are being printed or converted into strings in
variety of ways.  (See, for example bug #348 in Mantis.)

This diff changes float->string conversion to detect float special values and
use a consistent string representation for them.

library/string.m:
library/io.m:
runtime/mercury_float.c:
    Check if a float is not-a-number or of infinite magnitude when converting
    floats into strings.  If so, then use a standard representation of the
    value: "nan" for not-a-number values, and "infinity" / "-infinity" for
    values of infinite magnitude.
    For uppercase conversion specifiers in format strings, we output the above
    strings in uppercase (e.g. "NAN", "INFINITY").

library/float.m:
    Add is_infinite/1 and is_nan_or_infinite/1 as synonyms for is_inf/1 and
    is_nan_or_inf/1 respectively.

    Group float classification predicates into their own section.  Upcoming
    change will add more of them.

NEWS:
    Announce the above changes.

tests/general/string_format_special_floats.m:
tests/general/string_format_special_floats.exp:
    Modify this test to check that we actually print float special values as
    above.

tests/hard_coded/write_float_special.exp:
    Conform to the above change.

tests/EXPECT_FAIL_TESTS.all_grades:
    Do not expect the write_float_special test case to fail any more since
    the expected outputs should be the same on every platform.
Merge branch 'version-14_01-branch'
Speed up is_finite/1 and is_nan/1 in C grades.

The Mercury runtime procedures MR_is_{inf,nan} are defined as functions, even
on systems (e.g. all those that support the relevant bits of C99), where the
underlying C stdlib uses macros to implement those operations.  Define the
above runtime procedures as macros speeds up an artificial test case (counting
infinities in a list of floats) by ~3.5%.

Change the name of MR_is_inf to MR_is_infinite.

runtime/mercury_float.h:
	Rename MR_is_inf to MR_is_infinite.

	Define MR_is_{infinite,nan} as macros on systems that support C99.
	This avoids some unnecessary function call overhead.

	Rename the function versions of MR_is_infinite and MR_is_nan to
	MR_is_infinite_func and MR_is_nan_func.

runtime/mercury_float.c:
library/float.m:
	Conform to the above changes.
Add new float classification predicates.

Add the predicates is_finite/1 and is_zero/1 to the float module.
In C grades the implementation of the former maps down to the isfinite macro
(with C99).

configure.ac:
runtime/mercury_confg.h.in:
	Check if the C99 macro isfinite is available.

runtime/mercury_float.h:
	Add the macro MR_is_finite for testing if a floating point
	number is finite.  If the C stdlib provides this operation
	directly we use that, otherwise we define it in terms of
	MR_is_infinite and MR_is_nan.

library/float.m:
	Add the predicates is_finite/2 and is_zero/2.

	Expand tabs in this file.

	Fix capitalization in documentation.

library/int.m:
	Fix inconsistent capitalization in a spot.

library/string.m:
	Use is_finite/1 in place of negating is_nan_or_infinite/1.
Add float.infinity/0 to the standard library.

Add a constant function to the float module that returns positive infinity.
This is implemented for the C, Java, and C# backends.
The Erlang backend currently does not support it

library/float.m:
	Add the new function.

	Address review comments from Paul about my previous change.

tests/hard_coded/Mmakefile:
tests/hard_coded/test_infinity.{m,exp}:
	Test various operations involving infinity.

NEWS:
	Announce the addition.
Improve runtime sanity checking and error messages.

Always check the return value of calls to the function sem_init.
This function is not implemented on OS X and always returns an error.

Replace some direct calls to perror in the runtime with calls to MR_perror.
The latter ensures that the error message mentions that the error originates
from a call within the Mercury runtime.

runtime/mercury_context.c
runtime/mercury_prof_time.c:
runtime/mercury_threadscope.c:
	As above.
Document the problem with Mantis bug 360.

doc/reference_manual.texi:
    Document that minimal model is applicable only to model_non procedures
    and in .mm grades.

doc/user_guide.texi:
    Document the .mm grades.
Delete residual references to the mps grade component.

compiler/handle_options.m:
compiler/options.m:
	As above.
Remove GCC backend references from the TODO list.

compiler/notes/todo.html:
	As above.
Add missing local to foreign_decl pragma.

library/thread.m:
	The C functions ML_{incr,decr}_thread_barrier_count are declared
	with static linkage; their containing foreign_decl pragma should
	be marked as local.
Fix HTML in TODO list.

compiler/notes/todo.html:
	Fix a closing tag.
Rename MR_is_inf_func to MR_is_infinite_func as intended.

runtime/mercury_float.c:
	As above.
Add type cast in construction of direct arg functor value.

Add a type cast to the code generated by ml_gen_direct_arg_deconstruct
to construct a value with a direct argument functor.  The cast exists in
the same code generated by ml_gen_direct_arg_construct.

compiler/ml_unify_gen.m:
	As above.
Fix problems with gcc -ansi.

runtime/mercury_float.h:
	Only define MR_is_{nan,infinite,finite} as macros on systems that
	support C99.
Add a NEWS section for 14.01.2.

NEWS:
	As above.
Add type cast in construction of direct arg functor value.

Add a type cast to the code generated by ml_gen_direct_arg_deconstruct
to construct a value with a direct argument functor.  The cast exists in
the same code generated by ml_gen_direct_arg_construct.

compiler/ml_unify_gen.m:
	As above.