From ddc243f32a8c9817ea52647cab1d9752c36385b0 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 23 Jul 2018 10:29:25 -0400 Subject: vim-patch:8.0.0726: translations cleanup script is too conservative Problem: Translations cleanup script is too conservative. Solution: Also delete untranslated messages. https://github.com/vim/vim/commit/4d2ba822fd80f5b5ff6d9195a5f0fd802aabf304 --- src/nvim/po/cleanup.vim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/nvim/po/cleanup.vim b/src/nvim/po/cleanup.vim index 24ae74ed38..b27d88092f 100644 --- a/src/nvim/po/cleanup.vim +++ b/src/nvim/po/cleanup.vim @@ -8,12 +8,18 @@ let s:was_diff = &diff setl nodiff -silent g/^#: /d +" untranslated message preceded by c-format or comment +silent g/^#, c-format\n#/.d +silent g/^#\..*\n#/.d + +silent g/^#[:~] /d silent g/^#, fuzzy\(, .*\)\=\nmsgid ""\@!/.+1,/^$/-1s/^/#\~ / silent g/^msgstr"/s//msgstr "/ silent g/^msgid"/s//msgid "/ silent g/^msgstr ""\(\n"\)\@!/?^msgid?,.s/^/#\~ / +silent g/^\n\n\n/.d + if s:was_diff setl diff endif -- cgit From d551a49958230077f9bc78587636227b2518149a Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 23 Jul 2018 10:29:48 -0400 Subject: vim-patch:8.0.0734: the script to check translations can be improved Problem: The script to check translations can be improved. Solution: Restore the view when no errors are found. Check for matching line break at the end of the message. (Christian Brabandt) https://github.com/vim/vim/commit/7f93703149a46980f1588ff6b819f52e13084141 --- src/nvim/po/check.vim | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/nvim/po/check.vim b/src/nvim/po/check.vim index b323174550..33a4709e8f 100644 --- a/src/nvim/po/check.vim +++ b/src/nvim/po/check.vim @@ -38,6 +38,7 @@ let s:save_wrapscan = &wrapscan set nowrapscan " Start at the first "msgid" line. +let wsv = winsaveview() 1 /^msgid\> @@ -113,7 +114,43 @@ if search('msgid "\("\n"\)\?\([EW][0-9]\+:\).*\nmsgstr "\("\n"\)\?[^"]\@=\2\@!') endif endif +func! CountNl(first, last) + let nl = 0 + for lnum in range(a:first, a:last) + if getline(lnum) =~ '\\n' + let nl += 1 + endif + endfor + return nl +endfunc + +" Check that the \n at the end of the msid line is also present in the msgstr +" line. Skip over the header. +/^"MIME-Version: +while 1 + let lnum = search('^msgid\>') + if lnum <= 0 + break + endif + let strlnum = search('^msgstr\>') + let end = search('^$') + if end <= 0 + let end = line('$') + 1 + endif + let origcount = CountNl(lnum, strlnum - 1) + let transcount = CountNl(strlnum, end - 1) + " Allow for a few more or less line breaks when there are 2 or more + if origcount != transcount && (origcount <= 2 || transcount <= 2) + echomsg 'Mismatching "\\n" in line ' . line('.') + if error == 0 + let error = lnum + endif + endif +endwhile + if error == 0 + " If all was OK restore the view. + call winrestview(wsv) echomsg "OK" else exe error -- cgit From 1ed5abfe888b364e372ac280fb2ebf971f4fce23 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 23 Jul 2018 11:27:16 -0400 Subject: vim-patch:8.0.0794: checking translations fails with multiple NL Problem: The script to check translations fails if there is more than one NL in one line. Solution: Count the number of NL characters. Make count() accept a string. https://github.com/vim/vim/commit/9966b21a57277986217aa28237d6c247ebd060d7 --- runtime/doc/eval.txt | 7 ++++++- src/nvim/eval.c | 42 +++++++++++++++++++++++++++++-------- src/nvim/po/check.vim | 8 +++---- src/nvim/testdir/test_functions.vim | 8 ++++++- 4 files changed, 49 insertions(+), 16 deletions(-) diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index dce531b663..7b5fc191e9 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2990,11 +2990,16 @@ cosh({expr}) *cosh()* count({comp}, {expr} [, {ic} [, {start}]]) *count()* Return the number of times an item with value {expr} appears - in |List| or |Dictionary| {comp}. + in |String|, |List| or |Dictionary| {comp}. + If {start} is given then start with the item with this index. {start} can only be used with a |List|. + When {ic} is given and it's |TRUE| then case is ignored. + When {comp} is a string then the number of not overlapping + occurences of {expr} is returned. + *cscope_connection()* cscope_connection([{num} , {dbpath} [, {prepend}]]) diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 36662b2a39..1ba516a29c 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -7592,9 +7592,38 @@ static void f_copy(typval_T *argvars, typval_T *rettv, FunPtr fptr) static void f_count(typval_T *argvars, typval_T *rettv, FunPtr fptr) { long n = 0; - int ic = FALSE; + int ic = 0; + bool error = false; - if (argvars[0].v_type == VAR_LIST) { + if (argvars[2].v_type != VAR_UNKNOWN) { + ic = tv_get_number_chk(&argvars[2], &error); + } + + if (argvars[0].v_type == VAR_STRING) { + const char_u *expr = (char_u *)tv_get_string_chk(&argvars[1]); + const char_u *p = argvars[0].vval.v_string; + + if (!error && expr != NULL && p != NULL) { + if (ic) { + const size_t len = STRLEN(expr); + + while (*p != NUL) { + if (mb_strnicmp(p, expr, len) == 0) { + n++; + p += len; + } else { + MB_PTR_ADV(p); + } + } + } else { + char_u *next; + while ((next = (char_u *)strstr((char *)p, (char *)expr)) != NULL) { + n++; + p = next + STRLEN(expr); + } + } + } + } else if (argvars[0].v_type == VAR_LIST) { listitem_T *li; list_T *l; long idx; @@ -7602,9 +7631,6 @@ static void f_count(typval_T *argvars, typval_T *rettv, FunPtr fptr) if ((l = argvars[0].vval.v_list) != NULL) { li = tv_list_first(l); if (argvars[2].v_type != VAR_UNKNOWN) { - bool error = false; - - ic = tv_get_number_chk(&argvars[2], &error); if (argvars[3].v_type != VAR_UNKNOWN) { idx = tv_get_number_chk(&argvars[3], &error); if (!error) { @@ -7630,10 +7656,7 @@ static void f_count(typval_T *argvars, typval_T *rettv, FunPtr fptr) hashitem_T *hi; if ((d = argvars[0].vval.v_dict) != NULL) { - bool error = false; - if (argvars[2].v_type != VAR_UNKNOWN) { - ic = tv_get_number_chk(&argvars[2], &error); if (argvars[3].v_type != VAR_UNKNOWN) { EMSG(_(e_invarg)); } @@ -7649,8 +7672,9 @@ static void f_count(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } } - } else + } else { EMSG2(_(e_listdictarg), "count()"); + } rettv->vval.v_number = n; } diff --git a/src/nvim/po/check.vim b/src/nvim/po/check.vim index 33a4709e8f..ba5cad6c3e 100644 --- a/src/nvim/po/check.vim +++ b/src/nvim/po/check.vim @@ -117,14 +117,12 @@ endif func! CountNl(first, last) let nl = 0 for lnum in range(a:first, a:last) - if getline(lnum) =~ '\\n' - let nl += 1 - endif + let nl += count(getline(lnum), "\n") endfor return nl endfunc -" Check that the \n at the end of the msid line is also present in the msgstr +" Check that the \n at the end of the msgid line is also present in the msgstr " line. Skip over the header. /^"MIME-Version: while 1 @@ -141,7 +139,7 @@ while 1 let transcount = CountNl(strlnum, end - 1) " Allow for a few more or less line breaks when there are 2 or more if origcount != transcount && (origcount <= 2 || transcount <= 2) - echomsg 'Mismatching "\\n" in line ' . line('.') + echomsg 'Mismatching "\n" in line ' . line('.') if error == 0 let error = lnum endif diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index c59134908c..3b16f2ce9f 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -680,7 +680,13 @@ func Test_count() call assert_equal(0, count(d, 'c', 1)) call assert_fails('call count(d, "a", 0, 1)', 'E474:') - call assert_fails('call count("a", "a")', 'E712:') + + call assert_equal(0, count("foo", "bar")) + call assert_equal(1, count("foo", "oo")) + call assert_equal(2, count("foo", "o")) + call assert_equal(0, count("foo", "O")) + call assert_equal(2, count("foo", "O", 1)) + call assert_equal(2, count("fooooo", "oo")) endfunc func Test_changenr() -- cgit From 45a2c6543c00646569ba5a4ad0baf47f05b62571 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 23 Jul 2018 12:24:50 -0400 Subject: vim-patch:8.0.0830: translating messages is not ideal Problem: Translating messages is not ideal. Solution: Add a remark about obsolete messages. Use msgfmt in the check script. (Christian Brabandt) https://github.com/vim/vim/commit/aaef1bae3cc331e7a7bb9c698e707c90cd4ded15 --- src/nvim/po/check.vim | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/nvim/po/check.vim b/src/nvim/po/check.vim index ba5cad6c3e..2350e00e9a 100644 --- a/src/nvim/po/check.vim +++ b/src/nvim/po/check.vim @@ -146,6 +146,16 @@ while 1 endif endwhile +" Check that the file is well formed according to msgfmts understanding +if executable("msgfmt") + let filename = expand("%") + let a = system("msgfmt --statistics OLD_PO_FILE_INPUT=yes" . filename) + if v:shell_error != 0 + let error = matchstr(a, filename.':\zs\d\+\ze:')+0 + for line in split(a, '\n') | echomsg line | endfor + endif +endif + if error == 0 " If all was OK restore the view. call winrestview(wsv) -- cgit From b63f5c170d0544a454a6c2015b7d887ec51aa692 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 23 Jul 2018 12:34:14 -0400 Subject: vim-patch:8.0.0835: translations check with msgfmt does not work Problem: Translations check with msgfmt does not work. Solution: Add a space before the file name. https://github.com/vim/vim/commit/65cedb2074ce550d20a3069c200e2a5d4061d3f6 --- src/nvim/po/check.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nvim/po/check.vim b/src/nvim/po/check.vim index 2350e00e9a..22ee799e82 100644 --- a/src/nvim/po/check.vim +++ b/src/nvim/po/check.vim @@ -149,7 +149,7 @@ endwhile " Check that the file is well formed according to msgfmts understanding if executable("msgfmt") let filename = expand("%") - let a = system("msgfmt --statistics OLD_PO_FILE_INPUT=yes" . filename) + let a = system("msgfmt --statistics OLD_PO_FILE_INPUT=yes " . filename) if v:shell_error != 0 let error = matchstr(a, filename.':\zs\d\+\ze:')+0 for line in split(a, '\n') | echomsg line | endfor -- cgit From 7cf36fc67e88d41a8b1b9b47afbf6146b1baef6e Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 23 Jul 2018 12:41:16 -0400 Subject: vim-patch:8.0.1778: script to check translations does not always work Problem: Script to check translations does not always work. Solution: Go to first line before searching for MIME. https://github.com/vim/vim/commit/b07bbb0d29493fcf4ed080fe018535e64441d663 --- src/nvim/po/check.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/src/nvim/po/check.vim b/src/nvim/po/check.vim index 22ee799e82..086d67a88f 100644 --- a/src/nvim/po/check.vim +++ b/src/nvim/po/check.vim @@ -124,6 +124,7 @@ endfunc " Check that the \n at the end of the msgid line is also present in the msgstr " line. Skip over the header. +1 /^"MIME-Version: while 1 let lnum = search('^msgid\>') -- cgit From 57c095d5fc155bb29077f9fa2fb8e55b93b7f005 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 23 Jul 2018 12:42:15 -0400 Subject: vim-patch:8.0.1839: script to check .po file doesn't check for plural header Problem: Script to check .po file doesn't check for plural header. Solution: Add a check that the plural header is present when needed. https://github.com/vim/vim/commit/9cfc7d885cb3bf37362b11df19a38992893fb385 --- src/nvim/po/check.vim | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/nvim/po/check.vim b/src/nvim/po/check.vim index 086d67a88f..a441a3fee2 100644 --- a/src/nvim/po/check.vim +++ b/src/nvim/po/check.vim @@ -157,6 +157,23 @@ if executable("msgfmt") endif endif +" Check that the plural form is properly initialized +1 +let plural = search('^msgid_plural ', 'n') +if (plural && search('^"Plural-Forms: ', 'n') == 0) || (plural && search('^msgstr\[0\] ".\+"', 'n') != plural + 1) + if search('^"Plural-Forms: ', 'n') == 0 + echomsg "Missing Plural header" + if error == 0 + let error = search('\(^"[A-Za-z-_]\+: .*\\n"\n\)\+\zs', 'n') - 1 + endif + elseif error == 0 + let error = plural + endif +elseif !plural && search('^"Plural-Forms: ', 'n') + " We allow for a stray plural header, msginit adds one. +endif + + if error == 0 " If all was OK restore the view. call winrestview(wsv) -- cgit From 7c7701af1279996c999507750d4beb79ee0f03e0 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 23 Jul 2018 19:34:41 -0400 Subject: vim-patch:8.1.0111: .po files do not use recommended names Problem: .po files do not use recommended names. Solution: Give a warning if the recommended name is not used. Accept the recommended name for conversion. (Christian Brabandt, Ken Takata) https://github.com/vim/vim/commit/d1d037e90192ab64e4cec00b9d008b33bc69d979 --- src/nvim/po/check.vim | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/nvim/po/check.vim b/src/nvim/po/check.vim index a441a3fee2..eae27ef74d 100644 --- a/src/nvim/po/check.vim +++ b/src/nvim/po/check.vim @@ -173,12 +173,37 @@ elseif !plural && search('^"Plural-Forms: ', 'n') " We allow for a stray plural header, msginit adds one. endif +" Check that 8bit encoding is used instead of 8-bit +let cte = search('^"Content-Transfer-Encoding:\s\+8-bit', 'n') +let ctc = search('^"Content-Type:.*;\s\+\