Improved and fixed a bug in updatestatus
This commit is contained in:
parent
9c5af35c14
commit
d4cceab950
62
dwmblocks.c
62
dwmblocks.c
|
@ -10,10 +10,8 @@
|
||||||
|
|
||||||
#define CMDLENGTH 25
|
#define CMDLENGTH 25
|
||||||
#define STTLENGTH 256
|
#define STTLENGTH 256
|
||||||
#define LOCKFILE "/tmp/dwmblocks.pid"
|
|
||||||
#define NILL INT_MIN
|
#define NILL INT_MIN
|
||||||
|
#define LOCKFILE "/tmp/dwmblocks.pid"
|
||||||
#define EMPTYCMDOUT(block) (*block->cmdoutcur == '\n' || *block->cmdoutcur == '\0')
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *pathu;
|
char *pathu;
|
||||||
|
@ -215,7 +213,12 @@ updatestatus()
|
||||||
|
|
||||||
/* checking half of the function */
|
/* checking half of the function */
|
||||||
/* skip empty blocks */
|
/* skip empty blocks */
|
||||||
while (current->pathu && EMPTYCMDOUT(current)) {
|
for (;;) {
|
||||||
|
if (!current->pathu)
|
||||||
|
return 0;
|
||||||
|
/* skip delimiter for the first non-empty block */
|
||||||
|
if (*current->cmdoutcur != '\n' && *current->cmdoutcur != '\0')
|
||||||
|
goto skipdelimc;
|
||||||
if (*current->cmdoutcur != *current->cmdoutprv) {
|
if (*current->cmdoutcur != *current->cmdoutprv) {
|
||||||
*current->cmdoutprv = *current->cmdoutcur;
|
*current->cmdoutprv = *current->cmdoutcur;
|
||||||
current++;
|
current++;
|
||||||
|
@ -223,23 +226,31 @@ updatestatus()
|
||||||
}
|
}
|
||||||
current++;
|
current++;
|
||||||
}
|
}
|
||||||
/* skip delimiter in front of the first non-empty block */
|
|
||||||
if (current->pathu)
|
|
||||||
goto skipdelimc;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
/* main loop */
|
/* main loop */
|
||||||
for (; current->pathu; current++) {
|
for (; current->pathu; current++) {
|
||||||
|
/* handles delimiter */
|
||||||
|
if (*current->cmdoutcur != '\n' && *current->cmdoutcur != '\0')
|
||||||
s += delimlength;
|
s += delimlength;
|
||||||
skipdelimc:
|
else {
|
||||||
c = current->cmdoutcur; p = current->cmdoutprv;
|
if (*current->cmdoutcur != *current->cmdoutprv) {
|
||||||
do {
|
*current->cmdoutprv = *current->cmdoutcur;
|
||||||
if (*c != *p) {
|
current++;
|
||||||
s += c - current->cmdoutcur;
|
|
||||||
goto update1;
|
goto update1;
|
||||||
}
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
skipdelimc:
|
||||||
|
c = current->cmdoutcur; p = current->cmdoutprv;
|
||||||
|
if (*c != *p)
|
||||||
|
goto update2;
|
||||||
|
else {
|
||||||
c++; p++;
|
c++; p++;
|
||||||
} while (*c != '\n' && *c != '\0');
|
}
|
||||||
|
for (; *c != '\n' && *c != '\0'; c++, p++)
|
||||||
|
if (*c != *p) {
|
||||||
|
s += c - current->cmdoutcur;
|
||||||
|
goto update2;
|
||||||
|
}
|
||||||
s += c - current->cmdoutcur;
|
s += c - current->cmdoutcur;
|
||||||
if (current->pathc && current->signal)
|
if (current->pathc && current->signal)
|
||||||
s++;
|
s++;
|
||||||
|
@ -248,24 +259,31 @@ skipdelimc:
|
||||||
update0:
|
update0:
|
||||||
/* updating half of the function */
|
/* updating half of the function */
|
||||||
/* skip empty blocks */
|
/* skip empty blocks */
|
||||||
while (current->pathu && EMPTYCMDOUT(current)) {
|
for (;;) {
|
||||||
|
if (!current->pathu)
|
||||||
|
return 1;
|
||||||
|
/* skip delimiter for the first non-empty block */
|
||||||
|
if (*current->cmdoutcur != '\n' && *current->cmdoutcur != '\0')
|
||||||
|
goto skipdelimu;
|
||||||
*current->cmdoutprv = *current->cmdoutcur;
|
*current->cmdoutprv = *current->cmdoutcur;
|
||||||
current++;
|
current++;
|
||||||
}
|
}
|
||||||
/* skip delimiter in front of the first non-empty block */
|
update1:
|
||||||
if (current->pathu)
|
|
||||||
goto skipdelimu;
|
|
||||||
else
|
|
||||||
return 1;
|
|
||||||
/* main loop */
|
/* main loop */
|
||||||
for (; current->pathu; current++) {
|
for (; current->pathu; current++) {
|
||||||
|
/* handles delimiter */
|
||||||
|
if (*current->cmdoutcur != '\n' && *current->cmdoutcur != '\0') {
|
||||||
d = delim;
|
d = delim;
|
||||||
while (*d)
|
while (*d)
|
||||||
*(s++) = *(d++);
|
*(s++) = *(d++);
|
||||||
*(s++) = '\n'; /* to mark the end of delimiter */
|
*(s++) = '\n'; /* to mark the end of delimiter */
|
||||||
|
} else {
|
||||||
|
*current->cmdoutprv = *current->cmdoutcur;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
skipdelimu:
|
skipdelimu:
|
||||||
c = current->cmdoutcur; p = current->cmdoutprv;
|
c = current->cmdoutcur; p = current->cmdoutprv;
|
||||||
update1:
|
update2:
|
||||||
do {
|
do {
|
||||||
*(s++) = *c;
|
*(s++) = *c;
|
||||||
*p = *c;
|
*p = *c;
|
||||||
|
|
Loading…
Reference in a new issue