8578 sync fnmatch(3C) with upstream

Review Request #650 — Created Aug. 14, 2017 and submitted — Latest diff uploaded

  • pick up 2 POSIX-compliance fixes
commit 0a3b2e376d150258c8294c12a85bec99546ab84b
Author: ache <ache@FreeBSD.org>
Date:   Thu Aug 8 09:04:02 2013 +0000

    According to POSIX \ in the fnmatch(3) pattern should escape
    any character including '\0', but our version replace escaped '\0'
    with '\\'.
    I.e. fnmatch("\\", "\\", 0) should not match while fnmatch("\\", "", 0)
    should (Linux and NetBSD does the same). Was vice versa.

    PR:     181129
    MFC after:      1 week

commit 42ec48b371dbc12ac77467494d145dd597fbd7de
Author: pfg <pfg@FreeBSD.org>
Date:   Thu Aug 10 15:42:25 2017 +0000

    fnmatch(3): improve POSIX conformance.

    In a recent interpretation[1], "\\" shall return a non-zero value
    (indicating either no match or an error).

    The fix involves a change over r254091 and now the behavior matches the
    Sun/IBM/HP closed source implementations and also likely musl libc.

    Submitted by:   Joerg Schilling <joerg at schily.net>
    MFC after:      1 week

    [1] http://austingroupbugs.net/view.php?id=806
  • restore FNM_LEADING_DIR for compatibility
  • add FNM_CASEFOLD as alias to FNM_IGNORECASE for compatibility and use in the source to reduce diff
  • add various man page notes for current implementation
  • add upstream regression test cases

used the added test cases