summaryrefslogtreecommitdiff
path: root/ace
diff options
context:
space:
mode:
Diffstat (limited to 'ace')
-rw-r--r--ace/ACE.cpp6
-rw-r--r--ace/ACE.h17
2 files changed, 18 insertions, 5 deletions
diff --git a/ace/ACE.cpp b/ace/ACE.cpp
index adea0874652..f1c924305a4 100644
--- a/ace/ACE.cpp
+++ b/ace/ACE.cpp
@@ -254,7 +254,8 @@ const ACE_TCHAR *
ACE::execname (const ACE_TCHAR *old_name)
{
#if defined (ACE_WIN32)
- if (ACE_OS::strstr (old_name, ACE_LIB_TEXT (".exe")) == 0)
+ const ACE_TCHAR *suffix = ACE_OS::strrchr (old_name, ACE_LIB_TEXT ('.'));
+ if (suffix == 0 || ACE_OS::strcasecmp (suffix, ACE_LIB_TEXT (".exe")) != 0)
{
ACE_TCHAR *new_name;
@@ -271,7 +272,8 @@ ACE::execname (const ACE_TCHAR *old_name)
end = ACE_OS::strecpy (new_name, old_name);
// Concatenate the .exe suffix onto the end of the executable.
- ACE_OS::strcpy (end, ACE_LIB_TEXT (".exe"));
+ // end points _after_ the terminating nul.
+ ACE_OS::strcpy (end - 1, ACE_LIB_TEXT (".exe"));
return new_name;
}
diff --git a/ace/ACE.h b/ace/ACE.h
index 21a0a35fafb..1972b3e679f 100644
--- a/ace/ACE.h
+++ b/ace/ACE.h
@@ -407,9 +407,20 @@ public:
#endif /* ACE_HAS_WCHAR */
/**
- * On Win32 returns <pathname> if it already ends in ".exe,"
- * otherwise returns a dynamically allocated buffer containing
- * "<pathname>.exe". Always returns <pathname> on UNIX.
+ * On Windows, determines if a specified pathname ends with ".exe"
+ * (not case sensitive). If on Windows and there is no ".exe" suffix,
+ * a new ACE_TCHAR array is allocated and a copy of @c pathname with
+ * the ".exe" suffix is copied into it. In this case, the caller is
+ * responsible for calling delete [] on the returned pointer.
+ *
+ * @param pathname The name to check for a proper suffix.
+ *
+ * @retval @c pathname if there is a proper suffix for Windows. This is
+ * always the return value for non-Windows platforms.
+ * @retval If a suffix needs to be added, returns a pointer to new[]
+ * allocated memory containing the original @c pathname plus
+ * a ".exe" suffix. The caller is responsible for freeing the
+ * memory using delete [].
*/
static const ACE_TCHAR *execname (const ACE_TCHAR *pathname);