Configure misdetects strlcpy et al. with gcc -flto (RT#113022)
On OS X, allow Configure to override $ld with -Dld=...

Since it was added, hints/darwin.sh had been ignoring any user configuration
options and unconditionally setting ld='cc'. Instead, it should take a user
supplied value if one is given, otherwise defaulting to 'cc'.

The strange thing is that this was never noticed when commits cb3fc4263509f28c
and 69625aa92a91bf4c (May 2003) which added code which was intended offer
alternative behaviour if ld contained MACOSX_DEVELOPMENT_TARGET.
re_intuit_start(): stclass: use rx_origin more

In the stclass code block, we do

    s = rx_origin;
    ... stuff reading the value of s ...
    s = find_byclass(...);

change that to

    ... stuff reading the value of rx_origin ...
    s = find_byclass(...);
re_intuit_start(): use check_ix for efficiency
re_intuit_start(): remove if(check)

It this point in the stclass block, we have already confirmed that an
anchored substring exists and that the check substring is anchored.
So check cannot be null at this point. So don't test for it being null.
re_intuit_start(): reduce use of s in stclass code

s is mainly acting as a stand-in for rx_origin; so just use rx_origin
directly.
re_intuit_start(): eliminate t from stclass code

The 't' variable now just contains a copy of rx_origin; so just use
rx_origin directly, and eliminate t.
re_intuit_start(): eliminate debug-only var

'what' is only defined and assigned to in debugging builds.
Just calculate the value on the fly instead when printing debugging
output. Makes the code less messy.
add test for a code path in intuit_start()

Nothing in the test suite currently triggers *not* taking this branch:

    /* Have both, check_string is floating */
    if (rx_origin + start_shift >= check_at) /* Contradicts floating=check */

So add something that does trigger it.
re_intuit_start(): eliminate one label

Currently the code looks like:

    if (rx_origin + start_shift >= check_at)
        goto retry_floating_check;

    ....

  retry_floating_check:
    rx_origin = check_at - start_shift;
    goto hop_and_restart;

But that conditional only kicks in when the floating substring (which was
the check substring) matched, so this condition always applies:

    rx_origin + start_shift <= check_at

So the condition in the code will only ever be true when

    rx_origin + start_shift == check_at

In this case, this assignment is a noop:

    rx_origin = check_at - start_shift;

So skip it and jump directly to hop_and_restart. This eliminates the
retry_floating_check: label.
re_intuit_start(): swap if/else blocks

Change

    {
        if (cond) {
            A;
            goto x;
        }
        B;
        goto y;
    }

into
    {
        if (!cond) {
            B;
            goto y;
        }
        A;
        goto x;
    }

Should be functionally equivalent, but will allow for some further code
factorisation shortly.
re_intuit_start(): swap another if/else block

Change

    {
        if (cond)
            goto x;
        A;
        goto y;
    }
    x:

into

    {
        if (!cond) {
            A;
            goto y;
        }
    }
    x:

Functionally equivalent, but eliminates one 'goto'.
re_intuit_start(): remove redundant assertion

assert(prog->substrs->check_ix) is within the block
    if (prog->substrs->check_ix == 1)
so it's not needed any more.
re_intuit_start(): swap another if/else block

Change

    {
        ...
        if (has_anchored) {
            A;
            goto restart;
        }
        B;
        goto hop_and_restart;
    }

to

    {
        ...
        if (!has_anchored) {
            B;
            goto hop_and_restart;
        }
        A;
        goto restart;
    }

Functionally the same, but will allow simpler code shortly
re_intuit_start(): swap two blocks, delete label

Change

    if (!have_anchored) {
        A;
        goto hop_and_restart;
    }

    if (check_ix == 1) {
        B;
    }

  hop_and_restart:
    C;

To:

    if (have_anchored && check_ix == 1) {
        B;
    }

    if (!have_anchored) {
        A;
    }

    C;

This change should be functionally equivalent, but eliminates a label.
re_intuit_start(): de-duplicate condition

Change

    if (have_anchored && check_ix == 1) {
        B;
    }

    if (!have_anchored) {
        A;
    }

    C;

To:

    if (have_anchored) {
        if (check_ix == 1) {
            B;
        }
    }
    else {
        A;
    }

    C;

This change should be functionally equivalent, but eliminates calculating
the have_anchored condition twice.
re_intuit_start(): swap BmUSEFUL + stclass blocks

Currently the code that does BmUSEFUL()--, and which and frees the
substring if the count reaches zero, comes before the stclass code. This
is problematic, because by the time the stclass code is executed, the
check substrings may have been freed. The stclass code does have some
checks for this, but they are inadequate: I managed to produce code that
segfaulted. It's also hard to test - you have to run against the same
pattern 100 times to get the BmUSEFUL() count down to zero, then on the
101st attempt, do something that both triggers the decrement/free and
fails the st class.

By moving the BmUSEFUL()-- stuff to *after* the stclass code, it removes
this issue completely.

As to how it affects the BmUSEFUL() count: I think it makes it slightly
better. Before, a substring could match at rx_origin offset 0, triggering
BmUSEFUL()--, then the stclass could fail, triggering a new substring
match at at a non-zero offset, and thus doing BmUSEFUL()++. The overall
affect being neutral. Now, the overall effect is BmUSEFUL += 1, which
better reflects the fact that the substring *did* help us find a non-zero
offset.
re_intuit_start(): always initialise start_shift

The start_shift variable is usually initialised to prog->check_offset_min,
except for one code path where it is left at zero. It turns out that
in that code path, the value isn't (currently) used, so is safe. However,
that may change, so unconditionally initialise it.
re_intuit_start(): trivial reorg of stclass code

make all the actions on success follow the actions on failure,
rather than being partly before and partly after.

No functional changes.
re_intuit_start(): fix a comment about overlap

The comment said that we don't allow the anchored and floating substrings
to overlap. This is trivially wrong, e.g.

/aa+/ has an anchored of "aa" at 0 and a float of "a at 1..inf

Fix the comment to say what the assertion actually already tests for, i.e.
that the float doesn't start before the anchored.