* child.c: Getting input for the statusline
*
*/
+#include "common.h"
+
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <yajl/yajl_gen.h>
#include <paths.h>
-#include "common.h"
-
/* Global variables for child_*() */
i3bar_child child;
va_list args;
va_start(args, format);
if (vasprintf(&message, format, args) == -1) {
- return;
+ goto finish;
}
struct status_block *err_block = scalloc(1, sizeof(struct status_block));
err_block->full_text = i3string_from_utf8("Error: ");
err_block->name = sstrdup("error");
- err_block->color = sstrdup("red");
+ err_block->color = sstrdup("#ff0000");
err_block->no_separator = true;
struct status_block *message_block = scalloc(1, sizeof(struct status_block));
message_block->full_text = i3string_from_utf8(message);
message_block->name = sstrdup("error_message");
- message_block->color = sstrdup("red");
+ message_block->color = sstrdup("#ff0000");
message_block->no_separator = true;
TAILQ_INSERT_HEAD(&statusline_head, err_block, blocks);
TAILQ_INSERT_TAIL(&statusline_head, message_block, blocks);
+finish:
FREE(message);
va_end(args);
}
break;
}
ELOG("read() failed!: %s\n", strerror(errno));
+ FREE(buffer);
exit(EXIT_FAILURE);
}
if (n == 0) {
ELOG("stdin: received EOF\n");
+ FREE(buffer);
*ret_buffer_len = -1;
return NULL;
}
I3STRING_FREE(first->full_text);
/* Remove the trailing newline and terminate the string at the same
* time. */
- if (buffer[length - 1] == '\n' || buffer[length - 1] == '\r')
+ if (buffer[length - 1] == '\n' || buffer[length - 1] == '\r') {
buffer[length - 1] = '\0';
- else
+ } else {
buffer[length] = '\0';
- first->full_text = i3string_from_markup(buffer);
+ }
+
+ first->full_text = i3string_from_utf8(buffer);
}
static bool read_json_input(unsigned char *input, int length) {