Re: should strstr return const char* ?

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

 



Hello Jon,

On Sun, Feb 28, 2010 at 11:29 PM, Jon <jg@xxxxxxxx> wrote:
> Hi there,
>
> A couple of queries. I hope could be considered.
>
> I see this function on Ubuntu 9.10:
>
>     char *strstr(const char *haystack, const char *needle);
>
> Should it not return as const char * though?

As Mike Frysinger pointed out, man-pages here is documenting things as
they are in glibc. (Also, POSIX does not document a "const" here in
the spec.)

> Also could the description be clarified:
> DESCRIPTION
>       The strstr() function finds the first occurrence of the substring
> needle in the string haystack.  The terminating
>       '\0' characters are not compared.
>
>
> Can this be added: "If needle is longer than haystack it will never match.
> When the search reaches a character position in haystack which does not
> leave enough characters left to compare, searching will end, the haystack
> buffer will not be overrun.

I regard these points as reasonably self-evident, so I don't think
they really need to be specifically mentioned. (What else could one
reasonably expect to happen in these cases?)

Thanks,

Michael



-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Author of "The Linux Programming Interface" http://blog.man7.org/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux