aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-10-15 04:36:15 +0200
committerMattias Andrée <maandree@operamail.com>2015-10-15 04:36:15 +0200
commit2e6635bd6c02614a177c741b7667483dcb06722a (patch)
tree9295efeda7ea1368e5a259b5654e7cce33a23f4c
parentbetter solution to returning const if input is const, only requires C99 (actually: C99-capable version of GCC) and GCC, or C11 (diff)
downloadslibc-2e6635bd6c02614a177c741b7667483dcb06722a.tar.gz
slibc-2e6635bd6c02614a177c741b7667483dcb06722a.tar.bz2
slibc-2e6635bd6c02614a177c741b7667483dcb06722a.tar.xz
index and rindex return with const-quailifier if input has const
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--include/strings.h6
1 files changed, 6 insertions, 0 deletions
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
/**