pidgin: 79699160: We don't need named initialiers here sin...

grim at pidgin.im grim at pidgin.im
Mon May 26 23:25:48 EDT 2008


-----------------------------------------------------------------
Revision: 79699160e06b69f70db91eef65287f15685ec2bf
Ancestor: 58c7c464148cf9d446e535bd11591fa8cd99149b
Author: grim at pidgin.im
Date: 2008-05-27T03:24:19
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/79699160e06b69f70db91eef65287f15685ec2bf

Modified files:
        finch/libgnt/gntkeys.c

ChangeLog: 

We don't need named initialiers here since we're already doing an active initilization


-------------- next part --------------
============================================================
--- finch/libgnt/gntkeys.c	909790d405853245551c630baf47e2d57b2628f3
+++ finch/libgnt/gntkeys.c	907d8b2202bf8390615bf88b96e6438dcc9111a3
@@ -34,108 +34,6 @@ static GHashTable *specials;
 static const char *term;
 static GHashTable *specials;
 
-void gnt_init_keys()
-{
-	const char *controls[] = {"", "c-", "ctrl-", "ctr-", "ctl-", NULL};
-	const char *alts[] = {"", "alt-", "a-", "m-", "meta-", NULL};
-	int c, a, ch;
-	char key[32];
-
-	if (term == NULL) {
-		term = getenv("TERM");
-		if (!term)
-			term = "";  /* Just in case */
-	}
-
-	if (strcmp(term, "xterm") == 0 || strcmp(term, "rxvt") == 0) {
-		gnt_key_cup    = "\033" "[1;5A";
-		gnt_key_cdown  = "\033" "[1;5B";
-		gnt_key_cright = "\033" "[1;5C";
-		gnt_key_cleft  = "\033" "[1;5D";
-	} else if (strcmp(term, "screen") == 0 || strcmp(term, "rxvt-unicode") == 0) {
-		gnt_key_cup    = "\033" "Oa";
-		gnt_key_cdown  = "\033" "Ob";
-		gnt_key_cright = "\033" "Oc";
-		gnt_key_cleft  = "\033" "Od";
-	}
-
-	specials = g_hash_table_new(g_str_hash, g_str_equal);
-
-#define INSERT_KEY(k, code) do { \
-		g_hash_table_insert(specials, g_strdup(k), g_strdup(code)); \
-		gnt_keys_add_combination(code); \
-	} while (0)
-
-	INSERT_KEY("home",     GNT_KEY_HOME);
-	INSERT_KEY("end",      GNT_KEY_END);
-	INSERT_KEY("pageup",   GNT_KEY_PGUP);
-	INSERT_KEY("pagedown", GNT_KEY_PGDOWN);
-	INSERT_KEY("insert",   GNT_KEY_INS);
-	INSERT_KEY("delete",   GNT_KEY_DEL);
-	INSERT_KEY("back_tab", GNT_KEY_BACK_TAB);
-
-	INSERT_KEY("left",   GNT_KEY_LEFT);
-	INSERT_KEY("right",  GNT_KEY_RIGHT);
-	INSERT_KEY("up",     GNT_KEY_UP);
-	INSERT_KEY("down",   GNT_KEY_DOWN);
-
-	INSERT_KEY("tab",    "\t");
-	INSERT_KEY("menu",   GNT_KEY_POPUP);
-
-	INSERT_KEY("f1",   GNT_KEY_F1);
-	INSERT_KEY("f2",   GNT_KEY_F2);
-	INSERT_KEY("f3",   GNT_KEY_F3);
-	INSERT_KEY("f4",   GNT_KEY_F4);
-	INSERT_KEY("f5",   GNT_KEY_F5);
-	INSERT_KEY("f6",   GNT_KEY_F6);
-	INSERT_KEY("f7",   GNT_KEY_F7);
-	INSERT_KEY("f8",   GNT_KEY_F8);
-	INSERT_KEY("f9",   GNT_KEY_F9);
-	INSERT_KEY("f10",  GNT_KEY_F10);
-	INSERT_KEY("f11",  GNT_KEY_F11);
-	INSERT_KEY("f12",  GNT_KEY_F12);
-
-#define REM_LENGTH  (sizeof(key) - (cur - key))
-#define INSERT_COMB(k, code) do { \
-		snprintf(key, sizeof(key), "%s%s%s", controls[c], alts[a], k);  \
-		INSERT_KEY(key, code);  \
-	} while (0);
-
-	/* Lower-case alphabets */
-	for (a = 0, c = 0; controls[c]; c++, a = 0) {
-		if (c) {
-			INSERT_COMB("up",    gnt_key_cup);
-			INSERT_COMB("down",  gnt_key_cdown);
-			INSERT_COMB("left",  gnt_key_cleft);
-			INSERT_COMB("right", gnt_key_cright);
-		}
-
-		for (a = 0; alts[a]; a++) {
-			for (ch = 0; ch < 26; ch++) {
-				char str[2] = {'a' + ch, 0}, code[4] = "\0\0\0\0";
-				int ind = 0;
-				if (a)
-					code[ind++] = '\033';
-				code[ind] = (c ? 1 : 'a') + ch;
-				INSERT_COMB(str, code);
-			}
-		}
-	}
-	c = 0;
-	for (a = 0; alts[a]; a++) {
-		/* Upper-case alphabets */
-		for (ch = 0; ch < 26; ch++) {
-			char str[2] = {'A' + ch, 0}, code[] = {'\033', 'A' + ch, 0};
-			INSERT_COMB(str, code);
-		}
-		/* Digits */
-		for (ch = 0; ch < 10; ch++) {
-			char str[2] = {'0' + ch, 0}, code[] = {'\033', '0' + ch, 0};
-			INSERT_COMB(str, code);
-		}
-	}
-}
-
 void gnt_keys_refine(char *text)
 {
 	if (*text == 27 && *(text + 1) == '[' &&
@@ -197,7 +95,7 @@ struct _node
 	int flags;
 };
 
-static struct _node root = {.ref = 1, .flags = 0};
+struct _node root;
 
 static void add_path(struct _node *node, const char *path)
 {
@@ -288,3 +186,108 @@ void gnt_keys_print_combinations()
 	g_printerr("--------\n");
 }
 
+void gnt_init_keys()
+{
+	const char *controls[] = {"", "c-", "ctrl-", "ctr-", "ctl-", NULL};
+	const char *alts[] = {"", "alt-", "a-", "m-", "meta-", NULL};
+	int c, a, ch;
+	char key[32];
+
+	memset(&root, 0, sizeof(root));
+	root.ref = 1;
+
+	if (term == NULL) {
+		term = getenv("TERM");
+		if (!term)
+			term = "";  /* Just in case */
+	}
+
+	if (strcmp(term, "xterm") == 0 || strcmp(term, "rxvt") == 0) {
+		gnt_key_cup    = "\033" "[1;5A";
+		gnt_key_cdown  = "\033" "[1;5B";
+		gnt_key_cright = "\033" "[1;5C";
+		gnt_key_cleft  = "\033" "[1;5D";
+	} else if (strcmp(term, "screen") == 0 || strcmp(term, "rxvt-unicode") == 0) {
+		gnt_key_cup    = "\033" "Oa";
+		gnt_key_cdown  = "\033" "Ob";
+		gnt_key_cright = "\033" "Oc";
+		gnt_key_cleft  = "\033" "Od";
+	}
+
+	specials = g_hash_table_new(g_str_hash, g_str_equal);
+
+#define INSERT_KEY(k, code) do { \
+		g_hash_table_insert(specials, g_strdup(k), g_strdup(code)); \
+		gnt_keys_add_combination(code); \
+	} while (0)
+
+	INSERT_KEY("home",     GNT_KEY_HOME);
+	INSERT_KEY("end",      GNT_KEY_END);
+	INSERT_KEY("pageup",   GNT_KEY_PGUP);
+	INSERT_KEY("pagedown", GNT_KEY_PGDOWN);
+	INSERT_KEY("insert",   GNT_KEY_INS);
+	INSERT_KEY("delete",   GNT_KEY_DEL);
+	INSERT_KEY("back_tab", GNT_KEY_BACK_TAB);
+
+	INSERT_KEY("left",   GNT_KEY_LEFT);
+	INSERT_KEY("right",  GNT_KEY_RIGHT);
+	INSERT_KEY("up",     GNT_KEY_UP);
+	INSERT_KEY("down",   GNT_KEY_DOWN);
+
+	INSERT_KEY("tab",    "\t");
+	INSERT_KEY("menu",   GNT_KEY_POPUP);
+
+	INSERT_KEY("f1",   GNT_KEY_F1);
+	INSERT_KEY("f2",   GNT_KEY_F2);
+	INSERT_KEY("f3",   GNT_KEY_F3);
+	INSERT_KEY("f4",   GNT_KEY_F4);
+	INSERT_KEY("f5",   GNT_KEY_F5);
+	INSERT_KEY("f6",   GNT_KEY_F6);
+	INSERT_KEY("f7",   GNT_KEY_F7);
+	INSERT_KEY("f8",   GNT_KEY_F8);
+	INSERT_KEY("f9",   GNT_KEY_F9);
+	INSERT_KEY("f10",  GNT_KEY_F10);
+	INSERT_KEY("f11",  GNT_KEY_F11);
+	INSERT_KEY("f12",  GNT_KEY_F12);
+
+#define REM_LENGTH  (sizeof(key) - (cur - key))
+#define INSERT_COMB(k, code) do { \
+		snprintf(key, sizeof(key), "%s%s%s", controls[c], alts[a], k);  \
+		INSERT_KEY(key, code);  \
+	} while (0);
+
+	/* Lower-case alphabets */
+	for (a = 0, c = 0; controls[c]; c++, a = 0) {
+		if (c) {
+			INSERT_COMB("up",    gnt_key_cup);
+			INSERT_COMB("down",  gnt_key_cdown);
+			INSERT_COMB("left",  gnt_key_cleft);
+			INSERT_COMB("right", gnt_key_cright);
+		}
+
+		for (a = 0; alts[a]; a++) {
+			for (ch = 0; ch < 26; ch++) {
+				char str[2] = {'a' + ch, 0}, code[4] = "\0\0\0\0";
+				int ind = 0;
+				if (a)
+					code[ind++] = '\033';
+				code[ind] = (c ? 1 : 'a') + ch;
+				INSERT_COMB(str, code);
+			}
+		}
+	}
+	c = 0;
+	for (a = 0; alts[a]; a++) {
+		/* Upper-case alphabets */
+		for (ch = 0; ch < 26; ch++) {
+			char str[2] = {'A' + ch, 0}, code[] = {'\033', 'A' + ch, 0};
+			INSERT_COMB(str, code);
+		}
+		/* Digits */
+		for (ch = 0; ch < 10; ch++) {
+			char str[2] = {'0' + ch, 0}, code[] = {'\033', '0' + ch, 0};
+			INSERT_COMB(str, code);
+		}
+	}
+}
+


More information about the Commits mailing list