diff options
author | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-08-25 21:48:10 +0000 |
---|---|---|
committer | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2002-08-25 21:48:10 +0000 |
commit | e06c87b07e7b8c69643dc078626c50104e665c81 (patch) | |
tree | a90c532b363e917c65dcf1bff7765a13b156b7d1 | |
parent | 1a9e78e6f5f5d584df04b51cadc26607d121c807 (diff) | |
download | ATCD-e06c87b07e7b8c69643dc078626c50104e665c81.tar.gz |
ChangeLogTag: Sun Aug 25 16:36:53 2002 Jeff Parsons <parsons@cs.wustl.edu>
-rw-r--r-- | TAO/ChangeLog | 20 | ||||
-rw-r--r-- | TAO/TAO_IDL/fe/idl.ll | 6 | ||||
-rw-r--r-- | TAO/TAO_IDL/fe/lex.yy.cpp | 6 | ||||
-rw-r--r-- | TAO/TAO_IDL/util/utl_global.cpp | 128 |
4 files changed, 133 insertions, 27 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index afa4ac8b432..a65487fb34b 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,23 @@ +Sun Aug 25 16:36:53 2002 Jeff Parsons <parsons@cs.wustl.edu> + + * TAO_IDL/fe/idl.ll: + * TAO_IDL/fe/lex.yy.cpp: + * TAO_IDL/util/utl_global.cpp: + + Changed the storage of included IDL files from the + lexer to use the full name instead of the stripped + name (base file name only), and added checks to + validate_included_idl_files() to handle conditional + includes where the same local filename appears in + different subdiretories, and where a complete path + name is a substring of another one. Thanks to + Robert Hancock <hancock@SEDSystems.ca>, Andy Olson + <andrew.olson@lmco.com>, and to Terry Ware + <terry.ware@dc.alphatech.com> for reporting the bug. + This fix applies to [BUGID:821] and [BUGID:1225], but + I will wait to see if the fix works on all platforms + before I close the Bugzilla entries. + Sun Aug 25 15:07:05 2002 Jeff Parsons <parsons@cs.wustl.edu> * TAO_IDL/be/be_visitor_constant/constant_ch.cpp: diff --git a/TAO/TAO_IDL/fe/idl.ll b/TAO/TAO_IDL/fe/idl.ll index 002c4a8a91a..8479079301a 100644 --- a/TAO/TAO_IDL/fe/idl.ll +++ b/TAO/TAO_IDL/fe/idl.ll @@ -507,11 +507,13 @@ idl_parse_line_and_file (char *buf) idl_global->set_in_main_file (in_main_file); - // If it's an import file store the stripped name for the BE to use + // @@@ (JP) We no longer store the stripped name as before, since that + // made it impossible to validate included IDL files + // unambiguously. if (!(idl_global->in_main_file ()) && idl_global->import ()) { ACE_NEW (nm, - UTL_String (stripped_name (fname))); + UTL_String (fname)); // This call also manages the #pragma prefix. idl_global->store_include_file_name (nm); diff --git a/TAO/TAO_IDL/fe/lex.yy.cpp b/TAO/TAO_IDL/fe/lex.yy.cpp index 4b88a09b80c..163d2207ffe 100644 --- a/TAO/TAO_IDL/fe/lex.yy.cpp +++ b/TAO/TAO_IDL/fe/lex.yy.cpp @@ -2698,11 +2698,13 @@ idl_parse_line_and_file (char *buf) idl_global->set_in_main_file (in_main_file); - // If it's an import file store the stripped name for the BE to use + // @@@ (JP) We no longer store the stripped name as before, since that + // made it impossible to validate included IDL files + // unambiguously. if (!(idl_global->in_main_file ()) && idl_global->import ()) { ACE_NEW (nm, - UTL_String (stripped_name (fname))); + UTL_String (fname)); // This call also manages the #pragma prefix. idl_global->store_include_file_name (nm); diff --git a/TAO/TAO_IDL/util/utl_global.cpp b/TAO/TAO_IDL/util/utl_global.cpp index 4641ca4cd4b..c024429618f 100644 --- a/TAO/TAO_IDL/util/utl_global.cpp +++ b/TAO/TAO_IDL/util/utl_global.cpp @@ -604,46 +604,128 @@ IDL_GlobalData::n_included_idl_files (size_t n) void IDL_GlobalData::validate_included_idl_files (void) { - // Flag to make sure we dont repeat things. + // Flag to make sure we don't repeat things. static int already_done = 0; if (already_done == 1) - return; + { + return; + } already_done = 1; // New number of included_idl_files. size_t newj = 0; - for (size_t j = 0; - j < idl_global->n_included_idl_files (); - j++) + size_t n_lexer_includes = idl_global->n_included_idl_files (); + char **lexer_includes = idl_global->included_idl_files (); + char *lexer_include = 0; + char *lexer_base = 0; + size_t n_preproc_includes = idl_global->n_include_file_names (); + UTL_String **preproc_includes = idl_global->include_file_names (); + char *preproc_include = 0; + char *preproc_base = 0; + + for (size_t j = 0; j < n_lexer_includes; ++j) { - // Get the base part. - char *base_part = ACE_OS::strrchr (idl_global->included_idl_files ()[j], - '/'); - - // If no / then take the whole name. We dont need the / - // anyway. - if (base_part == 0) - base_part = idl_global->included_idl_files ()[j]; - else - base_part++; + // Get a name from the lexer's list of included IDL files. + lexer_include = lexer_includes[j]; // Check this name with the names list that we got from the // preprocessor. size_t valid_file = 0; - for (size_t ni = 0; - ni < idl_global->n_include_file_names (); - ni++) + + for (size_t ni = 0; ni < n_preproc_includes; ++ni) { - char *file_name = idl_global->include_file_names ()[ni]->get_string (); + preproc_include = preproc_includes[ni]->get_string (); - if (ACE_OS::strstr (file_name, base_part) != 0) + if (ACE_OS::strstr (preproc_include, lexer_include) != 0) { - // This file name is valid. - valid_file = 1; - break; + // Find the last occurrence of '/', if any,. + lexer_base = ACE_OS::strrchr (lexer_include, + '/'); + + int lexer_no_prefix = 0; + + // Does this include come from the working directory? + if (lexer_base == 0) + { + // Just use the whole string. + lexer_base = lexer_include; + + // Set the flag for later comparison. + lexer_no_prefix = 1; + } + // strrchr leaves the token at the beginning of the + // returned string, so we strip it off here. + else if (lexer_base[0] == '/') + { + ++lexer_base; + } + + preproc_base = ACE_OS::strrchr (preproc_include, + '/'); + int preproc_no_prefix = 0; + + // Does this include come from the working directory? + if (preproc_base == 0) + { + // Just use the whole string. + preproc_base = preproc_include; + + // Set the flag for later comparison. + preproc_no_prefix = 1; + } + // strrchr leaves the token at the beginning of the + // returned string, so we strip it off here. + else if (preproc_base[0] == '/') + { + ++preproc_base; + } + // VC++ preprocessor prepends '.\' to included filenames + // from the working directory. SunCC preprocessor prepends + // './'. Gnu preprocessor prepends nothing, so the code + // below makes them all equivalent. + else if (preproc_base[0] == '.') + { + if (preproc_base[1] == '\\' || preproc_base[1] == '/') + { + preproc_base += 2; + } + } + + // This tells us that the substring match above is bogus, + // since one file is from the working directory and one + // is from a subdirectory. If both files are from + // subdirectories, the substring match will have already + // failed, unless we have a true match. + if (lexer_no_prefix != preproc_no_prefix) + { + continue; + } + + // Belt-and-suspenders check for '\' in the path name, + // in case the lexer conversion function for VC++ lets + // some get through. If some did, we may still not have + // the base file name to use with strcmp. + char *tmp = ACE_OS::strrchr (preproc_base, + '\\'); + + if (tmp == 0) + { + tmp = preproc_base; + } + else if (tmp[0] == '\\') + { + preproc_base = tmp + 1; + } + + if (ACE_OS::strcmp (lexer_base, preproc_base) == 0) + { + // This file name is valid. + valid_file = 1; + break; + } } } |