summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-03-03 21:16:32 +0000
committerparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-03-03 21:16:32 +0000
commitb144489452a720f447c834a13bef7141825051ca (patch)
tree9e761ec81b5602bf86d58afb67b67cd84922fbd2
parent43797309d4e55be697080c1913ffc15b60047166 (diff)
downloadATCD-b144489452a720f447c834a13bef7141825051ca.tar.gz
ChangeLogTag: Mon Mar 3 15:12:32 2003 Jeff Parsons <j.parsons@vanderbilt.edu>
-rw-r--r--TAO/ChangeLog14
-rw-r--r--TAO/TAO_IDL/driver/drv_args.cpp113
-rw-r--r--TAO/TAO_IDL/driver/drv_preproc.cpp28
-rw-r--r--TAO/TAO_IDL/fe/fe_tmplinst.cpp8
-rw-r--r--TAO/TAO_IDL/include/drv_extern.h1
-rw-r--r--TAO/TAO_IDL/include/idl_global.h8
-rw-r--r--TAO/TAO_IDL/util/utl_global.cpp174
7 files changed, 212 insertions, 134 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index 669dd84ffe4..8a9927582a8 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,17 @@
+Mon Mar 3 15:12:32 2003 Jeff Parsons <j.parsons@vanderbilt.edu>
+
+ * TAO_IDL/driver/drv_args.cpp:
+ * TAO_IDL/driver/drv_preproc.cpp:
+ * TAO_IDL/fe/fe_tmplinst.cpp:
+ * TAO_IDL/include/drv_extern.h:
+ * TAO_IDL/include/idl_global.h:
+ * TAO_IDL/util/utl_global.cpp:
+
+ Modified scheme for validating included files. This change
+ was motivated by errors in include file generation when
+ files whose path names are substrings of each other are
+ on opposite sides of a conditional include.
+
Mon Mar 3 11:43:01 2003 Ossama Othman <ossama@uci.edu>
* tao/DynamicAny/DynStruct_i.cpp (current_member_kind):
diff --git a/TAO/TAO_IDL/driver/drv_args.cpp b/TAO/TAO_IDL/driver/drv_args.cpp
index 25b005de2e0..5348aabc131 100644
--- a/TAO/TAO_IDL/driver/drv_args.cpp
+++ b/TAO/TAO_IDL/driver/drv_args.cpp
@@ -567,10 +567,11 @@ DRV_check_gperf (void)
void
DRV_parse_args (long ac, char **av)
{
- char *buffer;
- char *s = 0;
- long i;
+ char *buffer;
+ char *s = 0;
+ long i;
+ DRV_store_env_include_paths ();
DRV_cpp_init ();
idl_global->set_prog_name (av[0]);
@@ -632,29 +633,29 @@ DRV_parse_args (long ac, char **av)
{
// Client stub's header file ending.
// @@ No error handling done here.
- idl_global->append_idl_flag (av[i+1]);
- be_global->client_hdr_ending (av[i+1]);
+ idl_global->append_idl_flag (av[i + 1]);
+ be_global->client_hdr_ending (av[i + 1]);
i++;
}
else if (av[i][2] == 's')
{
// Server skeleton's header file.
- idl_global->append_idl_flag (av[i+1]);
- be_global->server_hdr_ending (av[i+1]);
+ idl_global->append_idl_flag (av[i + 1]);
+ be_global->server_hdr_ending (av[i + 1]);
i++;
}
else if (av[i][2] == 'T')
{
// Server Template header ending.
- idl_global->append_idl_flag (av[i+1]);
- be_global->server_template_hdr_ending (av[i+1]);
+ idl_global->append_idl_flag (av[i + 1]);
+ be_global->server_template_hdr_ending (av[i + 1]);
i++;
}
else if (av[i][2] == 'I')
{
// Server Template header ending.
- idl_global->append_idl_flag (av[i+1]);
- be_global->implementation_hdr_ending (av[i+1]);
+ idl_global->append_idl_flag (av[i + 1]);
+ be_global->implementation_hdr_ending (av[i + 1]);
i++;
}
else
@@ -679,15 +680,15 @@ DRV_parse_args (long ac, char **av)
if (av[i][2] == 's')
{
- idl_global->append_idl_flag (av[i+1]);
- be_global->client_stub_ending (av[i+1]);
+ idl_global->append_idl_flag (av[i + 1]);
+ be_global->client_stub_ending (av[i + 1]);
i++;
}
else if (av[i][2] == 'i')
{
- idl_global->append_idl_flag (av[i+1]);
- be_global->client_inline_ending (av[i+1]);
+ idl_global->append_idl_flag (av[i + 1]);
+ be_global->client_inline_ending (av[i + 1]);
i++;
}
@@ -719,33 +720,33 @@ DRV_parse_args (long ac, char **av)
if (av[i][2] == 's')
{
- idl_global->append_idl_flag (av[i+1]);
- be_global->server_skeleton_ending (av[i+1]);
+ idl_global->append_idl_flag (av[i + 1]);
+ be_global->server_skeleton_ending (av[i + 1]);
i++;
}
else if (av[i][2] == 'T')
{
- idl_global->append_idl_flag (av[i+1]);
- be_global->server_template_skeleton_ending (av[i+1]);
+ idl_global->append_idl_flag (av[i + 1]);
+ be_global->server_template_skeleton_ending (av[i + 1]);
i++;
}
else if (av[i][2] == 'i')
{
- idl_global->append_idl_flag (av[i+1]);
- be_global->server_inline_ending (av[i+1]);
+ idl_global->append_idl_flag (av[i + 1]);
+ be_global->server_inline_ending (av[i + 1]);
i++;
}
else if (av[i][2] == 't')
{
- idl_global->append_idl_flag (av[i+1]);
- be_global->server_template_inline_ending (av[i+1]);
+ idl_global->append_idl_flag (av[i + 1]);
+ be_global->server_template_inline_ending (av[i + 1]);
i++;
}
else if (av[i][2] == 'I')
{
- idl_global->append_idl_flag (av[i+1]);
- be_global->implementation_skel_ending (av[i+1]);
+ idl_global->append_idl_flag (av[i + 1]);
+ be_global->implementation_skel_ending (av[i + 1]);
i++;
}
@@ -766,7 +767,7 @@ DRV_parse_args (long ac, char **av)
// <perfect_hash>, <dynamic_hash> or <binary_search>
// Default is perfect.
case 'H':
- idl_global->append_idl_flag (av[i+1]);
+ idl_global->append_idl_flag (av[i + 1]);
if (av[i+1] == 0 || av[i+1][0] == '-')
{
@@ -780,19 +781,19 @@ DRV_parse_args (long ac, char **av)
BE_GlobalData::TAO_DYNAMIC_HASH
);
}
- else if (ACE_OS::strcmp (av[i+1], "perfect_hash") == 0)
+ else if (ACE_OS::strcmp (av[i + 1], "perfect_hash") == 0)
{
be_global->lookup_strategy (
BE_GlobalData::TAO_PERFECT_HASH
);
}
- else if (ACE_OS::strcmp (av[i+1], "binary_search") == 0)
+ else if (ACE_OS::strcmp (av[i + 1], "binary_search") == 0)
{
be_global->lookup_strategy (
BE_GlobalData::TAO_BINARY_SEARCH
);
}
- else if (ACE_OS::strcmp (av[i+1], "linear_search") == 0)
+ else if (ACE_OS::strcmp (av[i + 1], "linear_search") == 0)
{
be_global->lookup_strategy (
BE_GlobalData::TAO_LINEAR_SEARCH
@@ -803,7 +804,7 @@ DRV_parse_args (long ac, char **av)
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("%s: unknown operation lookup <%s>\n"),
av[0],
- av[i+1]));
+ av[i + 1]));
ACE_OS::exit (99);
}
@@ -838,8 +839,8 @@ DRV_parse_args (long ac, char **av)
case 'g':
if (av[i][2] == '\0')
{
- idl_global->append_idl_flag (av[i+1]);
- idl_global->gperf_path (av[i+1]);
+ idl_global->append_idl_flag (av[i + 1]);
+ idl_global->gperf_path (av[i + 1]);
i++;
}
else
@@ -864,8 +865,8 @@ DRV_parse_args (long ac, char **av)
case 'o':
if (av[i][2] == '\0')
{
- idl_global->append_idl_flag (av[i+1]);
- be_global->output_dir (av [i+1]);
+ idl_global->append_idl_flag (av[i + 1]);
+ be_global->output_dir (av [i + 1]);
i++;
}
else
@@ -885,8 +886,8 @@ DRV_parse_args (long ac, char **av)
case 't':
if (av[i][2] == '\0')
{
- idl_global->append_idl_flag (av[i+1]);
- idl_global->temp_dir (av [i+1]);
+ idl_global->append_idl_flag (av[i + 1]);
+ idl_global->temp_dir (av [i + 1]);
i++;
}
else
@@ -909,7 +910,7 @@ DRV_parse_args (long ac, char **av)
{
if (i < ac - 1)
{
- idl_global->append_idl_flag (av[i+1]);
+ idl_global->append_idl_flag (av[i + 1]);
ACE_NEW (buffer,
char[ACE_OS::strlen (av[i])
@@ -919,9 +920,10 @@ DRV_parse_args (long ac, char **av)
ACE_OS::sprintf (buffer,
"%s%s",
av[i],
- av[i+1]);
+ av[i + 1]);
DRV_cpp_putarg (buffer);
+ idl_global->add_include_path (buffer + 2);
i++;
}
else
@@ -938,6 +940,7 @@ DRV_parse_args (long ac, char **av)
}
else
{
+ idl_global->add_include_path (av[i] + 2);
DRV_cpp_putarg (av[i]);
}
break;
@@ -1246,45 +1249,45 @@ DRV_parse_args (long ac, char **av)
{
int options = ACE_OS::strlen(av[i]) - 3;
int j;
- int k=i;
+ int k = i;
// optimized typecode support
be_global->gen_impl_files (1);
- for (j = 0; j < options; j++)
+ for (j = 0; j < options; ++j)
{
- if (av[k][j+3] == 's')
+ if (av[k][j + 3] == 's')
{
- idl_global->append_idl_flag (av[i+1]);
- be_global->implementation_skel_ending (av[i+1]);
+ idl_global->append_idl_flag (av[i + 1]);
+ be_global->implementation_skel_ending (av[i + 1]);
i++;
}
- else if (av[k][j+3] == 'h')
+ else if (av[k][j + 3] == 'h')
{
- idl_global->append_idl_flag (av[i+1]);
- be_global->implementation_hdr_ending (av[i+1]);
+ idl_global->append_idl_flag (av[i + 1]);
+ be_global->implementation_hdr_ending (av[i + 1]);
i++;
}
- else if (av[k][j+3] == 'b')
+ else if (av[k][j + 3] == 'b')
{
- idl_global->append_idl_flag (av[i+1]);
- be_global->impl_class_prefix (av[i+1]);
+ idl_global->append_idl_flag (av[i + 1]);
+ be_global->impl_class_prefix (av[i + 1]);
i++;
}
- else if (av[k][j+3] == 'e')
+ else if (av[k][j + 3] == 'e')
{
- idl_global->append_idl_flag (av[i+1]);
- be_global->impl_class_suffix (av[i+1]);
+ idl_global->append_idl_flag (av[i + 1]);
+ be_global->impl_class_suffix (av[i + 1]);
i++;
}
- else if (av[k][j+3] == 'c')
+ else if (av[k][j + 3] == 'c')
{
be_global->gen_copy_ctor (1);
}
- else if (av[k][j+3] == 'a')
+ else if (av[k][j + 3] == 'a')
{
be_global->gen_assign_op (1);
}
- else if (isalpha (av[k][j+3] ))
+ else if (isalpha (av[k][j + 3] ))
{
ACE_ERROR ((
LM_ERROR,
diff --git a/TAO/TAO_IDL/driver/drv_preproc.cpp b/TAO/TAO_IDL/driver/drv_preproc.cpp
index 9df7ea08a7a..1ee6c7cbbc0 100644
--- a/TAO/TAO_IDL/driver/drv_preproc.cpp
+++ b/TAO/TAO_IDL/driver/drv_preproc.cpp
@@ -175,6 +175,34 @@ DRV_get_line (FILE *f)
return I_TRUE;
}
+// Store include paths from the environment variable, if any.
+void
+DRV_store_env_include_paths (void)
+{
+ ACE_Env_Value<char*> incl_paths ("INCLUDE",
+ (char *) 0);
+ const char *aggr_str = incl_paths;
+
+ if (aggr_str != 0)
+ {
+ char separator;
+#if defined (ACE_WIN32)
+ separator = ';';
+#else
+ separator = ':';
+#endif
+ ACE_CString aggr_cstr (aggr_str);
+ ssize_t pos;
+
+ do
+ {
+ pos = aggr_cstr.find (separator);
+ idl_global->add_include_path (aggr_cstr.substr (0, pos).fast_rep ());
+ aggr_cstr = aggr_cstr.substr (pos + 1);
+ } while (pos != ACE_String_Base_Const::npos);
+ }
+}
+
// Initialize the cpp argument list.
void
DRV_cpp_init (void)
diff --git a/TAO/TAO_IDL/fe/fe_tmplinst.cpp b/TAO/TAO_IDL/fe/fe_tmplinst.cpp
index ecd72667998..06889897f6c 100644
--- a/TAO/TAO_IDL/fe/fe_tmplinst.cpp
+++ b/TAO/TAO_IDL/fe/fe_tmplinst.cpp
@@ -94,6 +94,10 @@ template class ACE_Unbounded_Queue_Iterator<AST_Operation *>;
template class ACE_Unbounded_Stack<char *>;
template class ACE_Unbounded_Stack_Iterator<char *>;
+template class ACE_Node<char *>;
+template class ACE_Unbounded_Set<char *>;
+template class ACE_Unbounded_Set_Iterator<char *>;
+
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
#pragma instantiate ACE_Hash_Map_Entry<ACE_CString,
@@ -173,4 +177,8 @@ template class ACE_Unbounded_Stack_Iterator<char *>;
#pragma instantiate ACE_Unbounded_Stack<char *>
#pragma instantiate ACE_Unbounded_Stack_Iterator<char *>
+#pragma instantiate ACE_Node<char *>
+#pragma instantiate ACE_Unbounded_Set<char *>
+#pragma instantiate ACE_Unbounded_Set_Iterator<char *>
+
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
diff --git a/TAO/TAO_IDL/include/drv_extern.h b/TAO/TAO_IDL/include/drv_extern.h
index 7de6ded7ae0..3529285e891 100644
--- a/TAO/TAO_IDL/include/drv_extern.h
+++ b/TAO/TAO_IDL/include/drv_extern.h
@@ -74,6 +74,7 @@ const unsigned long TAO_IDL_COMMAND_LINE_BUFFER_SIZE = 4 * 1024;
extern void DRV_parse_args (long, char **);
extern void DRV_usage (void);
extern void DRV_pre_proc (const char *myfile);
+extern void DRV_store_env_include_paths (void);
extern void DRV_cpp_init (void);
extern void DRV_cpp_putarg (const char *str);
extern void DRV_cpp_new_location (const char *new_loc);
diff --git a/TAO/TAO_IDL/include/idl_global.h b/TAO/TAO_IDL/include/idl_global.h
index 52f6663ca45..373e8268964 100644
--- a/TAO/TAO_IDL/include/idl_global.h
+++ b/TAO/TAO_IDL/include/idl_global.h
@@ -1,4 +1,3 @@
-
// $Id$
/*
@@ -449,7 +448,7 @@ public:
void repeat_include (idl_bool val);
// Accessors for repeat_include_ member.
- char *stripped_preproc_include (const char *name);
+ const char *stripped_preproc_include (const char *name);
// Takes an #include filename generated by the preprocessor, and
// strips off any command line -I prefix that may have been
// prepended.
@@ -464,6 +463,8 @@ public:
// keywords e.g. delete, operator etc. with _cxx_ prefix.
// Is set by the IFR Service.
+ void add_include_path (const char *s);
+ // Add another path to 'include_paths_'.
private:
// Data
@@ -540,6 +541,9 @@ private:
idl_bool preserve_cpp_keywords_;
// Do we allow C++ keywords as identifiers in the idl to stay as they are ?
+
+ ACE_Unbounded_Queue<char *> include_paths_;
+ // List of -I options passed to us.
};
diff --git a/TAO/TAO_IDL/util/utl_global.cpp b/TAO/TAO_IDL/util/utl_global.cpp
index 8cc8d2ea5ce..ce27b925b38 100644
--- a/TAO/TAO_IDL/util/utl_global.cpp
+++ b/TAO/TAO_IDL/util/utl_global.cpp
@@ -640,27 +640,102 @@ IDL_GlobalData::validate_included_idl_files (void)
// New number of included_idl_files.
size_t newj = 0;
+ char separator[2];
+ size_t n_found = 0;
+
+# if defined (ACE_WIN32)
+# define FULLPATH(full, partial, maxlen) ::_fullpath (full, partial, maxlen)
+ ACE_OS::strcpy (separator, "\\");
+# else
+# define FULLPATH(full, partial, maxlen) realpath (full, partial)
+ ACE_OS::strcpy (separator, "/");
+# endif
size_t n_pre_preproc_includes = idl_global->n_included_idl_files ();
char **pre_preproc_includes = idl_global->included_idl_files ();
size_t n_post_preproc_includes = idl_global->n_include_file_names ();
UTL_String **post_preproc_includes = idl_global->include_file_names ();
+ char pre_abspath[MAXPATHLEN];
+ char post_abspath[MAXPATHLEN];
+ char **path_tmp = 0;
+ char *post_tmp = 0;
+
for (size_t j = 0; j < n_pre_preproc_includes; ++j)
{
// Check this name with the names list that we got from the
// preprocessor.
size_t valid_file = 0;
+ (void) FULLPATH (pre_abspath, pre_preproc_includes[j], MAXPATHLEN);
- for (size_t ni = 0; ni < n_post_preproc_includes; ++ni)
+ if (pre_abspath != 0)
{
- if (ACE_OS::strcmp (post_preproc_includes[ni]->get_string (),
- pre_preproc_includes[j])
- == 0)
+ for (size_t ni = 0; ni < n_post_preproc_includes; ++ni)
{
- // This file name is valid.
- valid_file = 1;
- break;
+ post_tmp = post_preproc_includes[ni]->get_string ();
+ (void) FULLPATH (post_abspath, post_tmp, MAXPATHLEN);
+
+ if (post_abspath != 0
+ && ACE_OS::strcmp (pre_abspath, post_abspath) == 0)
+ {
+ FILE *test = ACE_OS::fopen (post_abspath, "r");
+
+ if (test == 0)
+ {
+ continue;
+ }
+
+ // This file name is valid.
+ valid_file = 1;
+ ++n_found;
+ break;
+ }
+ }
+ }
+
+ if (valid_file == 0)
+ {
+ for (ACE_Unbounded_Queue_Iterator<char *>iter (
+ this->include_paths_
+ );
+ !iter.done ();
+ iter.advance ())
+ {
+ iter.next (path_tmp);
+ ACE_CString pre_partial (*path_tmp);
+ pre_partial += separator;
+ pre_partial += pre_preproc_includes[j];
+ (void) FULLPATH (pre_abspath, pre_partial.c_str (), MAXPATHLEN);
+
+ if (pre_abspath != 0)
+ {
+ for (size_t m = 0; m < n_post_preproc_includes; ++m)
+ {
+ post_tmp = post_preproc_includes[m]->get_string ();
+ (void) FULLPATH (post_abspath, post_tmp, MAXPATHLEN);
+
+ if (post_abspath != 0
+ && ACE_OS::strcmp (pre_abspath, post_abspath) == 0)
+ {
+ FILE *test = ACE_OS::fopen (post_abspath, "r");
+
+ if (test == 0)
+ {
+ continue;
+ }
+
+ // This file name is valid.
+ valid_file = 1;
+ ++n_found;
+ break;
+ }
+ }
+ }
+
+ if (valid_file == 1)
+ {
+ break;
+ }
}
}
@@ -688,6 +763,11 @@ IDL_GlobalData::validate_included_idl_files (void)
// Increment the new index.
newj++;
}
+
+ if (n_found == n_post_preproc_includes)
+ {
+ break;
+ }
}
// Now adjust the count on the included_idl_files.
@@ -1082,86 +1162,21 @@ IDL_GlobalData::string_to_scoped_name (char *s)
return retval;
}
-char *
+const char *
IDL_GlobalData::stripped_preproc_include (const char *name)
{
// Some preprocessors prepend "./" to filenames in the
// working directory, some others prepend ".\". If either
- // of these are here, we want to strip them. Since we also
- // know we're in the working directory, we can skip the
- // command line prefix iteration.
+ // of these are here, we want to strip them.
if (name[0] == '.')
{
if (name[1] == '\\' || name[1] == '/')
{
- return (char *)name + 2;
- }
- }
-
- ssize_t cursor = this->idl_flags_.find ("-I", 0);
- ACE_CString c_name (name, 0, 0);
- ssize_t start = 0;
- ssize_t end = 0;
- char *candidate = 0;
-
- while (cursor != ACE_SString::npos)
- {
- // Skip over the "-I".
- start = cursor + 2;
-
- // If the "-I" is followed by a space. skip that too.
- if (this->idl_flags_[start] == ' ')
- {
- ++start;
- }
-
- // idl_flags_ uses ' ' as a separator.
- end = this->idl_flags_.find (' ', start);
-
- // If it's the last one, there won't be a space at the end.
- if (end == ACE_SString::npos)
- {
- end = this->idl_flags_.length ();
- }
-
- // Set the cursor for the next iteration, if any.
- cursor = this->idl_flags_.find ("-I", end);
- // If this prefix is found at the beginning of the name, strip it
- // and return it.
- if (c_name.find (this->idl_flags_.substr (start, end - start)) == 0)
- {
- // If the prefix ends in / or \, we don't need to strip the one
- // that *would* have been added for concatenation...
- char prefix_cap = this->idl_flags_[end - 1];
- size_t skip_slash = (prefix_cap != '\\' && prefix_cap != '/');
- char *rep = c_name.substr (end - start + skip_slash).rep ();
-
- // ...unless it's the SunCC preprocessor, which adds a / for
- // concatentation no matter what, so we check for it.
- if (rep[0] == '/')
- {
- ++rep;
- }
-
- // If there's more than one match in the list, we want the
- // longest one.
- if (candidate == 0
- || ACE_OS::strlen (rep) < ACE_OS::strlen (candidate))
- {
- candidate = rep;
- }
+ return name + 2;
}
}
- // If no prefix matches, just return the name unchanged.
- if (candidate != 0)
- {
- return candidate;
- }
- else
- {
- return (char *)name;
- }
+ return name;
}
/**
@@ -1185,4 +1200,9 @@ IDL_GlobalData::preserve_cpp_keywords (idl_bool val)
{
preserve_cpp_keywords_ = val;
}
-
+
+void
+IDL_GlobalData::add_include_path (const char *s)
+{
+ this->include_paths_.enqueue_tail (ACE::strnew (s));
+}