]> git.cworth.org Git - tar/blob - gnu/strnlen1.c
upstream: Fix extraction of device nodes.
[tar] / gnu / strnlen1.c
1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* Find the length of STRING + 1, but scan at most MAXLEN bytes.
4    Copyright (C) 2005-2006, 2009-2010 Free Software Foundation, Inc.
5
6    This program is free software: you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
18
19 #include <config.h>
20
21 /* Specification.  */
22 #include "strnlen1.h"
23
24 #include <string.h>
25
26 /* Find the length of STRING + 1, but scan at most MAXLEN bytes.
27    If no '\0' terminator is found in that many characters, return MAXLEN.  */
28 /* This is the same as strnlen (string, maxlen - 1) + 1.  */
29 size_t
30 strnlen1 (const char *string, size_t maxlen)
31 {
32   const char *end = (const char *) memchr (string, '\0', maxlen);
33   if (end != NULL)
34     return end - string + 1;
35   else
36     return maxlen;
37 }