public inbox for ecos-patches@sourceware.org
 help / color / mirror / Atom feed
From: Jonathan Larmour <jifl@jifvik.org>
To: eCos Patches List <ecos-patches@ecos.sourceware.org>
Subject: Add strnlen()
Date: Tue, 11 May 2010 16:17:00 -0000	[thread overview]
Message-ID: <4BE982EE.1040908@jifvik.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 215 bytes --]

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

[-- Attachment #2: wrypat.txt --]
[-- Type: text/plain, Size: 4341 bytes --]

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  <wry@ecoscentric.com>
+
+	* src/strnlen.cxx, tests/strnlen.c: Created.
+
 2009-01-26  Jonathan Larmour  <jifl@eCosCentric.com>
 
 	* 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	other threads:[~2010-05-11 16:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-11 16:17 Jonathan Larmour [this message]
2010-05-11 16:26 ` Jonathan Larmour
2010-05-12 10:21 ` Reminder: strlcat/strlcpy (was: Add strnlen()) Daniel Néri
2010-05-12 13:04   ` Reminder: strlcat/strlcpy Jonathan Larmour

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4BE982EE.1040908@jifvik.org \
    --to=jifl@jifvik.org \
    --cc=ecos-patches@ecos.sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).