diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2023-11-29 22:39:54 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2023-11-29 22:39:54 +0000 |
commit | 21cb7d04c387e4198ca8098a884c78b56ffcf4c2 (patch) | |
tree | 84fe5690df1551f0bb2bdfe1a13aacd29ebc1de7 /src/nvim/po/check.vim | |
parent | d9c904f85a23a496df4eb6be42aa43f007b22d50 (diff) | |
parent | 4a8bf24ac690004aedf5540fa440e788459e5e34 (diff) | |
download | rneovim-colorcolchar.tar.gz rneovim-colorcolchar.tar.bz2 rneovim-colorcolchar.zip |
Merge remote-tracking branch 'upstream/master' into colorcolcharcolorcolchar
Diffstat (limited to 'src/nvim/po/check.vim')
-rw-r--r-- | src/nvim/po/check.vim | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/nvim/po/check.vim b/src/nvim/po/check.vim index 7705ba8577..e67cb8c149 100644 --- a/src/nvim/po/check.vim +++ b/src/nvim/po/check.vim @@ -6,6 +6,9 @@ if 1 " Only execute this if the eval feature is available. +" using line continuation +set cpo&vim + let filename = "check-" . expand("%:t:r") . ".log" exe 'redir! > ' . filename @@ -30,8 +33,15 @@ func! GetMline() " remove '%' used for plural forms. let idline = substitute(idline, '\\nPlural-Forms: .\+;\\n', '', '') + " remove duplicate positional format arguments + let idline2 = "" + while idline2 != idline + let idline2 = idline + let idline = substitute(idline, '%\([1-9][0-9]*\)\$\([-+ #''.*]*[0-9]*l\=[dsuxXpoc%]\)\(.*\)%\1$\([-+ #''.*]*\)\(l\=[dsuxXpoc%]\)', '%\1$\2\3\4', 'g') + endwhile + " remove everything but % items. - return substitute(idline, '[^%]*\(%[-+ #''.0-9*]*l\=[dsuxXpoc%]\)\=', '\1', 'g') + return substitute(idline, '[^%]*\(%([1-9][0-9]*\$)\=[-+ #''.0-9*]*l\=[dsuxXpoc%]\)\=', '\1', 'g') endfunc " This only works when 'wrapscan' is not set. @@ -62,12 +72,18 @@ while 1 if getline(line('.') - 1) !~ "no-c-format" " go over the "msgid" and "msgid_plural" lines let prevfromline = 'foobar' + let plural = 0 while 1 + if getline('.') =~ 'msgid_plural' + let plural += 1 + endif let fromline = GetMline() if prevfromline != 'foobar' && prevfromline != fromline + \ && (plural != 1 + \ || count(prevfromline, '%') + 1 != count(fromline, '%')) echomsg 'Mismatching % in line ' . (line('.') - 1) echomsg 'msgid: ' . prevfromline - echomsg 'msgid ' . fromline + echomsg 'msgid: ' . fromline if error == 0 let error = line('.') endif @@ -89,6 +105,7 @@ while 1 while getline('.') =~ '^msgstr' let toline = GetMline() if fromline != toline + \ && (plural == 0 || count(fromline, '%') != count(toline, '%') + 1) echomsg 'Mismatching % in line ' . (line('.') - 1) echomsg 'msgid: ' . fromline echomsg 'msgstr: ' . toline |