diff options
| author | jvoisin | 2024-03-19 18:35:13 +0100 |
|---|---|---|
| committer | jvoisin | 2024-03-19 18:35:13 +0100 |
| commit | 8ed72e7c1caa0eb4238e649063c26a11720935de (patch) | |
| tree | 24e478a8ebdb9e69eefcea193781a39bc22c21c0 /tests | |
| parent | 140cffbe84a08669d67c3257258d2bb70ff29c3b (diff) | |
Relax our checks for memchr on C11 and above2.2
Since C11:
> This function behaves as if it reads the bytes sequentially and stops as soon
as a matching bytes is found: if the array pointed to by ptr is smaller than
count, but the match is found within the array, the behavior is well-defined.
Reported-by: q66
Diffstat (limited to '')
| -rw-r--r-- | tests/test_memchr_dynamic_read.c | 2 | ||||
| -rw-r--r-- | tests/test_memchr_static_read.c | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/tests/test_memchr_dynamic_read.c b/tests/test_memchr_dynamic_read.c index 2f8d214..8b25a15 100644 --- a/tests/test_memchr_dynamic_read.c +++ b/tests/test_memchr_dynamic_read.c | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | #include <string.h> | 3 | #include <string.h> |
| 4 | 4 | ||
| 5 | int main(int argc, char** argv) { | 5 | int main(int argc, char** argv) { |
| 6 | #if __STDC_VERSION__ < 201112L | ||
| 6 | const char* buffer = "12345"; | 7 | const char* buffer = "12345"; |
| 7 | memchr(buffer, (int)'4', strlen(buffer) - 1); | 8 | memchr(buffer, (int)'4', strlen(buffer) - 1); |
| 8 | puts(buffer); | 9 | puts(buffer); |
| @@ -12,5 +13,6 @@ int main(int argc, char** argv) { | |||
| 12 | CHK_FAIL_END | 13 | CHK_FAIL_END |
| 13 | 14 | ||
| 14 | puts(buffer); | 15 | puts(buffer); |
| 16 | #endif | ||
| 15 | return ret; | 17 | return ret; |
| 16 | } | 18 | } |
diff --git a/tests/test_memchr_static_read.c b/tests/test_memchr_static_read.c index ccf46af..edd266d 100644 --- a/tests/test_memchr_static_read.c +++ b/tests/test_memchr_static_read.c | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | #include <string.h> | 3 | #include <string.h> |
| 4 | 4 | ||
| 5 | int main(int argc, char** argv) { | 5 | int main(int argc, char** argv) { |
| 6 | #if __STDC_VERSION__ < 201112L | ||
| 6 | const char* buffer = "12345"; | 7 | const char* buffer = "12345"; |
| 7 | const char* padding = "ABCDEFGHIJKLMN"; | 8 | const char* padding = "ABCDEFGHIJKLMN"; |
| 8 | memchr(buffer, (int)'4', strlen(buffer) - 1); | 9 | memchr(buffer, (int)'4', strlen(buffer) - 1); |
| @@ -13,5 +14,6 @@ int main(int argc, char** argv) { | |||
| 13 | CHK_FAIL_END | 14 | CHK_FAIL_END |
| 14 | 15 | ||
| 15 | puts(buffer); | 16 | puts(buffer); |
| 17 | #endif | ||
| 16 | return ret; | 18 | return ret; |
| 17 | } | 19 | } |
