Changed variable name current to block

This commit is contained in:
Ashish Kumar Yadav 2020-11-15 13:24:15 +05:30
parent 230229c482
commit 6101909568

View file

@ -44,8 +44,8 @@ void
buttonhandler(int signal, siginfo_t *si, void *ucontext)
{
signal = si->si_value.sival_int >> 8;
for (Block *current = blocks; current->pathu; current++)
if (current->signal == signal)
for (Block *block = blocks; block->pathu; block++)
if (block->signal == signal)
switch (fork()) {
case -1:
perror("buttonhandler - fork");
@ -53,7 +53,7 @@ buttonhandler(int signal, siginfo_t *si, void *ucontext)
case 0:
{
char button[] = { '0' + (si->si_value.sival_int & 0xff), '\0' };
char *arg[] = { current->pathc, button, NULL };
char *arg[] = { block->pathc, button, NULL };
close(ConnectionNumber(dpy));
setsid();
@ -155,18 +155,18 @@ setupsignals()
sa.sa_flags |= SA_NODEFER;
sa.sa_mask = blocksigmask;
sa.sa_sigaction = sighandler;
for (Block *current = blocks; current->pathu; current++)
if (current->signal > 0)
sigaction(SIGRTMIN + current->signal, &sa, NULL);
for (Block *block = blocks; block->pathu; block++)
if (block->signal > 0)
sigaction(SIGRTMIN + block->signal, &sa, NULL);
}
void
sighandler(int signal, siginfo_t *si, void *ucontext)
{
signal -= SIGRTMIN;
for (Block *current = blocks; current->pathu; current++)
if (current->signal == signal)
getcmd(current, si->si_value.sival_int);
for (Block *block = blocks; block->pathu; block++)
if (block->signal == signal)
getcmd(block, si->si_value.sival_int);
setroot();
}
@ -177,9 +177,9 @@ statusloop()
/* first run */
sigprocmask(SIG_BLOCK, &blocksigmask, NULL);
for (Block *current = blocks; current->pathu; current++)
if (current->interval >= 0)
getcmd(current, NILL);
for (Block *block = blocks; block->pathu; block++)
if (block->interval >= 0)
getcmd(block, NILL);
setroot();
sigprocmask(SIG_UNBLOCK, &blocksigmask, NULL);
sleep(SLEEPINTERVAL);
@ -187,9 +187,9 @@ statusloop()
/* main loop */
while (statuscontinue) {
sigprocmask(SIG_BLOCK, &blocksigmask, NULL);
for (Block *current = blocks; current->pathu; current++)
if (current->interval > 0 && i % current->interval == 0)
getcmd(current, NILL);
for (Block *block = blocks; block->pathu; block++)
if (block->interval > 0 && i % block->interval == 0)
getcmd(block, NILL);
setroot();
sigprocmask(SIG_UNBLOCK, &blocksigmask, NULL);
sleep(SLEEPINTERVAL);
@ -210,84 +210,84 @@ updatestatus()
char *s = statusstr;
char *c, *p; /* for cmdoutcur and cmdoutprv */
const char *d; /* for delimiter */
Block *current = blocks;
Block *block = blocks;
/* checking half of the function */
/* find the first non-empty block */
for (;; current++) {
for (;; block++) {
/* all blocks are empty */
if (!current->pathu)
if (!block->pathu)
return 0;
/* contents of the current block changed */
if (*current->cmdoutcur != *current->cmdoutprv)
/* contents of the block changed */
if (*block->cmdoutcur != *block->cmdoutprv)
goto update0;
/* skip delimiter handler for the first non-empty block */
if (*current->cmdoutcur != '\n' && *current->cmdoutcur != '\0')
if (*block->cmdoutcur != '\n' && *block->cmdoutcur != '\0')
goto skipdelimc;
}
/* main loop */
for (; current->pathu; current++) {
/* contents of the current block changed */
if (*current->cmdoutcur != *current->cmdoutprv)
for (; block->pathu; block++) {
/* contents of the block changed */
if (*block->cmdoutcur != *block->cmdoutprv)
goto update1;
/* delimiter handler */
if (*current->cmdoutcur != '\n' && *current->cmdoutcur != '\0')
if (*block->cmdoutcur != '\n' && *block->cmdoutcur != '\0')
s += delimlength;
/* skip over empty blocks */
else
continue;
skipdelimc:
/* checking for the first byte has been done */
c = current->cmdoutcur + 1, p = current->cmdoutprv + 1;
c = block->cmdoutcur + 1, p = block->cmdoutprv + 1;
for (; *c != '\n' && *c != '\0'; c++, p++)
/* contents of the current block changed */
/* contents of the block changed */
if (*c != *p) {
s += c - current->cmdoutcur;
s += c - block->cmdoutcur;
goto update2;
}
s += c - current->cmdoutcur;
s += c - block->cmdoutcur;
/* byte containing info about signal number for the block */
if (current->pathc && current->signal)
if (block->pathc && block->signal)
s++;
}
return 0;
/* updating half of the function */
/* find the first non-empty block */
for (;; current++) {
for (;; block++) {
/* all blocks are empty */
if (!current->pathu)
if (!block->pathu)
return 1;
update0:
/* don't add delimiter before the first non-empty block */
if (*current->cmdoutcur != '\n' && *current->cmdoutcur != '\0')
if (*block->cmdoutcur != '\n' && *block->cmdoutcur != '\0')
goto skipdelimu;
*current->cmdoutprv = *current->cmdoutcur;
*block->cmdoutprv = *block->cmdoutcur;
}
/* main loop */
for (; current->pathu; current++) {
for (; block->pathu; block++) {
update1:
/* delimiter handler */
if (*current->cmdoutcur != '\n' && *current->cmdoutcur != '\0') {
if (*block->cmdoutcur != '\n' && *block->cmdoutcur != '\0') {
d = delim;
while (*d != '\0')
*(s++) = *(d++);
*(s++) = '\n'; /* to mark the end of delimiter */
/* skip over empty blocks */
} else {
*current->cmdoutprv = *current->cmdoutcur;
*block->cmdoutprv = *block->cmdoutcur;
continue;
}
skipdelimu:
c = current->cmdoutcur, p = current->cmdoutprv;
c = block->cmdoutcur, p = block->cmdoutprv;
update2:
do {
*(s++) = *c;
*p = *c;
c++, p++;
} while (*c != '\n' && *c != '\0');
if (current->pathc && current->signal)
*(s++) = current->signal;
if (block->pathc && block->signal)
*(s++) = block->signal;
}
*s = '\0';
return 1;
@ -342,9 +342,9 @@ main(int argc, char *argv[])
sigaddset(&blocksigmask, SIGHUP);
sigaddset(&blocksigmask, SIGINT);
sigaddset(&blocksigmask, SIGTERM);
for (Block *current = blocks; current->pathu; current++)
if (current->signal > 0)
sigaddset(&blocksigmask, SIGRTMIN + current->signal);
for (Block *block = blocks; block->pathu; block++)
if (block->signal > 0)
sigaddset(&blocksigmask, SIGRTMIN + block->signal);
setupsignals();
statusloop();
unlink(LOCKFILE);