autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: String functions with end pointers?


From: Paul Eggert
Subject: Re: String functions with end pointers?
Date: Tue, 25 Apr 2006 05:07:32 -0700
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

"Paul D. Smith" <address@hidden> writes:

> Are there any such functions in GLIB or similar?  Do people know of
> similar functions in other OS's etc.?  If not, and I wanted to think
> about creating some, what kind of naming convention would be
> appropriate?  I thought of strp*() but I don't know.

I don't know of any such functions, though they sound like nice ones
to have.

I wouldn't use strp*, since that prefix is already used for strpbrk
and strptime, not to mention glibc strpcpy.  Nor strl*, since it's
used for OpenBSD strlcpy and strlcat
<http://en.wikipedia.org/wiki/Strlcpy>.  Nor stre*, since it's used
for Plan 9 strecpy
<http://plan9.bell-labs.com/sources/plan9/sys/src/libc/port/strecpy.c>.

In fact, come to think of it, I wouldn't use str* at all, since the
functions you're talking about work on arbitrary memory buffers
that can contain internal NULs.

How about "meme*", for "memory with end pointer"?  (I think the "e" in
Plan 9 "strecpy" also means "end pointer".)  E.g.,

char *memechr(const char *str, const char *endp, int c);

And while you're at it, why not fix the type of the last arg, since
you're not assuming K&R compatibility any more?

char *memechr(const char *str, const char *endp, char c);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]