From 76bf21de26340a93005deea0c2f846edc6fc3743 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 26 Dec 2015 19:17:55 -0500 Subject: vim-patch:7.4.605 Problem: The # register is not writable, it cannot be restored after jumping around. Solution: Make the # register writable. (Marcin Szamotulski) https://github.com/vim/vim/commit/3b3a9498d1eab3c28c524cce115160528a9a9297 --- src/nvim/buffer.c | 2 +- src/nvim/globals.h | 2 ++ src/nvim/ops.c | 23 ++++++++++++++++++++++- src/nvim/version.c | 2 +- 4 files changed, 26 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 762cd3efd3..f498fca6ad 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -920,7 +920,7 @@ do_buffer ( if (start == DOBUF_FIRST) { /* don't warn when deleting */ if (!unload) - EMSGN(_("E86: Buffer %" PRId64 " does not exist"), count); + EMSGN(_(e_nobufnr), count); } else if (dir == FORWARD) EMSG(_("E87: Cannot go beyond last buffer")); else diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 52eebebf41..d68e952693 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -2,6 +2,7 @@ #define NVIM_GLOBALS_H #include +#include // EXTERN is only defined in main.c. That's where global variables are // actually defined and initialized. @@ -1239,6 +1240,7 @@ EXTERN char_u e_intern2[] INIT(= N_("E685: Internal error: %s")); EXTERN char_u e_maxmempat[] INIT(= N_( "E363: pattern uses more memory than 'maxmempattern'")); EXTERN char_u e_emptybuf[] INIT(= N_("E749: empty buffer")); +EXTERN char_u e_nobufnr[] INIT(= N_("E86: Buffer %" PRId64 " does not exist")); EXTERN char_u e_invalpat[] INIT(= N_( "E682: Invalid search pattern or delimiter")); diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 52b4fed9d7..159b4c03e7 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -705,8 +705,9 @@ bool valid_yank_reg(int regname, bool writing) { if ( (regname > 0 && ASCII_ISALNUM(regname)) || (!writing && vim_strchr((char_u *) - "/.%#:=" + "/.%:=" , regname) != NULL) + || regname == '#' || regname == '"' || regname == '-' || regname == '_' @@ -4658,6 +4659,26 @@ void write_reg_contents_ex(int name, return; } + if (name == '#') { + buf_T *buf; + + if (ascii_isdigit(*str)) { + int num = atoi((char *)str); + + buf = buflist_findnr(num); + if (buf == NULL) + EMSGN(_(e_nobufnr), (long)num); + } else { + buf = buflist_findnr(buflist_findpat(str, str + STRLEN(str), + true, false, false)); + } + if (buf == NULL) { + return; + } + curwin->w_alt_fnum = buf->b_fnum; + return; + } + if (name == '=') { size_t offset = 0; size_t totlen = (size_t) len; diff --git a/src/nvim/version.c b/src/nvim/version.c index b097ac4702..93222ae143 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -388,7 +388,7 @@ static int included_patches[] = { 608, // 607, 606, - // 605, + 605, 604, // 603, 602, -- cgit From 3fd62f961294d11fff5754a3c597e982b54ca74a Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 26 Dec 2015 20:12:24 -0500 Subject: file_pat_to_reg_pat, buflist_findpat: const params file_pat_to_reg_pat() and buflist_findpat() do not modify the data of these parameters. --- src/nvim/buffer.c | 31 +++++++++++++++---------------- src/nvim/fileio.c | 31 ++++++++++++++----------------- src/nvim/ops.c | 25 ++++++++++++------------- 3 files changed, 41 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index f498fca6ad..a6e3fedd3f 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -918,13 +918,15 @@ do_buffer ( if (buf == NULL) { /* could not find it */ if (start == DOBUF_FIRST) { - /* don't warn when deleting */ - if (!unload) + // don't warn when deleting + if (!unload) { EMSGN(_(e_nobufnr), count); - } else if (dir == FORWARD) + } + } else if (dir == FORWARD) { EMSG(_("E87: Cannot go beyond last buffer")); - else + } else { EMSG(_("E88: Cannot go before first buffer")); + } return FAIL; } @@ -1711,18 +1713,15 @@ static buf_T *buflist_findname_file_id(char_u *ffname, FileID *file_id, return NULL; } -/* - * Find file in buffer list by a regexp pattern. - * Return fnum of the found buffer. - * Return < 0 for error. - */ -int -buflist_findpat ( - char_u *pattern, - char_u *pattern_end, /* pointer to first char after pattern */ - int unlisted, /* find unlisted buffers */ - int diffmode, /* find diff-mode buffers only */ - int curtab_only /* find buffers in current tab only */ +/// Find file in buffer list by a regexp pattern. +/// Return fnum of the found buffer. +/// Return < 0 for error. +int buflist_findpat( + const char_u *pattern, + const char_u *pattern_end, // pointer to first char after pattern + int unlisted, // find unlisted buffers + int diffmode, // find diff-mode buffers only + int curtab_only // find buffers in current tab only ) { int match = -1; diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 1a6c85abaa..687e06a5b6 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -7096,26 +7096,23 @@ int match_file_list(char_u *list, char_u *sfname, char_u *ffname) return FALSE; } -/* - * Convert the given pattern "pat" which has shell style wildcards in it, into - * a regular expression, and return the result in allocated memory. If there - * is a directory path separator to be matched, then TRUE is put in - * allow_dirs, otherwise FALSE is put there -- webb. - * Handle backslashes before special characters, like "\*" and "\ ". - * - * Returns NULL on failure. - */ -char_u * -file_pat_to_reg_pat ( - char_u *pat, - char_u *pat_end, /* first char after pattern or NULL */ - char *allow_dirs, /* Result passed back out in here */ - int no_bslash /* Don't use a backward slash as pathsep */ +/// Convert the given pattern "pat" which has shell style wildcards in it, into +/// a regular expression, and return the result in allocated memory. If there +/// is a directory path separator to be matched, then TRUE is put in +/// allow_dirs, otherwise FALSE is put there -- webb. +/// Handle backslashes before special characters, like "\*" and "\ ". +/// +/// Returns NULL on failure. +char_u * file_pat_to_reg_pat( + const char_u *pat, + const char_u *pat_end, // first char after pattern or NULL + char *allow_dirs, // Result passed back out in here + int no_bslash // Don't use a backward slash as pathsep ) { - char_u *endp; + const char_u *endp; char_u *reg_pat; - char_u *p; + const char_u *p; int nested = 0; int add_dollar = TRUE; diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 159b4c03e7..2b1056e90e 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -703,18 +703,16 @@ char_u *get_expr_line_src(void) /// @param writing allow only writable registers bool valid_yank_reg(int regname, bool writing) { - if ( (regname > 0 && ASCII_ISALNUM(regname)) - || (!writing && vim_strchr((char_u *) - "/.%:=" - , regname) != NULL) - || regname == '#' - || regname == '"' - || regname == '-' - || regname == '_' - || regname == '*' - || regname == '+' - ) + if ((regname > 0 && ASCII_ISALNUM(regname)) + || (!writing && vim_strchr((char_u *) "/.%:=" , regname) != NULL) + || regname == '#' + || regname == '"' + || regname == '-' + || regname == '_' + || regname == '*' + || regname == '+') { return true; + } return false; } @@ -4666,11 +4664,12 @@ void write_reg_contents_ex(int name, int num = atoi((char *)str); buf = buflist_findnr(num); - if (buf == NULL) + if (buf == NULL) { EMSGN(_(e_nobufnr), (long)num); + } } else { buf = buflist_findnr(buflist_findpat(str, str + STRLEN(str), - true, false, false)); + true, false, false)); } if (buf == NULL) { return; -- cgit