[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gnulib] strnlen.h needed?
From: |
Bruno Haible |
Subject: |
Re: [bug-gnulib] strnlen.h needed? |
Date: |
Mon, 14 Mar 2005 15:30:43 +0100 |
User-agent: |
KMail/1.5 |
Dave Love wrote:
> Where shishi uses `strnlen', on a system without a native version of
> the function it gets an obscure warning about `rpl_strnlen' being
> undeclared.
>
> 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 is a fix.
Bruno
*** modules/strnlen 22 Sep 2004 15:11:04 -0000 1.4
--- modules/strnlen 14 Mar 2005 14:36:50 -0000
***************
*** 2,7 ****
--- 2,8 ----
strnlen() function: determine the length of a size-bounded string.
Files:
+ lib/strnlen.h
lib/strnlen.c
m4/strnlen.m4
***************
*** 13,18 ****
--- 14,20 ----
Makefile.am:
Include:
+ "strnlen.h"
License:
LGPL
*** /dev/null 1970-01-01 01:00:00.000000000 +0100
--- lib/strnlen.h 2005-03-14 15:27:38.000000000 +0100
***************
*** 0 ****
--- 1,29 ----
+ /* Length of a size-bounded string.
+ Copyright (C) 2005 Free Software Foundation, Inc.
+
+ 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. */
+
+ #if HAVE_STRNLEN
+
+ /* Get strnlen() declaration. */
+ #include <string.h>
+
+ #else
+
+ /* 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 *string, size_t maxlen);
+
+ #endif