From f550b551221fb0d6561b1ca14b113e3c667c861c Mon Sep 17 00:00:00 2001 From: claudio <> Date: Thu, 16 Apr 2020 12:37:52 +0000 Subject: [PATCH] Resync our strstr.c with the musl version. Removes some debug code and optimizes one statement in two-way string compare. OK tb@ millert@ --- src/lib/libc/string/strstr.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/lib/libc/string/strstr.c b/src/lib/libc/string/strstr.c index 079d69d2..241a080e 100644 --- a/src/lib/libc/string/strstr.c +++ b/src/lib/libc/string/strstr.c @@ -1,7 +1,7 @@ -/* $OpenBSD: strstr.c,v 1.8 2018/04/30 07:44:56 denis Exp $ */ +/* $OpenBSD: strstr.c,v 1.9 2020/04/16 12:37:52 claudio Exp $ */ /* - * Copyright (c) 2005-2014 Rich Felker + * Copyright (c) 2005-2018 Rich Felker * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -24,13 +24,8 @@ */ #include -#include #include -#ifdef DEBUG -#include -#endif - static char * twobyte_strstr(const unsigned char *h, const unsigned char *n) { @@ -146,11 +141,8 @@ twoway_strstr(const unsigned char *h, const unsigned char *n) /* Check last byte first; advance by shift on mismatch */ if (BITOP(byteset, h[l-1], &)) { k = l-shift[h[l-1]]; -#ifdef DEBUG - printf("adv by %zu (on %c) at [%s] (%zu;l=%zu)\n", k, h[l-1], h, shift[h[l-1]], l); -#endif if (k) { - if (mem0 && mem && k < p) k = l-p; + if (k < mem) k = mem; h += k; mem = 0; continue;