diff options
| author | Sean Dewar <seandewar@users.noreply.github.com> | 2021-09-15 00:35:33 +0100 |
|---|---|---|
| committer | Sean Dewar <seandewar@users.noreply.github.com> | 2021-09-15 13:34:54 +0100 |
| commit | 6436100b6e4baeee8685677ae4319e71580caa3c (patch) | |
| tree | 3745fa1102cb89d3ed238fcf6bc1786fe89fcf6b /src/nvim/charset.c | |
| parent | 04cde576edc1cb4795769ef2520416997c0f79c0 (diff) | |
| download | rneovim-6436100b6e4baeee8685677ae4319e71580caa3c.tar.gz rneovim-6436100b6e4baeee8685677ae4319e71580caa3c.tar.bz2 rneovim-6436100b6e4baeee8685677ae4319e71580caa3c.zip | |
backport: fix(:source, nvim_exec): handle Vimscript line continuations #14809
Problem:
Anonymous :source (no args) and nvim_exec() don't support Vimscript line continuations.
Solution:
Factor out the concat logic into concat_continued_line() and a
CONCAT_CONTINUED_LINES macro for simple concatenations where lines are
fetched individually.
Closes #14807
Diffstat (limited to 'src/nvim/charset.c')
| -rw-r--r-- | src/nvim/charset.c | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/src/nvim/charset.c b/src/nvim/charset.c index e2d844a351..a58c665905 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -1446,15 +1446,29 @@ void getvcols(win_T *wp, pos_T *pos1, pos_T *pos2, colnr_T *left, /// skipwhite: skip over ' ' and '\t'. /// -/// @param[in] q String to skip in. +/// @param[in] p String to skip in. /// /// @return Pointer to character after the skipped whitespace. -char_u *skipwhite(const char_u *q) +char_u *skipwhite(const char_u *const p) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET { - const char_u *p = q; - while (ascii_iswhite(*p)) { + return skipwhite_len(p, STRLEN(p)); +} + +/// Like `skipwhite`, but skip up to `len` characters. +/// @see skipwhite +/// +/// @param[in] p String to skip in. +/// @param[in] len Max length to skip. +/// +/// @return Pointer to character after the skipped whitespace, or the `len`-th +/// character in the string. +char_u *skipwhite_len(const char_u *p, size_t len) + FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL + FUNC_ATTR_NONNULL_RET +{ + for (; len > 0 && ascii_iswhite(*p); len--) { p++; } return (char_u *)p; @@ -1600,6 +1614,18 @@ char_u* skiptowhite_esc(char_u *p) { return p; } +/// Skip over text until '\n' or NUL. +/// +/// @param[in] p Text to skip over. +/// +/// @return Pointer to the next '\n' or NUL character. +char_u *skip_to_newline(const char_u *const p) + FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL + FUNC_ATTR_NONNULL_RET +{ + return (char_u *)xstrchrnul((const char *)p, NL); +} + /// Gets a number from a string and skips over it, signalling overflow. /// /// @param[out] pp A pointer to a pointer to char_u. |
