This is the mail archive of the cygwin-patches@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]