This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: Patch: jcf-path.c and filename case-insensitivity on Win32
Tom Tromey wrote:
> Ranjit> + #if defined (HAVE_DOS_BASED_FILE_SYSTEM) && defined (HAVE_STRCASECMP)
> Ranjit> + if (len > 4 && (strcasecmp (filename + len - 4, ".zip") == 0
> Ranjit> + || strcasecmp (filename + len - 4, ".jar") == 0))
> Ranjit> + #else
> Ranjit> if (len > 4 && (strcmp (filename + len - 4, ".zip") == 0
> Ranjit> || strcmp (filename + len - 4, ".jar") == 0))
> Ranjit> + #endif
>
> I'd prefer we add a new macro, like COMPARE_FILENAMES, and then define
> that as strcmp or strcasecmp.
>
> Best would be to do this in system.h, though personally I'd settle for
> some header in gcc/java/.
Ok, how does the following look?
Index: ChangeLog
from Ranjit Mathew <rmathew at hotmail dot com>
* jcf.h (COMPARE_FILENAMES): New macro similar to "strcmp" to
compare file name components depending on the case-sensitivity
or otherwise of the host file system.
* jcf-path.c (add_entry): Use COMPARE_FILENAMES instead of
"strcmp" to compare file name components.
Use IS_DIR_SEPARATOR instead of comparing directly against
DIR_SEPARATOR.
(jcf_path_extdirs_arg): Use IS_DIR_SEPARATOR instead of
comparing directly against DIR_SEPARATOR.
*** jcf.h Sun Mar 2 21:14:02 2003
--- jcf.h Sun Mar 2 21:27:34 2003
***************
*** 1,5 ****
/* Utility macros to read Java(TM) .class files and byte codes.
! Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
--- 1,6 ----
/* Utility macros to read Java(TM) .class files and byte codes.
! Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
! Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
*************** The Free Software Foundation is independ
*** 72,75 ****
--- 73,85 ----
#endif
+ /* On case-insensitive file systems, file name components must be
+ compared using "strcasecmp", if available, instead of "strcmp".
+ Assumes "config.h" has already been included. */
+ #if defined (HAVE_DOS_BASED_FILE_SYSTEM) && defined (HAVE_STRCASECMP)
+ #define COMPARE_FILENAMES(x, y) strcasecmp ((x), (y))
+ #else
+ #define COMPARE_FILENAMES(x, y) strcmp ((x), (y))
+ #endif
+
struct JCF;
typedef int (*jcf_filbuf_t) PARAMS ((struct JCF*, int needed));
*** jcf-path.c Mon Jan 27 21:43:44 2003
--- jcf-path.c Sun Mar 2 21:27:54 2003
***************
*** 1,5 ****
/* Handle CLASSPATH, -classpath, and path searching.
! Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
--- 1,6 ----
/* Handle CLASSPATH, -classpath, and path searching.
! Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software
! Foundation, Inc.
This program is free software; you can redistribute it and/or modify
*************** add_entry (entp, filename, is_system)
*** 149,154 ****
len = strlen (filename);
! if (len > 4 && (strcmp (filename + len - 4, ".zip") == 0
! || strcmp (filename + len - 4, ".jar") == 0))
{
n->flags |= FLAG_ZIP;
--- 150,156 ----
len = strlen (filename);
!
! if (len > 4 && (COMPARE_FILENAMES (filename + len - 4, ".zip") == 0
! || COMPARE_FILENAMES (filename + len - 4, ".jar") == 0))
{
n->flags |= FLAG_ZIP;
*************** add_entry (entp, filename, is_system)
*** 157,161 ****
way. Symlinks will fool this test. This is only used for
-MM and -MMD, so it probably isn't terribly important. */
! if (! strcmp (filename, LIBGCJ_ZIP_FILE))
n->flags |= FLAG_SYSTEM;
}
--- 159,163 ----
way. Symlinks will fool this test. This is only used for
-MM and -MMD, so it probably isn't terribly important. */
! if (! COMPARE_FILENAMES (filename, LIBGCJ_ZIP_FILE))
n->flags |= FLAG_SYSTEM;
}
*************** add_entry (entp, filename, is_system)
*** 164,168 ****
This is a little hack that lets the searching code in jcf-io.c
work more easily. Eww. */
! if (filename[len - 1] != '/' && filename[len - 1] != DIR_SEPARATOR)
{
char *f2 = alloca (len + 2);
--- 166,170 ----
This is a little hack that lets the searching code in jcf-io.c
work more easily. Eww. */
! if (! IS_DIR_SEPARATOR (filename[len - 1]))
{
char *f2 = alloca (len + 2);
*************** jcf_path_extdirs_arg (cp)
*** 379,383 ****
+ strlen (direntp->d_name) + 2);
strcpy (name, buf);
! if (name[dirname_length-1] != DIR_SEPARATOR)
{
name[dirname_length] = DIR_SEPARATOR;
--- 381,385 ----
+ strlen (direntp->d_name) + 2);
strcpy (name, buf);
! if (! IS_DIR_SEPARATOR (name[dirname_length-1]))
{
name[dirname_length] = DIR_SEPARATOR;