On Tue, 2023-03-28 at 08:35 +0200, Richard Biener wrote: > On Mon, Mar 27, 2023 at 8:00 PM Xi Ruoyao via Gcc-patches > <gcc-patches@gcc.gnu.org> wrote: > > > > memmem is not POSIX so the system may lack it. Then libiberty will > > provide an implementation, but it's a "supplemental function" and not > > declared in libiberty.h. We need to declare the prototype to use it > > then. > > Was there a reason to use memmem over strstr in the first place? Otherwise > looks reasonable.
Because we need to limit the range for matching in [begin, pos). If using strstr, we have to set *pos = 0, then change it back after the matching. I remember I tried this in the first place but the code did not look very pretty. Pushed r13-6888. Will make a backport into gcc-12 too after a bootstrapping for verification. > -- Xi Ruoyao <xry...@xry111.site> School of Aerospace Science and Technology, Xidian University