- /* 2nd pass to make space for separators */
- for (s = cfg.slots; s; s = s->next) {
- s->out_pos_lo += prefix;
- s->out_pos_hi += prefix;
- s->out_pos_cur = s->out_pos_lo;
- prefix += seplen;
- nslots++;
- }
- width += (seplen * (nslots - 1));
- buf = calloc(1, width + 1);
- if (buf == NULL)
- khlib_fatal(
- "[memory] Failed to allocate buffer of %d bytes",
- width
- );
- memset(buf, ' ', width);
- buf[width] = '\0';
- /* 3rd pass to set the separators */
- for (s = cfg.slots; s; s = s->next) {
- if (s->out_pos_lo) { /* Skip the first, left-most */
- /* Copying only seplen ensures we omit the '\0' byte. */
- strncpy(
- buf + (s->out_pos_lo - seplen),
- cfg.separator,
- seplen
- );
- }
- }
-
- if (cfg.output_to_x_root_window && !(d = XOpenDisplay(NULL)))
- khlib_fatal("XOpenDisplay failed with: %p\n", d);
- /* TODO: Handle signals */
- for (;;) {