On Tue, Sep 18, 2012 at 09:03:03AM -0700, Ian Lance Taylor wrote: > --- strnlen.c (revision 0) > +++ strnlen.c (revision 0) > @@ -0,0 +1,28 @@ > +/* Portable version of strnlen. > + This function is in the public domain. */ > + > +/* > + > +@deftypefn Supplemental size_t strnlen (const char *@var{s}, size_t > @var{maxlen}) > + > +Returns the length of @var{s}, as with @code{strlen}, but never looks > +past the first @var{maxlen} characters in the string. If there is no > +'\0' character in the first @var{maxlen} characters, returns > +@var{maxlen}. > + > +@end deftypefn > + > +*/ > + > +#include "config.h"
Shouldn't this #include <stddef.h> for size_t, or is config.h providing size_t? Or #include <sys/types.h> ? From what I can see, config.h doesn't always define size_t, only if sys/types.h doesn't define it. > + > +size_t > +strnlen (const char *s, size_t maxlen) > +{ > + size_t i; > + > + for (i = 0; i < maxlen; ++i) > + if (s[i] == '\0') > + break; > + return i; > +} Jakub