James Carlson <carls...@workingcode.com> wrote:

> On 5/1/10 2:01 AM, Richard L. Hamilton wrote:
> > I would very much like to see someone compare the OpenSolaris section 3*
> > man pages to The Open Group Base Specifications Issue 7 /
> > IEEE Std 1003.1???-2008
> > see what's what's missing, and get busy adding it.
>
> It sounds like this is your particular itch, so ...
>
> > I would even do some of the research and coding myself.  What I won't
> > do is spend a lot of time arguing about it and jumping through hoops.
>
> What arguing or hoops are you referring to?
>
> In general, trivial changes require trivial review.  Want to add
> strnlen() or something like that?  Cool.  It'll take a couple of short
> email messages, and you're done.
>
> In more detail: one short email message to describe the function (or

OK, let's see.... here is the code:

/* @(#)strnlen.c        1.1 10/04/26 Copyright 2010 J. Schilling */
/*
 *      strnlen() to be used if missing in libc
 *
 *      Copyright (c) 2010 J. Schilling
 */
/*
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * See the file CDDL.Schily.txt in this distribution for details.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file CDDL.Schily.txt from this distribution.
 */

#include <schily/standard.h>
#include <schily/unistd.h>
#include <schily/schily.h>

#ifndef HAVE_STRNLEN

EXPORT size_t
strnlen(s, len)
        register const char     *s;
        register size_t         len;
{
        register const char     *rs = s;

        if (++len == 0) {       /* unsigned overflow */
                while (len-- > 0 && *rs++ != '\0')
                        ;
                if (len == 0)
                        return (rs - s);
                return (--rs - s);
        } else {
                while (--len > 0 && *rs++ != '\0')
                        ;
                if (len == 0)
                        return (rs - s);
                return (--rs - s);
        }
}

#endif

Jörg

-- 
 EMail:jo...@schily.isdn.cs.tu-berlin.de (home) Jörg Schilling D-13353 Berlin
       j...@cs.tu-berlin.de                (uni)  
       joerg.schill...@fokus.fraunhofer.de (work) Blog: 
http://schily.blogspot.com/
 URL:  http://cdrecord.berlios.de/private/ ftp://ftp.berlios.de/pub/schily
_______________________________________________
opensolaris-code mailing list
opensolaris-code@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to