summaryrefslogtreecommitdiff
path: root/ace/OS.cpp
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2003-04-16 20:57:05 +0000
committerSteve Huston <shuston@riverace.com>2003-04-16 20:57:05 +0000
commit1de1cfc6d4a4ae18177d261f2f41986d04072377 (patch)
tree6db0a279af61014650d05783e89be22ff06d1347 /ace/OS.cpp
parent7a96e9028753f86ff5b2b8fd80f5534720e84501 (diff)
downloadATCD-1de1cfc6d4a4ae18177d261f2f41986d04072377.tar.gz
ChangeLogTag:Fri Mar 28 16:04:28 2003 Steve Huston <shuston@riverace.com>
Diffstat (limited to 'ace/OS.cpp')
-rw-r--r--ace/OS.cpp158
1 files changed, 12 insertions, 146 deletions
diff --git a/ace/OS.cpp b/ace/OS.cpp
index 09d88b6a746..801ab5d246d 100644
--- a/ace/OS.cpp
+++ b/ace/OS.cpp
@@ -3914,29 +3914,29 @@ ACE_OS::string_to_argv (ACE_TCHAR *buf,
// First pass: count arguments.
// '#' is the start-comment token..
- while (*cp != '\0' && *cp != '#')
+ while (*cp != ACE_LIB_TEXT ('\0') && *cp != ACE_LIB_TEXT ('#'))
{
// Skip whitespace..
while (ACE_OS::ace_isspace (*cp))
cp++;
// Increment count and move to next whitespace..
- if (*cp != '\0')
+ if (*cp != ACE_LIB_TEXT ('\0'))
argc++;
- while (*cp != '\0' && !ACE_OS::ace_isspace (*cp))
+ while (*cp != ACE_LIB_TEXT ('\0') && !ACE_OS::ace_isspace (*cp))
{
// Grok quotes....
- if (*cp == '\'' || *cp == '"')
+ if (*cp == ACE_LIB_TEXT ('\'') || *cp == ACE_LIB_TEXT ('"'))
{
ACE_TCHAR quote = *cp;
// Scan past the string..
- for (cp++; *cp != '\0' && *cp != quote; cp++)
+ for (cp++; *cp != ACE_LIB_TEXT ('\0') && *cp != quote; cp++)
continue;
// '\0' implies unmatched quote..
- if (*cp == '\0')
+ if (*cp == ACE_LIB_TEXT ('\0'))
{
argc--;
break;
@@ -3975,12 +3975,12 @@ ACE_OS::string_to_argv (ACE_TCHAR *buf,
// Copy next argument and move to next whitespace..
cp = argp;
- while (*ptr != '\0' && !ACE_OS::ace_isspace (*ptr))
- if (*ptr == '\'' || *ptr == '"')
+ while (*ptr != ACE_LIB_TEXT ('\0') && !ACE_OS::ace_isspace (*ptr))
+ if (*ptr == ACE_LIB_TEXT ('\'') || *ptr == ACE_LIB_TEXT ('"'))
{
ACE_TCHAR quote = *ptr++;
- while (*ptr != '\0' && *ptr != quote)
+ while (*ptr != ACE_LIB_TEXT ('\0') && *ptr != quote)
*cp++ = *ptr++;
if (*ptr == quote)
@@ -3989,7 +3989,7 @@ ACE_OS::string_to_argv (ACE_TCHAR *buf,
else
*cp++ = *ptr++;
- *cp = '\0';
+ *cp = ACE_LIB_TEXT ('\0');
#if !defined (ACE_LACKS_ENV)
// Check for environment variable substitution here.
@@ -4016,8 +4016,8 @@ ACE_OS::string_to_argv (ACE_TCHAR *buf,
errno = ENOMEM;
return -1;
}
- }
- }
+ }
+ }
if (argp != arg)
delete [] argp;
@@ -6955,140 +6955,6 @@ ACE_OS_Object_Manager_Manager::~ACE_OS_Object_Manager_Manager (void)
static ACE_OS_Object_Manager_Manager ACE_OS_Object_Manager_Manager_instance;
#endif /* ! ACE_HAS_NONSTATIC_OBJECT_MANAGER */
-# if defined (ACE_HAS_WINCE)
-ACE_CE_ARGV::ACE_CE_ARGV(ACE_TCHAR* cmdLine)
-: ce_argv_(0)
-, ce_argc_(0)
-{
- // Note: ACE has argv parser and processor; however, they cannot be
- // used because of dependency. ACE_OS is now separate from ACE, and
- // ACE depends on ACE_OS. Still, using all this array and complicated
- // pointer manipulation should be considered to be replaced and use STL
- // (or something) for better readability and code management. Also,
- // string_to_argv() does not work well for CE argv because of incorrect
- // '"' identification.
- const ACE_TCHAR* dummyArgv = ACE_TEXT("root"); // dummy for the first argv
- const ACE_TCHAR* separator = ACE_TEXT(" "); // blank space is a separator
-
- int formattedCmdLineLength =
- ACE_OS::strlen(dummyArgv) + ACE_OS::strlen(separator) + 1; // for 0 term.
- if (ACE_OS::strlen(cmdLine) > 0)
- {
- formattedCmdLineLength += ACE_OS::strlen(cmdLine);
- formattedCmdLineLength += ACE_OS::strlen(separator);
- }
-
- // formattedCmdLine will have dummyArgv and a separator at the beginning
- // of cmdLine and a separator at the end to generalize format and reduce
- // the amount of code.
- ACE_TCHAR* formattedCmdLine = 0;
- ACE_NEW(formattedCmdLine, ACE_TCHAR[formattedCmdLineLength]);
-
- ACE_OS::strcpy(formattedCmdLine, dummyArgv);
- ACE_OS::strcat(formattedCmdLine, separator);
-
- // start with 1 because of the dummyArgv at the beginning
- int max_possible_argc = 1;
- if (ACE_OS::strlen(cmdLine) > 0)
- {
- int formattedPos = ACE_OS::strlen(formattedCmdLine);
- int cmdLineLength = ACE_OS::strlen(cmdLine);
-
- // Inside of this for loop, it does same thing as strcat except it
- // checks and puts only one single white space between two argv entries.
- for (int i = 0; i < cmdLineLength; ++i)
- {
- if (iswspace(cmdLine[i]) != 0)
- ++max_possible_argc; // counting the number of white spaces
-
- formattedCmdLine[formattedPos++] = cmdLine[i];
-
- if (iswspace(cmdLine[i]) != 0)
- {
- // make sure there is only one white space between two
- // argv entries.
- while ((i < cmdLineLength) && (iswspace(cmdLine[i + 1]) != 0))
- ++i;
- }
- }
-
- formattedCmdLine[formattedPos] = 0;
- // make sure formattedCmdLine ends with a blank
- ACE_OS::strcat (formattedCmdLine, separator);
- }
-
- int formattedCmdLength = ACE_OS::strlen(formattedCmdLine);
-
- int insideQuotation = 0;
- int* argv_strlen = 0;
- int entry_size = 0;
- ACE_NEW (argv_strlen, int[max_possible_argc]);
-
- // determine argc
- for (int i = 0; i < formattedCmdLength; ++i)
- {
- if (formattedCmdLine[i] == '\\')
- {
- ++i; // ignore the following character
- ++entry_size;
- }
- else if (formattedCmdLine[i] == '"')
- {
- insideQuotation = (insideQuotation ? 0 : 1);
- }
- else if ((!insideQuotation) && (iswspace(formattedCmdLine[i]) != 0))
- {
- // new argv entry end found
- argv_strlen[ce_argc_++] = entry_size; // cache this entry size
- entry_size = 0;
- }
- else
- {
- ++entry_size;
- }
- }
-
- ACE_NEW (ce_argv_, ACE_TCHAR*[ce_argc_ + 1]);
- ce_argv_[ce_argc_] = 0; // Last command line entry is a NULL.
-
- for (int j = 0, cmdLinePos = 0; j < ce_argc_; ++j, ++cmdLinePos)
- {
- int length = argv_strlen[j];
-
- ACE_NEW (ce_argv_[j], ACE_TCHAR[length + 1]);
- ce_argv_[j][length] = 0; // string termination null
-
- if (iswspace (formattedCmdLine[cmdLinePos]) != 0)
- {
- // This is where prior argv has trailing '"' at the end.
- ++cmdLinePos;
- }
-
- for (int n = 0; n < length; ++n, ++cmdLinePos)
- {
- if ((formattedCmdLine[cmdLinePos] == '\\') ||
- (formattedCmdLine[cmdLinePos] == '"') )
- {
- ++cmdLinePos;
- }
-
- ce_argv_[j][n] = formattedCmdLine[cmdLinePos];
- }
- }
-
- delete argv_strlen;
- delete formattedCmdLine;
-}
-
-ACE_CE_ARGV::~ACE_CE_ARGV(void)
-{
- for (int i = 0; i < ce_argc_; ++i)
- delete [] ce_argv_[i];
-
- delete [] ce_argv_;
-}
-# endif // ACE_HAS_WINCE
-
// You may be asking yourself, why are we doing this? Well, in winbase.h,
// MS didn't follow their normal Api_FunctionA and Api_FunctionW style,
// so we have to #undef their define to get access to the unicode version.