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.
This commit is contained in:
Justin M. Keyes
2015-12-26 20:12:24 -05:00
parent 76bf21de26
commit 3fd62f9612
3 changed files with 41 additions and 46 deletions

View File

@@ -918,13 +918,15 @@ do_buffer (
if (buf == NULL) { /* could not find it */ if (buf == NULL) { /* could not find it */
if (start == DOBUF_FIRST) { if (start == DOBUF_FIRST) {
/* don't warn when deleting */ // don't warn when deleting
if (!unload) if (!unload) {
EMSGN(_(e_nobufnr), count); EMSGN(_(e_nobufnr), count);
} else if (dir == FORWARD) }
} else if (dir == FORWARD) {
EMSG(_("E87: Cannot go beyond last buffer")); EMSG(_("E87: Cannot go beyond last buffer"));
else } else {
EMSG(_("E88: Cannot go before first buffer")); EMSG(_("E88: Cannot go before first buffer"));
}
return FAIL; return FAIL;
} }
@@ -1711,18 +1713,15 @@ static buf_T *buflist_findname_file_id(char_u *ffname, FileID *file_id,
return NULL; return NULL;
} }
/* /// Find file in buffer list by a regexp pattern.
* Find file in buffer list by a regexp pattern. /// Return fnum of the found buffer.
* Return fnum of the found buffer. /// Return < 0 for error.
* Return < 0 for error. int buflist_findpat(
*/ const char_u *pattern,
int const char_u *pattern_end, // pointer to first char after pattern
buflist_findpat ( int unlisted, // find unlisted buffers
char_u *pattern, int diffmode, // find diff-mode buffers only
char_u *pattern_end, /* pointer to first char after pattern */ int curtab_only // find buffers in current tab only
int unlisted, /* find unlisted buffers */
int diffmode, /* find diff-mode buffers only */
int curtab_only /* find buffers in current tab only */
) )
{ {
int match = -1; int match = -1;

View File

@@ -7096,26 +7096,23 @@ int match_file_list(char_u *list, char_u *sfname, char_u *ffname)
return FALSE; return FALSE;
} }
/* /// Convert the given pattern "pat" which has shell style wildcards in it, into
* 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
* 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
* is a directory path separator to be matched, then TRUE is put in /// allow_dirs, otherwise FALSE is put there -- webb.
* allow_dirs, otherwise FALSE is put there -- webb. /// Handle backslashes before special characters, like "\*" and "\ ".
* Handle backslashes before special characters, like "\*" and "\ ". ///
* /// Returns NULL on failure.
* Returns NULL on failure. char_u * file_pat_to_reg_pat(
*/ const char_u *pat,
char_u * const char_u *pat_end, // first char after pattern or NULL
file_pat_to_reg_pat ( char *allow_dirs, // Result passed back out in here
char_u *pat, int no_bslash // Don't use a backward slash as pathsep
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 *reg_pat;
char_u *p; const char_u *p;
int nested = 0; int nested = 0;
int add_dollar = TRUE; int add_dollar = TRUE;

View File

@@ -704,17 +704,15 @@ char_u *get_expr_line_src(void)
bool valid_yank_reg(int regname, bool writing) bool valid_yank_reg(int regname, bool writing)
{ {
if ((regname > 0 && ASCII_ISALNUM(regname)) if ((regname > 0 && ASCII_ISALNUM(regname))
|| (!writing && vim_strchr((char_u *) || (!writing && vim_strchr((char_u *) "/.%:=" , regname) != NULL)
"/.%:="
, regname) != NULL)
|| regname == '#' || regname == '#'
|| regname == '"' || regname == '"'
|| regname == '-' || regname == '-'
|| regname == '_' || regname == '_'
|| regname == '*' || regname == '*'
|| regname == '+' || regname == '+') {
)
return true; return true;
}
return false; return false;
} }
@@ -4666,8 +4664,9 @@ void write_reg_contents_ex(int name,
int num = atoi((char *)str); int num = atoi((char *)str);
buf = buflist_findnr(num); buf = buflist_findnr(num);
if (buf == NULL) if (buf == NULL) {
EMSGN(_(e_nobufnr), (long)num); EMSGN(_(e_nobufnr), (long)num);
}
} else { } else {
buf = buflist_findnr(buflist_findpat(str, str + STRLEN(str), buf = buflist_findnr(buflist_findpat(str, str + STRLEN(str),
true, false, false)); true, false, false));