From 2e6635bd6c02614a177c741b7667483dcb06722a Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 15 Oct 2015 04:36:15 +0200 Subject: index and rindex return with const-quailifier if input has const MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- include/strings.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/strings.h b/include/strings.h index 433cd99..5ccad5f 100644 --- a/include/strings.h +++ b/include/strings.h @@ -134,6 +134,9 @@ int strncasecmp_l(const char*, const char*, size_t, locale_t) /* TODO */ char* index(const char*, int) __deprecated("Use 'strchr' instead.") __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure))); +#ifdef __CONST_CORRECT +# define index(...) (__const_correct(index, __VA_ARGS__)) +#endif /** * This function is identical to `strrchr`. @@ -143,6 +146,9 @@ char* index(const char*, int) char* rindex(const char*, int) __deprecated("Use 'strrchr' instead.") __GCC_ONLY(__attribute__((warn_unused_result, nonnull, pure))); +#ifdef __CONST_CORRECT +# define rindex(...) (__const_correct(rindex, __VA_ARGS__)) +#endif /** -- cgit v1.2.3-70-g09d2