LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File rarian-0.5.6-docs-from-desktop-entries-and-bundles.patch of Package rarian (Project openSUSE:Factory)

Index: rarian-0.5.8/librarian/rarian-main.c
===================================================================
--- rarian-0.5.8.orig/librarian/rarian-main.c
+++ rarian-0.5.8/librarian/rarian-main.c
@@ -227,14 +227,24 @@ past:
 	      int_path = rrn_strndup (cur_path, (first_colon-cur_path));
 	    else
 	      int_path = strdup (cur_path);
-		check_path = malloc (sizeof(char)*(strlen(int_path)+6));
-		sprintf (check_path, "%s/help", int_path);
+        check_path = malloc (sizeof (char) * (strlen (int_path) + 14)); 
+        snprintf (check_path, sizeof (char) * (strlen (int_path) + 14), 
+                  "%s/help", int_path);  
 #if ENABLE_OMF_READ
 		process_omf_dir (int_path);
 #endif
 		process_locale_dirs (check_path);
 
 		scan_directory (check_path);
+        
+        snprintf (check_path, sizeof (char) * (strlen (int_path) + 14), 
+                  "%s/applications", int_path);                         
+        scan_directory (check_path);                                    
+        
+        snprintf (check_path, sizeof (char) * (strlen (int_path) + 14), 
+                  "%s/help-bundle", int_path);                          
+        scan_directory (check_path); 
+
 		if (int_path && *int_path) {
 			free (int_path);
 		}
@@ -294,7 +304,8 @@ scan_directory (char *dir)
 	  char *suffix = NULL;
 	  
 	  suffix = strrchr (full_name, '.');
-	  if (!strcmp (suffix, ".document")) {
+      if (!strcmp (suffix, ".document") ||
+          !strcmp (suffix, ".desktop")) {   
 	    process_file (full_name);
 	  } else if (!strcmp (suffix, ".section")) {
 	    process_section (full_name);
Index: rarian-0.5.8/librarian/rarian-reg-full.c
===================================================================
--- rarian-0.5.8.orig/librarian/rarian-reg-full.c
+++ rarian-0.5.8/librarian/rarian-reg-full.c
@@ -102,7 +102,8 @@ rrn_reg_parse_file_full (char *filename)
 		if (!real || real[0] == '\n' || real[0] == '#') {
 			/* Black Line or comment.  Ignore. */
 		} else if (real[0] == '[') {
-			if (!strncmp (real, "[Document]", 10)) {
+			if (!strncmp (real, "[Document]", 10) ||
+			    !strncmp (real, "[Desktop Entry]", 15)) {
 				mode = 0;
 
 				if (sect) {
@@ -152,7 +153,7 @@ rrn_reg_parse_file_full (char *filename)
 		}
 	}
 
-    if (!reg->name || !reg->uri || !reg->type || !reg->categories ) {
+    if (!reg->name || !reg->uri || !reg->categories ) {
         rrn_reg_free_full (reg);
         reg = NULL;
     }
@@ -272,6 +273,9 @@ process_categories_full (char *cat_strin
 	int i;
 	do {
 		semi = strchr (current_break, ';');
+		if (!semi)
+			semi = strchr (current_break, '|');
+
 		if (result) {
 			tmp = malloc (sizeof (char *)*ncats);
 			for (i=0; i< ncats; i++) {
@@ -637,9 +641,20 @@ process_path_full (RrnRegFull *reg)
 	     */
 	    return;
 	  }
-	  /* Otherwise, promote to file: URI scheme, reusing the prefix vble */
-	  prefix = malloc (sizeof (char) * (strlen(entry->text)+6));
-	  sprintf (prefix, "file:%s", entry->text);
+
+	  if (entry->text [0] == '/') {
+		  /* If it's an absolute path, promote to file: URI scheme,
+		   * reusing the prefix vble */
+		  prefix = malloc (sizeof (char) * (strlen(entry->text) + 8));
+		  snprintf (prefix, sizeof (char) * (strlen (entry->text) + 8),
+			    "file://%s", entry->text);
+	  } else {
+		  /* Else, use the help: URI scheme */
+		  prefix = malloc (sizeof (char) * (strlen (entry->text) + 7));
+		  snprintf (prefix, sizeof (char) * (strlen (entry->text) + 7),
+			    "help:%s", entry->text);
+	  }
+
 	  free (entry->text);
 	  entry->text = prefix;
 	  entry = entry->next;
Index: rarian-0.5.8/librarian/rarian-reg-utils.c
===================================================================
--- rarian-0.5.8.orig/librarian/rarian-reg-utils.c
+++ rarian-0.5.8/librarian/rarian-reg-utils.c
@@ -121,7 +121,8 @@ rrn_reg_parse_file (char *filename)
 		if (!real || real[0] == '\n' || real[0] == '#') {
 			/* Black Line or comment.  Ignore. */
 		} else if (real[0] == '[') {
-			if (!strncmp (real, "[Document]", 10)) {
+			if (!strncmp (real, "[Document]", 10) ||
+			    !strncmp (real, "[Desktop Entry]", 15)) {
 				mode = 0;
 
 				if (sect) {
@@ -173,7 +174,7 @@ rrn_reg_parse_file (char *filename)
 		}
 	}
 
-    if (!reg->name || !reg->uri || !reg->type || !reg->categories ) {
+    if (!reg->name || !reg->uri || !reg->categories ) {
         rrn_reg_free (reg);
         reg = NULL;
     }
@@ -318,6 +319,9 @@ process_categories (char *cat_string)
 	int i;
 	do {
 		semi = strchr (current_break, ';');
+		if (!semi)
+			semi = strchr (current_break, '|');
+
 		if (result) {
 			tmp = malloc (sizeof (char *)*ncats);
 			for (i=0; i< ncats; i++) {
@@ -743,10 +747,22 @@ process_path (RrnReg *reg)
 		 */
 			return;
 	}
-	/* Otherwise, promote to file: URI scheme, reusing the prefix vble */
-	prefix = malloc (sizeof (char) * (strlen(reg->uri)+8));
-	sprintf (prefix, "file://%s", reg->uri);
+
+	if (reg->uri [0] == '/') {
+		/* If it's an absolute path, promote to file: URI scheme,
+		 * reusing the prefix vble */
+		prefix = malloc (sizeof (char) * (strlen (reg->uri) + 8));
+		snprintf (prefix, sizeof (char) * (strlen (reg->uri) + 8),
+			  "file://%s", reg->uri);
+	} else {
+		/* Else, use the help: URI scheme */
+		prefix = malloc (sizeof (char) * (strlen (reg->uri) + 7));
+		snprintf (prefix, sizeof (char) * (strlen (reg->uri) + 7),
+			  "help:%s", reg->uri);
+	}
+
 	free (reg->uri);
+
 	reg->uri = prefix;
 	while (child) {
 		process_section_path (reg->uri, child);