From 630287af48fcf25759f9e96d0ef39db90b5fa3af Mon Sep 17 00:00:00 2001 From: Ranjit Mathew Date: Mon, 10 Mar 2003 19:39:18 +0000 Subject: [PATCH] jcf-io.c (caching_stat): Account for both DIR_SEPARATOR and DIR_SEPARATOR_2 for a target. 2003-03-10 Ranjit Mathew * jcf-io.c (caching_stat): Account for both DIR_SEPARATOR and DIR_SEPARATOR_2 for a target. Correct minor typos. * jcf-write.c (make_class_file_name): Take both DIR_SEPARATOR and DIR_SEPARATOR_2 for a target into account. From-SVN: r64110 --- gcc/java/ChangeLog | 9 +++++++++ gcc/java/jcf-io.c | 10 ++++++++-- gcc/java/jcf-write.c | 38 ++++++++++++++++++++++++++++++-------- 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 163567caff0..1f8537fec5e 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,12 @@ +2003-03-10 Ranjit Mathew + + * jcf-io.c (caching_stat): Account for both DIR_SEPARATOR + and DIR_SEPARATOR_2 for a target. + Correct minor typos. + + * jcf-write.c (make_class_file_name): Take both DIR_SEPARATOR + and DIR_SEPARATOR_2 for a target into account. + 2003-03-08 Neil Booth * lang.c (java_init): Update prototype, move code to java_post_options. diff --git a/gcc/java/jcf-io.c b/gcc/java/jcf-io.c index 3b10f399b2c..cb56c096e2d 100644 --- a/gcc/java/jcf-io.c +++ b/gcc/java/jcf-io.c @@ -336,6 +336,7 @@ caching_stat (char *filename, struct stat *buf) { #if JCF_USE_SCANDIR char *sep; + char origsep; char *base; memoized_dirlist_entry *dent; void **slot; @@ -349,15 +350,20 @@ caching_stat (char *filename, struct stat *buf) /* Get the name of the directory. */ sep = strrchr (filename, DIR_SEPARATOR); +#ifdef DIR_SEPARATOR_2 + if (! sep) + sep = strrchr (filename, DIR_SEPARATOR_2); +#endif if (sep) { + origsep = *sep; *sep = '\0'; base = sep + 1; } else base = filename; - /* Obtain the entry for this directory form the hash table. */ + /* Obtain the entry for this directory from the hash table. */ slot = htab_find_slot (memoized_dirlists, filename, INSERT); if (!*slot) { @@ -380,7 +386,7 @@ caching_stat (char *filename, struct stat *buf) /* Put the separator back. */ if (sep) - *sep = DIR_SEPARATOR; + *sep = origsep; /* If the file is not in the list, there is no need to stat it; it does not exist. */ diff --git a/gcc/java/jcf-write.c b/gcc/java/jcf-write.c index a18f062e32f..d9fc6508259 100644 --- a/gcc/java/jcf-write.c +++ b/gcc/java/jcf-write.c @@ -3263,6 +3263,7 @@ make_class_file_name (tree clas) const char *dname, *cname, *slash; char *r; struct stat sb; + char sep; cname = IDENTIFIER_POINTER (identifier_subst (DECL_NAME (TYPE_NAME (clas)), "", '.', DIR_SEPARATOR, @@ -3274,24 +3275,45 @@ make_class_file_name (tree clas) char *t; dname = DECL_SOURCE_FILE (TYPE_NAME (clas)); slash = strrchr (dname, DIR_SEPARATOR); +#ifdef DIR_SEPARATOR_2 if (! slash) - { - dname = "."; - slash = dname + 1; - } + slash = strrchr (dname, DIR_SEPARATOR_2); +#endif + if (! slash) + { + dname = "."; + slash = dname + 1; + sep = DIR_SEPARATOR; + } + else + sep = *slash; + t = strrchr (cname, DIR_SEPARATOR); if (t) cname = t + 1; } else { + char *s; + dname = jcf_write_base_directory; + + s = strrchr (dname, DIR_SEPARATOR); +#ifdef DIR_SEPARATOR_2 + if (! s) + s = strrchr (dname, DIR_SEPARATOR_2); +#endif + if (s) + sep = *s; + else + sep = DIR_SEPARATOR; + slash = dname + strlen (dname); } r = xmalloc (slash - dname + strlen (cname) + 2); strncpy (r, dname, slash - dname); - r[slash - dname] = DIR_SEPARATOR; + r[slash - dname] = sep; strcpy (&r[slash - dname + 1], cname); /* We try to make new directories when we need them. We only do @@ -3303,7 +3325,7 @@ make_class_file_name (tree clas) dname = r + (slash - dname) + 1; while (1) { - char *s = strchr (dname, DIR_SEPARATOR); + char *s = strchr (dname, sep); if (s == NULL) break; *s = '\0'; @@ -3312,9 +3334,9 @@ make_class_file_name (tree clas) && mkdir (r, 0755) == -1) fatal_io_error ("can't create directory %s", r); - *s = DIR_SEPARATOR; + *s = sep; /* Skip consecutive separators. */ - for (dname = s + 1; *dname && *dname == DIR_SEPARATOR; ++dname) + for (dname = s + 1; *dname && *dname == sep; ++dname) ; }