diff options
author | Martijn van Duren <martijn@cvs.openbsd.org> | 2018-10-01 06:37:38 +0000 |
---|---|---|
committer | Martijn van Duren <martijn@cvs.openbsd.org> | 2018-10-01 06:37:38 +0000 |
commit | 7979d06eaa32b96f41c9703ec4e008ac347090c2 (patch) | |
tree | 34bf1270ced50fa86a548ac6909e1ec0854ce8a8 /lib/libc | |
parent | d5ac897b9e5b161f57fe2673a36ebfc4fa073853 (diff) |
As per POSIX, when str{,r}chr is comparing it should convert c to a char.
The C implementation of str{,r}chr are not linked to the build, because
assembly implementations are used, but change to code for easier reference.
At least the i386 and amd64 are checked and seem to do the correct thing.
Found thanks to the csh any/strchr change.
minor pointers and OK millert@
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/string/strchr.3 | 5 | ||||
-rw-r--r-- | lib/libc/string/strchr.c | 4 | ||||
-rw-r--r-- | lib/libc/string/strrchr.3 | 5 | ||||
-rw-r--r-- | lib/libc/string/strrchr.c | 4 |
4 files changed, 10 insertions, 8 deletions
diff --git a/lib/libc/string/strchr.3 b/lib/libc/string/strchr.3 index 854438677a6..07e7f29f5bb 100644 --- a/lib/libc/string/strchr.3 +++ b/lib/libc/string/strchr.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: strchr.3,v 1.12 2015/11/24 09:14:35 daniel Exp $ +.\" $OpenBSD: strchr.3,v 1.13 2018/10/01 06:37:37 martijn Exp $ .\" .\" Copyright (c) 1990, 1991 The Regents of the University of California. .\" All rights reserved. @@ -31,7 +31,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd $Mdocdate: November 24 2015 $ +.Dd $Mdocdate: October 1 2018 $ .Dt STRCHR 3 .Os .Sh NAME @@ -50,6 +50,7 @@ The .Fn strchr function locates the first occurrence of the character .Fa c +.Pq converted to a char in the string .Fa s . The terminating NUL character is considered part of the string. diff --git a/lib/libc/string/strchr.c b/lib/libc/string/strchr.c index b396b45b3b0..8bfa7ac3aa0 100644 --- a/lib/libc/string/strchr.c +++ b/lib/libc/string/strchr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strchr.c,v 1.3 2015/08/31 02:53:57 guenther Exp $ */ +/* $OpenBSD: strchr.c,v 1.4 2018/10/01 06:37:37 martijn Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -36,7 +36,7 @@ char * strchr(const char *p, int ch) { for (;; ++p) { - if (*p == ch) + if (*p == (char) ch) return((char *)p); if (!*p) return((char *)NULL); diff --git a/lib/libc/string/strrchr.3 b/lib/libc/string/strrchr.3 index f4ce691a6ea..5abb88ec70b 100644 --- a/lib/libc/string/strrchr.3 +++ b/lib/libc/string/strrchr.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: strrchr.3,v 1.11 2015/11/24 09:14:35 daniel Exp $ +.\" $OpenBSD: strrchr.3,v 1.12 2018/10/01 06:37:37 martijn Exp $ .\" .\" Copyright (c) 1990, 1991 The Regents of the University of California. .\" All rights reserved. @@ -31,7 +31,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd $Mdocdate: November 24 2015 $ +.Dd $Mdocdate: October 1 2018 $ .Dt STRRCHR 3 .Os .Sh NAME @@ -50,6 +50,7 @@ The .Fn strrchr function locates the last occurrence of the character .Fa c +.Pq converted to a char in the string .Fa s . The terminating diff --git a/lib/libc/string/strrchr.c b/lib/libc/string/strrchr.c index 93755721443..848d1ad22e4 100644 --- a/lib/libc/string/strrchr.c +++ b/lib/libc/string/strrchr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: strrchr.c,v 1.3 2015/08/31 02:53:57 guenther Exp $ */ +/* $OpenBSD: strrchr.c,v 1.4 2018/10/01 06:37:37 martijn Exp $ */ /* * Copyright (c) 1988 Regents of the University of California. * All rights reserved. @@ -38,7 +38,7 @@ strrchr(const char *p, int ch) char *save; for (save = NULL;; ++p) { - if (*p == ch) + if (*p == (char) ch) save = (char *)p; if (!*p) return(save); |