summaryrefslogtreecommitdiffstats
path: root/lib/libc/string/strstr.c
diff options
context:
space:
mode:
authorclaudio <claudio@openbsd.org>2020-04-16 12:37:52 +0000
committerclaudio <claudio@openbsd.org>2020-04-16 12:37:52 +0000
commit6fe343334b0dcbbc26c16d41932c5c93d0d829df (patch)
tree1105366cb9d12b78ffc662a95a167e845d4fc2f7 /lib/libc/string/strstr.c
parentIf available, use hardware "output.level" for volume control. (diff)
downloadwireguard-openbsd-6fe343334b0dcbbc26c16d41932c5c93d0d829df.tar.xz
wireguard-openbsd-6fe343334b0dcbbc26c16d41932c5c93d0d829df.zip
Resync our strstr.c with the musl version. Removes some debug code and
optimizes one statement in two-way string compare. OK tb@ millert@
Diffstat (limited to 'lib/libc/string/strstr.c')
-rw-r--r--lib/libc/string/strstr.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/lib/libc/string/strstr.c b/lib/libc/string/strstr.c
index 079d69d257f..241a080e7a8 100644
--- a/lib/libc/string/strstr.c
+++ b/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 <string.h>
-#include <stdlib.h>
#include <stdint.h>
-#ifdef DEBUG
-#include <stdio.h>
-#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;