Index: src/yelp-info-parser.c
===================================================================
RCS file: /cvs/gnome/yelp/src/yelp-info-parser.c,v
retrieving revision 1.13
diff -u -r1.13 yelp-info-parser.c
--- src/yelp-info-parser.c	11 May 2006 19:13:05 -0000	1.13
+++ src/yelp-info-parser.c	17 May 2006 17:46:32 -0000
@@ -103,6 +103,7 @@
 	
 	channel = yelp_io_channel_new_file (file, &error);
 	result = g_io_channel_read_to_end (channel, &str, &len, &error);
+
 	if (result != G_IO_STATUS_NORMAL) {
 	  g_error ("Error reading file: %s\n", error->message);
 	  exit (666);
@@ -122,17 +123,54 @@
 }
 
 static gchar *
-find_info_part (gchar *part_name)
+find_info_part (gchar *part_name, gchar *base)
 {
+  gchar *path;
+  gchar *tmp;
+  gchar *bzfname, *gzfname;
+  gchar *uri = NULL;
+  tmp = g_strrstr (base, "/");
+  path = g_strndup (base, tmp-base);
+
+  bzfname = g_strconcat (path, "/", part_name, ".bz2", NULL);
+  gzfname = g_strconcat (path, "/", part_name, ".gz", NULL);
+  
+  if (g_file_test (bzfname, G_FILE_TEST_EXISTS))
+    uri = g_strdup (bzfname);
+  else if (g_file_test (gzfname, G_FILE_TEST_EXISTS))
+    uri = g_strdup (gzfname);
+
+  g_free (bzfname);
+  g_free (gzfname);
+  g_free (path);
+  return uri;
+
+
+#if 0
   gchar ** paths = yelp_get_info_paths ();
   gint i;
   gchar *filename = NULL;
   gchar *uri = NULL;
   GDir *dir;
   gchar *bzfname, *gzfname;
+  gchar *subdir, *real_name;
+
+  /*TODO: part_name splitting contains "/" ? */
+  if (strstr (part_name, "/")) {
+    gchar *sub = NULL;
+    sub = strstr (part_name, "/");
+    subdir = g_strndup (part_name, sub - part_name);
+    sub++;
+    real_name = g_strdup (sub);
+    g_print ("Looking for %s in %s\n", real_name, subdir);
+  } else {
+    g_print ("No subdir in %s\n", part_name);
+    subdir = NULL;
+    real_name = part_name;
+  }
 
-  bzfname = g_strconcat (part_name, ".bz2", NULL);
-  gzfname = g_strconcat (part_name, ".gz", NULL);
+  bzfname = g_strconcat (real_name, ".bz2", NULL);
+  gzfname = g_strconcat (real_name, ".gz", NULL);
 
   for (i=0; paths[i]; i++) {
     dir = g_dir_open (paths[i], 0, NULL);
@@ -140,16 +178,38 @@
       continue;
 
     while ((filename = (gchar *) g_dir_read_name (dir))) {
+      if (subdir && g_str_equal (filename, subdir)) {
+	gchar *dirname = NULL;
+	g_dir_close (dir);
+	dirname = g_strconcat (paths[i], "/", subdir, 0);
+	dir = g_dir_open (dirname, 0, NULL);
+	g_free (dirname);
+	filename = g_dir_read_name (dir);
+	uri = g_strconcat (paths[i], "/", subdir, "/", NULL);
+      }
       if (g_str_equal (filename, bzfname)) {
-	uri = g_strconcat (paths[i], "/", bzfname, NULL);
+	if (subdir) {
+	  uri = g_strconcat (paths[i], "/", subdir, "/", bzfname, NULL);
+	} else {
+	  uri = g_strconcat (paths[i], "/", bzfname, NULL);
+
+	}
 	g_dir_close (dir);
 	goto done;
       } else if (g_str_equal (filename, gzfname)) {
-	uri = g_strconcat (paths[i], "/", gzfname, NULL);
+	if (subdir) {
+	  uri = g_strconcat (paths[i], "/", subdir, "/", gzfname, NULL);
+	} else {
+	  uri = g_strconcat (paths[i], "/", gzfname, NULL);
+	}
 	g_dir_close (dir);
 	goto done;
-      } else if (g_str_equal (filename, part_name)) {
-	uri = g_strconcat (paths[i], "/", part_name, NULL);
+      } else if (g_str_equal (filename, real_name)) {
+	if (subdir) {
+	  uri = g_strconcat (paths[i], "/", subdir, "/", real_name, NULL);
+	} else {
+	  uri = g_strconcat (paths[i], "/", real_name, NULL);
+	}
 	g_dir_close (dir);
 	goto done;
 
@@ -162,11 +222,11 @@
   g_free (gzfname);
   g_free (bzfname);
   return uri;
-
+#endif
 }
 
 static char
-*process_indirect_map (char *page)
+*process_indirect_map (char *page, gchar * file)
 {
 	char **lines;
 	char **ptr;
@@ -190,9 +250,9 @@
 
 		if (items[0])
 		{
-		        filename = find_info_part (items[0]);
-			str = open_info_file (filename);
-	
+		  filename = find_info_part (items[0], file);
+		  str = open_info_file (filename);
+		  
 			pages = g_strsplit (str, "", 2);
 			g_free (str);
 
@@ -579,7 +639,7 @@
 		{
 		  d (g_print ("Have the indirect mapping table\n"));
 			chained_info = TRUE;
-			str = process_indirect_map (*ptr);
+			str = process_indirect_map (*ptr, file);
 		}
 	}
 
@@ -592,7 +652,7 @@
 		
 		pages = 0;
 		offset = 0;
-		
+
 		page_list = g_strsplit (str, "\n", 0);
 		offsets2pages = g_hash_table_new (g_str_hash, g_str_equal);
 		
@@ -648,9 +708,9 @@
 	GtkTreeIter children;
 	xmlNodePtr newnode;
 
-	char *page_no;
-	char *page_name;
-	char *page_content;
+	char *page_no = NULL;
+	char *page_name = NULL;
+	char *page_content = NULL;
 	
 	d (g_print ("Decended\n"));
 	do
@@ -817,6 +877,7 @@
 						      NULL));
 
   menuitems = g_strsplit (split[1], "\n", -1);
+  g_strfreev (split);
 
   while (menuitems[i] != NULL) {
     gboolean menu = FALSE;
@@ -876,6 +937,7 @@
     i++;
     
   }
+  g_free (section_id);
   
   return newnode;
 }
Index: src/yelp-utils.c
===================================================================
RCS file: /cvs/gnome/yelp/src/yelp-utils.c,v
retrieving revision 1.35
diff -u -r1.35 yelp-utils.c
--- src/yelp-utils.c	4 Apr 2006 04:13:22 -0000	1.35
+++ src/yelp-utils.c	17 May 2006 17:46:32 -0000
@@ -905,6 +905,7 @@
     gchar *pattern;
     GPatternSpec *pspec = NULL;
     GPatternSpec *pspec1 = NULL;
+    gchar *subdir = NULL;
 
     if ((path = strchr(uri, ':')))
 	path++;
@@ -941,6 +942,20 @@
     else
 	info_name = g_strdup (path);
 
+    if (strstr (info_name, "/")) {
+	gchar *tmp = NULL;
+	gchar *real_name = NULL;
+	tmp = strstr (info_name, "/");
+	tmp++;
+	real_name = g_strdup (tmp);
+	subdir = g_strndup (info_name, (strstr (info_name, "/") - info_name));
+	g_print ("real name is %s\n", real_name);
+	g_free (info_name);
+	info_name = g_strdup (real_name);
+	g_free (real_name);
+    }
+
+
     pattern = g_strdup_printf ("%s.info.*", info_name);
     pspec = g_pattern_spec_new (pattern);
     g_free (pattern);
@@ -956,14 +971,30 @@
 	dir = g_dir_open (infopath[i], 0, NULL);
 	if (dir) {
 	    while ((filename = g_dir_read_name (dir))) {
-		if (g_str_equal (info_dot_info, filename)  ||
-		    g_pattern_match_string (pspec, filename) ||
-		    g_pattern_match_string (pspec1, filename) ||
-		    g_str_equal (info_name, filename)) {
-		    doc_uri = g_strconcat ("file://",
-					   infopath[i], "/",
-					   filename,
-					   NULL);
+		if (subdir && g_str_equal (filename, subdir)) {
+		    gchar *dirname = NULL;
+		    g_dir_close (dir);
+		    dirname = g_strconcat (infopath[i], "/", subdir, NULL);
+		    dir = g_dir_open (dirname, 0, NULL);
+		    g_free (dirname);
+		    filename = g_dir_read_name (dir);
+		}
+		else if (g_str_equal (info_dot_info, filename)  ||
+			 g_pattern_match_string (pspec, filename) ||
+			 g_pattern_match_string (pspec1, filename) ||
+			 g_str_equal (info_name, filename)) {
+		    if (subdir) {
+			doc_uri = g_strconcat ("file://",
+					       infopath[i], "/", subdir, "/",
+					       filename,
+					       NULL);
+		    } else {
+			doc_uri = g_strconcat ("file://",
+					       infopath[i], "/",
+					       filename,
+					       NULL);
+
+		    }
 		    g_dir_close (dir);
 		    goto done;
 		}
@@ -977,7 +1008,9 @@
 	g_pattern_spec_free (pspec);
     if (pspec1)
 	g_pattern_spec_free (pspec1);
+    g_free (subdir);
     g_free (info_dot_info);
     g_free (info_name);
+    g_print ("doc_uri is %s\n", doc_uri);
     return doc_uri;
 }
