To: vim_dev@googlegroups.com Subject: Patch 8.1.1822 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.1822 Problem: Confusing error message when range is not allowed. Solution: With ADDR_NONE give e_norange. Change e_invaddr to e_invrange for consistency. Files: src/ex_docmd.c, src/globals.h, src/testdir/test_excmd.vim *** ../vim-8.1.1821/src/ex_docmd.c 2019-08-05 21:51:36.801568843 +0200 --- src/ex_docmd.c 2019-08-06 21:23:57.181046580 +0200 *************** *** 4208,4213 **** --- 4208,4222 ---- return cmd; } + static void + addr_error(cmd_addr_T addr_type) + { + if (addr_type == ADDR_NONE) + emsg(_(e_norange)); + else + emsg(_(e_invrange)); + } + /* * Get a single EX address. * *************** *** 4264,4273 **** case ADDR_TABS: lnum = CURRENT_TAB_NR; break; - case ADDR_TABS_RELATIVE: case ADDR_NONE: case ADDR_UNSIGNED: ! emsg(_(e_invrange)); cmd = NULL; goto error; break; --- 4273,4282 ---- case ADDR_TABS: lnum = CURRENT_TAB_NR; break; case ADDR_NONE: + case ADDR_TABS_RELATIVE: case ADDR_UNSIGNED: ! addr_error(addr_type); cmd = NULL; goto error; break; *************** *** 4314,4323 **** case ADDR_TABS: lnum = LAST_TAB_NR; break; - case ADDR_TABS_RELATIVE: case ADDR_NONE: case ADDR_UNSIGNED: ! emsg(_(e_invrange)); cmd = NULL; goto error; break; --- 4323,4332 ---- case ADDR_TABS: lnum = LAST_TAB_NR; break; case ADDR_NONE: + case ADDR_TABS_RELATIVE: case ADDR_UNSIGNED: ! addr_error(addr_type); cmd = NULL; goto error; break; *************** *** 4346,4352 **** } if (addr_type != ADDR_LINES) { ! emsg(_(e_invaddr)); cmd = NULL; goto error; } --- 4355,4361 ---- } if (addr_type != ADDR_LINES) { ! addr_error(addr_type); cmd = NULL; goto error; } *************** *** 4378,4384 **** c = *cmd++; if (addr_type != ADDR_LINES) { ! emsg(_(e_invaddr)); cmd = NULL; goto error; } --- 4387,4393 ---- c = *cmd++; if (addr_type != ADDR_LINES) { ! addr_error(addr_type); cmd = NULL; goto error; } *************** *** 4428,4434 **** ++cmd; if (addr_type != ADDR_LINES) { ! emsg(_(e_invaddr)); cmd = NULL; goto error; } --- 4437,4443 ---- ++cmd; if (addr_type != ADDR_LINES) { ! addr_error(addr_type); cmd = NULL; goto error; } *************** *** 7926,7932 **** */ if (n == MAXLNUM || n < 0 || n > curbuf->b_ml.ml_line_count) { ! emsg(_(e_invaddr)); return; } --- 7935,7941 ---- */ if (n == MAXLNUM || n < 0 || n > curbuf->b_ml.ml_line_count) { ! emsg(_(e_invrange)); return; } *** ../vim-8.1.1821/src/globals.h 2019-08-03 23:08:11.089552674 +0200 --- src/globals.h 2019-08-06 21:24:22.428846451 +0200 *************** *** 1456,1462 **** EXTERN char e_internal[] INIT(= N_("E473: Internal error")); EXTERN char e_intern2[] INIT(= N_("E685: Internal error: %s")); EXTERN char e_interr[] INIT(= N_("Interrupted")); - EXTERN char e_invaddr[] INIT(= N_("E14: Invalid address")); EXTERN char e_invarg[] INIT(= N_("E474: Invalid argument")); EXTERN char e_invarg2[] INIT(= N_("E475: Invalid argument: %s")); EXTERN char e_duparg2[] INIT(= N_("E983: Duplicate argument: %s")); --- 1456,1461 ---- *** ../vim-8.1.1821/src/testdir/test_excmd.vim 2019-07-24 22:30:06.336638707 +0200 --- src/testdir/test_excmd.vim 2019-08-06 21:11:07.465050142 +0200 *************** *** 8,10 **** --- 8,21 ---- .dl call assert_equal(['a', 'c'], getline(1, 2)) endfunc + + func Test_range_error() + call assert_fails(':.echo 1', 'E481:') + call assert_fails(':$echo 1', 'E481:') + call assert_fails(':1,2echo 1', 'E481:') + call assert_fails(':+1echo 1', 'E481:') + call assert_fails(':/1/echo 1', 'E481:') + call assert_fails(':\/echo 1', 'E481:') + normal vv + call assert_fails(":'<,'>echo 1", 'E481:') + endfunc *** ../vim-8.1.1821/src/version.c 2019-08-06 20:34:07.392451015 +0200 --- src/version.c 2019-08-06 21:28:31.715006807 +0200 *************** *** 775,776 **** --- 775,778 ---- { /* Add new patch number below this line */ + /**/ + 1822, /**/ -- "So this is it," said Arthur, "we are going to die." "Yes," said Ford, "except...no! Wait a minute!" He suddenly lunged across the chamber at something behind Arthur's line of vision. "What's this switch?" he cried. "What? Where?" cried Arthur, twisting around. "No, I was only fooling," said Ford, "we are going to die after all." -- Douglas Adams, "The Hitchhiker's Guide to the Galaxy" /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///