OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib-1.10.0/] [newlib/] [libc/] [string/] [strnlen.c] - Diff between revs 1010 and 1765

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 1010 Rev 1765
/*
/*
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 (*str && n-- > 0)
  while (*str && n-- > 0)
    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.