diff options
Diffstat (limited to 'include/string.h')
| -rw-r--r-- | include/string.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/string.h b/include/string.h index 1fba9d9..4a3426a 100644 --- a/include/string.h +++ b/include/string.h | |||
| @@ -102,6 +102,17 @@ _FORTIFY_FN(strchr) char *strchr(const char * _FORTIFY_POS0 __s, int __c) | |||
| 102 | return __r; | 102 | return __r; |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | __access(read_only, 1, 2) | ||
| 106 | _FORTIFY_FN(strrchr) char *strrchr(const char * _FORTIFY_POS0 __s, int __c) | ||
| 107 | { | ||
| 108 | size_t __b = __bos(__s, 0); | ||
| 109 | |||
| 110 | char* __r = __builtin_strrchr(__s, __c); | ||
| 111 | if (__r - __s > __b) | ||
| 112 | __builtin_trap(); | ||
| 113 | return __r; | ||
| 114 | } | ||
| 115 | |||
| 105 | #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ | 116 | #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ |
| 106 | || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ | 117 | || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ |
| 107 | || defined(_BSD_SOURCE) | 118 | || defined(_BSD_SOURCE) |
