From 06771d24e51f49009db58740e100ee68f3588ac8 Mon Sep 17 00:00:00 2001 From: Ashish Kumar Yadav Date: Wed, 22 Jul 2020 19:14:53 +0530 Subject: [PATCH] Small tweaks to updatestatus to make it more intuitive --- dwmblocks.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/dwmblocks.c b/dwmblocks.c index 7da3670..3bdd4fd 100644 --- a/dwmblocks.c +++ b/dwmblocks.c @@ -200,8 +200,11 @@ updatestatus() for (current = blocks; current->pathu; current++) { if (EMPTYCMDOUT(current)) { - if (current->cmdoutprv[0] != current->cmdoutcur[0]) - goto updatestrstrt; + if (current->cmdoutprv[0] != current->cmdoutcur[0]) { + current->cmdoutprv[0] = current->cmdoutcur[0]; + current++; + goto update0; + } continue; } i = 0; @@ -211,7 +214,7 @@ updatestatus() continue; } else { str += i; - goto updatestrmddl; + goto update1; } } while (NOTATCMDOUTEND(current, i)); str += i; @@ -220,15 +223,14 @@ updatestatus() str += delimlength; } return 1; -updatestrstrt: - current->cmdoutprv[0] = current->cmdoutcur[0]; - for (current++; current->pathu; current++) { +update0: + for (; current->pathu; current++) { if (EMPTYCMDOUT(current)) { current->cmdoutprv[0] = current->cmdoutcur[0]; continue; } i = 0; -updatestrmddl: +update1: do { *(str++) = current->cmdoutcur[i]; current->cmdoutprv[i] = current->cmdoutcur[i]; @@ -240,6 +242,7 @@ updatestrmddl: *(str++) = delim[i]; *(str++) = '\n'; } + /* remove delimiter at the end if not all blocks are empty */ if (str != statusstr) *(str - delimlength) = '\0'; return 0;