diff options
author | Tom Praschan <13141438+tom-anders@users.noreply.github.com> | 2022-04-07 16:14:02 +0200 |
---|---|---|
committer | Tom Praschan <13141438+tom-anders@users.noreply.github.com> | 2022-04-09 15:39:46 +0200 |
commit | 45f62464d3e1f39e74fca627e27eea106ffe46ef (patch) | |
tree | 3ff4fdbd476d29c6427de9b3b02a63c0eb43b13a /src/nvim/indent_c.c | |
parent | 233014f92b5d4d5bf8a6f019241aafd1b05dd383 (diff) | |
download | rneovim-45f62464d3e1f39e74fca627e27eea106ffe46ef.tar.gz rneovim-45f62464d3e1f39e74fca627e27eea106ffe46ef.tar.bz2 rneovim-45f62464d3e1f39e74fca627e27eea106ffe46ef.zip |
vim-patch:8.2.4702: C++ scope labels are hard-coded
Problem: C++ scope labels are hard-coded.
Solution: Add 'cinscopedecls' to define the labels. (Tom Praschan,
closes vim/vim#10109)
https://github.com/vim/vim/commit/3506cf34c17c5eae6c2d1317db1fcd5a8493c288
Diffstat (limited to 'src/nvim/indent_c.c')
-rw-r--r-- | src/nvim/indent_c.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index 7f483d02ab..d26a27c1c2 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -512,24 +512,27 @@ static int cin_isdefault(const char_u *s) && s[1] != ':'; } -/* - * Recognize a "public/private/protected" scope declaration label. - */ -bool cin_isscopedecl(const char_u *s) +/// Recognize a scope declaration label set in 'cinscopedecls'. +bool cin_isscopedecl(const char_u *p) { - int i; + const char_u *s = cin_skipcomment(p); - s = cin_skipcomment(s); - if (STRNCMP(s, "public", 6) == 0) { - i = 6; - } else if (STRNCMP(s, "protected", 9) == 0) { - i = 9; - } else if (STRNCMP(s, "private", 7) == 0) { - i = 7; - } else { - return false; + const size_t cinsd_len = STRLEN(curbuf->b_p_cinsd) + 1; + char_u *cinsd_buf = xmalloc(cinsd_len); + + for (char_u *cinsd = curbuf->b_p_cinsd; *cinsd; ) { + const size_t len = copy_option_part(&cinsd, cinsd_buf, cinsd_len, ","); + if (STRNCMP(s, cinsd_buf, len) == 0) { + const char_u *skip = cin_skipcomment(s + len); + if (*skip == ':' && skip[1] != ':') { + return true; + } + } } - return *(s = cin_skipcomment(s + i)) == ':' && s[1] != ':'; + + xfree(cinsd_buf); + + return false; } // Maximum number of lines to search back for a "namespace" line. |