aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/jcf-path.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2007-01-09 19:58:05 +0000
committerTom Tromey <tromey@redhat.com>2007-01-09 19:58:05 +0000
commit5972b5daeba5bdba48a586780f63fe6c382fd584 (patch)
tree996a5f57d4a68c53473382e45cb22f574cb3e4db /gcc/java/jcf-path.c
parentc9e316bdb8658508945e116f659313e6da419992 (diff)
Merged gcj-eclipse branch to trunk.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@120621 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/java/jcf-path.c')
-rw-r--r--gcc/java/jcf-path.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/gcc/java/jcf-path.c b/gcc/java/jcf-path.c
index 65cd80ef30c..7baef2e35e9 100644
--- a/gcc/java/jcf-path.c
+++ b/gcc/java/jcf-path.c
@@ -1,5 +1,5 @@
/* Handle CLASSPATH, -classpath, and path searching.
- Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006
Free Software Foundation, Inc.
This file is part of GCC.
@@ -457,6 +457,38 @@ jcf_path_next (void *x)
return (void *) ent->next;
}
+static const char
+PATH_SEPARATOR_STR[] = {PATH_SEPARATOR, '\0'};
+
+char *
+jcf_path_compute (const char *prefix)
+{
+ struct entry *iter;
+ char *result;
+ int length = strlen (prefix) + 1;
+ int first;
+
+ for (iter = sealed; iter != NULL; iter = iter->next)
+ length += strlen (iter->name) + 1;
+
+ result = (char *) xmalloc (length);
+ strcpy (result, prefix);
+ first = 1;
+ for (iter = sealed; iter != NULL; iter = iter->next)
+ {
+ if (! first)
+ strcat (result, PATH_SEPARATOR_STR);
+ first = 0;
+ strcat (result, iter->name);
+ /* Ugly: we want to strip the '/' from zip entries when
+ computing a string classpath. */
+ if ((iter->flags & FLAG_ZIP) != 0)
+ result[strlen (result) - 1] = '\0';
+ }
+
+ return result;
+}
+
/* We guarantee that the return path will either be a zip file, or it
will end with a directory separator. */
char *