Improved and added comments in updatestatus
This commit is contained in:
parent
e0fa5c3700
commit
c802081605
52
dwmblocks.c
52
dwmblocks.c
|
@ -214,69 +214,69 @@ updatestatus()
|
||||||
Block *current = blocks;
|
Block *current = blocks;
|
||||||
|
|
||||||
/* checking half of the function */
|
/* checking half of the function */
|
||||||
/* skip empty blocks */
|
/* find first non-empty block */
|
||||||
for (;; current++) {
|
for (;; current++) {
|
||||||
|
/* all blocks are empty */
|
||||||
if (!current->pathu)
|
if (!current->pathu)
|
||||||
return 0;
|
return 0;
|
||||||
/* skip delimiter for the first non-empty block */
|
/* contents of the current block just changed */
|
||||||
|
if (*current->cmdoutcur != *current->cmdoutprv)
|
||||||
|
goto update0;
|
||||||
|
/* no delimiter before the first non-empty block */
|
||||||
if (*current->cmdoutcur != '\n' && *current->cmdoutcur != '\0')
|
if (*current->cmdoutcur != '\n' && *current->cmdoutcur != '\0')
|
||||||
goto skipdelimc;
|
goto skipdelimc;
|
||||||
if (*current->cmdoutcur != *current->cmdoutprv) {
|
|
||||||
*current->cmdoutprv = *current->cmdoutcur;
|
|
||||||
current++;
|
|
||||||
goto update0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/* main loop */
|
/* main loop */
|
||||||
for (; current->pathu; current++) {
|
for (; current->pathu; current++) {
|
||||||
/* handles delimiter */
|
/* contents of the current block just changed */
|
||||||
|
if (*current->cmdoutcur != *current->cmdoutprv)
|
||||||
|
goto update1;
|
||||||
|
/* delimiter handler */
|
||||||
|
/* current block is non-empty */
|
||||||
if (*current->cmdoutcur != '\n' && *current->cmdoutcur != '\0')
|
if (*current->cmdoutcur != '\n' && *current->cmdoutcur != '\0')
|
||||||
s += delimlength;
|
s += delimlength;
|
||||||
else {
|
/* skip over empty blocks */
|
||||||
if (*current->cmdoutcur != *current->cmdoutprv) {
|
else
|
||||||
*current->cmdoutprv = *current->cmdoutcur;
|
|
||||||
current++;
|
|
||||||
goto update1;
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
skipdelimc:
|
skipdelimc:
|
||||||
c = current->cmdoutcur; p = current->cmdoutprv;
|
/* checking for the first byte has been done */
|
||||||
if (*c != *p)
|
c = current->cmdoutcur + 1; p = current->cmdoutprv + 1;
|
||||||
goto update2;
|
|
||||||
else {
|
|
||||||
c++; p++;
|
|
||||||
}
|
|
||||||
for (; *c != '\n' && *c != '\0'; c++, p++)
|
for (; *c != '\n' && *c != '\0'; c++, p++)
|
||||||
|
/* contents of the current block just changed */
|
||||||
if (*c != *p) {
|
if (*c != *p) {
|
||||||
s += c - current->cmdoutcur;
|
s += c - current->cmdoutcur;
|
||||||
goto update2;
|
goto update2;
|
||||||
}
|
}
|
||||||
s += c - current->cmdoutcur;
|
s += c - current->cmdoutcur;
|
||||||
|
/* byte containing info about signal number for the block */
|
||||||
if (current->pathc && current->signal)
|
if (current->pathc && current->signal)
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
update0:
|
|
||||||
/* updating half of the function */
|
/* updating half of the function */
|
||||||
/* skip empty blocks */
|
/* find first non-empty block */
|
||||||
for (;; current++) {
|
for (;; current++) {
|
||||||
|
/* all blocks are empty */
|
||||||
if (!current->pathu)
|
if (!current->pathu)
|
||||||
return 1;
|
return 1;
|
||||||
/* skip delimiter for the first non-empty block */
|
update0:
|
||||||
|
/* skip delimiter before the first non-empty block */
|
||||||
if (*current->cmdoutcur != '\n' && *current->cmdoutcur != '\0')
|
if (*current->cmdoutcur != '\n' && *current->cmdoutcur != '\0')
|
||||||
goto skipdelimu;
|
goto skipdelimu;
|
||||||
*current->cmdoutprv = *current->cmdoutcur;
|
*current->cmdoutprv = *current->cmdoutcur;
|
||||||
}
|
}
|
||||||
update1:
|
|
||||||
/* main loop */
|
/* main loop */
|
||||||
for (; current->pathu; current++) {
|
for (; current->pathu; current++) {
|
||||||
/* handles delimiter */
|
update1:
|
||||||
|
/* delimiter handler */
|
||||||
|
/* current block is non-empty */
|
||||||
if (*current->cmdoutcur != '\n' && *current->cmdoutcur != '\0') {
|
if (*current->cmdoutcur != '\n' && *current->cmdoutcur != '\0') {
|
||||||
d = delim;
|
d = delim;
|
||||||
while (*d != '\0')
|
while (*d != '\0')
|
||||||
*(s++) = *(d++);
|
*(s++) = *(d++);
|
||||||
*(s++) = '\n'; /* to mark the end of delimiter */
|
*(s++) = '\n'; /* to mark the end of delimiter */
|
||||||
|
/* skip over empty blocks */
|
||||||
} else {
|
} else {
|
||||||
*current->cmdoutprv = *current->cmdoutcur;
|
*current->cmdoutprv = *current->cmdoutcur;
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in a new issue