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;
|
int j = bytesRead - 1;
|
||||||
while ((buffer[j] & 0b11000000) == 0x80)
|
while ((buffer[j] & 0b11000000) == 0x80)
|
||||||
j--;
|
j--;
|
||||||
|
|
||||||
|
// Cache last character and replace it with a trailing space
|
||||||
|
char ch = buffer[j];
|
||||||
buffer[j] = ' ';
|
buffer[j] = ' ';
|
||||||
|
|
||||||
// Trim trailing spaces
|
// Trim trailing spaces
|
||||||
@ -121,10 +124,9 @@ void updateBlock(int i) {
|
|||||||
j--;
|
j--;
|
||||||
buffer[j + 1] = '\0';
|
buffer[j + 1] = '\0';
|
||||||
|
|
||||||
|
// Clear the pipe
|
||||||
if (bytesRead == LEN(buffer)) {
|
if (bytesRead == LEN(buffer)) {
|
||||||
// Clear the pipe
|
while (ch != '\n' && read(pipes[i][0], &ch, 1) == 1)
|
||||||
char ch;
|
|
||||||
while (read(pipes[i][0], &ch, 1) == 1 && ch != '\n')
|
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user