[cfe-dev] [patch] Add configure option for C include search path

Rafael Espindola espindola at google.com
Thu Nov 12 15:05:08 PST 2009


> Assuming you agree with empty string -> empty list, this is simpler as:
> --
> void llvm::StringRef::split(std::vector<StringRef> &A,
>                            StringRef Separators, unsigned MaxSplit,
>                            bool KeepEmpty) const {
>  StringRef Str = *this;
>
>  while (!Str.empty() && A.size() != MaxSplit) {
>    std::pair<llvm::StringRef, llvm::StringRef> split = Str.split(Separators);
>
>    if (KeepEmptyLines || !split.first.empty())
>      A.push_back(split.first);
>
>    Str = split.second;
>  }
> }

Not for every input:

*) If A is not empty at function entry...

*) It also changes what is done with the tail:
   StringRef("a,b,c"),splits(parts, ",", 1). This produces ["a",
"b,c"] with my implementation, but ["a"] with yours. Python includes
the tail.

*) The case with KeepEmpty = false I referred to:

  StringRef("a,,b,c").split(parts, ",", 2, false); This will produce
["a", "b,c"] with my implementation, but ["a", "b"] with yours.

I have simplified the code a bit.

Cheers,
-- 
Rafael Ávila de Espíndola
-------------- next part --------------
A non-text attachment was scrubbed...
Name: splitstring.patch
Type: text/x-diff
Size: 5470 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20091112/907bed1e/attachment.patch>


More information about the cfe-dev mailing list