openpkg/patch.strnlen.c

Fri, 07 Sep 2012 19:08:07 +0200

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 07 Sep 2012 19:08:07 +0200
changeset 667
9dacbd1d1aa2
permissions
-rw-r--r--

Correct build configuration in Solaris subdir, correct english grammar,
remove irrelevant strip notice, introduce custom CFLAG logic, facilitate
use of Solaris Studio compiler with needed build configuration
adjustments, conditionally build 64 bit position independent code,
and accommodate tun(7) in newer Solaris releases by renaming driver
and module from conflicting 'tun' to 'vtun'. These changes include
some nonstandard 'I give up' logic causing out of tree builds by
manipulating the PATH, for example.

michael@428 1 /* Find the length of STRING, but scan at most MAXLEN characters.
michael@428 2 Copyright (C) 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
michael@428 3 Written by Simon Josefsson.
michael@428 4
michael@428 5 This program is free software; you can redistribute it and/or modify
michael@428 6 it under the terms of the GNU General Public License as published by
michael@428 7 the Free Software Foundation; either version 2, or (at your option)
michael@428 8 any later version.
michael@428 9
michael@428 10 This program is distributed in the hope that it will be useful,
michael@428 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
michael@428 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
michael@428 13 GNU General Public License for more details.
michael@428 14
michael@428 15 You should have received a copy of the GNU General Public License
michael@428 16 along with this program; if not, write to the Free Software Foundation,
michael@428 17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
michael@428 18
michael@428 19 #include <config.h>
michael@428 20
michael@428 21 #include <string.h>
michael@428 22
michael@428 23 /* Find the length of STRING, but scan at most MAXLEN characters.
michael@428 24 If no '\0' terminator is found in that many characters, return MAXLEN. */
michael@428 25
michael@428 26 size_t
michael@428 27 strnlen (const char *string, size_t maxlen)
michael@428 28 {
michael@428 29 const char *end = memchr (string, '\0', maxlen);
michael@428 30 return end ? (size_t) (end - string) : maxlen;
michael@428 31 }

mercurial