[ekg2-commit] r3920 - in trunk: ekg plugins/gtk plugins/httprc_xajax plugins/irc plugins/logs plugins/ncurses plugins/perl/common plugins/python plugins/readline: trunk/ekg/commands.c trunk/ekg/ekg.c trunk/ekg/events.c trunk/ekg/plugins.h trunk/ekg/protocol.c trunk/ekg/sessions.c trunk/ekg/stuff.c trunk/ekg/themes.c trunk/ekg/windows.c trunk/ekg/windows.h trunk/plugins/gtk/bindings.c trunk/plugins/gtk/completion.c trunk/plugins/gtk/main.c trunk/plugins/gtk/maingui.c trunk/plugins/gtk/menu.c trunk/plugins/httprc_xajax/httprc_xajax.c trunk/plugins/irc/autoacts.c trunk/plugins/logs/main.c trunk/plugins/ncurses/completion.c trunk/plugins/ncurses/main.c trunk/plugins/ncurses/mouse.c trunk/plugins/ncurses/old.c trunk/plugins/perl/common/Window.xs trunk/plugins/python/python-ekg.c trunk/plugins/python/python-window.c trunk/plugins/readline/main.c trunk/plugins/readline/readline-completion.c trunk/plugins/readline/ui-readline.c

SVN commit svn w toxygen.net
Czw, 20 Mar 2008, 11:15:53 CET


Author: peres
Date: 2008-03-20 11:15:52 +0100 (Thu, 20 Mar 2008)
New Revision: 3920

Modified:
   trunk/ekg/commands.c
   trunk/ekg/ekg.c
   trunk/ekg/events.c
   trunk/ekg/plugins.h
   trunk/ekg/protocol.c
   trunk/ekg/sessions.c
   trunk/ekg/stuff.c
   trunk/ekg/themes.c
   trunk/ekg/windows.c
   trunk/ekg/windows.h
   trunk/plugins/gtk/bindings.c
   trunk/plugins/gtk/completion.c
   trunk/plugins/gtk/main.c
   trunk/plugins/gtk/maingui.c
   trunk/plugins/gtk/menu.c
   trunk/plugins/httprc_xajax/httprc_xajax.c
   trunk/plugins/irc/autoacts.c
   trunk/plugins/logs/main.c
   trunk/plugins/ncurses/completion.c
   trunk/plugins/ncurses/main.c
   trunk/plugins/ncurses/mouse.c
   trunk/plugins/ncurses/old.c
   trunk/plugins/perl/common/Window.xs
   trunk/plugins/python/python-ekg.c
   trunk/plugins/python/python-window.c
   trunk/plugins/readline/main.c
   trunk/plugins/readline/readline-completion.c
   trunk/plugins/readline/ui-readline.c
Log:

Windows into lists3.



Modified: trunk/ekg/commands.c
===================================================================
--- trunk/ekg/commands.c	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/ekg/commands.c	2008-03-20 10:15:52 UTC (rev 3920)
@@ -944,11 +944,11 @@
                 }
 
                 if (for_all) {
-                        list_t l;
+                        window_t *w, *next;
 
-                        for (l = windows; l; l = l->next) {
-                        	window_t *w = l->data;
+                        for (w = windows; w; w = next) {
                                 char *for_command;
+				next = w->next;		/* this shall protect us from window killing (current one, not next) */
 
                                 if (!w || !w->target || !w->session)
                                         continue;
@@ -2389,11 +2389,9 @@
 
 	if (!(w = window_find_s(session, par0))) {		/* if we don't have window, we need to create it, in way specified by (config_make_window) */
 		if (config_make_window & 1) {
-			list_t l;
+			window_t *v;
 
-			for (l = windows; l; l = l->next) {
-				window_t *v = l->data;
-
+			for (v = windows; v; v = v->next) {
 				if (v->id < 2 || v->floating || v->target)
 					continue;
 
@@ -2716,13 +2714,12 @@
 				res = (last_command->function)(last_name, (const char **) par, s, target, (quiet & 1));
 				if (window_find_ptr(w) || (w == window_find_sa(s, target, 0)))
 					window_lock_dec(w);
-				else {
-					list_t l;
+				else { 
+					window_t *w;
 					debug("[WINDOW LOCKING] INTERNAL ERROR SETTING ALL WINDOW LOCKS TO 0 [wtarget=%s command=%s]\n", __(target), __(last_name));
 					/* may be faultly */
-					for (l=windows; l; l = l->next) {
-						window_t *w = l->data;
-						if ((!w) || !(w->lock)) continue;
+					for (w=windows; w; w = w->next) {
+						if (!(w->lock)) continue;
 						w->lock = 0;
 					}
 				}

Modified: trunk/ekg/ekg.c
===================================================================
--- trunk/ekg/ekg.c	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/ekg/ekg.c	2008-03-20 10:15:52 UTC (rev 3920)
@@ -1054,8 +1054,6 @@
 {
 	char *exit_exec = config_exit_exec;
 	extern int ekg2_dlclose(void *plugin);
-
-	list_t l;
 	int i;
 
 	msg_queue_write();
@@ -1220,15 +1218,14 @@
 
 	xfree(read_file(NULL, -1));	/* free internal read_file() buffer */
 
-	for (l = windows; l; l = l->next) {
-		window_t *w = l->data;
+	{
+		window_t *w;
 
-		if (!w)
-			continue;
+		for (w = windows; w; w = w->next) /* XXX: some LIST_ITEM_FREE ? */
+			xfree(w->target);
 
-		xfree(w->target);
+		LIST_DESTROY2(windows, NULL);	window_status = NULL; window_debug = NULL; window_current = NULL;	/* just in case */
 	}
-	list_destroy(windows, 1);	window_status = NULL; window_debug = NULL; window_current = NULL;	/* just in case */
 
 	{
 		query_t **ll;

Modified: trunk/ekg/events.c
===================================================================
--- trunk/ekg/events.c	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/ekg/events.c	2008-03-20 10:15:52 UTC (rev 3920)
@@ -418,11 +418,10 @@
 #define dayischanged(x) (oldtm->tm_##x != tm->tm_##x)
 	if (oldtm && (dayischanged(mday) /* day */ || dayischanged(mon) /* month */ || dayischanged(year)) /* year */)  {
 		if (config_display_day_changed) {
-			list_t l;
+			window_t *w;
 			char *ts = xstrdup(timestamp("%d %b %Y"));
 
-			for (l = windows; l; l = l->next) {
-				window_t *w = l->data;
+			for (w = windows; w; w = w->next) {
 				int oldact;
 				
 				if (!w || w->id == 0 || w->floating) continue; /* skip __debug && (floatings windows [__lastlog, __contacts, ...]) */

Modified: trunk/ekg/plugins.h
===================================================================
--- trunk/ekg/plugins.h	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/ekg/plugins.h	2008-03-20 10:15:52 UTC (rev 3920)
@@ -26,7 +26,7 @@
 #include "dynstuff.h"
 #include "sessions.h"
 
-#define EKG_ABI_VER 3910
+#define EKG_ABI_VER 3920
 
 #define EXPORT __attribute__ ((visibility("default")))
 

Modified: trunk/ekg/protocol.c
===================================================================
--- trunk/ekg/protocol.c	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/ekg/protocol.c	2008-03-20 10:15:52 UTC (rev 3920)
@@ -108,12 +108,10 @@
 static QUERY(protocol_userlist_changed) {
 	char **p1 = va_arg(ap, char**);
 	char **p2 = va_arg(ap, char**);
+	
+	window_t *w;
 
-	list_t l;
-
-        for (l = windows; l; l = l->next) {
-       		window_t *w = l->data;
-
+        for (w = windows; w; w = w->next) {
 		if (!w->target || xstrcasecmp(w->target, *p1))
 			continue;
 

Modified: trunk/ekg/sessions.c
===================================================================
--- trunk/ekg/sessions.c	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/ekg/sessions.c	2008-03-20 10:15:52 UTC (rev 3920)
@@ -142,7 +142,7 @@
 	plugin_t *pl;
 
 	session_t *s;
-	list_t l;
+	window_t *w;
 
 	if (!uid)
 		return NULL;
@@ -199,9 +199,7 @@
 
 	query_emit_id(NULL, SESSION_ADDED, &(s->uid));		/* It's read-only query, XXX */
 
-	for (l = windows; l; l = l->next) {
-		window_t *w = l->data;
-
+	for (w = windows; w; w = w->next) {
 /* previous version was unacceptable. So we do now this trick:
  * 	userlist (if plugin has one) have been already read by SESSION_ADDED emit. so now, 
  * 	we check throught get_uid() if this plugin can handle it.. [userlist must be read, if we have nosession window 
@@ -278,7 +276,7 @@
 int session_remove(const char *uid)
 {
 	session_t *s;
-	list_t l;
+	window_t *w;
 	char *tmp;
 	int count;
 
@@ -289,10 +287,8 @@
 
 	count = LIST_COUNT2(sessions);
 
-	for (l = windows; l; l = l->next) {
-		window_t *w = l->data;
-
-		if (w && w->session == s) {
+	for (w = windows; w; w = w->next) {
+		if (w->session == s) {
 			if (count > 1)
 				window_session_cycle(w);
 			else
@@ -1455,7 +1451,6 @@
  */
 void sessions_free() {
 	session_t *s;
-	list_t l;
 
         if (!sessions)
                 return;
@@ -1499,13 +1494,11 @@
 									 * XXX, think about it?
 									 */
 
-	for (l = windows; l; l = l->next) {
-		window_t *w = l->data;
+	{
+		window_t *w;
 
-		if (!w)
-			continue;
-
-		w->session = NULL;
+		for (w = windows; w; w = w->next)
+			w->session = NULL;
 	}
 
         LIST_DESTROY2(sessions, session_free_item);

Modified: trunk/ekg/stuff.c
===================================================================
--- trunk/ekg/stuff.c	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/ekg/stuff.c	2008-03-20 10:15:52 UTC (rev 3920)
@@ -186,15 +186,13 @@
  */
 
 void windows_save() {
-	list_t l;
+	window_t *w;
 
 	if (config_windows_save) {
 		string_t s = string_init(NULL);
 		int maxid = 0, i;
 		
-		for (l = windows; l; l = l->next) {
-			window_t *w = l->data;
-
+		for (w = windows; w; w = w->next) {
 			if (!w->floating && w->id > maxid)
 				maxid = w->id;
 		}
@@ -203,9 +201,7 @@
 			const char *target = "-";
 			const char *session_name = NULL;
 			
-			for (l = windows; l; l = l->next) {
-				window_t *w = l->data;
-
+			for (w = windows; w; w = w->next) {
 				if (w->id == i) {
 					target = w->target;
 					if (w->session)
@@ -229,9 +225,7 @@
 				string_append_c(s, '|');
 		}
 
-		for (l = windows; l; l = l->next) {
-			window_t *w = l->data;
-
+		for (w = windows; w; w = w->next) {
 			if (w->floating && (!w->target || xstrncmp(w->target, "__", 2))) {
 				char *tmp = saprintf("|*%d,%d,%d,%d,%d,%s", w->left, w->top, w->width, w->height, w->frames, w->target);
 				string_append(s, tmp);

Modified: trunk/ekg/themes.c
===================================================================
--- trunk/ekg/themes.c	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/ekg/themes.c	2008-03-20 10:15:52 UTC (rev 3920)
@@ -802,11 +802,9 @@
 
 	/* 3) if we don't have window here, and if ((config_make_window & 3) == 1) [unused], than we should find empty window. */
 		if ((config_make_window & 3) == 1) {
-			list_t l;
+			window_t *wa;
 		
-			for (l = windows; l; l = l->next) {
-				window_t *wa = l->data;
-
+			for (wa = windows; wa; wa = wa->next) {
 				if (!wa->target && wa->id > 1) {
 					w = wa;
 

Modified: trunk/ekg/windows.c
===================================================================
--- trunk/ekg/windows.c	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/ekg/windows.c	2008-03-20 10:15:52 UTC (rev 3920)
@@ -45,7 +45,7 @@
 
 int window_last_id = -1;		/* ostatnio wyświetlone okno */
 
-list_t windows = NULL;			/* lista okien */
+window_t *windows = NULL;		/* lista okien */
 int config_display_crap = 1;		/* czy wyświetlać śmieci? */
 
 window_t *window_current = NULL;	/* okno aktualne, zawsze na coś musi wskazywać! */
@@ -72,9 +72,10 @@
  */
 
 window_t *window_find_ptr(window_t *w) {
-	list_t l;
-	for (l = windows; l; l = l->next) {
-		if (w == l->data)
+	window_t *v;
+
+	for (v = windows; v; v = v->next) {
+		if (w == v)
 			return w;
 	}
 	return NULL;
@@ -100,7 +101,7 @@
 
 window_t *window_find_sa(session_t *session, const char *target, int session_null_means_no_session) {
 	userlist_t *u;
-	list_t l;
+	window_t *w;
 
 	if (!target || !xstrcasecmp(target, "__current"))
 		return window_current->id ? window_current : window_status;
@@ -111,9 +112,7 @@
 	if (!xstrcasecmp(target, "__debug"))
 		return window_debug;
 
-	for (l = windows; l; l = l->next) {
-		window_t *w = l->data;
-
+	for (w = windows; w; w = w->next) {
 		/* if targets match, and (sessions match or [no session was specified, and it doesn't matter to which session window belongs to]) */
 		if (w->target && ((session == w->session) || (!session && !session_null_means_no_session)) && !xstrcasecmp(target, w->target))
 			return w;
@@ -134,9 +133,7 @@
 			if (!(u = userlist_find(s, target))) 
 				continue;
 
-			for (l = windows; l; l = l->next) {
-				window_t *w = l->data;
-
+			for (w = windows; w; w = w->next) {
 				/* if there's target, and sessions match [no session specified, or sessions equal, check if entry (from userlist) match */
 				if ((!session || session == w->session) && w->target) {
 					if (u->nickname && !xstrcasecmp(u->nickname, w->target))
@@ -184,13 +181,11 @@
  *  - id - numer okna
  */
 void window_switch(int id) {
-	list_t l;
+	window_t *w;
 	userlist_t *u;
 	int ul_refresh = 0;
 
-	for (l = windows; l; l = l->next) {
-		window_t *w = l->data;
-
+	for (w = windows; w; w = w->next) {
 		if (id != w->id || w->floating)
 			continue;
 
@@ -287,18 +282,17 @@
 
 	/* if no new_id given, than let's search for window id.. */
 	if (new_id == 0) {
-		list_t l	= windows;	/* set to the beginning of the window list */
+		window_t *v	= windows;	/* set to the beginning of the window list */
 		int id		= 2;		/* [XXX] set to first valid id? */
 		
 		/* XXX, after it, we exactly know where to put new window to list, without list_add_sorted() we can do list_add_beggining() 
 		 * but it'll ugly code. So not doing it :) */
 
 		/* we can do this stuff. because windows are sorted by id */
-		while (l) {
-			window_t *w = l->data;
+		while (v) {
+			window_t *w = v;
+			v = v->next;		/* goto next window */
 
-			l = l->next;		/* goto next window */
-
 			if (w->id < 2)					/* [RESERVED CLASS: 0-1] 	0 for __debug, 1 for __status */
 				continue;
 
@@ -334,8 +328,7 @@
 	w->session = session;
 /*	w->userlist = NULL; */		/* xmalloc memset() to 0 memory */
 
-	LIST_ADD_SORTED(&windows, w, window_new_compare);
-
+	LIST_ADD_SORTED2(&windows, w, window_new_compare);
 	query_emit_id(NULL, UI_WINDOW_NEW, &w);	/* XXX */
 
 	return w;
@@ -370,13 +363,10 @@
  * przechodzi do kolejnego okna.
  */
 void window_next() {
-	window_t *next = NULL;
+	window_t *next = NULL, *w;
 	int passed = 0;
-	list_t l;
 
-	for (l = windows; l; l = l->next) {
-		window_t *w = l->data;
-
+	for (w = windows; w; w = w->next) {
 		if (passed && !w->floating) {
 			next = w;
 			break;
@@ -400,16 +390,13 @@
 
 /* XXX, need check */
 void window_prev() {
-	window_t *prev = NULL;
-	list_t l;
+	window_t *prev = NULL, *w;
 
-	for (l = windows; l; l = l->next) {
-		window_t *w = l->data;
-
+	for (w = windows; w; w = w->next) {
 		if (w->floating)
 			continue;
 
-		if (w == window_current && l != windows)
+		if (w == window_current && w != windows)
 			break;
 
 		prev = w;
@@ -419,11 +406,9 @@
 		return;
 
 	if (!prev->id) {
-		for (l = windows; l; l = l->next) {
-			window_t *w = l->data;
-
+		for (w = windows; w; w = w->next) {
 			if (!w->floating)
-				prev = l->data;
+				prev = w;
 		}
 	}
 
@@ -478,11 +463,9 @@
 
 	/* if config_sort_windows set, and it was not floating window... than resort stuff. */
 	if (config_sort_windows && !w->floating) {
-		list_t l;
+		window_t *w;
 
-		for (l = windows; l; l = l->next) {
-			window_t *w = l->data;
-
+		for (w = windows; w; w = w->next) {
 			if (w->floating)
 				continue;
 			/* XXX, i'm leaving it. however if we set sort_windows for example when we have: windows: 1, 3, 5, 7 and we will remove 3.. We'll still have: 1, 4, 6 not: 1, 2, 3 bug? */
@@ -495,7 +478,7 @@
 
 	xfree(w->target);
 	userlist_free_u(&(w->userlist));
-	list_remove(&windows, w, 1);
+	LIST_REMOVE2(&windows, w, NULL);	/* XXX: LIST_ITEM_FREE ? */
 }
 
 /**
@@ -513,11 +496,9 @@
  */
 
 window_t *window_exist(int id) {
-	list_t l;
+	window_t *w;
 
-        for (l = windows; l; l = l->next) {
-	        window_t *w = l->data;
-
+        for (w = windows; w; w = w->next) {
                 if (w->id == id) 
 			return w;
         }
@@ -532,6 +513,8 @@
  *
  * @param first		- 1st window id.
  * @param second 	- 2nd window id.
+ *
+ * @todo XXX: Rename to _swap, and make some real move.
  */
 
 static void window_move(int first, int second) {
@@ -540,14 +523,14 @@
 	if (!(w1 = window_exist(first)) || !(w2 = window_exist(second)))
 		return;
 
-        list_remove(&windows, w1, 0);
+        LIST_UNLINK2(&windows, w1);
 	w1->id = second;
 
-        list_remove(&windows, w2, 0);
+        LIST_UNLINK2(&windows, w2);
 	w2->id = first;
 
-	LIST_ADD_SORTED(&windows, w1, window_new_compare);
-	LIST_ADD_SORTED(&windows, w2, window_new_compare);
+	LIST_ADD_SORTED2(&windows, w1, window_new_compare);
+	LIST_ADD_SORTED2(&windows, w2, window_new_compare);
 }
 
 /**
@@ -587,11 +570,9 @@
 	}
 
 	if (!params[0] || !xstrcasecmp(params[0], ("list"))) {
-		list_t l;
+		window_t *w;
 
-		for (l = windows; l; l = l->next) {
-			window_t *w = l->data;
-
+		for (w = windows; w; w = w->next) {
 			if (w->id) {
 				if (w->target) {
 					if (!w->floating)
@@ -606,12 +587,10 @@
 	}
 
 	if (!xstrcasecmp(params[0], ("active"))) {
-		list_t l;
+		window_t *w;
 		int id = 0;
 
-		for (l = windows; l; l = l->next) {
-			window_t *w = l->data;
-
+		for (w = windows; w; w = w->next) {
 			if (w->act && !w->floating && w->id) {
 				id = w->id;
 				break;
@@ -766,11 +745,9 @@
 		window_t *w = window_current;
 
 		if (params[1]) {
-			list_t l;
+			window_t *ww;
 
-			for (w = NULL, l = windows; l; l = l->next) {
-				window_t *ww = l->data;
-
+			for (w = NULL, ww = windows; ww; ww = ww->next) {
 				if (ww->id == atoi(params[1])) {
 					w = ww;
 					break;

Modified: trunk/ekg/windows.h
===================================================================
--- trunk/ekg/windows.h	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/ekg/windows.h	2008-03-20 10:15:52 UTC (rev 3920)
@@ -44,7 +44,9 @@
 	char *expression;		/* expression */
 } window_lastlog_t;
 
-typedef struct {
+typedef struct window {
+	struct window *next;
+
 	unsigned short id;		/* numer okna */
 	char *target;			/* nick query albo inna nazwa albo NULL */
 	session_t *session;		/* której sesji dotyczy okno */
@@ -79,7 +81,7 @@
 
 #ifndef EKG2_WIN32_NOFUNCTION
 
-extern list_t windows;
+extern window_t *windows;
 extern window_t *window_debug;
 extern window_t *window_status;
 extern window_t *window_current;

Modified: trunk/plugins/gtk/bindings.c
===================================================================
--- trunk/plugins/gtk/bindings.c	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/plugins/gtk/bindings.c	2008-03-20 10:15:52 UTC (rev 3920)
@@ -195,15 +195,13 @@
 	int keyval = evt->keyval;
 	int mod, n;
 	int was_complete = 0;
-	list_t l;
+	window_t *w;
 
 	{
 		sess = NULL;
 
 		/* where did this event come from? */
-		for (l = windows; l; l = l->next) {
-			window_t *w = l->data;
-
+		for (w = windows; w; w = w->next) {
 			if (gtk_private_ui(w)->input_box == wid) {
 				sess = w;
 				if (gtk_private_ui(w)->is_tab)

Modified: trunk/plugins/gtk/completion.c
===================================================================
--- trunk/plugins/gtk/completion.c	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/plugins/gtk/completion.c	2008-03-20 10:15:52 UTC (rev 3920)
@@ -565,11 +565,8 @@
 static void window_generator(const char *text, int len)
 {
 	window_t *w;
-	list_t l;
 
-	for (l = windows; l; l=l->next)	{
-		w = (window_t *)l->data;
-
+	for (w = windows; w; w=w->next)	{
 		if (!w->target || xstrncmp(text, w->target, len))
 			continue;
 

Modified: trunk/plugins/gtk/main.c
===================================================================
--- trunk/plugins/gtk/main.c	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/plugins/gtk/main.c	2008-03-20 10:15:52 UTC (rev 3920)
@@ -226,12 +226,10 @@
 }
 
 static QUERY(gtk_ui_window_act_changed) { 		/* fe_set_tab_color() */
-	list_t l;
+	window_t *w;
 
-	for (l = windows; l; l = l->next) {
-		window_t *w = l->data;
+	for (w = windows; w; w = w->next)
 		fe_set_tab_color(w, w->act);
-	}
 
 	return 0;
 }
@@ -343,7 +341,7 @@
 
         int is_UI = 0;
 	int xfd;
-	list_t l;
+	window_t *w;
 
 	PLUGIN_CHECK_VER("gtk");
 
@@ -447,8 +445,8 @@
 
 	idle_add(&gtk_plugin, ekg2_xorg_idle, NULL);
 
-	for (l = windows; l; l = l->next)
-		ekg_gtk_window_new(l->data);	
+	for (w = windows; w; w = w->next)
+		ekg_gtk_window_new(w);
 
 	memset(gtk_history, 0, sizeof(gtk_history));
 

Modified: trunk/plugins/gtk/maingui.c
===================================================================
--- trunk/plugins/gtk/maingui.c	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/plugins/gtk/maingui.c	2008-03-20 10:15:52 UTC (rev 3920)
@@ -298,14 +298,12 @@
 #endif
 
 static gboolean mg_inputbox_focus(GtkWidget *widget, GdkEventFocus *event, gtk_window_ui_t *gui) {
-	list_t l;
+	window_t *w;
 
 	if (gui->is_tab)
 		return FALSE;
 
-	for (l = windows; l; l = l->next) {
-		window_t *w = l->data;
-
+	for (w = windows; w; w = w->next) {
 		if (gtk_private(w)->gui == gui) {
 #warning "window_switch() XXX"
 			window_switch(w->id);
@@ -342,11 +340,9 @@
 	if (gui->is_tab) {
 		sess = window_current;
 	} else {
-		list_t l;
+		window_t *w;
 
-		for (l = windows; l; l = l->next) {
-			window_t *w = l->data;
-
+		for (w = windows; w; w = w->next) {
 			if (gtk_private_ui(w) == gui) {
 				sess = w;
 				break;
@@ -2062,13 +2058,11 @@
 
 void mg_apply_setup(void) {
 	int done_main = FALSE;
-	list_t l;
+	window_t *w;
 
 	mg_create_tab_colors();
 
-	for (l = windows; l; l = l->next) {
-		window_t *w = l->data;
-
+	for (w = windows; w; w = w->next) {
 		gtk_xtext_set_time_stamp(gtk_private(w)->buffer, config_timestamp_show);
 		((xtext_buffer *) gtk_private(w)->buffer)->needs_recalc = TRUE;
 
@@ -2162,11 +2156,9 @@
 #endif
 
 void fe_set_away(session_t * serv) {
-	list_t l;
+	window_t *w;
 
-	for (l = windows; l; l = l->next) {
-		window_t *w = l->data;
-
+	for (w = windows; w; w = w->next) {
 		if (w->session == serv) {
 #if DARK
 			if (!sess->gui->is_tab || sess == current_tab) {

Modified: trunk/plugins/gtk/menu.c
===================================================================
--- trunk/plugins/gtk/menu.c	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/plugins/gtk/menu.c	2008-03-20 10:15:52 UTC (rev 3920)
@@ -643,10 +643,9 @@
 
 static void menu_setting_foreach(void (*callback) (window_t *), int id, guint state) {
 	int maindone = FALSE;	/* do it only once for EVERY tab */
-	list_t l;
+	window_t *w;
 
-	for (l = windows; l; l = l->next) {
-		window_t *w = l->data;
+	for (w = windows; w; w = w->next) {
 		gtk_window_ui_t *gui = gtk_private_ui(w);
 
 		if (!gui->is_tab || !maindone) {

Modified: trunk/plugins/httprc_xajax/httprc_xajax.c
===================================================================
--- trunk/plugins/httprc_xajax/httprc_xajax.c	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/plugins/httprc_xajax/httprc_xajax.c	2008-03-20 10:15:52 UTC (rev 3920)
@@ -643,10 +643,9 @@
 		} else {
 			char *temp;
 			int i, j;
-			list_t l;
-
 			window_t *w = window_current; 
 			ncurses_window_t *n;
+			list_t l;
 
 			/* if user is making a refresh, we must clear collected events
 			 * whether he has a cookie or not
@@ -695,8 +694,7 @@
 			string_append (htheader, itoa(window_current->id));
 			string_append (htheader, ";\n");
 
-			for (l = windows; l; l = l->next) {
-				window_t *w = l->data;
+			for (w = windows; w; w = w->next) {
 				char *tempdata;
 				if (w == window_current)
 					string_append_format(htheader, "gwins[%d] = new Array(2, \"%s\", new Array());\n ", w->id, window_target(w));

Modified: trunk/plugins/irc/autoacts.c
===================================================================
--- trunk/plugins/irc/autoacts.c	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/plugins/irc/autoacts.c	2008-03-20 10:15:52 UTC (rev 3920)
@@ -147,7 +147,6 @@
 
 int irc_autorejoin(session_t *s, int when, char *chan) {
 	irc_private_t *j;
-	list_t l;
 	string_t st;
 	window_t *w;
 	char *chanprefix;
@@ -166,9 +165,7 @@
 	switch (when) {
 		case IRC_REJOIN_CONNECT:
 			st = string_init(NULL);
-			for (l = windows; l; l = l->next) {
-				w = l->data;
-
+			for (w = windows; w; w = w->next) {
 				if (!w->target || w->session != s)			/* check if sessions match and has w->target */
 					continue;
 

Modified: trunk/plugins/logs/main.c
===================================================================
--- trunk/plugins/logs/main.c	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/plugins/logs/main.c	2008-03-20 10:15:52 UTC (rev 3920)
@@ -388,10 +388,9 @@
 }
 
 static QUERY(logs_postinit) {
-	list_t w;
-	for (w = windows; w; w = w->next) {
-		logs_window_new((window_t *) w->data);
-	}
+	window_t *w;
+	for (w = windows; w; w = w->next)
+		logs_window_new(w);
 	return 0;
 }
 

Modified: trunk/plugins/ncurses/completion.c
===================================================================
--- trunk/plugins/ncurses/completion.c	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/plugins/ncurses/completion.c	2008-03-20 10:15:52 UTC (rev 3920)
@@ -566,11 +566,8 @@
 static void window_generator(const char *text, int len)
 {
 	window_t *w;
-	list_t l;
 
-	for (l = windows; l; l=l->next)	{
-		w = (window_t *)l->data;
-
+	for (w = windows; w; w=w->next)	{
 		if (!w->target || xstrncmp(text, w->target, len))
 			continue;
 

Modified: trunk/plugins/ncurses/main.c
===================================================================
--- trunk/plugins/ncurses/main.c	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/plugins/ncurses/main.c	2008-03-20 10:15:52 UTC (rev 3920)
@@ -340,12 +340,10 @@
 	char *name = *(va_arg(ap, char**));
 
         if (!xstrcasecmp(name, "sort_windows") && config_sort_windows) {
-	        list_t l;
+	        window_t *w;
                 int id = 2;
 
-                for (l = windows; l; l = l->next) {
-	                window_t *w = l->data;
-                               
+                for (w = windows; w; w = w->next) {
 			if (w->floating)
                         	continue;
 
@@ -353,13 +351,10 @@
 	                        w->id = id++;
                 }
         } else if (!xstrcasecmp(name, "timestamp") || !xstrcasecmp(name, "ncurses:margin_size")) {
-       		list_t l;
+       		window_t *w;
 
-                for (l = windows; l; l = l->next) {
-	                window_t *w = l->data;
-
+                for (w = windows; w; w = w->next)
 	                ncurses_backlog_split(w, 1, 0);
-                }
 
                 ncurses_resize();
         }
@@ -374,10 +369,9 @@
 {
 	char *oldname = *(va_arg(ap, char**));
 	char *newname = *(va_arg(ap, char**));
-        list_t l;
+        window_t *w;
 
-        for (l = windows; l; l = l->next) {
-	        window_t *w = l->data;
+        for (w = windows; w; w = w->next) {
                 ncurses_window_t *n = w->private;
 
 	        if (w->target && !xstrcasecmp(w->target, oldname)) {
@@ -592,7 +586,7 @@
 
 EXPORT int ncurses_plugin_init(int prio)
 {
-	list_t l;
+	window_t *w;
 	int is_UI = 0;
 	va_list dummy;
 	char *termtype = getenv("TERM");
@@ -712,8 +706,8 @@
 	header_statusbar_resize(NULL);
 	ncurses_typing_retimer(NULL);
 
-	for (l = windows; l; l = l->next)
-		ncurses_window_new(l->data);
+	for (w = windows; w; w = w->next)
+		ncurses_window_new(w);
 
 	ncurses_initialized = 1;
 

Modified: trunk/plugins/ncurses/mouse.c
===================================================================
--- trunk/plugins/ncurses/mouse.c	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/plugins/ncurses/mouse.c	2008-03-20 10:15:52 UTC (rev 3920)
@@ -90,7 +90,7 @@
  */
 void ncurses_mouse_clicked_handler(int x, int y, int mouse_flag)
 {
-	list_t l;
+	window_t *w;
 #if 0
 	char *tmp;
 
@@ -132,21 +132,16 @@
 
 	/* debug("stalo sie: %s x: %d y: %d\n", tmp, x, y); */
 #endif
-	for (l = windows; l; l = l->next) {
-		window_t *w = l->data;
-		
-		if (!w)
-			continue;
-
+	for (w = windows; w; w = w->next) {
 		if (x > w->left && x <= w->left + w->width && y > w->top && y <= w->top + w->height) {
 			ncurses_window_t *n;
 			if (w->id == 0) { /* if we are reporting status window it means that we clicked 
 					 * on window_current and some other functions should be called */
 				ncurses_main_window_mouse_handler(x - w->left, y - w->top, mouse_flag);
 				break;
-			} else
-				n = w->private;
-
+			}
+			
+			n = w->private;
 			/* debug("window id:%d y %d height %d\n", w->id, w->top, w->height); */
 			if (n->handle_mouse)
 				n->handle_mouse(x - w->left, y - w->top, mouse_flag);
@@ -154,7 +149,7 @@
 		}
 	}
 
-	if (!l) { /* special screen sections */
+	if (!w) { /* special screen sections */
 			/* input */
 		if (y > stdscr->_maxy - input_size + 1) {
 			y -= (stdscr->_maxy - input_size + 2);

Modified: trunk/plugins/ncurses/old.c
===================================================================
--- trunk/plugins/ncurses/old.c	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/plugins/ncurses/old.c	2008-03-20 10:15:52 UTC (rev 3920)
@@ -281,12 +281,10 @@
 QUERY(ncurses_session_disconnect_handler) {
 	const char	*session	= *va_arg(ap, const char **);
 	const session_t	*s		= session_find(session);
-	list_t		l;
+	window_t	*w;
 
-	for (l = windows; l; l = l->next) {
-		window_t *w = l->data;
-
-		if (!w || w->session != s)
+	for (w = windows; w; w = w->next) {
+		if (w->session != s)
 			continue;
 
 		ncurses_window_gone(w);
@@ -753,7 +751,7 @@
 void ncurses_resize()
 {
 	int left, right, top, bottom, width, height;
-	list_t l;
+	window_t *w;
 
 	left = 0;
 	right = stdscr->_maxx + 1;
@@ -767,8 +765,7 @@
 	if (height < 1)
 		height = 1;
 
-	for (l = windows; l; l = l->next) {
-		window_t *w = l->data;
+	for (w = windows; w; w = w->next) {
 		ncurses_window_t *n = w->private;
 
 		if (!n)
@@ -839,8 +836,7 @@
 	if (top < 0)			top = 0;
 	if (top > stdscr->_maxy)	top = stdscr->_maxy;
 
-	for (l = windows; l; l = l->next) {
-		window_t *w = l->data;
+	for (w = windows; w; w = w->next) {
 		ncurses_window_t *n = w->private;
 		int delta;
 
@@ -962,10 +958,7 @@
 	ncurses_window_t *n;
 
 	if (match_arg(params[0], 'a', ("all"), 2)) {
-		list_t l;
-
-		for (l = windows; l; l = l->next) {
-			w = l->data;
+		for (w = windows; w; w = w->next) {
 			if (!w->floating && (w->act != 2)) {
 				n = w->private;
 				n->last_red_line = time(0);
@@ -1260,7 +1253,7 @@
  */
 void ncurses_refresh()
 {
-	list_t l;
+	window_t *w;
 
 	if (window_current && window_current->private /* !window_current->floating */) {
 		ncurses_window_t *n = window_current->private;
@@ -1272,8 +1265,7 @@
 			wnoutrefresh(n->window);
 	}
 
-	for (l = windows; l; l = l->next) {
-		window_t *w = l->data;
+	for (w = windows; w; w = w->next) {
 		ncurses_window_t *n = w->private;
 
 		if (!w->floating || w->hide)
@@ -1619,11 +1611,10 @@
 	{
 		string_t s = string_init("");
 		int act = 0;
-		list_t l;
+		window_t *w;
 
-		for (l = windows; l; l = l->next) {
+		for (w = windows; w; w = w->next) {
 			char tmp[33];
-			window_t *w = l->data;
 
 			if ((!w->act && !w->in_typing) || !w->id || (w == window_current)) 
 				continue;
@@ -1922,7 +1913,7 @@
 void ncurses_deinit()
 {
 	static int done = 0;
-	list_t l;
+	window_t *w;
 	int i;
 
 #ifdef SIGWINCH
@@ -1933,12 +1924,12 @@
 		close(winch_pipe[1]);
 	}
 
-	for (l = windows; l; ) {
-		window_t *w = l->data;
+	for (w = windows; w; ) {
+		window_t *next = w;
 
-		l = l->next;
-
 		ncurses_window_kill(w);
+
+		w = next;
 	}
 
 	tcsetattr(0, TCSADRAIN, &old_tio);
@@ -2673,13 +2664,12 @@
  */
 void changed_backlog_size(const char *var)
 {
-	list_t l;
+	window_t *w;
 
 	if (config_backlog_size < ncurses_screen_height)
 		config_backlog_size = ncurses_screen_height;
 
-	for (l = windows; l; l = l->next) {
-		window_t *w = l->data;
+	for (w = windows; w; w = w->next) {
 		ncurses_window_t *n = w->private;
 		int i;
 				
@@ -2807,7 +2797,7 @@
 
 int ncurses_lastlog_update(window_t *w) {
 	ncurses_window_t *n;
-	list_t l;
+	window_t *ww;
 	int retval = 0;
 
 	int old_start;
@@ -2831,8 +2821,7 @@
 
 	if (config_lastlog_display_all) {
 /* 3rd, other windows? */
-		for (l = windows; l; l = l->next) {
-			window_t *ww = l->data;
+		for (ww = windows; ww; w = ww->next) {
 			if (ww == window_current) continue;
 			if (ww == w) continue; /* ;p */
 

Modified: trunk/plugins/perl/common/Window.xs
===================================================================
--- trunk/plugins/perl/common/Window.xs	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/plugins/perl/common/Window.xs	2008-03-20 10:15:52 UTC (rev 3920)
@@ -28,10 +28,10 @@
 
 void windows()
 PREINIT:
-        list_t l;
+        window_t *w;
 PPCODE:
-        for (l = windows; l; l = l->next) {
-                XPUSHs(sv_2mortal(bless_window( (window_t *) l->data)));
+        for (w = windows; w; w = w->next) {
+                XPUSHs(sv_2mortal(bless_window( w )));
         }
 
 #####################

Modified: trunk/plugins/python/python-ekg.c
===================================================================
--- trunk/plugins/python/python-ekg.c	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/plugins/python/python-ekg.c	2008-03-20 10:15:52 UTC (rev 3920)
@@ -584,15 +584,14 @@
 PyObject *ekg_cmd_windows(PyObject * self, PyObject * pyargs)
 {
         PyObject *list;
-        list_t l;
-        int len = list_count(windows);
+        window_t *w;
+        int len = LIST_COUNT2(windows);
 
         list = PyList_New(len);
         len = 0;
 
-        for (l = windows; l; l = l->next) {
-                window_t *p = l->data;
-                PyList_SetItem(list, len, python_build_window_w(p));
+        for (w = windows; w; w = w->next) {
+                PyList_SetItem(list, len, python_build_window_w(w));
                 len++;
         }
         Py_INCREF(list);

Modified: trunk/plugins/python/python-window.c
===================================================================
--- trunk/plugins/python/python-window.c	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/plugins/python/python-window.c	2008-03-20 10:15:52 UTC (rev 3920)
@@ -268,30 +268,25 @@
 PyObject *ekg_window_prev(ekg_windowObj * self, PyObject * pyargs)
 {
         int id;
-        window_t *w = NULL;
-	list_t l;
+        window_t *w = NULL, *wnd;
 
         id = self->w->id;
 
         if (id < 2 || !(w = window_exist(id-1))) {
-                for (l = windows; l; l = l->next) {
-                        window_t *wnd = l->data;
-
+                for (wnd = windows; wnd; wnd = wnd->next) {
                         if (wnd->floating)
                                 continue;
 
-                        if (wnd == window_current && l != windows)
+                        if (wnd == window_current && wnd != windows)
                                 break;
 
-                        w = l->data;
+                        w = wnd;
                 }
 
                 if (!w->id) {
-                        for (l = windows; l; l = l->next) {
-                                window_t *wnd = l->data;
-
+                        for (wnd = windows; wnd; wnd = wnd->next) {
                                 if (!wnd->floating)
-                                        w = l->data;
+                                        w = wnd;
                         }
                 }
         }

Modified: trunk/plugins/readline/main.c
===================================================================
--- trunk/plugins/readline/main.c	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/plugins/readline/main.c	2008-03-20 10:15:52 UTC (rev 3920)
@@ -215,12 +215,10 @@
 static QUERY(readline_variable_changed) {
 	char *name = *(va_arg(ap, char**));
 	if (!xstrcasecmp(name, "sort_windows") && config_sort_windows) {
-		list_t l;
+		window_t *w;
 		int id = 1;
-		for (l = windows; l; l = l->next) {
-			window_t *w = l->data;
+		for (w = windows; w; w = w->next)
 			w->id = id++;
-		}
 	}
 	return 0;
 }
@@ -262,7 +260,7 @@
 EXPORT int readline_plugin_init(int prio) {
 	char c;
 	struct sigaction sa;
-	list_t l;
+	window_t *w;
 	int is_UI = 0;
 
 	PLUGIN_CHECK_VER("readline");
@@ -289,10 +287,8 @@
 
 	watch_add(&readline_plugin, 0, WATCH_READ, readline_watch_stdin, NULL);
 
-	for (l = windows; l; l = l->next) {
-		window_t *w = l->data;
+	for (w = windows; w; w = w->next)
 		w->private = xmalloc(sizeof(readline_window_t));
-	}
 	
 	window_refresh();
 	rl_initialize();

Modified: trunk/plugins/readline/readline-completion.c
===================================================================
--- trunk/plugins/readline/readline-completion.c	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/plugins/readline/readline-completion.c	2008-03-20 10:15:52 UTC (rev 3920)
@@ -422,17 +422,16 @@
 }
 
 GENERATOR(window) {
-	static list_t el;
+	static window_t *w;
 	static int len;
 
 	if (!state) {
-		el = windows;
+		w = windows;
 		len = xstrlen(text);
 	}
 
-	while (el) {
-		window_t *w = el->data;
-		el = el->next;
+	while (w) {
+		w = w->next;
 
 		if (!xstrncmp(text, w->target, len))
 			return xstrdup(w->target);

Modified: trunk/plugins/readline/ui-readline.c
===================================================================
--- trunk/plugins/readline/ui-readline.c	2008-03-19 23:42:06 UTC (rev 3919)
+++ trunk/plugins/readline/ui-readline.c	2008-03-20 10:15:52 UTC (rev 3920)
@@ -257,7 +257,7 @@
 {
 	static char buf[80];
 	const char *prompt = buf;
-	int count = list_count(windows);
+	int count = LIST_COUNT2(windows);
 	char *tmp, *act = window_activity();
 
         if (window_current->target) {
@@ -494,10 +494,9 @@
 {
 	string_t s = string_init("");
 	int first = 1;
-	list_t l;
+	window_t *w;
 
-	for (l = windows; l; l = l->next) {
-		window_t *w = l->data;
+	for (w = windows; w; w = w->next) {
 /* we cannot make it colorful with default formats because grey on black doesn't look so good... */
 		if (!w->act || !w->id) 
 			continue;



Więcej informacji o liście dyskusyjnej ekg2-commit