0
0
mirror of https://github.com/vim/vim.git synced 2025-07-26 11:04:33 -04:00

updated for version 7.3.677

Problem:    buf_spname() is used inconsistently.
Solution:   Make the return type a char_u pointer.  Check the size of the
            returned string.
This commit is contained in:
Bram Moolenaar 2012-10-03 18:25:00 +02:00
parent b213da0b57
commit e1704bada4
7 changed files with 17 additions and 18 deletions

View File

@ -2635,7 +2635,7 @@ buflist_list(eap)
continue; continue;
msg_putchar('\n'); msg_putchar('\n');
if (buf_spname(buf) != NULL) if (buf_spname(buf) != NULL)
STRCPY(NameBuff, buf_spname(buf)); vim_strncpy(NameBuff, buf_spname(buf), MAXPATHL - 1);
else else
home_replace(buf, buf->b_fname, NameBuff, MAXPATHL, TRUE); home_replace(buf, buf->b_fname, NameBuff, MAXPATHL, TRUE);
@ -3350,7 +3350,7 @@ maketitle()
else else
{ {
if (buf_spname(curbuf) != NULL) if (buf_spname(curbuf) != NULL)
i_name = (char_u *)buf_spname(curbuf); i_name = buf_spname(curbuf);
else /* use file name only in icon */ else /* use file name only in icon */
i_name = gettail(curbuf->b_ffname); i_name = gettail(curbuf->b_ffname);
*i_str = NUL; *i_str = NUL;
@ -3766,7 +3766,7 @@ build_stl_str_hl(wp, out, outlen, fmt, use_sandbox, fillchar,
case STL_FILENAME: case STL_FILENAME:
fillable = FALSE; /* don't change ' ' to fillchar */ fillable = FALSE; /* don't change ' ' to fillchar */
if (buf_spname(wp->w_buffer) != NULL) if (buf_spname(wp->w_buffer) != NULL)
STRCPY(NameBuff, buf_spname(wp->w_buffer)); vim_strncpy(NameBuff, buf_spname(wp->w_buffer), MAXPATHL - 1);
else else
{ {
t = (opt == STL_FULLPATH) ? wp->w_buffer->b_ffname t = (opt == STL_FULLPATH) ? wp->w_buffer->b_ffname
@ -5244,7 +5244,7 @@ write_viminfo_bufferlist(fp)
* Return special buffer name. * Return special buffer name.
* Returns NULL when the buffer has a normal file name. * Returns NULL when the buffer has a normal file name.
*/ */
char * char_u *
buf_spname(buf) buf_spname(buf)
buf_T *buf; buf_T *buf;
{ {
@ -5263,9 +5263,9 @@ buf_spname(buf)
goto win_found; goto win_found;
win_found: win_found:
if (win != NULL && win->w_llist_ref != NULL) if (win != NULL && win->w_llist_ref != NULL)
return _(msg_loclist); return (char_u *)_(msg_loclist);
else else
return _(msg_qflist); return (char_u *)_(msg_qflist);
} }
#endif #endif
#ifdef FEAT_QUICKFIX #ifdef FEAT_QUICKFIX
@ -5274,12 +5274,12 @@ win_found:
if (bt_nofile(buf)) if (bt_nofile(buf))
{ {
if (buf->b_sfname != NULL) if (buf->b_sfname != NULL)
return (char *)buf->b_sfname; return buf->b_sfname;
return _("[Scratch]"); return (char_u *)_("[Scratch]");
} }
#endif #endif
if (buf->b_fname == NULL) if (buf->b_fname == NULL)
return _("[No Name]"); return (char_u *)_("[No Name]");
return NULL; return NULL;
} }

View File

@ -1688,8 +1688,7 @@ check_changed_any(hidden)
msg_didout = FALSE; msg_didout = FALSE;
} }
if (EMSG2(_("E162: No write since last change for buffer \"%s\""), if (EMSG2(_("E162: No write since last change for buffer \"%s\""),
buf_spname(buf) != NULL ? (char_u *)buf_spname(buf) : buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname))
buf->b_fname))
{ {
save = no_wait_return; save = no_wait_return;
no_wait_return = FALSE; no_wait_return = FALSE;

View File

@ -7602,7 +7602,7 @@ ex_tabs(eap)
msg_putchar(bufIsChanged(wp->w_buffer) ? '+' : ' '); msg_putchar(bufIsChanged(wp->w_buffer) ? '+' : ' ');
msg_putchar(' '); msg_putchar(' ');
if (buf_spname(wp->w_buffer) != NULL) if (buf_spname(wp->w_buffer) != NULL)
STRCPY(IObuff, buf_spname(wp->w_buffer)); vim_strncpy(IObuff, buf_spname(wp->w_buffer), IOSIZE - 1);
else else
home_replace(wp->w_buffer, wp->w_buffer->b_fname, home_replace(wp->w_buffer, wp->w_buffer->b_fname,
IObuff, IOSIZE, TRUE); IObuff, IOSIZE, TRUE);

View File

@ -780,9 +780,7 @@ ml_open_file(buf)
need_wait_return = TRUE; /* call wait_return later */ need_wait_return = TRUE; /* call wait_return later */
++no_wait_return; ++no_wait_return;
(void)EMSG2(_("E303: Unable to open swap file for \"%s\", recovery impossible"), (void)EMSG2(_("E303: Unable to open swap file for \"%s\", recovery impossible"),
buf_spname(buf) != NULL buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname);
? (char_u *)buf_spname(buf)
: buf->b_fname);
--no_wait_return; --no_wait_return;
} }
@ -1315,7 +1313,7 @@ ml_recover()
smsg((char_u *)_("Using swap file \"%s\""), NameBuff); smsg((char_u *)_("Using swap file \"%s\""), NameBuff);
if (buf_spname(curbuf) != NULL) if (buf_spname(curbuf) != NULL)
STRCPY(NameBuff, buf_spname(curbuf)); vim_strncpy(NameBuff, buf_spname(curbuf), MAXPATHL - 1);
else else
home_replace(NULL, curbuf->b_ffname, NameBuff, MAXPATHL, TRUE); home_replace(NULL, curbuf->b_ffname, NameBuff, MAXPATHL, TRUE);
smsg((char_u *)_("Original file \"%s\""), NameBuff); smsg((char_u *)_("Original file \"%s\""), NameBuff);

View File

@ -51,7 +51,7 @@ void ex_buffer_all __ARGS((exarg_T *eap));
void do_modelines __ARGS((int flags)); void do_modelines __ARGS((int flags));
int read_viminfo_bufferlist __ARGS((vir_T *virp, int writing)); int read_viminfo_bufferlist __ARGS((vir_T *virp, int writing));
void write_viminfo_bufferlist __ARGS((FILE *fp)); void write_viminfo_bufferlist __ARGS((FILE *fp));
char *buf_spname __ARGS((buf_T *buf)); char_u *buf_spname __ARGS((buf_T *buf));
void buf_addsign __ARGS((buf_T *buf, int id, linenr_T lnum, int typenr)); void buf_addsign __ARGS((buf_T *buf, int id, linenr_T lnum, int typenr));
linenr_T buf_change_sign_type __ARGS((buf_T *buf, int markId, int typenr)); linenr_T buf_change_sign_type __ARGS((buf_T *buf, int markId, int typenr));
int buf_getsigntype __ARGS((buf_T *buf, linenr_T lnum, int type)); int buf_getsigntype __ARGS((buf_T *buf, linenr_T lnum, int type));

View File

@ -9876,7 +9876,7 @@ get_trans_bufname(buf)
buf_T *buf; buf_T *buf;
{ {
if (buf_spname(buf) != NULL) if (buf_spname(buf) != NULL)
STRCPY(NameBuff, buf_spname(buf)); vim_strncpy(NameBuff, buf_spname(buf), MAXPATHL - 1);
else else
home_replace(buf, buf->b_fname, NameBuff, MAXPATHL, TRUE); home_replace(buf, buf->b_fname, NameBuff, MAXPATHL, TRUE);
trans_characters(NameBuff, MAXPATHL); trans_characters(NameBuff, MAXPATHL);

View File

@ -719,6 +719,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
677,
/**/ /**/
676, 676,
/**/ /**/