area_add: Use str directly
I don't why p was used, if there was a reason, please don't merge.
This commit is contained in:
parent
3483f1b083
commit
bb466a8c16
15
bar.c
15
bar.c
|
@ -251,13 +251,12 @@ area_shift (xcb_window_t win, const int align, int delta)
|
||||||
bool
|
bool
|
||||||
area_add (char *str, const char *optend, char **end, monitor_t *mon, const int x, const int align, const int button)
|
area_add (char *str, const char *optend, char **end, monitor_t *mon, const int x, const int align, const int button)
|
||||||
{
|
{
|
||||||
char *p = str;
|
|
||||||
char *trail;
|
char *trail;
|
||||||
area_t *a;
|
area_t *a;
|
||||||
|
|
||||||
// A wild close area tag appeared!
|
// A wild close area tag appeared!
|
||||||
if (*p != ':') {
|
if (*str != ':') {
|
||||||
*end = p;
|
*end = str;
|
||||||
|
|
||||||
/* Find most recent unclosed area. */
|
/* Find most recent unclosed area. */
|
||||||
int i;
|
int i;
|
||||||
|
@ -297,19 +296,19 @@ area_add (char *str, const char *optend, char **end, monitor_t *mon, const int x
|
||||||
a = &astack.slot[astack.pos++];
|
a = &astack.slot[astack.pos++];
|
||||||
|
|
||||||
// Found the closing : and check if it's just an escaped one
|
// Found the closing : and check if it's just an escaped one
|
||||||
for (trail = strchr(++p, ':'); trail && trail[-1] == '\\'; trail = strchr(trail + 1, ':'))
|
for (trail = strchr(++str, ':'); trail && trail[-1] == '\\'; trail = strchr(trail + 1, ':'))
|
||||||
;
|
;
|
||||||
|
|
||||||
// Find the trailing : and make sure it's within the formatting block, also reject empty commands
|
// Find the trailing : and make sure it's within the formatting block, also reject empty commands
|
||||||
if (!trail || p == trail || trail > optend) {
|
if (!trail || str == trail || trail > optend) {
|
||||||
*end = p;
|
*end = str;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
*trail = '\0';
|
*trail = '\0';
|
||||||
|
|
||||||
// Sanitize the user command by unescaping all the :
|
// Sanitize the user command by unescaping all the :
|
||||||
for (char *needle = p; *needle; needle++) {
|
for (char *needle = str; *needle; needle++) {
|
||||||
int delta = trail - &needle[1];
|
int delta = trail - &needle[1];
|
||||||
if (needle[0] == '\\' && needle[1] == ':') {
|
if (needle[0] == '\\' && needle[1] == ':') {
|
||||||
memmove(&needle[0], &needle[1], delta);
|
memmove(&needle[0], &needle[1], delta);
|
||||||
|
@ -318,7 +317,7 @@ area_add (char *str, const char *optend, char **end, monitor_t *mon, const int x
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is a pointer to the string buffer allocated in the main
|
// This is a pointer to the string buffer allocated in the main
|
||||||
a->cmd = p;
|
a->cmd = str;
|
||||||
a->active = true;
|
a->active = true;
|
||||||
a->align = align;
|
a->align = align;
|
||||||
a->begin = x;
|
a->begin = x;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user