harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r820581 - /harmony/enhanced/classlib/trunk/modules/luni/src/main/native/launcher/shared/main.c
Date Thu, 01 Oct 2009 09:09:31 GMT
Author: hindessm
Date: Thu Oct  1 09:09:31 2009
New Revision: 820581

URL: http://svn.apache.org/viewvc?rev=820581&view=rev
Log:
Fix findDirInPath to ignore trailing slashes.  I think this is the
most common problem case since bash completion adds trailing slashes
for directories but we could consider comparing using realpath(3) to
do matching on a canonical form if we want to handle more cases.

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/native/launcher/shared/main.c

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/native/launcher/shared/main.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/launcher/shared/main.c?rev=820581&r1=820580&r2=820581&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/native/launcher/shared/main.c (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/native/launcher/shared/main.c Thu
Oct  1 09:09:31 2009
@@ -1037,17 +1037,28 @@
 static BOOLEAN findDirInPath(char *path, char *dir, char *separator)
 {
   char *pos;
+  int pathlen;
   int dirlen = strlen(dir);
+  while (dirlen > 1 && dir[dirlen-1] == DIR_SEPARATOR) {
+    dirlen--;
+  }
 
   while ((pos = strchr(path, *separator)) != NULL) {
-    int pathlen = pos - path;
+    int savedpathlen = pathlen = pos - path;
+    while (pathlen > 1 && path[pathlen-1] == DIR_SEPARATOR) {
+      pathlen--;
+    }
     if (dirlen == pathlen && !strncmp(path, dir, dirlen)) {
       return TRUE;
     }
-    path += pathlen + 1;
+    path += savedpathlen + 1;
   }
 
-  return !strcmp(dir, path);
+  pathlen = strlen(path);
+  while (pathlen > 1 && path[pathlen-1] == DIR_SEPARATOR) {
+    pathlen--;
+  }
+  return dirlen == pathlen && !strncmp(path, dir, dirlen);
 }
 
 /**



Mime
View raw message