summaryrefslogtreecommitdiff
path: root/ACE/ace
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>2006-12-28 15:02:27 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>2006-12-28 15:02:27 +0000
commit94f4b0ba8f212bb09b5efa14e4c95528773f8a69 (patch)
treee002c3df98658bcc81598476ea9e547deba7cf22 /ACE/ace
parent14459d2552fe459d06c6212e8e0505fdfdcfb29d (diff)
downloadATCD-94f4b0ba8f212bb09b5efa14e4c95528773f8a69.tar.gz
ChangeLogTag:Thu
Diffstat (limited to 'ACE/ace')
-rw-r--r--ACE/ace/ARGV.cpp6
-rw-r--r--ACE/ace/ARGV.h11
-rw-r--r--ACE/ace/ARGV.inl4
-rw-r--r--ACE/ace/OS_NS_unistd.cpp11
4 files changed, 21 insertions, 11 deletions
diff --git a/ACE/ace/ARGV.cpp b/ACE/ace/ARGV.cpp
index de4a4ef6a3b..bbc361e48af 100644
--- a/ACE/ace/ARGV.cpp
+++ b/ACE/ace/ARGV.cpp
@@ -154,7 +154,7 @@ ACE_ARGV_T<CHAR_TYPE>::ACE_ARGV_T (CHAR_TYPE *first_argv[],
quote_args);
// convert the second argv to a string
- second_argc = ACE_OS::argv_to_string (second_argv,
+ second_argc = ACE_OS::argv_to_string (second_argv,
second_buf,
substitute_env_args,
quote_args);
@@ -249,10 +249,10 @@ ACE_ARGV_T<CHAR_TYPE>::add (const CHAR_TYPE *next_arg, bool quote_arg)
template <typename CHAR_TYPE>
int
-ACE_ARGV_T<CHAR_TYPE>::add (CHAR_TYPE *argv[])
+ACE_ARGV_T<CHAR_TYPE>::add (CHAR_TYPE *argv[], bool quote_args)
{
for (int i = 0; argv[i] != 0; i++)
- if (this->add (argv[i], true) == -1)
+ if (this->add (argv[i], quote_args) == -1)
return -1;
return 0;
diff --git a/ACE/ace/ARGV.h b/ACE/ace/ARGV.h
index 446620a9060..15b583dbbf4 100644
--- a/ACE/ace/ARGV.h
+++ b/ACE/ace/ARGV.h
@@ -129,7 +129,7 @@ public:
* in place of the environment variable name.
*
* @param quote_args If non-zero each argument @a argv[i] needs to
- * be enclosed in double quotes ('"').
+ * be enclosed in double quotes ('"').
*/
ACE_ARGV_T (CHAR_TYPE *argv[],
bool substitute_env_args = true,
@@ -148,6 +148,10 @@ public:
* reference (e.g., @c $VAR) will have its environment
* variable value in the resultant vector in place
* of the environment variable name.
+ *
+ * @param quote_args If non-zero each arguments @a first_argv[i] and
+ * @a second_argv[i] needs to be enclosed
+ * in double quotes ('"').
*/
ACE_ARGV_T (CHAR_TYPE *first_argv[],
CHAR_TYPE *second_argv[],
@@ -234,11 +238,14 @@ public:
* @param argv Pointers to the arguments to add to the vector.
* @a argv must be terminated by a 0 pointer.
*
+ * @param quote_args If non-zero each argument @a argv[i] needs to
+ * be enclosed in double quotes ('"').
+ *
* @retval 0 on success; -1 on failure. Most likely @c errno values are:
* - EINVAL: This object is not in iterative mode.
* - ENOMEM: Not enough memory available to save @a next_arg.
*/
- int add (CHAR_TYPE *argv[]);
+ int add (CHAR_TYPE *argv[], bool quote_args = false);
private:
/// Copy constructor not implemented.
diff --git a/ACE/ace/ARGV.inl b/ACE/ace/ARGV.inl
index 5ea1df3608f..e84166f49ba 100644
--- a/ACE/ace/ARGV.inl
+++ b/ACE/ace/ARGV.inl
@@ -43,6 +43,10 @@ ACE_INLINE int
ACE_ARGV_T<CHAR_TYPE>::argc (void) const
{
ACE_TRACE ("ACE_ARGV_T::argc");
+ // Try to create the argv_ if it isn't there
+ ACE_ARGV_T<CHAR_TYPE> *nonconst_this =
+ const_cast <ACE_ARGV_T<CHAR_TYPE> *> (this);
+ (void) nonconst_this->argv ();
return this->argc_;
}
diff --git a/ACE/ace/OS_NS_unistd.cpp b/ACE/ace/OS_NS_unistd.cpp
index fdbfedbd345..10ba2d9a0b2 100644
--- a/ACE/ace/OS_NS_unistd.cpp
+++ b/ACE/ace/OS_NS_unistd.cpp
@@ -80,7 +80,8 @@ ACE_OS::argv_to_string (ACE_TCHAR **argv,
}
}
#endif /* ACE_LACKS_ENV */
- if (ACE_OS::strchr (argv_p[i], ACE_LIB_TEXT (' ')) != 0)
+ if (quote_args
+ && ACE_OS::strchr (argv_p[i], ACE_LIB_TEXT (' ')) != 0)
{
if (argv_p == argv)
{
@@ -97,7 +98,7 @@ ACE_OS::argv_to_string (ACE_TCHAR **argv,
if (ACE_OS::strchr (temp, ACE_LIB_TEXT ('"')) != 0)
{
for (int j = 0; temp[j] != 0; ++j)
- if (temp[j] == ACE_LIB_TEXT ('"'))
+ if (temp[j] == ACE_LIB_TEXT ('"'))
++quotes;
}
argv_p[i] =
@@ -110,8 +111,7 @@ ACE_OS::argv_to_string (ACE_TCHAR **argv,
}
ACE_TCHAR *end = argv_p[i];
- if (quote_args)
- *end++ = ACE_LIB_TEXT ('"');
+ *end++ = ACE_LIB_TEXT ('"');
if (quotes > 0)
{
@@ -126,8 +126,7 @@ ACE_OS::argv_to_string (ACE_TCHAR **argv,
else
end = ACE_OS::strecpy (end, temp);
- if (quote_args)
- end[-1] = ACE_LIB_TEXT ('"');
+ end[-1] = ACE_LIB_TEXT ('"');
*end = ACE_LIB_TEXT ('\0');
if (temp != argv[i])