From a5481957c65985fc1f885464ae9b43f92d0dc519 Mon Sep 17 00:00:00 2001 From: lonerover Date: Fri, 17 Mar 2017 22:48:42 +0800 Subject: vim-patch:7.4.2255 Problem: The script that checks translations can't handle plurals. Solution: Check for plural msgid and msgstr entries. Leave the cursor on the first error. https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7 --- src/nvim/po/check.vim | 76 +++++++++++++++++++++++++++++++++++++-------------- src/nvim/version.c | 2 +- 2 files changed, 56 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/nvim/po/check.vim b/src/nvim/po/check.vim index 1622741da6..b323174550 100644 --- a/src/nvim/po/check.vim +++ b/src/nvim/po/check.vim @@ -33,36 +33,66 @@ func! GetMline() return substitute(idline, '[^%]*\(%[-+ #''.0-9*]*l\=[dsuxXpoc%]\)\=', '\1', 'g') endfunc -" This only works when 'wrapscan' is set. +" This only works when 'wrapscan' is not set. let s:save_wrapscan = &wrapscan -set wrapscan +set nowrapscan " Start at the first "msgid" line. 1 -/^msgid -let startline = line('.') +/^msgid\> + +" When an error is detected this is set to the line number. +" Note: this is used in the Makefile. let error = 0 while 1 if getline(line('.') - 1) !~ "no-c-format" - let fromline = GetMline() + " go over the "msgid" and "msgid_plural" lines + let prevfromline = 'foobar' + while 1 + let fromline = GetMline() + if prevfromline != 'foobar' && prevfromline != fromline + echomsg 'Mismatching % in line ' . (line('.') - 1) + echomsg 'msgid: ' . prevfromline + echomsg 'msgid ' . fromline + if error == 0 + let error = line('.') + endif + endif + if getline('.') !~ 'msgid_plural' + break + endif + let prevfromline = fromline + endwhile + if getline('.') !~ '^msgstr' - echo 'Missing "msgstr" in line ' . line('.') - let error = 1 - endif - let toline = GetMline() - if fromline != toline - echo 'Mismatching % in line ' . (line('.') - 1) - echo 'msgid: ' . fromline - echo 'msgstr: ' . toline - let error = 1 + echomsg 'Missing "msgstr" in line ' . line('.') + if error == 0 + let error = line('.') + endif endif + + " check all the 'msgstr' lines + while getline('.') =~ '^msgstr' + let toline = GetMline() + if fromline != toline + echomsg 'Mismatching % in line ' . (line('.') - 1) + echomsg 'msgid: ' . fromline + echomsg 'msgstr: ' . toline + if error == 0 + let error = line('.') + endif + endif + if line('.') == line('$') + break + endif + endwhile endif - " Find next msgid. - " Wrap around at the end of the file, quit when back at the first one. - /^msgid - if line('.') == startline + " Find next msgid. Quit when there is no more. + let lnum = line('.') + silent! /^msgid\> + if line('.') == lnum break endif endwhile @@ -77,12 +107,16 @@ endwhile " 1 if search('msgid "\("\n"\)\?\([EW][0-9]\+:\).*\nmsgstr "\("\n"\)\?[^"]\@=\2\@!') > 0 - echo 'Mismatching error/warning code in line ' . line('.') - let error = 1 + echomsg 'Mismatching error/warning code in line ' . line('.') + if error == 0 + let error = line('.') + endif endif if error == 0 - echo "OK" + echomsg "OK" +else + exe error endif redir END diff --git a/src/nvim/version.c b/src/nvim/version.c index 5b3a7398d5..b9286c2a4e 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -186,7 +186,7 @@ static int included_patches[] = { // 2258 NA // 2257 NA // 2256, - // 2255, + 2255, // 2254 NA // 2253 NA // 2252 NA -- cgit From 26d7757ccbc57125a3dfe3b2cad0f07a2e567df1 Mon Sep 17 00:00:00 2001 From: lonerover Date: Fri, 17 Mar 2017 23:09:15 +0800 Subject: vim-patch:7.4.2256 Problem: Coverity complains about null pointer check. Solution: Remove wrong and superfluous error check. https://github.com/vim/vim/commit/db249f26edf7a5f88d1f4468d08ec5b84f5ab7ad --- src/nvim/eval.c | 5 ++++- src/nvim/version.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index d4daffb469..5de999f175 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -4860,7 +4860,10 @@ static int get_string_tv(char_u **arg, typval_T *rettv, int evaluate) } *name = NUL; - *arg = p + 1; + if (*p != NUL) { // just in case + p++; + } + *arg = p; return OK; } diff --git a/src/nvim/version.c b/src/nvim/version.c index b9286c2a4e..5cdd0d96fe 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -185,7 +185,7 @@ static int included_patches[] = { // 2259, // 2258 NA // 2257 NA - // 2256, + 2256, 2255, // 2254 NA // 2253 NA -- cgit