~ chicken-core (chicken-5) 758656d63e727de9cedbed3c15a8c6fe87e5ef73
commit 758656d63e727de9cedbed3c15a8c6fe87e5ef73
Author: Peter Bex <peter.bex@xs4all.nl>
AuthorDate: Fri Feb 7 21:42:31 2014 +0100
Commit: Mario Domenech Goulart <mario.goulart@gmail.com>
CommitDate: Fri Feb 7 20:37:54 2014 -0200
Move C_strlcat/C_strlcpy definitions up in chicken.h
This is needed so that the uses of C_strlcat and C_strcpy in the
PRIVATE_REPOSITORY block's inline functions aren't interpreted as
implicit forward declarations of external functions by the C compiler,
thereby preventing our definitions from being inlined.
Signed-off-by: Mario Domenech Goulart <mario.goulart@gmail.com>
diff --git a/chicken.h b/chicken.h
index b2cccf47..90fbeffc 100644
--- a/chicken.h
+++ b/chicken.h
@@ -2889,6 +2889,41 @@ C_inline C_word C_a_i_record8(C_word **ptr, int n, C_word x1, C_word x2, C_word
return (C_word)p0;
}
+/* These strl* functions are based on public domain code by C.B. Falconer */
+#ifdef HAVE_STRLCPY
+# define C_strlcpy strlcpy
+#else
+C_inline size_t C_strlcpy(char *dst, const char *src, size_t sz)
+{
+ const char *start = src;
+
+ if (sz--) {
+ while ((*dst++ = *src))
+ if (sz--) src++;
+ else {
+ *(--dst) = '\0';
+ break;
+ }
+ }
+ while (*src++) continue;
+ return src - start - 1;
+}
+#endif
+
+#ifdef HAVE_STRLCAT
+# define C_strlcat strlcat
+#else
+C_inline size_t C_strlcat(char *dst, const char *src, size_t sz)
+{
+ char *start = dst;
+
+ while (*dst++) /* assumes sz >= strlen(dst) */
+ if (sz) sz--; /* i.e. well formed string */
+ dst--;
+ return dst - start + C_strlcpy(dst, src, sz);
+}
+#endif
+
#ifdef C_PRIVATE_REPOSITORY
# if defined(C_MACOSX) && defined(C_GUI)
@@ -3052,41 +3087,6 @@ C_path_to_executable(C_char *fname)
}
#endif
-/* These strl* functions are based on public domain code by C.B. Falconer */
-#ifdef HAVE_STRLCPY
-# define C_strlcpy strlcpy
-#else
-C_inline size_t C_strlcpy(char *dst, const char *src, size_t sz)
-{
- const char *start = src;
-
- if (sz--) {
- while ((*dst++ = *src))
- if (sz--) src++;
- else {
- *(--dst) = '\0';
- break;
- }
- }
- while (*src++) continue;
- return src - start - 1;
-}
-#endif
-
-#ifdef HAVE_STRLCAT
-# define C_strlcat strlcat
-#else
-C_inline size_t C_strlcat(char *dst, const char *src, size_t sz)
-{
- char *start = dst;
-
- while (*dst++) /* assumes sz >= strlen(dst) */
- if (sz) sz--; /* i.e. well formed string */
- dst--;
- return dst - start + C_strlcpy(dst, src, sz);
-}
-#endif
-
C_END_C_DECLS
#endif /* ___CHICKEN */
Trap