From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 28042 invoked from network); 21 Apr 2023 15:50:15 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 21 Apr 2023 15:50:15 -0000 Received: (qmail 24444 invoked by uid 550); 21 Apr 2023 15:50:12 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 24174 invoked from network); 21 Apr 2023 15:48:45 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202211; t=1682092109; bh=2Ib6HsoUjVR7fc9n0g7EdRHiDVqetFFNkuA3hGZfN7U=; h=Date:From:To:Subject:References:In-Reply-To:From; b=nqaYIn7rAmZ/p9eoNMxFiZ3Dt7Eldk5P7AyGgg8adb+ru7OanyKKbNE/wHzBbSbYQ 3KXMxzh4RBQyfjltTP/V3hS5PgBj/jjVaW4QsOIw3f3Ik6FvWn3Lll/LXykWncnMww bIzL10VAxXhGYa8vGyILAMoGPdJpyTXSfOdvHi5yhmPOTbO5/6Wiqrl96hrglsS2CC VeZEpbiQdzfj/Tyzg4Thkw42tuQcH/v0FQ5hI3npfHRRvo4spmqNM9dsF9GlN6x9Z4 RhoJf3GNy3tVZhAwp4EzfuY3LFh95zS1LwRlaw6jg89mYQahgskZgaop9e9PQj7Xzu leKqOZtnP582w== Date: Fri, 21 Apr 2023 17:48:28 +0200 From: =?utf-8?B?0L3QsNCx?= To: musl@lists.openwall.com Message-ID: References: <73caac41e70db544c53b1aa947627206d3eb625b.1682024413.git.nabijaczleweli@nabijaczleweli.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="dobfkvoyslv6dv4v" Content-Disposition: inline In-Reply-To: <73caac41e70db544c53b1aa947627206d3eb625b.1682024413.git.nabijaczleweli@nabijaczleweli.xyz> User-Agent: NeoMutt/20230407 Subject: [musl] REG_STARTEND tests --dobfkvoyslv6dv4v Content-Type: multipart/mixed; boundary="3pk3fbkjqakfvwco" Content-Disposition: inline --3pk3fbkjqakfvwco Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable I didn't formalise the tests last night, but see the attached file, which passes cleanly on NetBSD and the illumos gate. On musl with 1/2 I get $ ~/store/code/musl/prefix/bin/musl-clang tst-reg-startend.c -o \ /tmp/tst-reg-startend -DSTANDALONE -static && /tmp/tst-reg-startend 2>&1 | cat -A tst-reg-startend.c: ^a.c$: ac: no match tst-reg-startend.c: ^a.*c$: ac: no match tst-reg-startend.c: ^a[^c]c$: ac: no match tst-reg-startend.c: ^a..: ac: no match tst-reg-startend.c: ..c: ac: no match tst-reg-startend.c: [^z]c: ac: no match tst-reg-startend.c: [^z]c: ac: wanted {2, 4}, got {1, 4} And with 2/2 it passes cleanly. glibc gives me a host of errors, but I'll post fixes and include this test there later. Best, =D0=BD=D0=B0=D0=B1 Please keep me in CC. --3pk3fbkjqakfvwco Content-Type: text/x-csrc; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable /* Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include #include #include #include #include #include #define M(s, e) (regmatch_t) {.rm_so =3D s, .rm_eo =3D e} #define MEQ(l, r) ((l).rm_so =3D=3D (r).rm_so && (l).rm_eo =3D=3D (r).rm_eo) static const regmatch_t bound =3D M(1, 4); static const char *const regex_ac[] =3D {"^a", "c$", "^a.c$", "^a.*c$", "^a[^c]c$", "^a..", "..c", "[^z]c", NULL}; static const char *const regex_aa[] =3D {"^a", "a$", "^\\(a\\).\\1$", "^a[^a]*", NULL}; static const char *const data_ac[] =3D {"_a\0cdef", "_abcdef"}; static const char *const data_aa[] =3D {"_a\0adef", "_abadef"}; static const regmatch_t results_ac[] =3D {M(1, 2), M(3, 4), M(1, 4), M(1, 4), M(1, 4), M(1, 4), M(1, 4), M(2, 4)}; static const regmatch_t results_aa[] =3D {M(1, 2), M(3, 4), M(1, 4), M(1, 3)}; static_assert(sizeof(regex_ac) / sizeof(*regex_ac) - 1 =3D=3D sizeof(results_ac) / sizeof(*results_ac), ""); static_assert(sizeof(regex_aa) / sizeof(*regex_aa) - 1 =3D=3D sizeof(results_aa) / sizeof(*results_aa), ""); static bool testbunch (const char *const *regexes, const char *const data[static 2], const regmatch_t *results) { #define BASEERR(data) \ err =3D true, \ fprintf (stderr, __FILE__ ": %s: ", *regexes), \ fwrite (data[i] + bound.rm_so, 1, bound.rm_eo - bound.rm_so, stderr) bool err =3D false; for (; *regexes; ++regexes, ++results) { regex_t rgx; assert (!regcomp (&rgx, *regexes, 0)); for (size_t i =3D 0; i < 2; ++i) { regmatch_t match =3D bound; if (regexec (&rgx, data[i], 1, &match, REG_STARTEND)) BASEERR(data), fputs (": no match\n", stderr); if (!MEQ(match, *results)) BASEERR(data), fprintf (stderr, ": wanted {%d, %d}, got {%d, %d= }\n", (int)results->rm_so, (int)results->rm_e= o, (int)match.rm_so, (int)match.rm_eo); } regfree(&rgx); } return err; } static const char *const a=C4=87_data[2] =3D {"_aa=C4=87def", "_a=C4=87def"= }; static const bool a=C4=87_exp[] =3D {false, true}; static bool testa=C4=87() { bool err =3D false; regex_t rgx; const char *const regexes[] =3D {"a=C4=87"}; assert (!regcomp (&rgx, *regexes, 0)); for (size_t i =3D 0; i < 2; ++i) { regmatch_t match =3D bound; if (regexec (&rgx, a=C4=87_data[i], 1, &match, REG_STARTEND) =3D=3D a= =C4=87_exp[i]) BASEERR(a=C4=87_data), fprintf (stderr, ": %s match\n", a=C4=87_exp[i] ? "no" : "yes"); if (!MEQ(match, bound)) BASEERR(a=C4=87_data), fprintf (stderr, ": wanted {%d, %d}, got {%d= , %d}\n", (int)bound.rm_so, (int)bound.rm_eo, (int)match.rm_so, (int)match.rm_eo); } regfree(&rgx); return err; } static int do_test (int argc, char **argv) { (void) argc, (void) argv; assert (setlocale (LC_ALL, "C.UTF-8")); return testbunch (regex_ac, data_ac, results_ac) || testbunch (regex_aa, data_aa, results_aa) || testa=C4=87 (); } #if !STANDALONE #include "../test-skeleton.c" #else int main(int argc, char **argv) { return do_test(argc, argv); } #endif --3pk3fbkjqakfvwco-- --dobfkvoyslv6dv4v Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEfWlHToQCjFzAxEFjvP0LAY0mWPEFAmRCsEwACgkQvP0LAY0m WPG6sA//VgOPcENaz7o7tOc9mXtpBeKrQgmKGf5G19c8Iyf/Gjfkko+uWaLaDL1t ZdubVXiVx+Lno348Dy2h96ddBO8aNBe0Un1WIgQ/TODcAQugz8ez3dhA7GVw9Q8t E7XDvdf9PFjmub2WWDXfskMAdr/Z+a9eDeWgdOaE7vhWFIE5lgeKnA/FfRff0n7w mKm4XaFFSam1zFmF+w+B3XA/UNk1JFN2d0WIzy7GTDAoExBcj+ww2HQqa972t8sX KihgsDuThUP9WPrZ62UFle1jDGFXzG5CWSXUeIUxKKlXNKenHIpWmmJhaXFvCNwu DRDwWF90mbLGtoxNpZRcdY8vzp65GLzx9k/n2U8EcdTtCJEsAi/TEQo0ufvhXSHa FbDa/PuF75nT+xXgOAa9BWFOa7bj/oJcUgO05XB5mvf8uQ+ZzMEJPXNHgHa+N+Jr GQ5YxyiD6vlft6eeobjiqGy2NFkgFkEYRWjd3rrXlPb1EOunm5ksbWCNLuAYgy7F X/r3lyjtu6Y0KciKMkaLlcu/Nc7EyJazbL/UiBAf2O9tknarzUvAS5Qxx4Bq6ERt 8tiBKwTmTtp8oB/hXynAoc6XmoCii5MRTsaFmkJYbJXHB1EkEQbCOGK3OzHTdor8 iwnI5VRJs1D6Br75VaPDBkjYaXYLlJBS3uA9dSSlm6pLKQXy4aM= =+BcA -----END PGP SIGNATURE----- --dobfkvoyslv6dv4v--