gcc/gcc/java/win32-host.c

88 lines
2.5 KiB
C
Raw Normal View History

/* Platform-Specific Win32 Functions
Copyright (C) 2003-2016 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>.
Java and all Java-based marks are trademarks or registered trademarks
of Sun Microsystems, Inc. in the United States and other countries.
The Free Software Foundation is independent of Sun Microsystems, Inc. */
/* Written by Mohan Embar <gnustuff@thisiscool.com>, March 2003. */
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "jcf.h"
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
/* Simulate an open() failure with ENOENT */
static int
file_not_found (void);
static int
file_not_found (void)
{
errno = ENOENT;
return -1;
}
int
jcf_open_exact_case (const char *filename, int oflag)
{
int filename_len = strlen (filename);
int found_file_len;
HANDLE found_file_handle;
WIN32_FIND_DATA fd;
/* See if we can find this file. */
found_file_handle = FindFirstFile (filename, &fd);
if (found_file_handle == INVALID_HANDLE_VALUE)
return file_not_found ();
FindClose (found_file_handle);
found_file_len = strlen (fd.cFileName);
/* This should never happen. */
if (found_file_len > filename_len)
return file_not_found ();
/* Here, we're only actually comparing the filename and not
checking the case of any containing directory components.
Although we're not fully obeying our contract, checking
all directory components would be tedious and time-consuming
and it's a pretty safe assumption that mixed-case package
names are a fringe case.... */
Changelog c-family/ 2011-03-25 Kai Tietz <ktietz@redhat.com> * c-ada-spec.c (compare_comment): Use filename_cmp instead of strcmp for filename. Changelog fortran/ 2011-03-25 Kai Tietz <ktietz@redhat.com> * scanner.c (preprocessor_line): Use filename_cmp instead of strcmp. Changelog gcc/ 2011-03-25 Kai Tietz <ktietz@redhat.com> * collect2.c (write_c_file_stat): Handle backslash as right-hand directory separator. (resolve_lib_name): Use IS_DIR_SEPARATOR instead of checking just for slash. * coverage.c (coverage_init): Use IS_ABSOLUTE_PATH instead of checking for trailing slash. * gcc.c (record_temp_file): Use filename_cmp instead of strcmp. (do_spec_1): Likewise. (replace_outfile_spec_function): Likewise. (is_directory): Use filename_ncmp instead of strncmp. (print_multilib_info): Likewise. * gcov.c (find_source): Use filename_cmp instead instead of strcmp. (make_gcov_file_name): Fix order of slash/backslash checks. * incpath.c (DIRS_EQ): Use filename_cmp instead of strcmp. (add_standard_paths): Likewise. * mips-tfile.c (saber_stop): Handle backslash. * prefix.c (update_path): Use filename_ncmp instead of strncmp. * profile.c (output_location): Use filename_cmp instead of strcmp. * read-md.c (handle_toplevel_file): Handle backslash. * tlink.c (frob_extension): Likewise. * tree-cfg.c (same_line_p): Use filename_cmp instead of strcmp. * tree-dump.c (dequeue_and_dump): Handle backslash. * tree.c (get_file_function_name): Likewise. * gengtype.c (read_input_list): Likewise. (get_file_realbasename): Likewise. (get_output_file_with_visibility): Use filename_cmp instead of strcmp. ChangeLog java/ 2011-03-25 Kai Tietz <ktietz@redhat.com> * jcf-parse.c (java_read_sourcefilenames): Use filename_cmp instead of strcmp. (set_source_filename): Likewise. * win32-host.c (jcf_open_exact_case): Likewise. ChangeLog lto/ 2011-03-25 Kai Tietz <ktietz@redhat.com> * lto.c (lto_resolution_read): Use filename_cmp instead of strcmp. (lto_read_section_data): Likewise. ChangeLog cp/ 2011-03-25 Kai Tietz <ktietz@redhat.com> * lex.c (interface_strcmp): Handle dos-paths. (handle_pragma_implementation): Use filename_cmp instead of strcmp. (in_main_input_context): Likewise. From-SVN: r171522
2011-03-25 20:20:52 +01:00
if (filename_cmp (filename + filename_len - found_file_len, fd.cFileName))
{
/* Reject this because it is not a perfect-case match. */
/* printf("************\nRejected:\n%s\n%s\n************\n\n", filename, fd.cFileName); */
return file_not_found ();
}
else
{
return open (filename, oflag);
}
}
#endif /* WIN32 */