diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-09-07 04:17:51 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-09-07 04:17:51 +0000 |
commit | 027290ebc37d5dd85440815f3d5840cd83b51b7a (patch) | |
tree | 741c367da9a77dcda962807f1e8335bb6faf3581 | |
parent | fde65b269be13ab2bbe9cdfc11f22844306198ee (diff) | |
download | ATCD-027290ebc37d5dd85440815f3d5840cd83b51b7a.tar.gz |
*** empty log message ***
-rw-r--r-- | ChangeLog-98b | 6 | ||||
-rw-r--r-- | TAO/ChangeLog-98c | 8 | ||||
-rw-r--r-- | TAO/TAO_IDL/be/be_decl.cpp | 8 | ||||
-rw-r--r-- | TAO/TAO_IDL/util/utl_global.cpp | 40 | ||||
-rw-r--r-- | TAO/orbsvcs/tests/ImplRepo/ir_implrepo_impl.cpp | 2 | ||||
-rw-r--r-- | ace/ACE.cpp | 53 | ||||
-rw-r--r-- | ace/ACE.h | 26 | ||||
-rw-r--r-- | ace/ACE.i | 22 | ||||
-rw-r--r-- | ace/OS.h | 2 | ||||
-rw-r--r-- | ace/OS.i | 22 |
10 files changed, 137 insertions, 52 deletions
diff --git a/ChangeLog-98b b/ChangeLog-98b index ea999afc805..0c8b7bdbcb8 100644 --- a/ChangeLog-98b +++ b/ChangeLog-98b @@ -1,5 +1,11 @@ Sun Sep 6 15:49:46 1998 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> + * ace/ACE: Added several new helper string functions, which were + mined from the drwho program. + + * ace/OS: Moved strnew() into class ACE, which is where it + belongs... + * ace/Containers: Merged the ACE_Array class entirely into the Containers files, which is more consistent with the general design of ACE. Also, removed ace/Array.i and Array.cpp since diff --git a/TAO/ChangeLog-98c b/TAO/ChangeLog-98c index c456fa7765d..845314a3d18 100644 --- a/TAO/ChangeLog-98c +++ b/TAO/ChangeLog-98c @@ -1,3 +1,11 @@ +Sun Sep 6 23:06:38 1998 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> + + * TAO_IDL/be/be_decl.cpp, + TAO_IDL/util/utl_global.cpp, + orbsvcs/tests/ImplRepo/ir_implrepo_impl.cpp: + Replaced all uses of ACE_OS::strnew() with ACE::strnew() to + reflect the new changes. + Sun Sep 6 17:57:16 1998 Darrell Brunsch <brunsch@cs.wustl.edu> * tests/Simple/time/Client_i.cpp: Changed the use of exceptions in diff --git a/TAO/TAO_IDL/be/be_decl.cpp b/TAO/TAO_IDL/be/be_decl.cpp index df1f7505b65..19bc1cdf1f5 100644 --- a/TAO/TAO_IDL/be/be_decl.cpp +++ b/TAO/TAO_IDL/be/be_decl.cpp @@ -368,7 +368,7 @@ be_decl::compute_prefix () { idl_global->err ()->syntax_error (IDL_GlobalData::PS_PragmaPrefixSyntax); - this->prefix_ = ACE_OS::strnew (""); + this->prefix_ = ACE::strnew (""); return; } int l = end - tmp; @@ -381,15 +381,15 @@ be_decl::compute_prefix () // Could not find it in the local scope, try to recurse to the top // scope... if (this->defined_in () == 0) - this->prefix_ = ACE_OS::strnew (""); + this->prefix_ = ACE::strnew (""); else { be_scope* scope = be_scope::narrow_from_scope (this->defined_in ()); if (scope == 0) - this->prefix_ = ACE_OS::strnew (""); + this->prefix_ = ACE::strnew (""); else - this->prefix_ = ACE_OS::strnew (scope->decl()->prefix ()); + this->prefix_ = ACE::strnew (scope->decl()->prefix ()); } } diff --git a/TAO/TAO_IDL/util/utl_global.cpp b/TAO/TAO_IDL/util/utl_global.cpp index 9b1906da658..6ed98328ee2 100644 --- a/TAO/TAO_IDL/util/utl_global.cpp +++ b/TAO/TAO_IDL/util/utl_global.cpp @@ -107,15 +107,15 @@ IDL_GlobalData::IDL_GlobalData() pd_idl_src_file (0), export_macro_ (0), export_include_ (0), - client_hdr_ending_ (ACE_OS::strnew ("C.h")), - client_stub_ending_ (ACE_OS::strnew ("C.cpp")), - client_inline_ending_ (ACE_OS::strnew ("C.i")), - server_hdr_ending_ (ACE_OS::strnew ("S.h")), - server_template_hdr_ending_ (ACE_OS::strnew ("S_T.h")), - server_skeleton_ending_ (ACE_OS::strnew ("S.cpp")), - server_template_skeleton_ending_ (ACE_OS::strnew ("S_T.cpp")), - server_inline_ending_ (ACE_OS::strnew ("S.i")), - server_template_inline_ending_ (ACE_OS::strnew ("S_T.i")), + client_hdr_ending_ (ACE::strnew ("C.h")), + client_stub_ending_ (ACE::strnew ("C.cpp")), + client_inline_ending_ (ACE::strnew ("C.i")), + server_hdr_ending_ (ACE::strnew ("S.h")), + server_template_hdr_ending_ (ACE::strnew ("S_T.h")), + server_skeleton_ending_ (ACE::strnew ("S.cpp")), + server_template_skeleton_ending_ (ACE::strnew ("S_T.cpp")), + server_inline_ending_ (ACE::strnew ("S.i")), + server_template_inline_ending_ (ACE::strnew ("S_T.i")), perfect_hasher_ (0), output_dir_ (0) { @@ -804,7 +804,7 @@ void IDL_GlobalData::client_hdr_ending (const char* s) { delete this->client_hdr_ending_; - this->client_hdr_ending_ = ACE_OS::strnew (s); + this->client_hdr_ending_ = ACE::strnew (s); } // Get the client_hdr_ending. @@ -818,7 +818,7 @@ void IDL_GlobalData::client_inline_ending (const char* s) { delete this->client_inline_ending_; - this->client_inline_ending_ = ACE_OS::strnew (s); + this->client_inline_ending_ = ACE::strnew (s); } const char* @@ -832,7 +832,7 @@ void IDL_GlobalData::client_stub_ending (const char* s) { delete this->client_stub_ending_; - this->client_stub_ending_ = ACE_OS::strnew (s); + this->client_stub_ending_ = ACE::strnew (s); } const char* @@ -845,7 +845,7 @@ void IDL_GlobalData::server_hdr_ending (const char* s) { delete this->server_hdr_ending_; - this->server_hdr_ending_ = ACE_OS::strnew (s); + this->server_hdr_ending_ = ACE::strnew (s); } const char* @@ -858,7 +858,7 @@ void IDL_GlobalData::server_template_hdr_ending (const char* s) { delete this->server_template_hdr_ending_; - this->server_template_hdr_ending_ = ACE_OS::strnew (s); + this->server_template_hdr_ending_ = ACE::strnew (s); } const char* @@ -871,7 +871,7 @@ void IDL_GlobalData::server_skeleton_ending (const char* s) { delete this->server_skeleton_ending_; - this->server_skeleton_ending_ = ACE_OS::strnew (s); + this->server_skeleton_ending_ = ACE::strnew (s); } const char* @@ -884,7 +884,7 @@ void IDL_GlobalData::server_template_skeleton_ending (const char* s) { delete this->server_template_skeleton_ending_; - this->server_template_skeleton_ending_ = ACE_OS::strnew (s); + this->server_template_skeleton_ending_ = ACE::strnew (s); } const char* @@ -897,7 +897,7 @@ void IDL_GlobalData::server_inline_ending (const char* s) { delete this->server_inline_ending_; - this->server_inline_ending_ = ACE_OS::strnew (s); + this->server_inline_ending_ = ACE::strnew (s); } const char* @@ -910,7 +910,7 @@ void IDL_GlobalData::server_template_inline_ending (const char* s) { delete this->server_template_inline_ending_; - this->server_template_inline_ending_ = ACE_OS::strnew (s); + this->server_template_inline_ending_ = ACE::strnew (s); } const char* @@ -923,7 +923,7 @@ void IDL_GlobalData::output_dir (const char* s) { delete this->output_dir_; - this->output_dir_ = ACE_OS::strnew (s); + this->output_dir_ = ACE::strnew (s); } const char* @@ -936,7 +936,7 @@ void IDL_GlobalData::perfect_hasher (const char* s) { delete this->perfect_hasher_; - this->perfect_hasher_ = ACE_OS::strnew (s); + this->perfect_hasher_ = ACE::strnew (s); } const char* diff --git a/TAO/orbsvcs/tests/ImplRepo/ir_implrepo_impl.cpp b/TAO/orbsvcs/tests/ImplRepo/ir_implrepo_impl.cpp index 7e2b28fd00a..2ad1c1da9b9 100644 --- a/TAO/orbsvcs/tests/ImplRepo/ir_implrepo_impl.cpp +++ b/TAO/orbsvcs/tests/ImplRepo/ir_implrepo_impl.cpp @@ -95,7 +95,7 @@ IR_iRepo_i::parse_args (void) get_opts.optarg), -1); break; case 'f': // read the IOR from the file. - this->server_input_file_ = ACE_OS::strnew (get_opts.optarg); + this->server_input_file_ = ACE::strnew (get_opts.optarg); break; case '?': // display help for use of the server. default: diff --git a/ace/ACE.cpp b/ace/ACE.cpp index 80e395532ec..fad7898ae1b 100644 --- a/ace/ACE.cpp +++ b/ace/ACE.cpp @@ -2924,6 +2924,59 @@ ACE::get_ip_interfaces (size_t &count, #endif /* ACE_WIN32 */ } +char * +ACE::strndup (const char *str, size_t n) +{ + const char *t = str; + size_t len; + + // Figure out how long this string is (remember, it might not be + // NUL-terminated). + + for (len = 0; + len < n && *t++ != '\0'; + len++) + continue; + + char *s; + ACE_ALLOCATOR_RETURN (s, + (char *) ACE_OS::malloc (len + 1), + 0); + s[len] = '\0'; + return ACE_OS::strncpy (s, str, len); +} + +char * +ACE::strnnew (const char *str, size_t n) +{ + const char *t = str; + size_t len; + + // Figure out how long this string is (remember, it might not be + // NUL-terminated). + + for (len = 0; + len < n && *t++ != '\0'; + len++) + continue; + + char *s; + ACE_NEW_RETURN (s, + char[len + 1], + 0); + s[len] = '\0'; + return ACE_OS::strncpy (s, str, len); +} + +const char * +ACE::strend (const char *s) +{ + while (*s++ != '\0') + continue; + + return s; +} + #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) && (defined (__unix) || defined (__Lynx__)) template class ACE_Auto_Array_Ptr<struct ifreq>; template class ACE_Auto_Basic_Array_Ptr<struct ifreq>; diff --git a/ace/ACE.h b/ace/ACE.h index 2cd3cca4158..2dc03b17bd0 100644 --- a/ace/ACE.h +++ b/ace/ACE.h @@ -444,9 +444,29 @@ public: // <ACE_OS::free> #endif /* ACE_HAS_WINCE */ - static char *strecpy (char *s, const char *t); - // Copies <t> to <s>, returning a pointer to the end of the copied - // region (rather than the beginning, a la <strcpy>. + static char *strecpy (char *des, const char *src); + // Copies <src> to <des>, returning a pointer to the end of the + // copied region, rather than the beginning, as <strcpy> does. + + static const char *strend (const char *); + // Returns a pointer to the "end" of the string, i.e., the character + // past the '\0'. + + static char *strnew (const char *s); + // This method is just like <strdup>, except that it uses <operator + // new> rather than <malloc>. + + static wchar_t *strnew (const wchar_t *s); + // This method is just like <strdup>, except that it uses <operator + // new> rather than <malloc>. + + static char *strndup (const char *str, size_t n); + // Create a fresh new copy of <str>, up to <n> chars long. Uses + // <ACE_OS::malloc> to allocate the new string. + + static char *strnnew (const char *str, size_t n); + // Create a fresh new copy of <str>, up to <n> chars long. Uses + // <ACE_OS::malloc> to allocate the new string. static char *strsplit_r (char *s, const char *token, diff --git a/ace/ACE.i b/ace/ACE.i index 9a1b91cec45..79ddf4dd9d7 100644 --- a/ace/ACE.i +++ b/ace/ACE.i @@ -128,3 +128,25 @@ ACE::debug (char c) { ACE::debug_ = c; } + +ACE_INLINE char * +ACE::strnew (const char *s) +{ + // ACE_TRACE ("ACE::strnew"); + char *t = new char [::strlen(s) + 1]; + if (t == 0) + return 0; + else + return ACE_OS::strcpy (t, s); +} + +ACE_INLINE wchar_t * +ACE::strnew (const wchar_t *s) +{ + // ACE_TRACE ("ACE_OS::strnew"); + wchar_t *t = new wchar_t[::wcslen (s) + 1]; + if (t == 0) + return 0; + else + return ACE_OS::strcpy (t, s); +} @@ -5045,7 +5045,6 @@ public: const char *t, size_t len); static char *strdup (const char *s); // Uses malloc - static char *strnew (const char *s); // Uses new static size_t strlen (const char *s); static char *strncpy (char *s, const char *t, @@ -5140,7 +5139,6 @@ public: const wchar_t *t, size_t len); static wchar_t *strdup (const wchar_t *s); // Uses malloc - static wchar_t *strnew (const wchar_t *s); // Uses new static int sprintf (wchar_t *buf, const wchar_t *format, ...); @@ -1425,17 +1425,6 @@ ACE_OS::strdup (const char *s) #endif /* ACE_HAS_STRDUP_EMULATION */ } -ACE_INLINE char * -ACE_OS::strnew (const char *s) -{ - // ACE_TRACE ("ACE_OS::strnew"); - char *t = new char [::strlen(s) + 1]; - if (t == 0) - return 0; - else - return ACE_OS::strcpy (t, s); -} - #if !defined (ACE_HAS_WINCE) ACE_INLINE int ACE_OS::vsprintf (char *buffer, const char *format, va_list argptr) @@ -9534,17 +9523,6 @@ ACE_OS::strdup (const wchar_t *s) # endif /* __BORLANDC__ */ } -ACE_INLINE wchar_t * -ACE_OS::strnew (const wchar_t *s) -{ - // ACE_TRACE ("ACE_OS::strnew"); - wchar_t *t = new wchar_t [::wcslen(s) + 1]; - if (t == 0) - return 0; - else - return ACE_OS::strcpy (t, s); -} - ACE_INLINE int ACE_OS::vsprintf (wchar_t *buffer, const wchar_t *format, va_list argptr) { |