mirror of
https://github.com/mintycube/dwmblocks.git
synced 2024-10-22 14:05:47 +02:00
Handle the bytesRead = CMDLENGTH case properly
This commit is contained in:
parent
1676c07b8f
commit
c720d07df8
8
main.c
8
main.c
@ -114,6 +114,9 @@ void updateBlock(int i) {
|
||||
int j = bytesRead - 1;
|
||||
while ((buffer[j] & 0b11000000) == 0x80)
|
||||
j--;
|
||||
|
||||
// Cache last character and replace it with a trailing space
|
||||
char ch = buffer[j];
|
||||
buffer[j] = ' ';
|
||||
|
||||
// Trim trailing spaces
|
||||
@ -121,10 +124,9 @@ void updateBlock(int i) {
|
||||
j--;
|
||||
buffer[j + 1] = '\0';
|
||||
|
||||
// Clear the pipe
|
||||
if (bytesRead == LEN(buffer)) {
|
||||
// Clear the pipe
|
||||
char ch;
|
||||
while (read(pipes[i][0], &ch, 1) == 1 && ch != '\n')
|
||||
while (ch != '\n' && read(pipes[i][0], &ch, 1) == 1)
|
||||
;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user