bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-gnulib] Re: strnlen.h needed?


From: Simon Josefsson
Subject: [bug-gnulib] Re: strnlen.h needed?
Date: Mon, 14 Mar 2005 15:16:40 +0100
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/22.0.50 (gnu/linux)

Dave Love <address@hidden> writes:

> It looks as if gnulib needs a strnlen.h which declares rpl_strnlen
> appropriately (conditional on HAVE_STRNLEN) and it should be used in
> files where strnlen is called.

I agree.  Here's a patch for gnulib.  Untested, but based on
snprintf.h.

2005-03-14  Simon Josefsson  <address@hidden>

        * strnlen.h: New file.

2005-03-14  Simon Josefsson  <address@hidden>

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

Index: lib/strnlen.h
===================================================================
RCS file: lib/strnlen.h
diff -N lib/strnlen.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ lib/strnlen.h       14 Mar 2005 14:15:53 -0000
@@ -0,0 +1,29 @@
+/* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#ifndef STRNLEN_H
+#define STRNLEN_H
+
+/* Get strnlen declaration, if available.  */
+#include <string.h>
+
+#if defined HAVE_DECL_STRNLEN && !HAVE_DECL_STRNLEN
+extern size_t strnlen(const char *s, size_t maxlen);
+#endif
+
+#endif /* STRNLEN_H */
Index: modules/strnlen
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/strnlen,v
retrieving revision 1.4
diff -u -p -r1.4 strnlen
--- modules/strnlen     22 Sep 2004 15:11:04 -0000      1.4
+++ modules/strnlen     14 Mar 2005 14:15:53 -0000
@@ -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
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]