[Gnome-print] gnome-font-install fix



Hi,

This patch wasn't reviewed before 0.30, it seems like a pretty obvious
patch. Can we get it in?

Havoc

--- gnome-print-0.30/installer/gnome-font-install.c.options	Tue Jul  3 21:14:57 2001
+++ gnome-print-0.30/installer/gnome-font-install.c	Sat Oct  6 00:46:20 2001
@@ -14,6 +14,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <dirent.h>
+#include <errno.h>
 #include <string.h>
 #include <stdio.h>
 #include <popt-gnome.h>
@@ -128,6 +129,7 @@
 	char ** args;
 	FILE *of;
 	gint i;
+        int result;
 
 	/* Initialize dictionaries */
 	goodafm_dict = g_hash_table_new (g_str_hash, g_str_equal);
@@ -138,8 +140,15 @@
 
 	/* Parse arguments */
 	ctx = poptGetContext (NULL, argc, argv, options, 0);
-	g_return_val_if_fail (ctx != NULL, 1);
-	g_return_val_if_fail (poptGetNextOpt (ctx) == -1, 1);
+
+	result = poptGetNextOpt (ctx);
+	if (result != -1) { 
+                fprintf(stderr, "%s: %s: %s\n",
+                        "gnome-print-install",
+                        poptBadOption(ctx, POPT_BADOPTION_NOALIAS),
+                        poptStrerror(result));
+                return 1;
+	}
 	args = (char **) poptGetArgs (ctx);
 
 	if (!gfi_clean) {
@@ -240,7 +249,8 @@
 			gfi_write_fontmap (of);
 			fclose (of);
 		} else {
-			g_print ("Cannot open output file %s\n", target);
+			fprintf (stderr, "gnome-font-install: Cannot open output file %s: %s\n", target, g_strerror (errno));
+			exit (1);
 		}
 	} else {
 		gfi_write_fontmap (stdout);
@@ -1011,7 +1021,10 @@
 				if (slash) {
 					*slash = '\0';
 					slash++;
-					path = g_hash_table_lookup (assignment_dict, metrics + 1);
+					if (assignment_dict)
+						path = g_hash_table_lookup (assignment_dict, metrics + 1);
+					else
+						path = NULL;
 					for (l = path; l != NULL; l = l->next) {
 						gchar *fn;
 						fn = g_concat_dir_and_file (l->data, slash);
@@ -1060,7 +1073,10 @@
 				if (slash) {
 					*slash = '\0';
 					slash++;
-					path = g_hash_table_lookup (assignment_dict, glyphs + 1);
+					if (assignment_dict)
+						path = g_hash_table_lookup (assignment_dict, glyphs + 1);
+					else
+						path = NULL;
 					for (l = path; l != NULL; l = l->next) {
 						gchar *fn;
 						fn = g_concat_dir_and_file (l->data, slash);




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]