Patch 7.4.870

81 views
Skip to first unread message

Bram Moolenaar

unread,
Sep 15, 2015, 12:30:14 PM9/15/15
to vim...@googlegroups.com

Patch 7.4.870
Problem: May get into an invalid state when using getchar() in an
expression mapping.
Solution: Anticipate mod_mask to change. (idea by Yukihiro Nakadaira)
Files: src/getchar.c


*** ../vim-7.4.869/src/getchar.c 2015-09-15 14:12:01.378632565 +0200
--- src/getchar.c 2015-09-15 18:17:50.192261837 +0200
***************
*** 1630,1642 ****
last_recorded_len = 0;
for (;;) /* this is done twice if there are modifiers */
{
if (mod_mask) /* no mapping after modifier has been read */
{
++no_mapping;
++allow_keys;
}
c = vgetorpeek(TRUE);
! if (mod_mask)
{
--no_mapping;
--allow_keys;
--- 1630,1645 ----
last_recorded_len = 0;
for (;;) /* this is done twice if there are modifiers */
{
+ int did_inc = FALSE;
+
if (mod_mask) /* no mapping after modifier has been read */
{
++no_mapping;
++allow_keys;
+ did_inc = TRUE; /* mod_mask may change value */
}
c = vgetorpeek(TRUE);
! if (did_inc)
{
--no_mapping;
--allow_keys;
*** ../vim-7.4.869/src/version.c 2015-09-15 17:58:22.760394656 +0200
--- src/version.c 2015-09-15 18:15:46.745544634 +0200
***************
*** 743,744 ****
--- 743,746 ----
{ /* Add new patch number below this line */
+ /**/
+ 870,
/**/

--
I once paid $12 to peer at the box that held King Tutankhamen's little
bandage-covered midget corpse at the De Young Museum in San Francisco. I
remember thinking how pleased he'd be about the way things turned out in his
afterlife.
(Scott Adams - The Dilbert principle)

/// Bram Moolenaar -- Br...@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 ///

watiko

unread,
Feb 14, 2016, 11:25:58 PM2/14/16
to vim_dev
Hi, Bram.

There is a related issue:

```sh
vim -u NONE -i NONE -c 'nnoremap <expr> x getchar()'
```

Then type "x<S-Space>" and "iX<Esc>", I got too many "X"s.

```version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Feb 15 2016 13:19:05)
Included patches: 1-1320
Compiled by watiko@cDesk
Huge version with GTK2-GNOME GUI. Features included (+) or not (-):
```

Thanks,
watiko

h_east

unread,
Feb 15, 2016, 1:12:28 AM2/15/16
to vim_dev
Hi,

2016-2-15(Mon) 13:25:58 UTC+9 watiko:


> Hi, Bram.
>
> There is a related issue:

No.
Reported issue also occurred in Vim 7.4.869.
This patch doesn't matter.

>
> ```sh
> vim -u NONE -i NONE -c 'nnoremap <expr> x getchar()'
> ```
>
> Then type "x<S-Space>" and "iX<Esc>", I got too many "X"s.
>
> ```version
> VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Feb 15 2016 13:19:05)
> Included patches: 1-1320
> Compiled by watiko@cDesk
> Huge version with GTK2-GNOME GUI. Features included (+) or not (-):
> ```

Simple verification method:
$ vim -u NONE -c 'nnoremap <expr> x getchar()'

(1)
type:
x#:

Displayed to command-line:
:.,.+34


(2)
type:
x!:

Displayed to command-line:
:.,.+32

Remarks:
Character `#`'s ascii code is 35(dec).
Character `!`'s ascii code is 33(dec).
These are matched to displayed number + 1.

Thanks for reporting this.
--
Best regards,
Hirohito Higashi (a.k.a. h_east)

Bram Moolenaar

unread,
Feb 15, 2016, 7:09:41 AM2/15/16
to h_east, vim_dev
Isn't this expected behavior? getchar() returns a number, so typing
x#:
Is equivalent to:
34:

Perhaps you want:
nnoremap <expr> x nr2char(getchar())

--
hundred-and-one symptoms of being an internet addict:
262. Your computer has it's own phone line - but your daughter doesn't.

Shohei Uzuki

unread,
Feb 15, 2016, 7:23:27 AM2/15/16
to vim...@googlegroups.com
Aha, I see. I was confused a little bit. Thanks, Hirohito and Bram.

2016年2月15日(月) 21:09 Bram Moolenaar <Br...@moolenaar.net>:
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to a topic in the Google Groups "vim_dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_dev/6b1LKhtG6f0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vim_dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages