if (bytes_read < 0)
return GUI_CHILD_IO_ERROR;
buffer[bytes_read] = NUL;
- if (strcmp(buffer, "ok") == 0)
+ if (STRCMP(buffer, "ok") == 0)
return GUI_CHILD_OK;
return GUI_CHILD_FAILED;
}
# endif
)
{
+ size_t slen = 2; // 2 spaces by default
+
# ifdef FEAT_NETBEANS_INTG
if (*s == MULTISIGN_BYTE)
multi_sign = TRUE;
if (*curwin->w_p_scl == 'n' && *(curwin->w_p_scl + 1) == 'u' &&
(curwin->w_p_nu || curwin->w_p_rnu))
{
- sprintf((char *)extra, "%*c ", number_width(curwin), ' ');
- s = extra;
+ int n = number_width(curwin);
+
+ slen = MIN(n, (int)sizeof(extra) - 1);
}
- else
- s = (char_u *)" ";
+ vim_memset(extra, ' ', slen);
+ extra[slen] = NUL;
+ s = extra;
if (len == 1 && col > 0)
--col;
- len = (int)STRLEN(s);
+ len = (int)slen;
if (len > 2)
// right align sign icon in the number column
signcol = col + len - 3;
tabpage_T *tp,
int tooltip) // TRUE: get tooltip
{
- int modified = FALSE;
- char_u buf[40];
- int wincount;
- win_T *wp;
char_u **opt;
// Use 'guitablabel' or 'guitabtooltip' if it's set.
// use a default label.
if (**opt == NUL || *NameBuff == NUL)
{
+ win_T *wp;
+ int wincount = 0;
+ int modified = FALSE;
+
// Get the buffer name into NameBuff[] and shorten it.
get_trans_bufname(tp == curtab ? curbuf : tp->tp_curwin->w_buffer);
if (!tooltip)
shorten_dir(NameBuff);
- wp = (tp == curtab) ? firstwin : tp->tp_firstwin;
- for (wincount = 0; wp != NULL; wp = wp->w_next, ++wincount)
+ FOR_ALL_WINDOWS_IN_TAB(tp, wp)
+ {
+ ++wincount;
if (bufIsChanged(wp->w_buffer))
modified = TRUE;
+ }
+
if (modified || wincount > 1)
{
+ char_u buf[40] = "+ "; // Tentatively assume modified only
+ size_t buflen = 2;
+ size_t NameBufflen = STRLEN(NameBuff);
+
if (wincount > 1)
- vim_snprintf((char *)buf, sizeof(buf), "%d", wincount);
- else
- buf[0] = NUL;
- if (modified)
- STRCAT(buf, "+");
- STRCAT(buf, " ");
- STRMOVE(NameBuff + STRLEN(buf), NameBuff);
- mch_memmove(NameBuff, buf, STRLEN(buf));
+ buflen = vim_snprintf_safelen(
+ (char *)buf,
+ sizeof(buf),
+ "%d%s ",
+ wincount,
+ modified ? "+" : "");
+
+ // Make sure resulting NameBuff will not exceed it's bounds.
+ if (NameBufflen + buflen < MAXPATHL)
+ {
+ mch_memmove(NameBuff + buflen, NameBuff, NameBufflen + 1); // +1 for NUL
+ mch_memmove(NameBuff, buf, buflen);
+ }
}
}
}
text = arg;
if (text != NULL)
{
- text = vim_strsave(text);
+ int len = (int)STRLEN(text);
+
+ text = vim_strnsave(text, len);
if (text != NULL)
{
- int len = (int)STRLEN(text);
int i;
// Remove "\V"