To: vim_dev@googlegroups.com Subject: Patch 8.2.5092 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.5092 Problem: Using "'<,'>" in Ex mode may compare unrelated pointers. Solution: Set eap->cmd to "+" only later. Files: src/ex_docmd.c *** ../vim-8.2.5091/src/ex_docmd.c 2022-06-14 13:30:31.640876084 +0100 --- src/ex_docmd.c 2022-06-14 15:42:53.780803667 +0100 *************** *** 2786,2793 **** { char_u *orig_cmd = eap->cmd; char_u *cmd_start = NULL; ! int did_plus_cmd = FALSE; ! char_u *p; int starts_with_colon = FALSE; int vim9script = in_vim9script(); int has_visual_range = FALSE; --- 2786,2792 ---- { char_u *orig_cmd = eap->cmd; char_u *cmd_start = NULL; ! int use_plus_cmd = FALSE; int starts_with_colon = FALSE; int vim9script = in_vim9script(); int has_visual_range = FALSE; *************** *** 2799,2805 **** { // The automatically inserted Visual area range is skipped, so that // typing ":cmdmod cmd" in Visual mode works without having to move the ! // range to after the modififiers. eap->cmd += 5; cmd_start = eap->cmd; has_visual_range = TRUE; --- 2798,2806 ---- { // The automatically inserted Visual area range is skipped, so that // typing ":cmdmod cmd" in Visual mode works without having to move the ! // range to after the modififiers. The command will be ! // "'<,'>cmdmod cmd", parse "cmdmod cmd" and then put back "'<,'>" ! // before "cmd" below. eap->cmd += 5; cmd_start = eap->cmd; has_visual_range = TRUE; *************** *** 2808,2813 **** --- 2809,2816 ---- // Repeat until no more command modifiers are found. for (;;) { + char_u *p; + while (*eap->cmd == ' ' || *eap->cmd == '\t' || *eap->cmd == ':') { if (*eap->cmd == ':') *************** *** 2815,2830 **** ++eap->cmd; } ! // in ex mode, an empty line works like :+ if (*eap->cmd == NUL && exmode_active && (getline_equal(eap->getline, eap->cookie, getexmodeline) || getline_equal(eap->getline, eap->cookie, getexline)) && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) { ! eap->cmd = (char_u *)"+"; ! did_plus_cmd = TRUE; if (!skip_only) ex_pressedreturn = TRUE; } // ignore comment and empty lines --- 2818,2833 ---- ++eap->cmd; } ! // in ex mode, an empty command (after modifiers) works like :+ if (*eap->cmd == NUL && exmode_active && (getline_equal(eap->getline, eap->cookie, getexmodeline) || getline_equal(eap->getline, eap->cookie, getexline)) && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) { ! use_plus_cmd = TRUE; if (!skip_only) ex_pressedreturn = TRUE; + break; // no modifiers following } // ignore comment and empty lines *************** *** 3108,3119 **** // Since the modifiers have been parsed put the colon on top of the // space: "'<,'>mod cmd" -> "mod:'<,'>cmd // Put eap->cmd after the colon. ! if (did_plus_cmd) { size_t len = STRLEN(cmd_start); ! // Special case: empty command may have been changed to "+": ! // "'<,'>mod" -> "mod'<,'>+ mch_memmove(orig_cmd, cmd_start, len); STRCPY(orig_cmd + len, "'<,'>+"); } --- 3111,3122 ---- // Since the modifiers have been parsed put the colon on top of the // space: "'<,'>mod cmd" -> "mod:'<,'>cmd // Put eap->cmd after the colon. ! if (use_plus_cmd) { size_t len = STRLEN(cmd_start); ! // Special case: empty command uses "+": ! // "'<,'>mods" -> "mods'<,'>+ mch_memmove(orig_cmd, cmd_start, len); STRCPY(orig_cmd + len, "'<,'>+"); } *************** *** 3126,3137 **** } else // No modifiers, move the pointer back. ! // Special case: empty command may have been changed to "+". ! if (did_plus_cmd) eap->cmd = (char_u *)"'<,'>+"; else eap->cmd = orig_cmd; } return OK; } --- 3129,3142 ---- } else // No modifiers, move the pointer back. ! // Special case: change empty command to "+". ! if (use_plus_cmd) eap->cmd = (char_u *)"'<,'>+"; else eap->cmd = orig_cmd; } + else if (use_plus_cmd) + eap->cmd = (char_u *)"+"; return OK; } *** ../vim-8.2.5091/src/version.c 2022-06-14 14:59:12.655158068 +0100 --- src/version.c 2022-06-14 15:38:47.605444670 +0100 *************** *** 736,737 **** --- 736,739 ---- { /* Add new patch number below this line */ + /**/ + 5092, /**/ -- Females are strictly forbidden to appear unshaven in public. [real standing law in New Mexico, United States of America] /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///