2005-08-10 Simon Josefsson <jas@extundo.com>
authorSimon Josefsson <simon@josefsson.org>
Thu, 11 Aug 2005 09:56:12 +0000 (09:56 +0000)
committerSimon Josefsson <simon@josefsson.org>
Thu, 11 Aug 2005 09:56:12 +0000 (09:56 +0000)
* strndup.c: Use strnlen.h.

* strnlen.h: New file.

2005-08-11  Simon Josefsson  <jas@extundo.com>

* modules/strnlen (Files): Add strnlen.h.

2005-08-10  Simon Josefsson  <jas@extundo.com>

* strnlen.m4: New file.

* strndup.m4: Don't check for strnlen declaration, done in
strnlen.m4.

ChangeLog
lib/ChangeLog
lib/strndup.c
lib/strnlen.h [new file with mode: 0644]
m4/ChangeLog
m4/strndup.m4
m4/strnlen.m4
modules/strnlen

index 46b96b15cdf64ef17ae25c3b67a5c96315cf1e78..3434d652f1dd41c0cf5af6c00e5a3d2ff65f4f4b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-08-11  Simon Josefsson  <jas@extundo.com>
+
+       * modules/strnlen (Files): Add strnlen.h.
+
 2005-08-10  Simon Josefsson  <jas@extundo.com>
 
        * tests/test-iconvme.c: New file.
index a44fa6f6fcc71fe6f59fe945a5605342fcc07688..7d9d4c6439b0fa9ee64755979c5a89f1968896c7 100644 (file)
@@ -1,3 +1,9 @@
+2005-08-10  Simon Josefsson  <jas@extundo.com>
+
+       * strndup.c: Use strnlen.h.
+
+       * strnlen.h: New file.
+
 2005-08-02  Simon Josefsson  <jas@extundo.com>
 
        * getline.h, getline.c: Rewrite.
index 366a4eb5700c726b247c3617acb53fd86b12d429..b2d7c0e0bb8d94c2dcd8c78feda704ef662e6027 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1998, 2000, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998, 2000, 2003, 2005 Free Software Foundation, Inc.
 
    NOTE: The canonical source of this file is maintained with the GNU C Library.
    Bugs can be reported to bug-glibc@prep.ai.mit.edu.
 #include <stdlib.h>
 #include <string.h>
 
-#ifndef HAVE_DECL_STRNLEN
-"this configure-time declaration test was not run"
-#endif
-#if !HAVE_DECL_STRNLEN
-size_t strnlen ();
-#endif
+/* Get strnlen. */
+#include "strnlen.h"
 
 #undef __strndup
 #undef strndup
diff --git a/lib/strnlen.h b/lib/strnlen.h
new file mode 100644 (file)
index 0000000..f1ca757
--- /dev/null
@@ -0,0 +1,32 @@
+/* Find the length of STRING, but scan at most MAXLEN characters.
+   Copyright (C) 2005 Free Software Foundation, Inc.
+   Written by Simon Josefsson.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef STRNLEN_H
+#define STRNLEN_H
+
+/* Get strnlen declaration, if available.  */
+#include <string.h>
+
+#if defined HAVE_DECL_STRNLEN && !HAVE_DECL_STRNLEN
+/* Find the length (number of bytes) of STRING, but scan at most
+   MAXLEN bytes.  If no '\0' terminator is found in that many bytes,
+   return MAXLEN.  */
+extern size_t strnlen(const char *s, size_t maxlen);
+#endif
+
+#endif /* STRNLEN_H */
index 8180ab2579b5090253f6b3cb53154a93239c36f7..57994d8b8969a5c8aea459025e95f4e97fd538db 100644 (file)
@@ -1,3 +1,10 @@
+2005-08-10  Simon Josefsson  <jas@extundo.com>
+
+       * strnlen.m4: New file.
+
+       * strndup.m4: Don't check for strnlen declaration, done in
+       strnlen.m4.
+
 2005-08-10  Stepan Kasal  <kasal@ucw.cz>
 
        * onceonly_2_57.m4: Really require Autoconf 2.57.
index 57945045686e90f034e82aee316a218209c41aeb..66cedb4334c1af2cf0292db9f5738129343254cf 100644 (file)
@@ -1,4 +1,4 @@
-# strndup.m4 serial 4
+# strndup.m4 serial 5
 dnl Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -18,6 +18,4 @@ AC_DEFUN([gl_FUNC_STRNDUP],
 ])
 
 # Prerequisites of lib/strndup.c.
-AC_DEFUN([gl_PREREQ_STRNDUP], [
-  AC_CHECK_DECLS(strnlen)
-])
+AC_DEFUN([gl_PREREQ_STRNDUP], [:])
index e6af315cb6b7307103d4671b780d31c58221275d..67964c8d7d5f461420d50f68b262cd1ff34471cb 100644 (file)
@@ -1,11 +1,13 @@
-# strnlen.m4 serial 4
-dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
+# strnlen.m4 serial 5
+dnl Copyright (C) 2002-2003, 2005 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_FUNC_STRNLEN],
 [
+  AC_LIBSOURCES([strnlen.c, strnlen.h])
+
   dnl Persuade glibc <string.h> to declare strnlen().
   AC_REQUIRE([AC_GNU_SOURCE])
 
@@ -22,4 +24,6 @@ AC_DEFUN([gl_FUNC_STRNLEN],
 ])
 
 # Prerequisites of lib/strnlen.c.
-AC_DEFUN([gl_PREREQ_STRNLEN], [:])
+AC_DEFUN([gl_PREREQ_STRNLEN], [
+  AC_CHECK_DECLS_ONCE(strnlen)
+])
index 4f52435a84c68e7d91ad23585144fbf6551783b3..26ae3f3db56fba55b753eaa03d9c6237567369c9 100644 (file)
@@ -2,6 +2,7 @@ Description:
 strnlen() function: determine the length of a size-bounded string.
 
 Files:
+lib/strnlen.h
 lib/strnlen.c
 m4/strnlen.m4