All of lore.kernel.org
 help / color / mirror / Atom feed
* should strstr    return const char*  ?
@ 2010-02-28 21:29 Jon
       [not found] ` <4B8AE057.7000000-hus3n9K41k0@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Jon @ 2010-02-28 21:29 UTC (permalink / raw)
  To: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w; +Cc: linux-man-u79uwXL29TY76Z2rM5mHXA

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?

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.

Thanks again for considering this.
Cheers, Jon
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: should strstr    return const char*  ?
       [not found] ` <4B8AE057.7000000-hus3n9K41k0@public.gmane.org>
@ 2010-03-05 20:08   ` Mike Frysinger
  2010-06-19  5:49   ` Michael Kerrisk
  1 sibling, 0 replies; 3+ messages in thread
From: Mike Frysinger @ 2010-03-05 20:08 UTC (permalink / raw)
  To: Jon; +Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w, linux-man-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: Text/Plain, Size: 387 bytes --]

On Sunday 28 February 2010 16:29:59 Jon wrote:
> I see this function on Ubuntu 9.10:
> 
>       char *strstr(const char *haystack, const char *needle);
> 
> Should it not return as const char * though?

man pages document the API only.  if you want to propose changing a function, 
you'd have to ask the glibc mainling lists and/or more likely the POSIX 
mailing lists.
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: should strstr return const char* ?
       [not found] ` <4B8AE057.7000000-hus3n9K41k0@public.gmane.org>
  2010-03-05 20:08   ` Mike Frysinger
@ 2010-06-19  5:49   ` Michael Kerrisk
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Kerrisk @ 2010-06-19  5:49 UTC (permalink / raw)
  To: Jon; +Cc: linux-man-u79uwXL29TY76Z2rM5mHXA

Hello Jon,

On Sun, Feb 28, 2010 at 11:29 PM, Jon <jg-hus3n9K41k0@public.gmane.org> 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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-06-19  5:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-28 21:29 should strstr return const char* ? Jon
     [not found] ` <4B8AE057.7000000-hus3n9K41k0@public.gmane.org>
2010-03-05 20:08   ` Mike Frysinger
2010-06-19  5:49   ` Michael Kerrisk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.