This is the mail archive of the
cygwin-patches@cygwin.com
mailing list for the Cygwin project.
RE: For the curious: Setup.exe char-> String patch
- From: "Gary R Van Sickle" <tiberius at braemarinc dot com>
- To: <cygwin-patches at cygwin dot com>
- Date: Fri, 1 Feb 2002 20:26:42 -0600
- Subject: RE: For the curious: Setup.exe char-> String patch
> +// does this character exist in the string?
> +// 0 is false, 1 is the first position...
> +size_t
> +String::find(char aChar) const
> +{
> + for (size_t i=0; i < theData->length; ++i)
> + if (theData->theString[i] == aChar)
> + return i;
> + return 0;
>
> ### Won't this return 0 if aChar is in the first position in
> theData->theString?
>
I think it would behoove us greatly to duplicate the semantics of
std::string here, and return a zero-based offset on success, and an "npos"
on failure.
> geturl.cc:
>
> static void
> -init_dialog (char const *url, int length, HWND owner)
> +init_dialog (String const url, int length, HWND owner)
^^^^^^^^^^^^^^^^
This would be better written "const String &url".
--
Gary R. Van Sickle
Braemar Inc.
11481 Rupp Dr.
Burnsville, MN 55337