OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [string/] [strnlen.c] - Blame information for rev 277

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/*
2
FUNCTION
3
        <<strnlen>>---character string length
4
 
5
INDEX
6
        strnlen
7
 
8
ANSI_SYNOPSIS
9
        #include <string.h>
10
        size_t strnlen(const char *<[str]>, size_t <[n]>);
11
 
12
TRAD_SYNOPSIS
13
        #include <string.h>
14
        size_t strnlen(<[str]>, <[n]>)
15
        char *<[src]>;
16
        size_t <[n]>;
17
 
18
DESCRIPTION
19
        The <<strnlen>> function works out the length of the string
20
        starting at <<*<[str]>>> by counting chararacters until it
21
        reaches a NUL character or the maximum: <[n]> number of
22
        characters have been inspected.
23
 
24
RETURNS
25
        <<strnlen>> returns the character count or <[n]>.
26
 
27
PORTABILITY
28
<<strnlen>> is a GNU extension.
29
 
30
<<strnlen>> requires no supporting OS subroutines.
31
 
32
*/
33
 
34
#undef __STRICT_ANSI__
35
#include <_ansi.h>
36
#include <string.h>
37
 
38
size_t
39
_DEFUN (strnlen, (str, n),
40
        _CONST char *str _AND
41
        size_t n)
42
{
43
  _CONST char *start = str;
44
 
45
  while (n-- > 0 && *str)
46
    str++;
47
 
48
  return str - start;
49
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.