aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2025-01-22 11:06:31 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2025-01-22 11:06:31 +0200
commita78a985bb6aa02227ce9e5833a25af37ae9a3e86 (patch)
tree4a52fc448f431cc15e199a4f4668855a6e3b6037
parentdf312bd38f8335e66dea39d7bccf25d20443d774 (diff)
Improve next_word() documentationHEADmaster
-rw-r--r--libbutl/utility.hxx11
1 files changed, 11 insertions, 0 deletions
diff --git a/libbutl/utility.hxx b/libbutl/utility.hxx
index cdf7cf2..04c0e56 100644
--- a/libbutl/utility.hxx
+++ b/libbutl/utility.hxx
@@ -208,12 +208,23 @@ namespace butl
// for (size_t b (0), e (0), m (0), n (s.size ());
// next_word (s, n, b, e, m, '\n', '\r'), b != n; )
// {
+ // // Treat consecutive \r\n (CRLF) as if they were a single
+ // // delimiter.
+ // //
+ // if (b != 0 && text[b - 1] == '\r' &&
+ // e != n && text[e] == '\n' &&
+ // m != 2)
+ // continue;
+ //
// string l (s, b, e - b);
// }
//
// For string "\na\n" this code will observe the {"", "a", ""} words. And
// for just "\n" it will observe the {"", ""} words.
//
+ // Note also that you may erase up to (but not including) the delimiter from
+ // the string, provided you adjust b, e, and n before calling next_word().
+ //
std::size_t
next_word (const std::string&, std::size_t& b, std::size_t& e,
char d1 = ' ', char d2 = '\0');