cvsimport

This commit is contained in:
okan 2015-03-29 00:21:05 +00:00
commit bc21e4aa37
8 changed files with 39 additions and 33 deletions

View File

@ -103,6 +103,7 @@ size_t strlcpy(char *, const char *, size_t);
#define CWM_NOGAP 0x0002
#define CWM_WIN 0x0001
#define CWM_CMD 0x0002
#define CWM_QUIT 0x0000
#define CWM_RUNNING 0x0001
@ -271,7 +272,6 @@ struct binding {
unsigned int modmask;
union press press;
int flags;
int argtype;
};
TAILQ_HEAD(keybinding_q, binding);
TAILQ_HEAD(mousebinding_q, binding);
@ -578,6 +578,7 @@ void u_spawn(char *);
void *xcalloc(size_t, size_t);
void *xmalloc(size_t);
void *xreallocarray(void *, size_t, size_t);
char *xstrdup(const char *);
int xasprintf(char **, const char *, ...)
__attribute__((__format__ (printf, 2, 3)))

View File

@ -887,6 +887,7 @@ client_mwm_hints(struct client_ctx *cc)
!(mwmh->decorations & MWM_DECOR_ALL) &&
!(mwmh->decorations & MWM_DECOR_BORDER))
cc->bwidth = 0;
XFree(mwmh);
}
}

20
conf.c
View File

@ -491,11 +491,10 @@ conf_bind_kbd(struct conf *c, const char *bind, const char *cmd)
{
struct binding *kb;
const char *key;
unsigned int i, mask;
unsigned int i;
kb = xcalloc(1, sizeof(*kb));
key = conf_bind_getmask(bind, &mask);
kb->modmask |= mask;
kb = xmalloc(sizeof(*kb));
key = conf_bind_getmask(bind, &kb->modmask);
kb->press.keysym = XStringToKeysym(key);
if (kb->press.keysym == NoSymbol) {
@ -519,15 +518,13 @@ conf_bind_kbd(struct conf *c, const char *bind, const char *cmd)
kb->callback = name_to_func[i].handler;
kb->flags = name_to_func[i].flags;
kb->argument = name_to_func[i].argument;
kb->argtype |= ARG_INT;
TAILQ_INSERT_TAIL(&c->keybindingq, kb, entry);
return(1);
}
kb->callback = kbfunc_cmdexec;
kb->flags = 0;
kb->flags = CWM_CMD;
kb->argument.c = xstrdup(cmd);
kb->argtype |= ARG_CHAR;
TAILQ_INSERT_TAIL(&c->keybindingq, kb, entry);
return(1);
}
@ -543,7 +540,7 @@ conf_unbind_kbd(struct conf *c, struct binding *unbind)
if (key->press.keysym == unbind->press.keysym) {
TAILQ_REMOVE(&c->keybindingq, key, entry);
if (key->argtype & ARG_CHAR)
if (key->flags & CWM_CMD)
free(key->argument.c);
free(key);
}
@ -555,11 +552,10 @@ conf_bind_mouse(struct conf *c, const char *bind, const char *cmd)
{
struct binding *mb;
const char *button, *errstr;
unsigned int i, mask;
unsigned int i;
mb = xcalloc(1, sizeof(*mb));
button = conf_bind_getmask(bind, &mask);
mb->modmask |= mask;
mb = xmalloc(sizeof(*mb));
button = conf_bind_getmask(bind, &mb->modmask);
mb->press.button = strtonum(button, Button1, Button5, &errstr);
if (errstr) {

View File

@ -91,7 +91,7 @@ group_restack(struct group_ctx *gc)
if (cc->stackingorder > highstack)
highstack = cc->stackingorder;
}
winlist = xcalloc((highstack + 1), sizeof(*winlist));
winlist = xreallocarray(NULL, (highstack + 1), sizeof(*winlist));
/* Invert the stacking order for XRestackWindows(). */
TAILQ_FOREACH(cc, &gc->clientq, group_entry) {

14
menu.c
View File

@ -189,9 +189,7 @@ menu_complete_path(struct menu_ctx *mc)
{
struct menu *mi, *mr;
struct menu_q menuq;
char *path = NULL;
path = xcalloc(1, sizeof(mr->text));
mr = xcalloc(1, sizeof(*mr));
TAILQ_INIT(&menuq);
@ -200,17 +198,15 @@ menu_complete_path(struct menu_ctx *mc)
CWM_MENU_DUMMY, search_match_path_any, NULL)) != NULL) {
mr->abort = mi->abort;
mr->dummy = mi->dummy;
strlcpy(path, mi->text, sizeof(mi->text));
if (mi->text[0] != '\0')
snprintf(mr->text, sizeof(mr->text), "%s \"%s\"",
mc->searchstr, mi->text);
else if (!mr->abort)
strlcpy(mr->text, mc->searchstr, sizeof(mr->text));
}
menuq_clear(&menuq);
if (path[0] != '\0')
snprintf(mr->text, sizeof(mr->text), "%s \"%s\"",
mc->searchstr, path);
else if (!mr->abort)
strlcpy(mr->text, mc->searchstr, sizeof(mr->text));
free(path);
return(mr);
}

11
parse.y
View File

@ -121,21 +121,21 @@ main : FONTNAME STRING {
}
| BORDERWIDTH NUMBER {
if ($2 < 0 || $2 > UINT_MAX) {
yyerror("invalid borderwidth: %lld", $2);
yyerror("invalid borderwidth");
YYERROR;
}
conf->bwidth = $2;
}
| MOVEAMOUNT NUMBER {
if ($2 < 0 || $2 > INT_MAX) {
yyerror("invalid movemount: %lld", $2);
yyerror("invalid movemount");
YYERROR;
}
conf->mamount = $2;
}
| SNAPDIST NUMBER {
if ($2 < 0 || $2 > INT_MAX) {
yyerror("invalid snapdist: %lld", $2);
yyerror("invalid snapdist");
YYERROR;
}
conf->snapdist = $2;
@ -152,8 +152,8 @@ main : FONTNAME STRING {
}
| AUTOGROUP NUMBER STRING {
if ($2 < 0 || $2 > 9) {
yyerror("invalid autogroup");
free($3);
yyerror("invalid autogroup: %lld", $2);
YYERROR;
}
conf_autogroup(conf, $2, $3);
@ -178,8 +178,7 @@ main : FONTNAME STRING {
$3 < 0 || $3 > INT_MAX ||
$4 < 0 || $4 > INT_MAX ||
$5 < 0 || $5 > INT_MAX) {
yyerror("invalid gap: %lld %lld %lld %lld",
$2, $3, $4, $5);
yyerror("invalid gap");
YYERROR;
}
conf->gap.top = $2;

View File

@ -61,6 +61,18 @@ xcalloc(size_t no, size_t siz)
return(p);
}
void *
xreallocarray(void *ptr, size_t nmemb, size_t size)
{
void *p;
p = reallocarray(ptr, nmemb, size);
if (p == NULL)
errx(1, "xreallocarray: out of memory (new_size %zu bytes)",
nmemb * size);
return(p);
}
char *
xstrdup(const char *str)
{

View File

@ -220,7 +220,7 @@ xu_ewmh_net_client_list(struct screen_ctx *sc)
if (i == 0)
return;
winlist = xcalloc(i, sizeof(*winlist));
winlist = xreallocarray(NULL, i, sizeof(*winlist));
TAILQ_FOREACH(cc, &sc->clientq, entry)
winlist[j++] = cc->win;
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_CLIENT_LIST],
@ -320,7 +320,7 @@ xu_ewmh_net_desktop_names(struct screen_ctx *sc)
TAILQ_FOREACH(gc, &sc->groupq, entry)
len += strlen(gc->name) + 1;
q = p = xcalloc(len, sizeof(*p));
q = p = xreallocarray(NULL, len, sizeof(*p));
tlen = len;
TAILQ_FOREACH(gc, &sc->groupq, entry) {
@ -332,6 +332,7 @@ xu_ewmh_net_desktop_names(struct screen_ctx *sc)
XChangeProperty(X_Dpy, sc->rootwin, ewmh[_NET_DESKTOP_NAMES],
cwmh[UTF8_STRING], 8, PropModeReplace, (unsigned char *)p, len);
free(p);
}
/* Application Window Properties */
@ -356,7 +357,7 @@ xu_ewmh_get_net_wm_state(struct client_ctx *cc, int *n)
(unsigned char **)&p)) <= 0)
return(NULL);
state = xcalloc(*n, sizeof(Atom));
state = xreallocarray(NULL, *n, sizeof(Atom));
(void)memcpy(state, p, *n * sizeof(Atom));
XFree((char *)p);
@ -443,7 +444,7 @@ xu_ewmh_set_net_wm_state(struct client_ctx *cc)
int n, i, j;
oatoms = xu_ewmh_get_net_wm_state(cc, &n);
atoms = xcalloc((n + _NET_WM_STATES_NITEMS), sizeof(Atom));
atoms = xreallocarray(NULL, (n + _NET_WM_STATES_NITEMS), sizeof(Atom));
for (i = j = 0; i < n; i++) {
if (oatoms[i] != ewmh[_NET_WM_STATE_STICKY] &&
oatoms[i] != ewmh[_NET_WM_STATE_MAXIMIZED_HORZ] &&