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

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [newlib-1.18.0/] [newlib-1.18.0-or32-1.0rc1/] [newlib/] [libc/] [string/] [strnlen.c] - Diff between revs 207 and 345

Only display areas with differences | Details | Blame | View Log

Rev 207 Rev 345
/*
/*
FUNCTION
FUNCTION
        <<strnlen>>---character string length
        <<strnlen>>---character string length
 
 
INDEX
INDEX
        strnlen
        strnlen
 
 
ANSI_SYNOPSIS
ANSI_SYNOPSIS
        #include <string.h>
        #include <string.h>
        size_t strnlen(const char *<[str]>, size_t <[n]>);
        size_t strnlen(const char *<[str]>, size_t <[n]>);
 
 
TRAD_SYNOPSIS
TRAD_SYNOPSIS
        #include <string.h>
        #include <string.h>
        size_t strnlen(<[str]>, <[n]>)
        size_t strnlen(<[str]>, <[n]>)
        char *<[src]>;
        char *<[src]>;
        size_t <[n]>;
        size_t <[n]>;
 
 
DESCRIPTION
DESCRIPTION
        The <<strnlen>> function works out the length of the string
        The <<strnlen>> function works out the length of the string
        starting at <<*<[str]>>> by counting chararacters until it
        starting at <<*<[str]>>> by counting chararacters until it
        reaches a NUL character or the maximum: <[n]> number of
        reaches a NUL character or the maximum: <[n]> number of
        characters have been inspected.
        characters have been inspected.
 
 
RETURNS
RETURNS
        <<strnlen>> returns the character count or <[n]>.
        <<strnlen>> returns the character count or <[n]>.
 
 
PORTABILITY
PORTABILITY
<<strnlen>> is a GNU extension.
<<strnlen>> is a GNU extension.
 
 
<<strnlen>> requires no supporting OS subroutines.
<<strnlen>> requires no supporting OS subroutines.
 
 
*/
*/
 
 
#undef __STRICT_ANSI__
#undef __STRICT_ANSI__
#include <_ansi.h>
#include <_ansi.h>
#include <string.h>
#include <string.h>
 
 
size_t
size_t
_DEFUN (strnlen, (str, n),
_DEFUN (strnlen, (str, n),
        _CONST char *str _AND
        _CONST char *str _AND
        size_t n)
        size_t n)
{
{
  _CONST char *start = str;
  _CONST char *start = str;
 
 
  while (n-- > 0 && *str)
  while (n-- > 0 && *str)
    str++;
    str++;
 
 
  return str - start;
  return str - start;
}
}
 
 

powered by: WebSVN 2.1.0

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