changeset 74:fc8169ab4627

Fix inifile_select
author David Demelier <markand@malikania.fr>
date Sun, 13 Nov 2011 17:15:55 +0100
parents 653d583376c9
children 37fa222d7cc6
files inifile.c
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/inifile.c	Sun Nov 13 16:38:29 2011 +0100
+++ b/inifile.c	Sun Nov 13 17:15:55 2011 +0100
@@ -170,20 +170,24 @@
 			s = STAILQ_NEXT(s, next);
 		else
 			s = STAILQ_FIRST(&file->sections);
-	} else if (file->q_section && strcmp(file->q_section->key, section) != 0)
-		/* Seek from beginning since there is no order */
+	} else
 		s = STAILQ_FIRST(&file->sections);
 
-	STAILQ_FOREACH(s, &file->sections, next) {
+	while (s != NULL) {
 		if (strcmp(s->key, section) == 0) {
 			file->q_section = s;
-			found = 0;
+			found = 1;
 			break;
 		}
 
 		s = STAILQ_NEXT(s, next);
 	}
 
+#ifdef INIFILE_DEBUG
+	if (found == 1)
+		printf("-- selected section [%s]\n", s->key);
+#endif
+
 	if (found < 0)
 		file->q_section = NULL;