This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] libjava: java.net.URI.relativize method results inconsistent with other Java VMs


>>>>> "Luciano" == Luciano Chavez <lnx1138@us.ibm.com> writes:

Luciano> This patch corrects two issues found in URI.relativize()
Luciano> method in libjava/classpath/java/net/URI.java. It applies
Luciano> from gcc 4.1.2 through latest trunk:

Thanks.  I am checking in a slightly different patch, appended.
There's no need to use 'new String(rawPath)', because Strings are
immutable.

I'm also checking it in to Classpath.

Just FYI... it is easier for us if you write a ChangeLog entry and
submit it with your patch.

Tom

ChangeLog:
2008-01-21  Luciano Chavez  <lnx1138@us.ibm.com>

	PR libgcj/34369:
	* java/net/URI.java (relativize): Check initial segment for
	trailing "/".

Index: java/net/URI.java
===================================================================
--- java/net/URI.java	(revision 131699)
+++ java/net/URI.java	(working copy)
@@ -1,5 +1,5 @@
 /* URI.java -- An URI class
-   Copyright (C) 2002, 2004, 2005, 2006  Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005, 2006, 2008  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -968,12 +968,18 @@
       return uri;
     if (rawAuthority != null && !(rawAuthority.equals(uri.getRawAuthority())))
       return uri;
-    if (!(uri.getRawPath().startsWith(rawPath)))
-      return uri;
+    String basePath = rawPath;
+    if (!(uri.getRawPath().equals(rawPath)))
+      {
+	if (!(basePath.endsWith("/")))
+	  basePath = basePath.concat("/");
+	if (!(uri.getRawPath().startsWith(basePath)))
+	  return uri;
+      }
     try
       {
 	return new URI(null, null, 
-		       uri.getRawPath().substring(rawPath.length()),
+		       uri.getRawPath().substring(basePath.length()),
 		       uri.getRawQuery(), uri.getRawFragment());
       }
     catch (URISyntaxException e)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]