Ross Younger sent this addition of strnlen() to me off-list for review,
and after some feedback, I said it was ok, so here it is.

Jifl
-- 
--["No sense being pessimistic, it wouldn't work anyway"]-- Opinions==mine
Index: ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/language/c/libc/string/current/ChangeLog,v
retrieving revision 1.11
diff -u -5 -p -r1.11 ChangeLog
--- ChangeLog   29 Jan 2009 17:49:53 -0000      1.11
+++ ChangeLog   11 May 2010 16:13:52 -0000
@@ -1,5 +1,9 @@
+2010-05-10  Ross Younger  <[email protected]>
+
+       * src/strnlen.cxx, tests/strnlen.c: Created.
+
 2009-01-26  Jonathan Larmour  <[email protected]>
 
        * tests/memchr.c (main): Rename to cyg_user_start if main isn't
        going to be called.
        * tests/memcmp1.c (main): Ditto.
Index: cdl/string.cdl
===================================================================
RCS file: 
/cvs/ecos/ecos/packages/language/c/libc/string/current/cdl/string.cdl,v
retrieving revision 1.8
diff -u -5 -p -r1.8 string.cdl
--- cdl/string.cdl      29 Jan 2009 17:49:53 -0000      1.8
+++ cdl/string.cdl      11 May 2010 16:13:52 -0000
@@ -164,10 +164,20 @@ cdl_package CYGPKG_LIBC_STRING {
         compile       strdup.cxx
         description   "
                 This option indicates whether strdup() is to be supported."
     }
 
+    cdl_option CYGFUN_LIBC_STRING_GNU_STRNLEN {
+        display       "Provide strnlen() GNU extension"
+        flavor        bool
+        default_value 1
+        compile       strnlen.cxx
+        description   "
+            This option controls support for the strnlen() function.
+            (This is a GNU extension, not part of ANSI C.)"
+    }
+
     cdl_component CYGPKG_LIBC_STRING_OPTIONS {
         display "C library string functions build options"
         flavor  none
         no_define
         description   "
@@ -200,11 +210,11 @@ cdl_package CYGPKG_LIBC_STRING {
 
         cdl_option CYGPKG_LIBC_STRING_TESTS {
             display "C library string function tests"
             flavor  data
             no_define
-            calculated { "tests/memchr tests/memcmp1 tests/memcmp2 
tests/memcpy1 tests/memcpy2 tests/memmove1 tests/memmove2 tests/memset 
tests/strcat1 tests/strcat2 tests/strchr tests/strcmp1 tests/strcmp2 
tests/strcoll1 tests/strcoll2 tests/strcpy1 tests/strcpy2 tests/strcspn 
tests/strcspn tests/strlen tests/strncat1 tests/strncat2 tests/strncpy1 
tests/strncpy2 tests/strpbrk tests/strrchr tests/strspn tests/strstr 
tests/strtok tests/strxfrm1 tests/strxfrm2" }
+            calculated { "tests/memchr tests/memcmp1 tests/memcmp2 
tests/memcpy1 tests/memcpy2 tests/memmove1 tests/memmove2 tests/memset 
tests/strcat1 tests/strcat2 tests/strchr tests/strcmp1 tests/strcmp2 
tests/strcoll1 tests/strcoll2 tests/strcpy1 tests/strcpy2 tests/strcspn 
tests/strcspn tests/strlen tests/strncat1 tests/strncat2 tests/strncpy1 
tests/strncpy2 tests/strpbrk tests/strrchr tests/strspn tests/strstr 
tests/strtok tests/strxfrm1 tests/strxfrm2 tests/strnlen" }
             description   "
                 This option specifies the set of tests for the C library
                 string functions."
         }
     }
Index: include/string.h
===================================================================
RCS file: 
/cvs/ecos/ecos/packages/language/c/libc/string/current/include/string.h,v
retrieving revision 1.5
diff -u -5 -p -r1.5 string.h
--- include/string.h    29 Jan 2009 17:49:53 -0000      1.5
+++ include/string.h    11 May 2010 16:13:52 -0000
@@ -153,10 +153,16 @@ strlen( const char * );
 #ifndef __STRICT_ANSI__
 extern char *
 strdup( const char * );
 #endif
 
+// This is a GNU extension
+#ifdef CYGFUN_LIBC_STRING_GNU_STRNLEN
+extern size_t
+strnlen( const char *, size_t );
+#endif
+
 #ifdef __cplusplus
 }   /* extern "C" */
 #endif
 
 /* INLINE FUNCTIONS */
Index: include/stringsupp.hxx
===================================================================
RCS file: 
/cvs/ecos/ecos/packages/language/c/libc/string/current/include/stringsupp.hxx,v
retrieving revision 1.5
diff -u -5 -p -r1.5 stringsupp.hxx
--- include/stringsupp.hxx      29 Jan 2009 17:49:53 -0000      1.5
+++ include/stringsupp.hxx      11 May 2010 16:13:52 -0000
@@ -210,8 +210,14 @@ __strlen( const char * );
 
 // NB This is a BSD function
 __externC char *
 __strdup( const char * );
 
+// NB This is a GNU extension
+#ifdef CYGFUN_LIBC_STRING_GNU_STRNLEN
+__externC size_t
+__strnlen( const char *, size_t );
+#endif
+
 #endif // CYGONCE_LIBC_STRING_STRINGSUPP_HXX multiple inclusion protection
 
 // EOF stringsupp.hxx

Reply via email to