Patch for #59656 (g_filename_from_uri errors)



This merges the two error codes G_CONVERT_ERROR_NOT_ABSOLUTE_FILE_URI and 
G_CONVERT_ERROR_INVALID_URI into G_CONVERT_ERROR_BAD_URI. There is really 
nothing you could do if you got  G_CONVERT_ERROR_NOT_ABSOLUTE_FILE_URI 
anyway, and we do get good error reporting by using the string anyway.

/ Alex

Index: glib/gconvert.c
===================================================================
RCS file: /cvs/gnome/glib/glib/gconvert.c,v
retrieving revision 1.20
diff -u -p -r1.20 gconvert.c
--- glib/gconvert.c	2001/09/14 19:29:35	1.20
+++ glib/gconvert.c	2001/09/25 19:54:32
@@ -1198,7 +1198,7 @@ g_filename_from_uri (const char *uri,
 
   if (!has_case_prefix (uri, "file:/"))
     {
-      g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_NOT_ABSOLUTE_FILE_URI,
+      g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_BAD_URI,
 		   _("The URI `%s' is not an absolute URI using the file scheme"),
 		   uri);
       return NULL;
@@ -1208,7 +1208,7 @@ g_filename_from_uri (const char *uri,
   
   if (strchr (path_part, '#') != NULL)
     {
-      g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_INVALID_URI,
+      g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_BAD_URI,
 		   _("The local file URI `%s' may not include a `#'"),
 		   uri);
       return NULL;
@@ -1225,7 +1225,7 @@ g_filename_from_uri (const char *uri,
 
       if (path_part == NULL)
 	{
-	  g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_INVALID_URI,
+	  g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_BAD_URI,
 		       _("The URI `%s' is invalid"),
 		       uri);
 	  return NULL;
@@ -1234,7 +1234,7 @@ g_filename_from_uri (const char *uri,
       unescaped_hostname = g_unescape_uri_string (host_part, "", path_part - host_part);
       if (unescaped_hostname == NULL)
 	{
-	  g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_INVALID_URI,
+	  g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_BAD_URI,
 		       _("The hostname of the URI `%s' contains invalidly escaped characters"),
 		       uri);
 	  return NULL;
@@ -1250,7 +1250,7 @@ g_filename_from_uri (const char *uri,
 
   if (filename == NULL)
     {
-      g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_INVALID_URI,
+      g_set_error (error, G_CONVERT_ERROR, G_CONVERT_ERROR_BAD_URI,
 		   _("The URI `%s' contains invalidly escaped characters"),
 		   uri);
       return NULL;
Index: glib/gconvert.h
===================================================================
RCS file: /cvs/gnome/glib/glib/gconvert.h,v
retrieving revision 1.10
diff -u -p -r1.10 gconvert.h
--- glib/gconvert.h	2001/08/27 18:01:08	1.10
+++ glib/gconvert.h	2001/09/25 19:54:32
@@ -38,8 +38,7 @@ typedef enum 
   G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
   G_CONVERT_ERROR_FAILED,
   G_CONVERT_ERROR_PARTIAL_INPUT,
-  G_CONVERT_ERROR_NOT_ABSOLUTE_FILE_URI,
-  G_CONVERT_ERROR_INVALID_URI,
+  G_CONVERT_ERROR_BAD_URI,
   G_CONVERT_ERROR_NOT_ABSOLUTE_PATH
 } GConvertError;
 
Index: tests/uri-test.c
===================================================================
RCS file: /cvs/gnome/glib/tests/uri-test.c,v
retrieving revision 1.2
diff -u -p -r1.2 uri-test.c
--- tests/uri-test.c	2001/08/27 18:01:08	1.2
+++ tests/uri-test.c	2001/09/25 19:54:32
@@ -103,14 +103,14 @@ from_uri_tests[] = {
   { "file://otherhost/etc", "/etc", "otherhost"},
   { "file://otherhost/etc/%23%25%20file", "/etc/#% file", "otherhost"},
   { "file://%C3%B6%C3%A4%C3%A5/etc", "/etc", "öäå"},
-  { "file:////etc/%C3%B6%C3%C3%C3%A5", NULL, NULL, G_CONVERT_ERROR_INVALID_URI},
-  { "file://localhost/åäö", NULL, NULL, G_CONVERT_ERROR_INVALID_URI},
-  { "file://åäö/etc", NULL, NULL, G_CONVERT_ERROR_INVALID_URI},
-  { "file:///some/file#bad", NULL, NULL, G_CONVERT_ERROR_INVALID_URI},
-  { "file://some", NULL, NULL, G_CONVERT_ERROR_INVALID_URI},
-  { "", NULL, NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_FILE_URI}, /* should be G_CONVERT_ERROR_INVALID_URI */
-  { "file:test", NULL, NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_FILE_URI},
-  { "http://www.yahoo.com/";, NULL, NULL, G_CONVERT_ERROR_NOT_ABSOLUTE_FILE_URI},
+  { "file:////etc/%C3%B6%C3%C3%C3%A5", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
+  { "file://localhost/åäö", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
+  { "file://åäö/etc", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
+  { "file:///some/file#bad", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
+  { "file://some", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
+  { "", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
+  { "file:test", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
+  { "http://www.yahoo.com/";, NULL, NULL, G_CONVERT_ERROR_BAD_URI},
   { "file:////etc", "/etc"}, /* should be "//etc" -- mistake in code for DOS results in dropped slash */
   { "file://///etc", "//etc"}, /* should be "///etc" -- mistake in code for DOS results in dropped slash */
   { "file:///c:\\foo", "/c:\\foo"}, /* should be "c:\\foo" on DOS perhaps, but that would be bad for Unix */
@@ -125,7 +125,7 @@ from_uri_tests[] = {
   { "file://%C3%80%C3%BF/", "/", "\xC3\x80\xC3\xBF"},
   { "file://@/", "/", "@"},
   { "file://:/", "/", ":"},
-  { "file://#/", NULL, NULL, G_CONVERT_ERROR_INVALID_URI},
+  { "file://#/", NULL, NULL, G_CONVERT_ERROR_BAD_URI},
   { "file://%23/", "/", "#"}, /* is it dangerous to return a hostname with a "#" character in it? */
   { "file://%2F/", "/", "/"}, /* is it dangerous to return a hostname with a "/" character in it? */
 };





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