diff options
| author | cvs2svn <admin@example.com> | 2025-08-02 06:16:35 +0000 |
|---|---|---|
| committer | cvs2svn <admin@example.com> | 2025-08-02 06:16:35 +0000 |
| commit | a397c95f8aea58533e72379d6e0de12683ecd0dc (patch) | |
| tree | 45ccaccd0ce2ea01650f0a9f5e9268a656e17e51 /src/regress/lib/libc/strchr | |
| parent | a79e90e7342954ae2287db505811ca3c1cd336d7 (diff) | |
| download | openbsd-tb_20250802.tar.gz openbsd-tb_20250802.tar.bz2 openbsd-tb_20250802.zip | |
This commit was manufactured by cvs2git to create tag 'tb_20250802'.tb_20250802
Diffstat (limited to 'src/regress/lib/libc/strchr')
| -rw-r--r-- | src/regress/lib/libc/strchr/Makefile | 8 | ||||
| -rw-r--r-- | src/regress/lib/libc/strchr/strchrtest.c | 66 |
2 files changed, 0 insertions, 74 deletions
diff --git a/src/regress/lib/libc/strchr/Makefile b/src/regress/lib/libc/strchr/Makefile deleted file mode 100644 index 355c0d9421..0000000000 --- a/src/regress/lib/libc/strchr/Makefile +++ /dev/null | |||
| @@ -1,8 +0,0 @@ | |||
| 1 | # $OpenBSD: Makefile,v 1.1 2021/07/24 05:45:49 visa Exp $ | ||
| 2 | |||
| 3 | PROG= strchrtest | ||
| 4 | |||
| 5 | CFLAGS+= -fno-builtin-strchr | ||
| 6 | CFLAGS+= -fno-builtin-strrchr | ||
| 7 | |||
| 8 | .include <bsd.regress.mk> | ||
diff --git a/src/regress/lib/libc/strchr/strchrtest.c b/src/regress/lib/libc/strchr/strchrtest.c deleted file mode 100644 index 0be4c8df63..0000000000 --- a/src/regress/lib/libc/strchr/strchrtest.c +++ /dev/null | |||
| @@ -1,66 +0,0 @@ | |||
| 1 | /* $OpenBSD: strchrtest.c,v 1.2 2021/09/01 09:26:32 jasper Exp $ */ | ||
| 2 | |||
| 3 | /* | ||
| 4 | * Copyright (c) 2021 Visa Hankala | ||
| 5 | * | ||
| 6 | * Permission to use, copy, modify, and distribute this software for any | ||
| 7 | * purpose with or without fee is hereby granted, provided that the above | ||
| 8 | * copyright notice and this permission notice appear in all copies. | ||
| 9 | * | ||
| 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 17 | */ | ||
| 18 | |||
| 19 | #include <assert.h> | ||
| 20 | #include <stdio.h> | ||
| 21 | #include <stdlib.h> | ||
| 22 | #include <string.h> | ||
| 23 | #include <unistd.h> | ||
| 24 | |||
| 25 | int | ||
| 26 | main(void) | ||
| 27 | { | ||
| 28 | char *buf; | ||
| 29 | size_t bufsize; | ||
| 30 | |||
| 31 | /* Allocate buffer with guard pages. */ | ||
| 32 | bufsize = getpagesize(); | ||
| 33 | buf = malloc(bufsize); | ||
| 34 | if (buf == NULL) { | ||
| 35 | fprintf(stderr, "unable to allocate memory\n"); | ||
| 36 | return 1; | ||
| 37 | } | ||
| 38 | |||
| 39 | memset(buf, 0, bufsize); | ||
| 40 | assert(strchr(buf, 'a') == NULL); | ||
| 41 | assert(strchr(buf, '\0') == buf); | ||
| 42 | assert(strrchr(buf, 'a') == NULL); | ||
| 43 | assert(strrchr(buf, '\0') == buf); | ||
| 44 | |||
| 45 | memcpy(buf, "haystack\xcf\x80", 10); | ||
| 46 | assert(strchr(buf, 'a') == buf + 1); | ||
| 47 | assert(strchr(buf, '\x80') == buf + 9); | ||
| 48 | assert(strchr(buf, 0x180) == buf + 9); | ||
| 49 | assert(strchr(buf, '\0') == buf + 10); | ||
| 50 | assert(strrchr(buf, 'a') == buf + 5); | ||
| 51 | assert(strrchr(buf, '\xcf') == buf + 8); | ||
| 52 | assert(strrchr(buf, 0x3cf) == buf + 8); | ||
| 53 | assert(strrchr(buf, '\0') == buf + 10); | ||
| 54 | |||
| 55 | memset(buf, 'a', bufsize - 2); | ||
| 56 | buf[0] = 'b'; | ||
| 57 | buf[bufsize - 2] = 'b'; | ||
| 58 | assert(strchr(buf, 'b') == buf); | ||
| 59 | assert(strchr(buf, 'c') == NULL); | ||
| 60 | assert(strchr(buf, '\0') == buf + bufsize - 1); | ||
| 61 | assert(strrchr(buf, 'b') == buf + bufsize - 2); | ||
| 62 | assert(strrchr(buf, 'c') == NULL); | ||
| 63 | assert(strrchr(buf, '\0') == buf + bufsize - 1); | ||
| 64 | |||
| 65 | return 0; | ||
| 66 | } | ||
