Revision: 2746
          http://tmux.svn.sourceforge.net/tmux/?rev=2746&view=rev
Author:   tcunha
Date:     2012-03-18 02:17:20 +0000 (Sun, 18 Mar 2012)
Log Message:
-----------
Sync OpenBSD patchset 1067:

Use snprintf for constructing attribute string, from Tim Ruehsen.

Modified Paths:
--------------
    trunk/attributes.c

Modified: trunk/attributes.c
===================================================================
--- trunk/attributes.c  2012-03-18 02:12:24 UTC (rev 2745)
+++ trunk/attributes.c  2012-03-18 02:17:20 UTC (rev 2746)
@@ -26,27 +26,21 @@
 attributes_tostring(u_char attr)
 {
        static char     buf[128];
+       size_t          len;
 
        if (attr == 0)
                return ("none");
 
-       buf[0] = '\0';
-       if (attr & GRID_ATTR_BRIGHT)
-               strlcat(buf, "bright,", sizeof (buf));
-       if (attr & GRID_ATTR_DIM)
-               strlcat(buf, "dim,", sizeof (buf));
-       if (attr & GRID_ATTR_UNDERSCORE)
-               strlcat(buf, "underscore,", sizeof (buf));
-       if (attr & GRID_ATTR_BLINK)
-               strlcat(buf, "blink,", sizeof (buf));
-       if (attr & GRID_ATTR_REVERSE)
-               strlcat(buf, "reverse,", sizeof (buf));
-       if (attr & GRID_ATTR_HIDDEN)
-               strlcat(buf, "hidden,", sizeof (buf));
-       if (attr & GRID_ATTR_ITALICS)
-               strlcat(buf, "italics,", sizeof (buf));
-       if (*buf != '\0')
-               *(strrchr(buf, ',')) = '\0';
+       len = xsnprintf(buf, sizeof buf, "%s%s%s%s%s%s%s",
+               attr & GRID_ATTR_BRIGHT ? "bright," : "",
+               attr & GRID_ATTR_DIM ? "dim," : "",
+               attr & GRID_ATTR_UNDERSCORE ? "underscore," : "",
+               attr & GRID_ATTR_BLINK ? "blink," : "",
+               attr & GRID_ATTR_REVERSE ? "reverse," : "",
+               attr & GRID_ATTR_HIDDEN ? "hidden," : "",
+               attr & GRID_ATTR_ITALICS ? "italics," : "");
+       if (len > 0)
+               buf[len - 1] = '\0';
 
        return (buf);
 }

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
tmux-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-cvs

Reply via email to