<commit_before>/* Sets the root window name every time a line is read from stdin to the
   contents of the line read.
*/

#include <xcb/xcb.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>

#define NAME_LENGTH 1024  /* maximum number of characters read per line */

static xcb_connection_t *xc;
static xcb_screen_t *screen;
static char name[NAME_LENGTH];

void sigh(int sig)
{
	fprintf(stderr, "Signal %d, exiting...\n", sig);
	xcb_disconnect(xc);
	exit(1);
}

int main(int argc, char *argv[])
{
	int i, sn;
	int c = '\0';

	xc = xcb_connect(NULL, &sn);
	if (xc == NULL) {
		fprintf(stderr, "%s: unable to open display\n", argv[0]);
		exit(2);
	}
	screen = xcb_setup_roots_iterator(xcb_get_setup(xc)).data;

	signal(SIGINT, sigh);
	signal(SIGTERM, sigh);

	while (c != EOF) {
		for (i = 0; i < NAME_LENGTH; ++i) {
			c = getchar();
			if (c == '\n' || c == EOF)<commit_msg>Fix segfault when opening display fails.<commit_after>/* Sets the root window name every time a line is read from stdin to the
   contents of the line read.
*/

#include <xcb/xcb.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>

#define NAME_LENGTH 1024  /* maximum number of characters read per line */

static xcb_connection_t *xc;
static xcb_screen_t *screen;
static char name[NAME_LENGTH];

void sigh(int sig)
{
	fprintf(stderr, "Signal %d, exiting...\n", sig);
	xcb_disconnect(xc);
	exit(1);
}

int main(int argc, char *argv[])
{
	int i, c = '\0';

	xc = xcb_connect(NULL, NULL);
	if (xcb_get_setup(xc) == NULL) {
		fprintf(stderr, "%s: unable to open display\n", argv[0]);
		xcb_disconnect(xc);
		exit(2);
	}
	screen = xcb_setup_roots_iterator(xcb_get_setup(xc)).data;

	signal(SIGINT, sigh);
	signal(SIGTERM, sigh);

	while (c != EOF) {
		for (i = 0; i < NAME_LENGTH; ++i) {
			c = getchar();
			if (c == '\n' || c == EOF)
{'fraction_non_alphanumeric': 0.16083150984682712, 'fraction_numerical': 0.009846827133479213, 'mean_word_length': 4.010958904109589, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3259304', 'n_tokens_mistral': 747, 'n_tokens_neox': 703, 'n_words': 213}