summaryrefslogtreecommitdiff
path: root/src/lib/libc/string
diff options
context:
space:
mode:
authorclaudio <>2020-04-16 12:37:52 +0000
committerclaudio <>2020-04-16 12:37:52 +0000
commit6728bc88015cac4fc489f77e6be70489786696e4 (patch)
treefb61460c9541a97a9bc2c5e45f05e887f780f8f3 /src/lib/libc/string
parent91dba821852635bf10933b608abc3930ffee1898 (diff)
downloadopenbsd-6728bc88015cac4fc489f77e6be70489786696e4.tar.gz
openbsd-6728bc88015cac4fc489f77e6be70489786696e4.tar.bz2
openbsd-6728bc88015cac4fc489f77e6be70489786696e4.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 'src/lib/libc/string')
-rw-r--r--src/lib/libc/string/strstr.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/lib/libc/string/strstr.c b/src/lib/libc/string/strstr.c
index 079d69d257..241a080e7a 100644
--- a/src/lib/libc/string/strstr.c
+++ b/src/lib/libc/string/strstr.c
@@ -1,7 +1,7 @@
1/* $OpenBSD: strstr.c,v 1.8 2018/04/30 07:44:56 denis Exp $ */ 1/* $OpenBSD: strstr.c,v 1.9 2020/04/16 12:37:52 claudio Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2005-2014 Rich Felker 4 * Copyright (c) 2005-2018 Rich Felker
5 * 5 *
6 * Permission is hereby granted, free of charge, to any person obtaining 6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the 7 * a copy of this software and associated documentation files (the
@@ -24,13 +24,8 @@
24 */ 24 */
25 25
26#include <string.h> 26#include <string.h>
27#include <stdlib.h>
28#include <stdint.h> 27#include <stdint.h>
29 28
30#ifdef DEBUG
31#include <stdio.h>
32#endif
33
34static char * 29static char *
35twobyte_strstr(const unsigned char *h, const unsigned char *n) 30twobyte_strstr(const unsigned char *h, const unsigned char *n)
36{ 31{
@@ -146,11 +141,8 @@ twoway_strstr(const unsigned char *h, const unsigned char *n)
146 /* Check last byte first; advance by shift on mismatch */ 141 /* Check last byte first; advance by shift on mismatch */
147 if (BITOP(byteset, h[l-1], &)) { 142 if (BITOP(byteset, h[l-1], &)) {
148 k = l-shift[h[l-1]]; 143 k = l-shift[h[l-1]];
149#ifdef DEBUG
150 printf("adv by %zu (on %c) at [%s] (%zu;l=%zu)\n", k, h[l-1], h, shift[h[l-1]], l);
151#endif
152 if (k) { 144 if (k) {
153 if (mem0 && mem && k < p) k = l-p; 145 if (k < mem) k = mem;
154 h += k; 146 h += k;
155 mem = 0; 147 mem = 0;
156 continue; 148 continue;