diff options
| author | aneporada <[email protected]> | 2024-11-12 07:55:22 +0300 |
|---|---|---|
| committer | Maxim Yurchuk <[email protected]> | 2024-11-12 11:34:44 +0300 |
| commit | 3d93c5084c3b9f301d4fbfb9815a90eac174f211 (patch) | |
| tree | c8cc0bc991054b26261120816cd4dc9e26c94206 /yql/essentials/utils/line_split.cpp | |
| parent | 8937a36ecfbe0ac99bb69555af2704146c13e57b (diff) | |
Merge GH PR #9404
commit_hash:d780798556aedbe2be898d69185380f2ecb95f9c
Diffstat (limited to 'yql/essentials/utils/line_split.cpp')
| -rw-r--r-- | yql/essentials/utils/line_split.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/yql/essentials/utils/line_split.cpp b/yql/essentials/utils/line_split.cpp new file mode 100644 index 00000000000..657d0edd9bf --- /dev/null +++ b/yql/essentials/utils/line_split.cpp @@ -0,0 +1,39 @@ +#include "line_split.h" + +TLineSplitter::TLineSplitter(IInputStream& stream) + : Stream_(stream) +{ +} + +size_t TLineSplitter::Next(TString& st) { + st.clear(); + char c; + size_t ret = 0; + if (HasPendingLineChar_) { + st.push_back(PendingLineChar_); + HasPendingLineChar_ = false; + ++ret; + } + + while (Stream_.ReadChar(c)) { + ++ret; + if (c == '\n') { + break; + } else if (c == '\r') { + if (Stream_.ReadChar(c)) { + ++ret; + if (c != '\n') { + --ret; + PendingLineChar_ = c; + HasPendingLineChar_ = true; + } + } + + break; + } else { + st.push_back(c); + } + } + + return ret; +} |
