*Massive cleanup (\n\n -> \n, *\n -> \n, cleanup for(...) to for (...), and some other cleanups by hand)
*Fix a possible crash in Spell::DoAllEffectOnTarget --HG-- branch : trunk
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
// $Id: Lib_Find.cpp 80826 2008-03-04 14:51:23Z wotte $
|
||||
|
||||
#include "ace/Lib_Find.h"
|
||||
#include "ace/Log_Msg.h"
|
||||
#include "ace/OS_NS_string.h"
|
||||
@@ -9,23 +8,18 @@
|
||||
#include "ace/OS_NS_stdlib.h"
|
||||
#include "ace/OS_Memory.h"
|
||||
#include "ace/OS_NS_fcntl.h"
|
||||
|
||||
#if defined (ACE_WIN32)
|
||||
# include "ace/OS_NS_strings.h"
|
||||
#endif /* ACE_WIN32 */
|
||||
|
||||
#if defined (ACE_OPENVMS)
|
||||
#include "ace/RB_Tree.h"
|
||||
#include "ace/Thread_Mutex.h"
|
||||
#include "ace/Singleton.h"
|
||||
|
||||
#include /**/ "descrip.h"
|
||||
#include /**/ "chfdef.h"
|
||||
#include /**/ "stsdef.h"
|
||||
#include /**/ "libdef.h"
|
||||
|
||||
extern "C" int LIB$FIND_IMAGE_SYMBOL(...);
|
||||
|
||||
class ACE_LD_Symbol_Registry
|
||||
{
|
||||
// @internal
|
||||
@@ -50,23 +44,17 @@ class ACE_LD_Symbol_Registry
|
||||
// - first try directly from DLL using the RTL dlsym() function and if that fails;
|
||||
// - try to find symbol in singleton registry.
|
||||
public:
|
||||
|
||||
typedef ACE_RB_Tree<const ACE_TCHAR*,
|
||||
void*,
|
||||
ACE_Less_Than<const ACE_TCHAR*>,
|
||||
ACE_Thread_Mutex>
|
||||
TREE;
|
||||
|
||||
void register_symbol (const ACE_TCHAR* symname, void* symaddr);
|
||||
|
||||
void* find_symbol (const ACE_TCHAR* symname);
|
||||
|
||||
ACE_LD_Symbol_Registry () {}
|
||||
private:
|
||||
|
||||
TREE symbol_registry_;
|
||||
};
|
||||
|
||||
void
|
||||
ACE_LD_Symbol_Registry::register_symbol (const ACE_TCHAR* symname,
|
||||
void* symaddr)
|
||||
@@ -85,34 +73,26 @@ ACE_LD_Symbol_Registry::register_symbol (const ACE_TCHAR* symname,
|
||||
ACE_TEXT_ALWAYS_CHAR (symname)));
|
||||
}
|
||||
}
|
||||
|
||||
void*
|
||||
ACE_LD_Symbol_Registry::find_symbol (const ACE_TCHAR* symname)
|
||||
{
|
||||
void* symaddr = 0;
|
||||
int const result = symbol_registry_.find (symname, symaddr);
|
||||
|
||||
return (result == 0 ? symaddr : 0);
|
||||
}
|
||||
|
||||
/// Declare a process wide singleton
|
||||
ACE_SINGLETON_DECLARE (ACE_Singleton,
|
||||
ACE_LD_Symbol_Registry,
|
||||
ACE_Thread_Mutex)
|
||||
|
||||
typedef ACE_Singleton<ACE_LD_Symbol_Registry, ACE_Thread_Mutex>
|
||||
ACE_LD_SYMBOL_REGISTRY;
|
||||
|
||||
#if defined (ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION)
|
||||
template ACE_Singleton<ACE_LD_Symbol_Registry, ACE_Thread_Mutex> *
|
||||
ACE_Singleton<ACE_LD_Symbol_Registry, ACE_Thread_Mutex>::singleton_;
|
||||
#endif /* ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION */
|
||||
#endif
|
||||
|
||||
ACE_RCSID(ace, Lib_Find, "$Id: Lib_Find.cpp 80826 2008-03-04 14:51:23Z wotte $")
|
||||
|
||||
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
|
||||
|
||||
int
|
||||
ACE::ldfind (const ACE_TCHAR* filename,
|
||||
ACE_TCHAR pathname[],
|
||||
@@ -125,20 +105,17 @@ ACE::ldfind (const ACE_TCHAR* filename,
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
dsc$descriptor nameDsc;
|
||||
nameDsc.dsc$b_class = DSC$K_CLASS_S;
|
||||
nameDsc.dsc$b_dtype = DSC$K_DTYPE_T;
|
||||
nameDsc.dsc$w_length = ACE_OS::strlen(filename);
|
||||
nameDsc.dsc$a_pointer = (char*)filename;
|
||||
|
||||
char symbol[] = "NULL";
|
||||
dsc$descriptor symbolDsc;
|
||||
symbolDsc.dsc$b_class = DSC$K_CLASS_S;
|
||||
symbolDsc.dsc$b_dtype = DSC$K_DTYPE_T;
|
||||
symbolDsc.dsc$w_length = ACE_OS::strlen(symbol);
|
||||
symbolDsc.dsc$a_pointer = symbol;
|
||||
|
||||
int symbolValue;
|
||||
int result;
|
||||
try
|
||||
@@ -149,7 +126,6 @@ ACE::ldfind (const ACE_TCHAR* filename,
|
||||
{
|
||||
result = sig.chf$l_sig_name;
|
||||
}
|
||||
|
||||
int severity = result & STS$M_SEVERITY;
|
||||
int conditionId = result & STS$M_COND_ID;
|
||||
if (severity == STS$K_SUCCESS || severity == STS$K_WARNING || severity == STS$K_INFO ||
|
||||
@@ -158,14 +134,12 @@ ACE::ldfind (const ACE_TCHAR* filename,
|
||||
ACE_OS::strcpy(pathname, filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ACE_OS::strlen(filename) + ACE_OS::strlen(ACE_DLL_PREFIX) >= maxpathnamelen)
|
||||
{
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
ACE_OS::strcpy(pathname, ACE_DLL_PREFIX);
|
||||
ACE_OS::strcat(pathname, filename);
|
||||
nameDsc.dsc$w_length = ACE_OS::strlen(pathname);
|
||||
@@ -178,7 +152,6 @@ ACE::ldfind (const ACE_TCHAR* filename,
|
||||
{
|
||||
result = sig.chf$l_sig_name;
|
||||
}
|
||||
|
||||
severity = result & STS$M_SEVERITY;
|
||||
conditionId = result & STS$M_COND_ID;
|
||||
if (severity == STS$K_SUCCESS || severity == STS$K_WARNING || severity == STS$K_INFO ||
|
||||
@@ -189,7 +162,6 @@ ACE::ldfind (const ACE_TCHAR* filename,
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
#endif /* ACE_OPENVMS */
|
||||
|
||||
#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE) && \
|
||||
!defined (ACE_HAS_PHARLAP)
|
||||
ACE_TCHAR expanded_filename[MAXPATHLEN];
|
||||
@@ -199,7 +171,6 @@ ACE::ldfind (const ACE_TCHAR* filename,
|
||||
/ sizeof (ACE_TCHAR)))
|
||||
filename = expanded_filename;
|
||||
#endif /* ACE_WIN32 && !ACE_HAS_WINCE && !ACE_HAS_PHARLAP */
|
||||
|
||||
ACE_TCHAR tempcopy[MAXPATHLEN + 1];
|
||||
ACE_TCHAR searchpathname[MAXPATHLEN + 1];
|
||||
#if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK)
|
||||
@@ -208,7 +179,6 @@ ACE::ldfind (const ACE_TCHAR* filename,
|
||||
#else
|
||||
ACE_TCHAR searchfilename[MAXPATHLEN + 1];
|
||||
#endif /* ACE_WIN32 && ACE_LD_DECORATOR_STR && !ACE_DISABLE_DEBUG_DLL_CHECK */
|
||||
|
||||
// Create a copy of filename to work with.
|
||||
if (ACE_OS::strlen (filename) + 1
|
||||
> (sizeof tempcopy / sizeof (ACE_TCHAR)))
|
||||
@@ -218,19 +188,15 @@ ACE::ldfind (const ACE_TCHAR* filename,
|
||||
}
|
||||
else
|
||||
ACE_OS::strcpy (tempcopy, filename);
|
||||
|
||||
// Insert canonical directory separators.
|
||||
ACE_TCHAR *separator_ptr;
|
||||
|
||||
#if (ACE_DIRECTORY_SEPARATOR_CHAR != '/')
|
||||
// Make all the directory separators "canonical" to simplify
|
||||
// subsequent code.
|
||||
ACE::strrepl (tempcopy, ACE_DIRECTORY_SEPARATOR_CHAR, '/');
|
||||
#endif /* ACE_DIRECTORY_SEPARATOR_CHAR */
|
||||
|
||||
// Separate filename from pathname.
|
||||
separator_ptr = ACE_OS::strrchr (tempcopy, '/');
|
||||
|
||||
// This is a relative path.
|
||||
if (separator_ptr == 0)
|
||||
{
|
||||
@@ -243,20 +209,15 @@ ACE::ldfind (const ACE_TCHAR* filename,
|
||||
separator_ptr[1] = '\0';
|
||||
ACE_OS::strcpy (searchpathname, tempcopy);
|
||||
}
|
||||
|
||||
bool has_suffix = false;
|
||||
|
||||
// Check to see if this has an appropriate DLL suffix for the OS
|
||||
// platform.
|
||||
ACE_TCHAR *s = ACE_OS::strrchr (searchfilename, '.');
|
||||
|
||||
const ACE_TCHAR *dll_suffix = ACE_DLL_SUFFIX;
|
||||
|
||||
if (s != 0)
|
||||
{
|
||||
// If we have a dot, we have a suffix
|
||||
has_suffix = true;
|
||||
|
||||
// Check whether this matches the appropriate platform-specific
|
||||
// suffix.
|
||||
#if defined (ACE_WIN32)
|
||||
@@ -273,7 +234,6 @@ ACE::ldfind (const ACE_TCHAR* filename,
|
||||
s));
|
||||
}
|
||||
}
|
||||
|
||||
// Make sure we've got enough space in searchfilename.
|
||||
if (ACE_OS::strlen (searchfilename)
|
||||
+ ACE_OS::strlen (ACE_DLL_PREFIX)
|
||||
@@ -283,18 +243,15 @@ ACE::ldfind (const ACE_TCHAR* filename,
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK)
|
||||
size_t len_searchfilename = ACE_OS::strlen (searchfilename);
|
||||
if (! has_suffix)
|
||||
ACE_OS::strcpy (searchfilename + len_searchfilename,
|
||||
decorator);
|
||||
|
||||
for (int tag = 1; tag >= 0; tag --)
|
||||
{
|
||||
if (tag == 0)
|
||||
searchfilename [len_searchfilename] = 0;
|
||||
|
||||
#endif /* ACE_WIN32 && ACE_LD_DECORATOR_STR && !ACE_DISABLE_DEBUG_DLL_CHECK */
|
||||
// Use absolute pathname if there is one.
|
||||
if (ACE_OS::strlen (searchpathname) > 0)
|
||||
@@ -322,7 +279,6 @@ ACE::ldfind (const ACE_TCHAR* filename,
|
||||
has_suffix ? ACE_TEXT ("") : dll_suffix);
|
||||
if (ACE_OS::access (pathname, F_OK) == 0)
|
||||
return 0;
|
||||
|
||||
// Second, try matching the filename *with* adding a prefix.
|
||||
ACE_OS::sprintf (pathname,
|
||||
ACE_TEXT ("%s%s%s%s"),
|
||||
@@ -334,7 +290,6 @@ ACE::ldfind (const ACE_TCHAR* filename,
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Use relative filenames via LD_LIBRARY_PATH or PATH (depending on
|
||||
// OS platform).
|
||||
else
|
||||
@@ -355,7 +310,6 @@ ACE::ldfind (const ACE_TCHAR* filename,
|
||||
}
|
||||
else if (pathlen > 0)
|
||||
return 0;
|
||||
|
||||
// In case not found we should try again with the ACE_DLL_PREFIX
|
||||
// prefixed
|
||||
ACE_OS::strcpy (searchfilename, ACE_DLL_PREFIX);
|
||||
@@ -389,7 +343,6 @@ ACE::ldfind (const ACE_TCHAR* filename,
|
||||
ld_path = wide_ldpath.wchar_rep ();
|
||||
# endif /* ACE_WIN32 || !ACE_USES_WCHAR */
|
||||
# endif /* ACE_DEFAULT_LD_SEARCH_PATH */
|
||||
|
||||
#if defined (ACE_HAS_WINCE)
|
||||
ACE_TCHAR *ld_path_temp = 0;
|
||||
if (ld_path != 0)
|
||||
@@ -401,7 +354,6 @@ ACE::ldfind (const ACE_TCHAR* filename,
|
||||
{
|
||||
ACE_OS::strcpy (ld_path_temp,
|
||||
ACE_LD_SEARCH_PATH_SEPARATOR_STR);
|
||||
|
||||
ACE_OS::strcat (ld_path_temp, ld_path);
|
||||
ld_path = ld_path_temp;
|
||||
}
|
||||
@@ -412,7 +364,6 @@ ACE::ldfind (const ACE_TCHAR* filename,
|
||||
}
|
||||
}
|
||||
#endif /* ACE_HAS_WINCE */
|
||||
|
||||
if (ld_path != 0
|
||||
&& (ld_path = ACE_OS::strdup (ld_path)) != 0)
|
||||
{
|
||||
@@ -423,21 +374,17 @@ ACE::ldfind (const ACE_TCHAR* filename,
|
||||
// third iteration would be "/bar". However, this is not
|
||||
// the case; one only gets two iterations: "/foo" followed
|
||||
// by "/bar".
|
||||
|
||||
// This is especially a problem in parsing Unix paths
|
||||
// because it is permissible to specify 'the current
|
||||
// directory' as an empty entry. So, we introduce the
|
||||
// following special code to cope with this:
|
||||
|
||||
// Look at each dynamic lib directory in the search path.
|
||||
|
||||
ACE_TCHAR *nextholder = 0;
|
||||
const ACE_TCHAR *path_entry =
|
||||
ACE::strsplit_r (ld_path,
|
||||
ACE_LD_SEARCH_PATH_SEPARATOR_STR,
|
||||
nextholder);
|
||||
int result = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
// Check if at end of search path.
|
||||
@@ -462,7 +409,6 @@ ACE::ldfind (const ACE_TCHAR* filename,
|
||||
// that the loop condition will still work.
|
||||
else if (path_entry[0] == '\0')
|
||||
path_entry = ACE_TEXT (".");
|
||||
|
||||
// First, try matching the filename *without* adding a
|
||||
// prefix.
|
||||
ACE_OS::sprintf (pathname,
|
||||
@@ -473,7 +419,6 @@ ACE::ldfind (const ACE_TCHAR* filename,
|
||||
has_suffix ? ACE_TEXT ("") : dll_suffix);
|
||||
if (ACE_OS::access (pathname, F_OK) == 0)
|
||||
break;
|
||||
|
||||
// Second, try matching the filename *with* adding a
|
||||
// prefix.
|
||||
ACE_OS::sprintf (pathname,
|
||||
@@ -485,14 +430,12 @@ ACE::ldfind (const ACE_TCHAR* filename,
|
||||
has_suffix ? ACE_TEXT ("") : dll_suffix);
|
||||
if (ACE_OS::access (pathname, F_OK) == 0)
|
||||
break;
|
||||
|
||||
// Fetch the next item in the path
|
||||
path_entry =
|
||||
ACE::strsplit_r (0,
|
||||
ACE_LD_SEARCH_PATH_SEPARATOR_STR,
|
||||
nextholder);
|
||||
}
|
||||
|
||||
#if defined (ACE_HAS_WINCE)
|
||||
if (ld_path_temp != 0)
|
||||
ACE_OS::free (ld_path_temp);
|
||||
@@ -509,17 +452,14 @@ ACE::ldfind (const ACE_TCHAR* filename,
|
||||
#if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK)
|
||||
}
|
||||
#endif /* ACE_WIN32 && ACE_LD_DECORATOR_STR && !ACE_DISABLE_DEBUG_DLL_CHECK */
|
||||
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
FILE *
|
||||
ACE::ldopen (const ACE_TCHAR *filename,
|
||||
const ACE_TCHAR *type)
|
||||
{
|
||||
ACE_TRACE ("ACE::ldopen");
|
||||
|
||||
ACE_TCHAR buf[MAXPATHLEN + 1];
|
||||
if (ACE::ldfind (filename,
|
||||
buf,
|
||||
@@ -528,42 +468,34 @@ ACE::ldopen (const ACE_TCHAR *filename,
|
||||
else
|
||||
return ACE_OS::fopen (buf, type);
|
||||
}
|
||||
|
||||
ACE_TCHAR *
|
||||
ACE::ldname (const ACE_TCHAR *entry_point)
|
||||
{
|
||||
ACE_TRACE ("ACE::ldname");
|
||||
|
||||
#if defined(ACE_NEEDS_DL_UNDERSCORE)
|
||||
size_t size =
|
||||
1 // leading '_'
|
||||
+ ACE_OS::strlen (entry_point)
|
||||
+ 1;
|
||||
|
||||
ACE_TCHAR *new_name;
|
||||
ACE_NEW_RETURN (new_name,
|
||||
ACE_TCHAR[size],
|
||||
0);
|
||||
|
||||
ACE_OS::strcpy (new_name, ACE_TEXT ("_"));
|
||||
ACE_OS::strcat (new_name, entry_point);
|
||||
|
||||
return new_name;
|
||||
#else /* ACE_NEEDS_DL_UNDERSCORE */
|
||||
size_t size =
|
||||
ACE_OS::strlen (entry_point)
|
||||
+ 1;
|
||||
|
||||
ACE_TCHAR *new_name;
|
||||
ACE_NEW_RETURN (new_name,
|
||||
ACE_TCHAR[size],
|
||||
0);
|
||||
|
||||
ACE_OS::strcpy (new_name, entry_point);
|
||||
return new_name;
|
||||
#endif /* ACE_NEEDS_DL_UNDERSCORE */
|
||||
}
|
||||
|
||||
#if defined (ACE_OPENVMS)
|
||||
void
|
||||
ACE::ldregister (const ACE_TCHAR *entry_point,
|
||||
@@ -572,7 +504,6 @@ ACE::ldregister (const ACE_TCHAR *entry_point,
|
||||
ACE_LD_SYMBOL_REGISTRY::instance ()->register_symbol (entry_point,
|
||||
entry_addr);
|
||||
}
|
||||
|
||||
void *
|
||||
ACE::ldsymbol (ACE_SHLIB_HANDLE sh, const ACE_TCHAR *entry_point)
|
||||
{
|
||||
@@ -580,11 +511,9 @@ ACE::ldsymbol (ACE_SHLIB_HANDLE sh, const ACE_TCHAR *entry_point)
|
||||
// if not found through dlsym() try registry
|
||||
if (symaddr == 0)
|
||||
symaddr = ACE_LD_SYMBOL_REGISTRY::instance ()->find_symbol (entry_point);
|
||||
|
||||
return symaddr;
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
ACE::get_temp_dir (ACE_TCHAR *buffer, size_t buffer_len)
|
||||
{
|
||||
@@ -592,27 +521,20 @@ ACE::get_temp_dir (ACE_TCHAR *buffer, size_t buffer_len)
|
||||
#if defined (ACE_WIN32)
|
||||
result = ACE_TEXT_GetTempPath (static_cast<DWORD> (buffer_len),
|
||||
buffer);
|
||||
|
||||
// Make sure to return -1 if there is an error
|
||||
if (result == 0 && ::GetLastError () != ERROR_SUCCESS
|
||||
|| result > static_cast<int> (buffer_len))
|
||||
result = -1;
|
||||
|
||||
#else /* ACE_WIN32 */
|
||||
|
||||
// NOTE! Non-Windows platforms don't deal with wide chars for env.
|
||||
// variables, so do this narrow-char and convert to wide for the
|
||||
// caller if necessary.
|
||||
|
||||
// On non-win32 platforms, check to see what the TMPDIR environment
|
||||
// variable is defined to be. If it doesn't exist, just use /tmp
|
||||
const char *tmpdir = ACE_OS::getenv ("TMPDIR");
|
||||
|
||||
if (tmpdir == 0)
|
||||
tmpdir = "/tmp";
|
||||
|
||||
size_t len = ACE_OS::strlen (tmpdir);
|
||||
|
||||
// Check to see if the buffer is large enough for the string,
|
||||
// another /, and its null character (hence the + 2)
|
||||
if ((len + 2) > buffer_len)
|
||||
@@ -622,7 +544,6 @@ ACE::get_temp_dir (ACE_TCHAR *buffer, size_t buffer_len)
|
||||
else
|
||||
{
|
||||
ACE_OS::strcpy (buffer, ACE_TEXT_CHAR_TO_TCHAR (tmpdir));
|
||||
|
||||
// Add a trailing slash because we cannot assume there is already one
|
||||
// at the end. And having an extra one should not cause problems.
|
||||
buffer[len] = ACE_TEXT ('/');
|
||||
@@ -632,7 +553,6 @@ ACE::get_temp_dir (ACE_TCHAR *buffer, size_t buffer_len)
|
||||
#endif /* ACE_WIN32 */
|
||||
return result;
|
||||
}
|
||||
|
||||
ACE_HANDLE
|
||||
ACE::open_temp_file (const ACE_TCHAR *name, int mode, int perm)
|
||||
{
|
||||
@@ -647,10 +567,8 @@ ACE::open_temp_file (const ACE_TCHAR *name, int mode, int perm)
|
||||
// Open it.
|
||||
ACE_HANDLE handle = ACE_OS::open (name, mode, perm);
|
||||
#endif /* ACE_WIN32 */
|
||||
|
||||
if (handle == ACE_INVALID_HANDLE)
|
||||
return ACE_INVALID_HANDLE;
|
||||
|
||||
// Unlink it so that the file will be removed automatically when the
|
||||
// process goes away.
|
||||
if (ACE_OS::unlink (name) == -1)
|
||||
@@ -659,47 +577,37 @@ ACE::open_temp_file (const ACE_TCHAR *name, int mode, int perm)
|
||||
// Return the handle.
|
||||
return handle;
|
||||
}
|
||||
|
||||
size_t
|
||||
ACE::strrepl (char *s, char search, char replace)
|
||||
{
|
||||
ACE_TRACE ("ACE::strrepl");
|
||||
|
||||
size_t replaced = 0;
|
||||
|
||||
for (size_t i = 0; s[i] != '\0'; i++)
|
||||
if (s[i] == search)
|
||||
{
|
||||
s[i] = replace;
|
||||
++replaced;
|
||||
}
|
||||
|
||||
return replaced;
|
||||
}
|
||||
|
||||
|
||||
// Split a string up into 'token'-delimited pieces, ala Perl's
|
||||
// "split".
|
||||
|
||||
char *
|
||||
ACE::strsplit_r (char *str,
|
||||
const char *token,
|
||||
char *&next_start)
|
||||
{
|
||||
char *result = 0;
|
||||
|
||||
if (str != 0)
|
||||
next_start = str;
|
||||
|
||||
if (next_start != 0)
|
||||
{
|
||||
char *tok_loc = ACE_OS::strstr (next_start, token);
|
||||
|
||||
if (tok_loc != 0)
|
||||
{
|
||||
// Return the beginning of the string.
|
||||
result = next_start;
|
||||
|
||||
// Insure it's terminated.
|
||||
*tok_loc = '\0';
|
||||
next_start = tok_loc + ACE_OS::strlen (token);
|
||||
@@ -710,10 +618,8 @@ ACE::strsplit_r (char *str,
|
||||
next_start = (char *) 0;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#if defined (ACE_HAS_WCHAR)
|
||||
wchar_t *
|
||||
ACE::strsplit_r (wchar_t *str,
|
||||
@@ -721,19 +627,15 @@ ACE::strsplit_r (wchar_t *str,
|
||||
wchar_t *&next_start)
|
||||
{
|
||||
wchar_t *result = 0;
|
||||
|
||||
if (str != 0)
|
||||
next_start = str;
|
||||
|
||||
if (next_start != 0)
|
||||
{
|
||||
wchar_t *tok_loc = ACE_OS::strstr (next_start, token);
|
||||
|
||||
if (tok_loc != 0)
|
||||
{
|
||||
// Return the beginning of the string.
|
||||
result = next_start;
|
||||
|
||||
// Insure it's terminated.
|
||||
*tok_loc = '\0';
|
||||
next_start = tok_loc + ACE_OS::strlen (token);
|
||||
@@ -744,27 +646,21 @@ ACE::strsplit_r (wchar_t *str,
|
||||
next_start = (wchar_t *) 0;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t
|
||||
ACE::strrepl (wchar_t *s, wchar_t search, wchar_t replace)
|
||||
{
|
||||
ACE_TRACE ("ACE::strrepl");
|
||||
|
||||
size_t replaced = 0;
|
||||
|
||||
for (size_t i = 0; s[i] != '\0'; i++)
|
||||
if (s[i] == search)
|
||||
{
|
||||
s[i] = replace;
|
||||
++replaced;
|
||||
}
|
||||
|
||||
return replaced;
|
||||
}
|
||||
#endif /* ACE_HAS_WCHAR */
|
||||
|
||||
ACE_END_VERSIONED_NAMESPACE_DECL
|
||||
|
||||
|
||||
Reference in New Issue
Block a user