[hackers] [wmii] Take advantage of strlcat in libixp

From: Kris Maglione <jg_AT_suckless.org>
Date: Sat Feb 17 08:24:17 2007

changeset: 1893:5a578dc52ed4
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Sat Feb 17 02:20:11 2007 -0500
summary: Take advantage of strlcat in libixp

diff -r 3101a0221763 -r 5a578dc52ed4 client.c
--- a/client.c Fri Feb 16 17:24:39 2007 -0500
+++ b/client.c Sat Feb 17 02:20:11 2007 -0500
@@ -576,7 +576,9 @@ resize_client(Client *c, XRectangle *r)
                 return;
         }
 
- c->rect = f->rect;
+ c->rect = f->crect;
+ c->rect.x += f->rect.x;
+ c->rect.y += f->rect.y;
         if(f->area->mode == Colmax
         && f->area->sel != f) {
                 unmap_frame(c);
@@ -782,7 +784,6 @@ void
 void
 apply_tags(Client *c, const char *tags) {
         uint i, j, k, n;
- int len;
         Bool add;
         char buf[512], last;
         char *toks[32], *cur;
@@ -792,7 +793,7 @@ apply_tags(Client *c, const char *tags)
                 if(tags[n] != ' ' && tags[n] != '\t') break;
         if(tags[n] == '+' || tags[n] == '-')
                 strncpy(buf, c->tags, sizeof(c->tags));
- strncat(buf, &tags[n], sizeof(buf) - strlen(buf));
+ ixp_strlcat(buf, &tags[n], sizeof(buf));
         trim(buf, " \t/");
 
         n = 0;
@@ -849,15 +850,12 @@ apply_tags(Client *c, const char *tags)
         }
         c->tags[0] = '\0';
         qsort(toks, j, sizeof(char *), compare_tags);
- len = sizeof(c->tags);
         if(!j) return;
- for(i=0, n=0; i < j && len > 1; i++)
+ for(i=0, n=0; i < j; i++)
                 if(!n || strcmp(toks[i], toks[n-1])) {
                         if(i)
- strncat(c->tags, "+", len);
- len -= strlen(c->tags);
- strncat(c->tags, toks[i], len);
- len -= strlen(c->tags);
+ ixp_strlcat(c->tags, "+", sizeof(c->tags));
+ ixp_strlcat(c->tags, toks[i], sizeof(c->tags));
                         toks[n++] = toks[i];
                 }
         toks[n] = nil;
diff -r 3101a0221763 -r 5a578dc52ed4 event.c
--- a/event.c Fri Feb 16 17:24:39 2007 -0500
+++ b/event.c Sat Feb 17 02:20:11 2007 -0500
@@ -58,7 +58,7 @@ buttonpress(XEvent *e) {
                                 break;
                         case Button3:
                                 do_mouse_resize(f->client, False,
- quadofcoord(&f->client->rect, ev->x, ev->y));
+ quadofcoord(&f->rect, ev->x, ev->y));
                                 frame_to_top(f);
                                 focus(f->client, True);
                                 break;
@@ -74,7 +74,7 @@ buttonpress(XEvent *e) {
                                 else if(!ev->subwindow
                                 && !ispointinrect(ev->x, ev->y, &f->titlebar.rect))
                                         do_mouse_resize(f->client, False,
- quadofcoord(&f->client->rect, ev->x, ev->y));
+ quadofcoord(&f->rect, ev->x, ev->y));
                                 if(f->client != sel_client())
                                         focus(f->client, True);
                         }
@@ -100,6 +100,9 @@ configurerequest(XEvent *e) {
                         fprintf(stderr, "Configure: %s\n\ta: x=%d y=%d w=%d h=%d\n",
                                 c->name, c->rect.x, c->rect.y, c->rect.width, c->rect.height);
                 gravitate_client(c, True);
+ if(verbose)
+ fprintf(stderr, "\tb: x=%d y=%d w=%d h=%d\n",
+ c->rect.x, c->rect.y, c->rect.width, c->rect.height);
                 if(ev->value_mask & CWX)
                         c->rect.x = ev->x;
                 if(ev->value_mask & CWY)
@@ -110,6 +113,9 @@ configurerequest(XEvent *e) {
                         c->rect.height = ev->height;
                 if(ev->value_mask & CWBorderWidth)
                         c->border = ev->border_width;
+ if(verbose)
+ fprintf(stderr, "\tb: x=%d y=%d w=%d h=%d\n",
+ c->rect.x, c->rect.y, c->rect.width, c->rect.height);
                 gravitate_client(c, False);
                 if(verbose)
                         fprintf(stderr, "\tb: x=%d y=%d w=%d h=%d\n",
@@ -125,7 +131,9 @@ configurerequest(XEvent *e) {
                 frect->x -= def.border;
                 frect->width += 2 * def.border;
                 frect->height += frame_delta_h();
- c->rect = f->crect;
+ if(verbose)
+ fprintf(stderr, "\tb: x=%d y=%d w=%d h=%d\n",
+ frect->x, frect->y, frect->width, frect->height);
 
                 if(c->sel->area->floating)
                         resize_client(c, frect);
diff -r 3101a0221763 -r 5a578dc52ed4 main.c
--- a/main.c Fri Feb 16 17:24:39 2007 -0500
+++ b/main.c Sat Feb 17 02:20:11 2007 -0500
@@ -2,6 +2,10 @@
  * See LICENSE file for license details.
  */
 #include "wmii.h"
+#include <X11/Xatom.h>
+#include <X11/Xproto.h>
+#include <X11/cursorfont.h>
+#include <X11/keysym.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <locale.h>
@@ -13,11 +17,6 @@
 #include <sys/stat.h>
 #include <sys/wait.h>
 #include <unistd.h>
-#include <X11/cursorfont.h>
-#include <X11/Xproto.h>
-#include <X11/keysym.h>
-#include <X11/Xatom.h>
-#include <X11/Xproto.h>
 
 Bool verbose;
 Bool starting;
Received on Sat Feb 17 2007 - 08:24:17 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:55:24 UTC