This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

wcsnlen


Hello.
Here is wcsnlen with documentation header. Please, add Copyright header
yourself.

wchar.h_diff - is patch that adds wcsnlen prototype to wchar.h (wchar.h
is fresh since was given from Newlib CVS today)

Best Regards, Artem B. Bityuckiy.



/* 
FUNCTION
        <<wcsnlen>>---get fixed-size wide character string length
    
INDEX
        wcsnlen

ANSI_SYNOPSIS
        #include <wchar.h>
        size_t wcsnlen(const wchar_t *<[s]>, size_t <[maxlen]>);

TRAD_SYNOPSIS
        #include <wchar.h>
        size_t wcsnlen(<[s]>, <[maxlen]>)
        wchar_t *<[s]>;
        size_t <[maxlen]>;

DESCRIPTION
        The <<wcsnlen>> function computes the number of wide character codes
        in the wide character string pointed to by <[s]> not including the
        terminating L'\0' wide character but at most <[maxlen]> wide
        characters.

RETURNS
        <<wcsnlen>> returns the length of <[s]> if it is less then <[maxlen]>,
        or <[maxlen]> if there is no L'\0' wide character in first <[maxlen]>
        characters.

PORTABILITY
<<wcsnlen>> is GNU extension..
<<wcsnlen>> requires no supporting OS subroutines.
*/

#include <_ansi.h>
#include <sys/types.h>
#include <wchar.h>

size_t
_DEFUN(wcsnlen, (s, maxlen), 
                 _CONST wchar_t *s _AND 
                 size_t maxlen)
{
    _CONST wchar_t *p;

    p = s;
    while (*p && maxlen-- > 0)
            p++;

    return (size_t)(p - s);
}



57a58
> size_t        _EXFUN(wcsnlen, (const wchar_t *, size_t ));




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]