summaryrefslogtreecommitdiff
path: root/src/winmsg.c
diff options
context:
space:
mode:
authorMike Gerwitz <mike@mikegerwitz.com>2013-12-11 10:46:33 -0500
committerAmadeusz Sławiński <amade@asmblr.net>2015-06-26 15:17:18 +0200
commit78dc153b6111b487cc51e924868cce8e8b87c742 (patch)
tree19721de459b7d512296e7b80ea2e8f099d2b8a1b /src/winmsg.c
parentf32ca1040b689dc105655d100d2cc4e738ee9351 (diff)
downloadscreen-78dc153b6111b487cc51e924868cce8e8b87c742.tar.gz
Added wmbc_str{,n}cpy and replaced existing refactored strncpy's
All remaining calls in MakeWinMsgEv will be replaced as they are refactored into their own functions. Until then, they will continue to work as before, but will not expand the buffer.
Diffstat (limited to 'src/winmsg.c')
-rw-r--r--src/winmsg.c33
1 files changed, 8 insertions, 25 deletions
diff --git a/src/winmsg.c b/src/winmsg.c
index 1a90c71..743a5ad 100644
--- a/src/winmsg.c
+++ b/src/winmsg.c
@@ -326,15 +326,8 @@ winmsg_esc_ex(Focus, Window *win, Event *ev)
winmsg_esc(HostName)
{
- size_t max = wmbc_bytesleft(wmbc);
-
- *wmbc->p = '\0';
- if (strlen(HostName) < max) {
- strncpy(wmbc->p, HostName, max);
- if (*wmbc->p)
- wmc_set(cond);
- }
- wmbc_fastfw(wmbc);
+ if (*wmbc_strcpy(wmbc, HostName))
+ wmc_set(cond);
return s;
}
@@ -376,16 +369,10 @@ winmsg_esc(Rend)
winmsg_esc(SessName)
{
char *session_name = strchr(SocketName, '.') + 1;
- size_t max = wmbc_bytesleft(wmbc);
- *wmbc->p = '\0';
- if (strlen(session_name) < max) {
- strncpy(wmbc->p, session_name, max);
- if (*wmbc->p)
- wmc_set(cond);
- }
+ if (*wmbc_strcpy(wmbc, session_name))
+ wmc_set(cond);
- wmbc_fastfw(wmbc);
return s;
}
@@ -440,16 +427,12 @@ winmsg_esc_ex(WinArgv, Window *win)
winmsg_esc_ex(WinTitle, Window *win)
{
- size_t max = wmbc_bytesleft(wmbc);
+ if (!win)
+ return s;
- *wmbc->p = '\0';
- if (win && strlen(win->w_title) < max) {
- strncpy(wmbc->p, win->w_title, max);
- if (*wmbc->p)
- wmc_set(cond);
- }
+ if (*wmbc_strcpy(wmbc, win->w_title))
+ wmc_set(cond);
- wmbc_fastfw(wmbc);
return s;
}