[hackers] [wmii] Fix some bugs (fancy debugging code vindicated). Add some comments. Shut up ken.

From: Kris Maglione <jg_AT_suckless.org>
Date: Mon Jan 28 23:59:59 2008

changeset: 2266:3209815c2cec
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Mon Jan 28 17:58:23 2008 -0500
summary: Fix some bugs (fancy debugging code vindicated). Add some comments. Shut up ken.

diff -r fd899ccc36b1 -r 3209815c2cec cmd/wmii/client.c
--- a/cmd/wmii/client.c Sun Jan 27 16:08:25 2008 -0500
+++ b/cmd/wmii/client.c Mon Jan 28 17:58:23 2008 -0500
@@ -17,7 +17,7 @@ enum {
                    | EnterWindowMask
                    | FocusChangeMask,
         ButtonMask = ButtonPressMask
- | ButtonReleaseMask
+ | ButtonReleaseMask,
 };
 
 static Group* group;
@@ -113,7 +113,6 @@ client_create(XWindow w, XWindowAttribut
 
         XSetWindowBorderWidth(display, w, 0);
         XAddToSaveSet(display, w);
- XSelectInput(display, c->w.w, ClientMask);
 
         fwa.override_redirect = true;
         fwa.background_pixmap = None;
@@ -132,6 +131,8 @@ client_create(XWindow w, XWindowAttribut
         c->w.aux = c;
         sethandler(c->framewin, &framehandler);
         sethandler(&c->w, &handlers);
+
+ XSelectInput(display, c->w.w, ClientMask);
 
         p.x = def.border;
         p.y = labelh(def.font);
@@ -426,6 +427,7 @@ focus(Client *c, bool user) {
         View *v;
         Frame *f;
 
+ USED(user);
         f = c->sel;
         if(!f)
                 return;
@@ -442,9 +444,10 @@ focus(Client *c, bool user) {
 
 void
 client_focus(Client *c) {
+ static long id;
         flushevents(FocusChangeMask, True);
 
- Dprint(DFocus, "client_focus(%p[%C]) => %s\n", c, c, clientname(c));
+ Dprint(DFocus, "client_focus([%C]%s) %ld\n", c, clientname(c), id++);
 
         if(c) {
                 if(c->noinput)
@@ -453,8 +456,12 @@ client_focus(Client *c) {
                         c->group->client = c;
         }
 
+ sync();
+ flushevents(FocusChangeMask, true);
+ Dprint(DFocus, "client_focus([%C]%s) %ld\n", c, clientname(c), id);
         if(screen->focus != c) {
- Dprint(DFocus, "\t%s => %s\n", clientname(screen->focus), clientname(c));
+ Dprint(DFocus, "\t[%C]%s => [%C]%s\n", screen->focus, clientname(screen->focus),
+ c, clientname(c));
                 if(c)
                         setfocus(&c->w, RevertToParent);
                 else
@@ -462,7 +469,7 @@ client_focus(Client *c) {
                 event("ClientFocus %C\n", c);
 
                 sync();
- flushevents(FocusChangeMask, True);
+ flushevents(FocusChangeMask, true);
         }
 }
 
@@ -535,12 +542,16 @@ client_configure(Client *c) {
 }
 
 void
+client_message(Client *c, char *msg, long l2) {
+ sendmessage(&c->w, "WM_PROTOCOLS", xatom(msg), xtime, l2, 0, 0);
+}
+
+void
 client_kill(Client *c, bool nice) {
         if(nice && (c->proto & ProtoDelete)) {
- sendmessage(&c->w, "WM_PROTOCOLS", xatom("WM_DELETE_WINDOW"), xtime, 0, 0, 0);
+ client_message(c, "WM_DELETE_WINDOW", 0);
                 ewmh_pingclient(c);
- }
- else
+ }else
                 XKillClient(display, c->w.w);
 }
 
@@ -799,12 +810,12 @@ enter_event(Window *w, XCrossingEvent *e
         c = w->aux;
         if(e->detail != NotifyInferior) {
                 if(screen->focus != c) {
- Dprint(DGeneric, "enter_notify(c) => %s\n", c->name);
+ Dprint(DGeneric, "enter_notify([%C]%s)\n", c, c->name);
                         focus(c, false);
                 }
                 client_setcursor(c, cursor[CurNormal]);
         }else
- Dprint(DGeneric, "enter_notify(c[NotifyInferior]) => %s\n", c->name);
+ Dprint(DGeneric, "enter_notify(%C[NotifyInferior]%s)\n", c, c->name);
 }
 
 static void
@@ -813,7 +824,7 @@ focusin_event(Window *w, XFocusChangeEve
 
         c = w->aux;
 
- print_focus(c, c->name);
+ print_focus("focusin_event", c, c->name);
 
         if(e->mode == NotifyGrab)
                 screen->hasgrab = c;
@@ -835,7 +846,7 @@ focusout_event(Window *w, XFocusChangeEv
                 if(screen->focus)
                         screen->hasgrab = screen->focus;
         }else if(screen->focus == c) {
- print_focus(&c_magic, "<magic>");
+ print_focus("focusout_event", &c_magic, "<magic>");
                 screen->focus = &c_magic;
                 if(c->sel)
                         frame_draw(c->sel);
diff -r fd899ccc36b1 -r 3209815c2cec cmd/wmii/column.c
--- a/cmd/wmii/column.c Sun Jan 27 16:08:25 2008 -0500
+++ b/cmd/wmii/column.c Mon Jan 28 17:58:23 2008 -0500
@@ -36,12 +36,14 @@ column_new(View *v, Area *pos, uint w) {
 
         a = area_create(v, pos, w);
         return a;
+#if 0
         if(!a)
                 return nil;
 
         view_arrange(v);
         if(v == screen->sel)
                 view_focus(screen, v);
+#endif
 }
 
 void
@@ -105,15 +107,10 @@ column_attachrect(Area *a, Frame *f, Rec
 
 void
 column_remove(Frame *f) {
- Client *c;
         Frame *pr;
         Area *a;
- View *v;
 
         a = f->area;
- v = a->view;
- c = f->client;
-
         pr = f->aprev;
 
         frame_remove(f);
diff -r fd899ccc36b1 -r 3209815c2cec cmd/wmii/event.c
--- a/cmd/wmii/event.c Sun Jan 27 16:08:25 2008 -0500
+++ b/cmd/wmii/event.c Mon Jan 28 17:58:23 2008 -0500
@@ -35,6 +35,7 @@ findenter(Display *d, XEvent *e, XPointe
 findenter(Display *d, XEvent *e, XPointer v) {
         long *l;
 
+ USED(d);
         l = (long*)v;
         if(*l)
                 return False;
@@ -164,9 +165,9 @@ leavenotify(XEvent *e) {
 }
 
 void
-print_focus(Client *c, const char *to) {
- Dprint(DFocus, "screen->focus: %p[%C] => %p[%C]\n",
- screen->focus, screen->focus, c, c);
+print_focus(const char *fn, Client *c, const char *to) {
+ Dprint(DFocus, "%s() screen->focus:\n", fn);
+ Dprint(DFocus, "\t%C => %C\n", screen->focus, c);
         Dprint(DFocus, "\t%s => %s\n", clientname(screen->focus), to);
 }
 
@@ -179,7 +180,7 @@ focusin(XEvent *e) {
         ev = &e->xfocus;
         /* Yes, we're focusing in on nothing, here. */
         if(ev->detail == NotifyDetailNone) {
- print_focus(&c_magic, "<magic[none]>");
+ print_focus("focusin", &c_magic, "<magic[none]>");
                 screen->focus = &c_magic;
                 setfocus(screen->barwin, RevertToParent);
                 return;
@@ -195,7 +196,7 @@ focusin(XEvent *e) {
                 return;
 
         if(ev->window == screen->barwin->w) {
- print_focus(nil, "<nil>");
+ print_focus("focusin", nil, "<nil>");
                 screen->focus = nil;
         }
         else if((w = findwin(ev->window)))
@@ -205,7 +206,7 @@ focusin(XEvent *e) {
                         screen->hasgrab = &c_root;
                 /* Some unmanaged window has grabbed focus */
                 else if((c = screen->focus)) {
- print_focus(&c_magic, "<magic>");
+ print_focus("focusin", &c_magic, "<magic>");
                         screen->focus = &c_magic;
                         if(c->sel)
                                 frame_draw(c->sel);
@@ -231,7 +232,7 @@ focusout(XEvent *e) {
 
         if((ev->mode == NotifyGrab)
         && XCheckMaskEvent(display, KeyPressMask, &me))
- dispatch_event(&me);
+ dispatch_event(&me);
         else if((w = findwin(ev->window)))
                 handle(w, focusout, ev);
 }
diff -r fd899ccc36b1 -r 3209815c2cec cmd/wmii/ewmh.c
--- a/cmd/wmii/ewmh.c Sun Jan 27 16:08:25 2008 -0500
+++ b/cmd/wmii/ewmh.c Mon Jan 28 17:58:23 2008 -0500
@@ -30,8 +30,10 @@ ewmh_init(void) {
         changeprop_long(&scr.root, Net("SUPPORTING_WM_CHECK"), "WINDOW", win, 1);
         changeprop_long(ewmhwin, Net("SUPPORTING_WM_CHECK"), "WINDOW", win, 1);
         changeprop_string(ewmhwin, Net("WM_NAME"), myname);
+
+ long zz[] = {0, 0};
         changeprop_long(&scr.root, Net("DESKTOP_VIEWPORT"), "CARDINAL",
- (long[]){0, 0}, 2);
+ zz, 2);
 
         long supported[] = {
                 /* Misc */
@@ -137,6 +139,7 @@ pingtimeout(long id, void *v) {
 pingtimeout(long id, void *v) {
         Client *c;
 
+ USED(id);
         c = v;
         event("Unresponsive %C\n", c);
         c->w.ewmh.ping = 0;
@@ -154,7 +157,7 @@ ewmh_pingclient(Client *c) {
         if(e->ping)
                 return;
 
- sendmessage(&c->w, "WM_PROTOCOLS", NET("WM_PING"), xtime, c->w.w, 0, 0);
+ client_message(c, Net("WM_PING"), c->w.w);
         e->ping = xtime++;
         e->timer = ixp_settimer(&srv, PingTime, pingtimeout, c);
 }
@@ -179,7 +182,7 @@ struct Prop {
 };
 
 static long
-getmask(Prop *props, long *vals, int n) {
+getmask(Prop *props, ulong *vals, int n) {
         Prop *p;
         long ret;
 
@@ -212,10 +215,10 @@ ewmh_getwintype(Client *c) {
                 {Type("NORMAL"), TypeNormal},
                 {0, }
         };
- long *types;
+ ulong *types;
         long n, mask;
 
- n = getprop_long(&c->w, Net("WM_WINDOW_TYPE"), "ATOM",
+ n = getprop_ulong(&c->w, Net("WM_WINDOW_TYPE"), "ATOM",
                 0L, &types, 16);
         Dprint(DEwmh, "ewmh_getwintype(%C) n = %ld\n", c, n);
         mask = getmask(props, types, n);
@@ -236,10 +239,10 @@ ewmh_protocols(Window *w) {
                 {Net("WM_PING"), ProtoPing},
                 {0, }
         };
- long *protos;
+ ulong *protos;
         long n, mask;
 
- n = getprop_long(w, "WM_PROTOCOLS", "ATOM",
+ n = getprop_ulong(w, "WM_PROTOCOLS", "ATOM",
                 0L, &protos, 16);
         Dprint(DEwmh, "ewmh_protocols(%W) n = %ld\n", w, n);
         mask = getmask(props, protos, n);
@@ -299,10 +302,11 @@ ewmh_clientmessage(XClientMessageEvent *
 ewmh_clientmessage(XClientMessageEvent *e) {
         Client *c;
         View *v;
- long *l;
- int msg, action, i;
-
- l = e->data.l;
+ ulong *l;
+ ulong msg;
+ int action, i;
+
+ l = (ulong*)e->data.l;
         msg = e->message_type;
         Dprint(DEwmh, "ClientMessage: %A\n", msg);
 
diff -r fd899ccc36b1 -r 3209815c2cec cmd/wmii/fns.h
--- a/cmd/wmii/fns.h Sun Jan 27 16:08:25 2008 -0500
+++ b/cmd/wmii/fns.h Mon Jan 28 17:58:23 2008 -0500
@@ -3,7 +3,10 @@
  */
 
 #ifdef VARARGCK
+# pragma varargck argpos debug 2
+# pragma varargck argpos dprint 1
 # pragma varargck argpos event 1
+# pragma varargck argpos warning 1
 #
 # pragma varargck type "C" Client*
 # pragma varargck type "r" void
@@ -44,6 +47,7 @@ void client_kill(Client*, bool);
 void client_kill(Client*, bool);
 void client_manage(Client*);
 void client_map(Client*);
+void client_message(Client*, char*, long);
 void client_prop(Client*, Atom);
 void client_reparent(Client*, Window*, Point);
 void client_resize(Client*, Rectangle);
@@ -83,7 +87,7 @@ void dispatch_event(XEvent*);
 void dispatch_event(XEvent*);
 uint flushenterevents(void);
 uint flushevents(long, bool dispatch);
-void print_focus(Client*, const char*);
+void print_focus(const char*, Client*, const char*);
 
 /* ewmh.c */
 int ewmh_clientmessage(XClientMessageEvent*);
diff -r fd899ccc36b1 -r 3209815c2cec cmd/wmii/frame.c
--- a/cmd/wmii/frame.c Sun Jan 27 16:08:25 2008 -0500
+++ b/cmd/wmii/frame.c Mon Jan 28 17:58:23 2008 -0500
@@ -136,6 +136,10 @@ frame_restack(Frame *f, Frame *above) {
 /* Handlers */
 static void
 bup_event(Window *w, XButtonEvent *e) {
+ if((e->state & def.mod) != def.mod)
+ XAllowEvents(display, ReplayPointer, e->time);
+ else
+ XUngrabPointer(display, e->time);
         event("ClientClick %C %d\n", w->aux, e->button);
 }
 
@@ -157,6 +161,7 @@ bdown_event(Window *w, XButtonEvent *e)
                         frame_restack(f, nil);
                         view_restack(f->view);
                         focus(c, false);
+ grabpointer(c->framewin, nil, cursor[CurNone], ButtonReleaseMask);
                         break;
                 case Button3:
                         focus(c, false);
@@ -166,9 +171,7 @@ bdown_event(Window *w, XButtonEvent *e)
                         XAllowEvents(display, ReplayPointer, e->time);
                         break;
                 }
- if(e->button != Button1)
- XUngrabPointer(display, e->time);
- }else{
+ }else {
                 if(e->button == Button1) {
                         if(!e->subwindow) {
                                 frame_restack(f, nil);
@@ -293,7 +296,7 @@ frame_resize(Frame *f, Rectangle r) {
 frame_resize(Frame *f, Rectangle r) {
         Client *c;
         Rectangle fr, cr;
- int collapsed;
+ int collapsed, dx;
 
         if(Dx(r) <= 0 || Dy(r) <= 0)
                 die("Frame rect: %R\n", r);
@@ -330,9 +333,11 @@ frame_resize(Frame *f, Rectangle r) {
         if(f->area->floating)
                 f->r = fr;
         else {
- cr.min.x += ((Dx(fr) - Dx(cr)) - 2 * (cr.min.x - fr.min.x))
- / 2;
                 f->r = r;
+ dx = Dx(r) - Dx(cr);
+ dx -= 2 * (cr.min.x - fr.min.x);
+ cr.min.x += dx / 2;
+ cr.max.x += dx / 2;
         }
         f->crect = rectsubpt(cr, f->r.min);
 
@@ -356,7 +361,9 @@ frame_draw(Frame *f) {
                 return;
 
         c = f->client;
-
+ fr = rectsetorigin(c->framewin->r, ZP);
+
+ /* Pick colors. */
         if(c == screen->focus
         || c == selclient())
                 col = &def.focuscolor;
@@ -368,24 +375,24 @@ frame_draw(Frame *f) {
                                 col = &def.focuscolor;
                                 break;
                         }
- fr = c->framewin->r;
- fr = rectsubpt(fr, fr.min);
-
- /* background */
+
+ /* Background/border */
         r = fr;
         fill(screen->ibuf, r, col->bg);
         border(screen->ibuf, r, 1, col->border);
 
+ /* Title border */
         r.max.y = r.min.y + labelh(def.font);
         border(screen->ibuf, r, 1, col->border);
 
         f->titlebar = insetrect(r, 3);
         f->titlebar.max.y += 3;
 
- /* Odd state of focus. */
+ /* Odd focus. Ulselected, with keyboard focus. */
+ /* Draw a border just inside the titlebar. */
+ /* FIXME: Perhaps this should be normcolored? */
         if(c != selclient() && col == &def.focuscolor)
- border(screen->ibuf, insetrect(r, 1),
- 1, def.normcolor.bg);
+ border(screen->ibuf, insetrect(r, 1), 1, def.normcolor.bg);
 
         /* grabbox */
         r.min = Pt(2, 2);
@@ -397,10 +404,12 @@ frame_draw(Frame *f) {
                 fill(screen->ibuf, r, col->fg);
         border(screen->ibuf, r, 1, col->border);
 
- /* Odd state of focus. */
+ /* Odd focus. Selected, without keyboard focus. */
+ /* Draw a border around the grabbox. */
         if(c != screen->focus && col == &def.focuscolor)
- border(screen->ibuf, insetrect(r, -1),
- 1, def.normcolor.bg);
+ border(screen->ibuf, insetrect(r, -1), 1, def.normcolor.bg);
+
+ /* Draw a border on borderless/titleless selected apps. */
         if(c->borderless && c->titleless && c == selclient())
                 setborder(c->framewin, def.border, def.focuscolor.border);
         else
@@ -513,12 +522,10 @@ move_focus(Frame *old_f, Frame *f) {
 
 void
 frame_focus(Frame *f) {
- Client *c;
         Frame *old_f;
         View *v;
         Area *a, *old_a;
 
- c = f->client;
         v = f->view;
         a = f->area;
         old_a = v->sel;
diff -r fd899ccc36b1 -r 3209815c2cec cmd/wmii/key.c
--- a/cmd/wmii/key.c Sun Jan 27 16:08:25 2008 -0500
+++ b/cmd/wmii/key.c Mon Jan 28 17:58:23 2008 -0500
@@ -167,10 +167,11 @@ fake_keypress(ulong mod, KeyCode key) {
 
 static Key *
 match_keys(Key *k, ulong mod, KeyCode keycode, bool seq) {
- Key *ret = nil, *next;
-
- /* I *hate* GCC 4. */
- for(next = k->tnext; k; (void)((k=next) && (next=k->tnext))) {
+ Key *ret, *next;
+ volatile int i; /* shut up ken */
+
+ ret = nil;
+ for(next = k->tnext; k; i = (k=next) && (next=k->tnext)) {
                 if(seq)
                         k = k->next;
                 if(k && (k->mod == mod) && (k->key == keycode)) {
diff -r fd899ccc36b1 -r 3209815c2cec cmd/wmii/main.c
--- a/cmd/wmii/main.c Sun Jan 27 16:08:25 2008 -0500
+++ b/cmd/wmii/main.c Mon Jan 28 17:58:23 2008 -0500
@@ -286,7 +286,7 @@ doublefork(void) {
                 waitpid(pid, &status, 0);
                 return pid;
         }
- return -1; /* not reached */
+ /* NOTREACHED */
 }
 
 static void
diff -r fd899ccc36b1 -r 3209815c2cec cmd/wmii/message.c
--- a/cmd/wmii/message.c Sun Jan 27 16:08:25 2008 -0500
+++ b/cmd/wmii/message.c Mon Jan 28 17:58:23 2008 -0500
@@ -838,7 +838,7 @@ warning(const char *fmt, ...) {
         va_end(ap);
 
         event("Warning %s\n", s);
- fprint(2, "%s: warning: %s\n", s);
+ fprint(2, "%s: warning: %s\n", argv0, s);
         free(s);
 }
 
diff -r fd899ccc36b1 -r 3209815c2cec cmd/wmii/mouse.c
--- a/cmd/wmii/mouse.c Sun Jan 27 16:08:25 2008 -0500
+++ b/cmd/wmii/mouse.c Mon Jan 28 17:58:23 2008 -0500
@@ -705,7 +705,7 @@ mouse_movegrabbox(Client *c) {
 }
 # endif
 
-int
+static int
 thcol(Frame *f) {
         Framewin *fw;
         Frame *fprev, *fnext;
@@ -800,7 +800,7 @@ done:
         return ret;
 }
 
-int
+static int
 tvcol(Frame *f) {
         Framewin *fw;
         Window *cwin;
@@ -858,13 +858,13 @@ done:
         return ret;
 }
 
-int
+static int
 tfloat(Frame *f) {
         Rectangle *rects;
         Rectangle frect, origin;
         Point pt, pt1;
         Client *c;
- Align align, grav;
+ Align align;
         uint nrect, button;
         int ret;
 
@@ -885,8 +885,10 @@ tfloat(Frame *f) {
         pt = querypointer(&scr.root);
         pt1 = grabboxcenter(f);
         goto casmotion;
+label:
         for(;;pt1=pt)
                 switch (readmouse(&pt, &button)) {
+ default: goto label; /* shut up ken */
                 case MotionNotify:
                 casmotion:
                         origin = rectaddpt(origin, subpt(pt, pt1));
@@ -894,7 +896,7 @@ tfloat(Frame *f) {
                         frect = origin;
 
                         align = Center;
- grav = snap_rect(rects, nrect, &frect, &align, def.snap);
+ snap_rect(rects, nrect, &frect, &align, def.snap);
 
                         frect = frame_hints(f, frect, Center);
                         frect = constrain(frect);
@@ -922,7 +924,7 @@ void
 void
 grab_button(XWindow w, uint button, ulong mod) {
         XGrabButton(display, button, mod, w, false, ButtonMask,
- GrabModeSync, GrabModeSync, None, None);
+ GrabModeSync, GrabModeAsync, None, None);
         if((mod != AnyModifier) && (numlock_mask != 0)) {
                 XGrabButton(display, button, mod | numlock_mask, w, false, ButtonMask,
                         GrabModeSync, GrabModeAsync, None, None);
diff -r fd899ccc36b1 -r 3209815c2cec cmd/wmii/utf.c
--- a/cmd/wmii/utf.c Sun Jan 27 16:08:25 2008 -0500
+++ b/cmd/wmii/utf.c Mon Jan 28 17:58:23 2008 -0500
@@ -29,21 +29,28 @@ toutf8n(const char *str, size_t nstr) {
 
         iconv(cd, nil, nil, nil, nil);
 
- bsize = nstr * 1.25 + 4;
+ bsize = nstr << 1;
         buf = emalloc(bsize);
         pos = buf;
         nbuf = bsize-1;
+ /* The (void*) cast is because, while the BSDs declare:
+ * size_t iconv(iconv_t, const char**, size_t*, char**, size_t*),
+ * GNU/Linux and POSIX declare:
+ * size_t iconv(iconv_t, char**, size_t*, char**, size_t*).
+ * This just happens to be safer than declaring our own
+ * prototype.
+ */
         while(iconv(cd, (void*)&str, &nstr, &pos, &nbuf) == -1)
                 if(errno == E2BIG) {
- bsize *= 1.25 + 4;
+ bsize <<= 1;
                         nbuf = pos - buf;
                         buf = erealloc(buf, bsize);
                         pos = buf + nbuf;
                         nbuf = bsize - nbuf - 1;
                 }else
                         break;
- *pos = '\0';
- return buf;
+ *pos++ = '\0';
+ return erealloc(buf, pos-buf);
 }
 
 char*
diff -r fd899ccc36b1 -r 3209815c2cec cmd/wmii/view.c
--- a/cmd/wmii/view.c Sun Jan 27 16:08:25 2008 -0500
+++ b/cmd/wmii/view.c Mon Jan 28 17:58:23 2008 -0500
@@ -68,7 +68,7 @@ view_create(const char *name) {
                 if(!strcmp(name, v->name))
                         return v;
 
- v = emallocz(sizeof(View));
+ v = emallocz(sizeof *v);
         v->id = id++;
         v->r = screen->r;
         v->r.max.y = screen->barwin->r.min.y;
diff -r fd899ccc36b1 -r 3209815c2cec cmd/wmii/x11.c
--- a/cmd/wmii/x11.c Sun Jan 27 16:08:25 2008 -0500
+++ b/cmd/wmii/x11.c Mon Jan 28 17:58:23 2008 -0500
@@ -692,6 +692,11 @@ changeprop_long(Window *w, char *prop, c
 }
 
 void
+changeprop_ulong(Window *w, char *prop, char *type, ulong data[], int len) {
+ changeproperty(w, prop, type, 32, (uchar*)data, len);
+}
+
+void
 changeprop_textlist(Window *w, char *prop, char *type, char *data[]) {
         char **p, *s, *t;
         int len, n;
@@ -759,6 +764,11 @@ getprop_long(Window *w, char *prop, char
         free(*ret);
         *ret = 0;
         return 0;
+}
+
+ulong
+getprop_ulong(Window *w, char *prop, char *type, ulong offset, ulong **ret, ulong length) {
+ return getprop_long(w, prop, type, offset, (long**)ret, length);
 }
 
 char**
diff -r fd899ccc36b1 -r 3209815c2cec cmd/wmii/xdnd.c
--- a/cmd/wmii/xdnd.c Sun Jan 27 16:08:25 2008 -0500
+++ b/cmd/wmii/xdnd.c Mon Jan 28 17:58:23 2008 -0500
@@ -26,7 +26,7 @@ xdnd_clientmessage(XClientMessageEvent *
         Rectangle r;
         Point p;
         long pos, siz;
- int msg;
+ ulong msg;
 
         dnd = nil;
         msg = e->message_type;
diff -r fd899ccc36b1 -r 3209815c2cec cmd/wmiir.c
--- a/cmd/wmiir.c Sun Jan 27 16:08:25 2008 -0500
+++ b/cmd/wmiir.c Mon Jan 28 17:58:23 2008 -0500
@@ -185,7 +185,6 @@ static int
 static int
 xremove(int argc, char *argv[]) {
         char *file;
- int n;
 
         ARGBEGIN{
         default:
@@ -194,10 +193,8 @@ xremove(int argc, char *argv[]) {
 
         file = EARGF(usage());
         do {
- if(ixp_remove(client, file) == 0) {
+ if(!ixp_remove(client, file))
                         fprint(2, "%s: Can't remove file '%s': %r\n", argv0, file);
- n++;
- }
         }while((file = ARGF()));
         return 0;
 }
diff -r fd899ccc36b1 -r 3209815c2cec config.mk
--- a/config.mk Sun Jan 27 16:08:25 2008 -0500
+++ b/config.mk Mon Jan 28 17:58:23 2008 -0500
@@ -10,7 +10,7 @@ PREFIX = /usr/local
 
 # Includes and libs
 INCPATH = .:$(ROOT)/include:$(INCLUDE):/usr/include
-LIBS = -L/usr/lib -lc -L$(ROOT)/lib
+LIBS = -L/usr/lib -L$(ROOT)/lib
 
 # Flags
 include $(ROOT)/mk/gcc.mk
@@ -36,6 +36,14 @@ LIBIXP = $(LIBDIR)/libixp.a
 
 # Operating System Configurations
 
+# KenCC
+# Note: wmii *must* always compile under KenCC. It's vital for
+# argument checking in formatted IO, and similar diagnostics.
+#CFLAGS = -wF
+#STATIC = # Implied
+#CC=pcc -c
+#LD=pcc
+
 # *BSD
 #LIBICONV = -liconv
 # +Darwin
diff -r fd899ccc36b1 -r 3209815c2cec include/fmt.h
--- a/include/fmt.h Sun Jan 27 16:08:25 2008 -0500
+++ b/include/fmt.h Mon Jan 28 17:58:23 2008 -0500
@@ -55,6 +55,13 @@ extern int (*fmtdoquote)(int);
 extern int (*fmtdoquote)(int);
 
 #ifdef VARARGCK
+/* *sigh* */
+ typedef unsigned char _fmt_uchar;
+ typedef unsigned short _fmt_ushort;
+ typedef unsigned int _fmt_uint;
+ typedef unsigned long _fmt_ulong;
+ typedef unsigned long long _fmt_uvlong;
+ typedef long long _fmt_vlong;
 # pragma varargck argpos fmtprint 2
 # pragma varargck argpos fprint 2
 # pragma varargck argpos print 1
@@ -67,26 +74,26 @@ extern int (*fmtdoquote)(int);
 # pragma varargck argpos snprint 3
 # pragma varargck argpos sprint 2
 
-# pragma varargck type "lld" vlong
-# pragma varargck type "llx" vlong
-# pragma varargck type "lld" uvlong
-# pragma varargck type "llx" uvlong
+# pragma varargck type "lld" _fmt_vlong
+# pragma varargck type "llx" _fmt_vlong
+# pragma varargck type "lld" _fmt_uvlong
+# pragma varargck type "llx" _fmt_uvlong
 # pragma varargck type "ld" long
 # pragma varargck type "lx" long
 # pragma varargck type "lb" long
-# pragma varargck type "ld" ulong
-# pragma varargck type "lx" ulong
-# pragma varargck type "lb" ulong
+# pragma varargck type "ld" _fmt_ulong
+# pragma varargck type "lx" _fmt_ulong
+# pragma varargck type "lb" _fmt_ulong
 # pragma varargck type "d" int
 # pragma varargck type "x" int
 # pragma varargck type "c" int
 # pragma varargck type "C" int
 # pragma varargck type "b" int
-# pragma varargck type "d" uint
-# pragma varargck type "x" uint
-# pragma varargck type "c" uint
-# pragma varargck type "C" uint
-# pragma varargck type "b" uint
+# pragma varargck type "d" _fmt_uint
+# pragma varargck type "x" _fmt_uint
+# pragma varargck type "c" _fmt_uint
+# pragma varargck type "C" _fmt_uint
+# pragma varargck type "b" _fmt_uint
 # pragma varargck type "f" double
 # pragma varargck type "e" double
 # pragma varargck type "g" double
diff -r fd899ccc36b1 -r 3209815c2cec include/util.h
--- a/include/util.h Sun Jan 27 16:08:25 2008 -0500
+++ b/include/util.h Mon Jan 28 17:58:23 2008 -0500
@@ -23,8 +23,13 @@ typedef unsigned int uint;
 typedef unsigned int uint;
 typedef unsigned long ulong;
 typedef unsigned long long uvlong;
+typedef long long vlong;
 
-typedef long long vlong;
+#ifdef VARARGCK
+# pragma varargck argpos _die 3
+# pragma varargck argpos fatal 1
+# pragma varargck argpos sxprint 1
+#endif
 
 #define strlcat wmii_strlcat
 /* util.c */
@@ -52,7 +57,7 @@ char *argv0;
 #undef ARGF
 #undef EARGF
 #define ARGBEGIN \
- int _argtmp=0, _inargv=0; char *_argv=nil; \
+ int _argtmp=0, _inargv; char *_argv=nil; \
                 if(!argv0) argv0=*argv; argv++, argc--; \
                 _inargv=1; USED(_inargv); \
                 while(argc && argv[0][0] == '-') { \
diff -r fd899ccc36b1 -r 3209815c2cec include/x11.h
--- a/include/x11.h Sun Jan 27 16:08:25 2008 -0500
+++ b/include/x11.h Mon Jan 28 17:58:23 2008 -0500
@@ -144,9 +144,9 @@ struct Screen {
 
 #ifdef VARARGCK
 # pragma varargck type "A" Atom
-# pragma varargck type "W" Window*
 # pragma varargck type "P" Point
 # pragma varargck type "R" Rectangle
+# pragma varargck type "W" Window*
 #endif
 
 Display *display;
@@ -181,6 +181,7 @@ void changeprop_short(Window*, char*, ch
 void changeprop_short(Window*, char*, char*, short[], int);
 void changeprop_string(Window*, char*, char*);
 void changeprop_textlist(Window*, char*, char*, char*[]);
+void changeprop_ulong(Window*, char*, char*, ulong[], int);
 void changeproperty(Window*, char*, char*, int width, uchar*, int);
 void copyimage(Image*, Rectangle, Image*, Point);
 Window* createwindow(Window *parent, Rectangle, int depth, uint class, WinAttr*, int valuemask);
@@ -201,6 +202,7 @@ ulong getprop_long(Window*, char*, char*
 ulong getprop_long(Window*, char*, char*, ulong, long**, ulong);
 char* getprop_string(Window*, char*);
 int getprop_textlist(Window *w, char *name, char **ret[]);
+ulong getprop_ulong(Window*, char*, char*, ulong, ulong**, ulong);
 ulong getproperty(Window*, char *prop, char *type, Atom *actual, ulong offset, uchar **ret, ulong length);
 int grabpointer(Window*, Window *confine, Cursor, int mask);
 void initdisplay(void);
diff -r fd899ccc36b1 -r 3209815c2cec mk/lib.mk
--- a/mk/lib.mk Sun Jan 27 16:08:25 2008 -0500
+++ b/mk/lib.mk Mon Jan 28 17:58:23 2008 -0500
@@ -11,6 +11,8 @@ depend: ${OBJ:=.depend}
 
 libclean:
         for i in $(LIB) $(OFILES); do \
+ [ -e $$i ] && \
+ echo CLEAN $$($(CLEANNAME) $(BASE)$$i); \
                 rm -f $$i; \
         done 2>/dev/null || true
 
diff -r fd899ccc36b1 -r 3209815c2cec mk/many.mk
--- a/mk/many.mk Sun Jan 27 16:08:25 2008 -0500
+++ b/mk/many.mk Mon Jan 28 17:58:23 2008 -0500
@@ -13,6 +13,7 @@ printinstall:
 
 manyclean:
         for i in ${TARG:=.o} ${TARG:=.O} $(OFILES); do \
+ [ -e $$i ] && \
                 echo CLEAN $$($(CLEANNAME) $(BASE)$$i); \
                 rm -f $$i; \
         done 2>/dev/null || true
diff -r fd899ccc36b1 -r 3209815c2cec mk/one.mk
--- a/mk/one.mk Sun Jan 27 16:08:25 2008 -0500
+++ b/mk/one.mk Mon Jan 28 17:58:23 2008 -0500
@@ -14,6 +14,7 @@ printinstall:
 
 oneclean:
         for i in $(PROG) $(OFILES); do \
+ [ -e $$i ] && \
                 echo CLEAN $$($(CLEANNAME) $(BASE)$$i); \
                 rm -f $$i; \
         done 2>/dev/null || true
diff -r fd899ccc36b1 -r 3209815c2cec mk/so.mk
--- a/mk/so.mk Sun Jan 27 16:08:25 2008 -0500
+++ b/mk/so.mk Mon Jan 28 17:58:23 2008 -0500
@@ -12,6 +12,8 @@ depend: ${OBJ:=.depend}
 
 soclean:
         for i in $(SO) $(OFILES_PIC); do \
+ [ -e $$i ] && \
+ echo CLEAN $$($(CLEANNAME) $(BASE)$$i); \
                 rm -f $$i; \
         done 2>/dev/null || true
 
diff -r fd899ccc36b1 -r 3209815c2cec rc/rc.wmii.rc
--- a/rc/rc.wmii.rc Sun Jan 27 16:08:25 2008 -0500
+++ b/rc/rc.wmii.rc Mon Jan 28 17:58:23 2008 -0500
@@ -240,16 +240,16 @@ Action rehash
 
 # Tag Bar Setup
 ifs=$wi_nl{
- oldbars=`{comm -23 <{wmiir ls /lbar} \
+ rc -c 'wmiir rm /lbar/^$*' >[2]/dev/null \
+ `{comm -23 <{wmiir ls /lbar} \
                            <{wi_tags}}
- if(! ~ $oldbars '')
- wmiir rm /lbar/^$oldbars
         seltag=`{wi_seltag}
- for(tag in `{wi_tags}) {
+ for(tag in `{wi_tags}) {{
                 if(~ $tag $seltag)
- echo $wmiifocuscol $tag | wmiir create /lbar/$tag
+ echo $wmiifocuscol $tag
                 if not
- echo $wmiinormcol $tag | wmiir create /lbar/$tag}}
+ echo $wmiinormcol $tag
+ } | wmiir create /lbar/$tag}}
 
 wi_eventloop
 
diff -r fd899ccc36b1 -r 3209815c2cec util/compile
--- a/util/compile Sun Jan 27 16:08:25 2008 -0500
+++ b/util/compile Mon Jan 28 17:58:23 2008 -0500
@@ -9,7 +9,7 @@ xtmp=/tmp/cc.$$.$USER.out
 
 echo CC $($bin/cleanname ${BASE}$outfile)
 [ -n "$noisycc" ] && echo $CC -o $outfile $CFLAGS $@
-$CC -o $outfile $CFLAGS $@ 2>$xtmp
+$CC -o $outfile $CFLAGS $@ 2>&1 >$xtmp
 status=$?
 
 base=$(echo $BASE | sed 's/,/\\,/g')
@@ -57,6 +57,8 @@ cat $xtmp | sed "s,^$re,$base&,g; s,\([[
 cat $xtmp | sed "s,^$re,$base&,g; s,\([[:space:]]\)$re,\1$base\2,g" |
         egrep -v ': error: .Each undeclared identifier|: error: for each function it appears|is dangerous, better use|is almost always misused|: In function |: At top level:|support .long long.|use of C99 long long|ISO C forbids conversion' |
         sed 's/ .first use in this function.$//; s/\"\([^\"][^\"]*\)\", line \([0-9][0-9]*\)/\1:\2/g' |
+ awk '$1 == "warning:"{t=$2" "$1; sub(/^[^ ]+ [^ ]+ /, ""); $0 = t" "$0}; //' |
+ awk '{sub(/\[/, ": [", $1); print}' |
         undup 1>&2
 
 rm -f $xtmp
Received on Mon Jan 28 2008 - 23:59:59 UTC

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