Index: trunk/src/VBox/Runtime/common/misc/getopt.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/misc/getopt.cpp	(revision 34537)
+++ trunk/src/VBox/Runtime/common/misc/getopt.cpp	(revision 34542)
@@ -207,9 +207,8 @@
             {
                 /*
-                 * A value is required with the argument. We're trying to be very
+                 * A value is required with the argument. We're trying to be
                  * understanding here and will permit any of the following:
                  *      --long12:value,  --long12=value, --long12 value,
                  *      --long:value,    --long=value,   --long value,
-                 *      --long: value,   --long= value
                  *
                  * If the option is index, then all trailing chars must be
@@ -574,8 +573,7 @@
              * Find the argument value.
              *
-             * A value is required with the argument. We're trying to be very
+             * A value is required with the argument. We're trying to be
              * understanding here and will permit any of the following:
-             *      -svalue, -s:value, -s=value,
-             *      -s value, -s: value, -s= value
+             *      -svalue, -s value, -s:value and -s=value
              * (Ditto for long options.)
              */
@@ -583,8 +581,5 @@
             if (fShort)
             {
-                if (    pszArgThis[2] == '\0'
-                    ||  (  pszArgThis[3] == '\0'
-                         && (   pszArgThis[2] == ':'
-                             || pszArgThis[2] == '=')) )
+                if (pszArgThis[2] == '\0')
                 {
                     if (iThis + 1 >= pState->argc)
@@ -636,6 +631,5 @@
                 else
                 {
-                    if (    pszArgThis[cchLong]     == '\0'
-                        ||  pszArgThis[cchLong + 1] == '\0')
+                    if (pszArgThis[cchLong] == '\0')
                     {
                         if (iThis + 1 >= pState->argc)
Index: trunk/src/VBox/Runtime/testcase/tstRTGetOpt.cpp
===================================================================
--- trunk/src/VBox/Runtime/testcase/tstRTGetOpt.cpp	(revision 34537)
+++ trunk/src/VBox/Runtime/testcase/tstRTGetOpt.cpp	(revision 34542)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2007-2009 Oracle Corporation
+ * Copyright (C) 2007-2010 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -111,17 +111,22 @@
     {
         "-s",               "string1",
-        "--optwithstring",  "string2",
+        "-sstring2",
+        "-s:string3",
+        "-s=string4",
+        "-s:",
+        "-s=",
+        "--optwithstring",  "string5",
+        "--optwithstring:string6",
+        "--optwithstring=string7",
+        "--optwithstring:",
+        "--optwithstring=",
 
         "-i",               "-42",
         "-i:-42",
         "-i=-42",
-        "-i:",              "-42",
-        "-i=",              "-42",
 
         "--optwithint",     "42",
         "--optwithint:42",
         "--optwithint=42",
-        "--optwithint:",    "42",
-        "--optwithint=",    "42",
 
         "-v",
@@ -134,5 +139,5 @@
 
         "nodash",
-        "nodashval",        "string3",
+        "nodashval",        "string9",
 
         "filename1",
@@ -147,10 +152,12 @@
         "--mac:1:::::c",
 
-        "--strindex786",    "string4",
-        "--strindex786:string5",
-        "--strindex786=string6",
-        "strindex687",      "string7",
-        "strindex687:string8",
-        "strindex687=string9",
+        "--strindex786",    "string10",
+        "--strindex786:string11",
+        "--strindex786=string12",
+        "strindex687",      "string13",
+        "strindex687:string14",
+        "strindex687=string15",
+        "strindex688:",
+        "strindex689=",
         "--intindex137",    "1000",
         "--macindex138",    "08:0:27:00:ab:f3",
@@ -191,6 +198,33 @@
     CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, "string1"));
     CHECK(GetState.uIndex == UINT32_MAX);
+    CHECK_GETOPT(RTGetOpt(&GetState, &Val), 's', 1);
+    CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, "string2"));
+    CHECK(GetState.uIndex == UINT32_MAX);
+    CHECK_GETOPT(RTGetOpt(&GetState, &Val), 's', 1);
+    CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, "string3"));
+    CHECK(GetState.uIndex == UINT32_MAX);
+    CHECK_GETOPT(RTGetOpt(&GetState, &Val), 's', 1);
+    CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, "string4"));
+    CHECK(GetState.uIndex == UINT32_MAX);
+    CHECK_GETOPT(RTGetOpt(&GetState, &Val), 's', 1);
+    CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, ""));
+    CHECK(GetState.uIndex == UINT32_MAX);
+    CHECK_GETOPT(RTGetOpt(&GetState, &Val), 's', 1);
+    CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, ""));
+    CHECK(GetState.uIndex == UINT32_MAX);
     CHECK_GETOPT(RTGetOpt(&GetState, &Val), 's', 2);
-    CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, "string2"));
+    CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, "string5"));
+    CHECK(GetState.uIndex == UINT32_MAX);
+    CHECK_GETOPT(RTGetOpt(&GetState, &Val), 's', 1);
+    CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, "string6"));
+    CHECK(GetState.uIndex == UINT32_MAX);
+    CHECK_GETOPT(RTGetOpt(&GetState, &Val), 's', 1);
+    CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, "string7"));
+    CHECK(GetState.uIndex == UINT32_MAX);
+    CHECK_GETOPT(RTGetOpt(&GetState, &Val), 's', 1);
+    CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, ""));
+    CHECK(GetState.uIndex == UINT32_MAX);
+    CHECK_GETOPT(RTGetOpt(&GetState, &Val), 's', 1);
+    CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, ""));
     CHECK(GetState.uIndex == UINT32_MAX);
 
@@ -201,8 +235,4 @@
     CHECK(Val.i32 == -42);
     CHECK_GETOPT(RTGetOpt(&GetState, &Val), 'i', 1);
-    CHECK(Val.i32 == -42);
-    CHECK_GETOPT(RTGetOpt(&GetState, &Val), 'i', 2);
-    CHECK(Val.i32 == -42);
-    CHECK_GETOPT(RTGetOpt(&GetState, &Val), 'i', 2);
     CHECK(Val.i32 == -42);
 
@@ -213,8 +243,4 @@
     CHECK(Val.i32 == 42);
     CHECK_GETOPT(RTGetOpt(&GetState, &Val), 'i', 1);
-    CHECK(Val.i32 == 42);
-    CHECK_GETOPT(RTGetOpt(&GetState, &Val), 'i', 2);
-    CHECK(Val.i32 == 42);
-    CHECK_GETOPT(RTGetOpt(&GetState, &Val), 'i', 2);
     CHECK(Val.i32 == 42);
 
@@ -239,5 +265,5 @@
     CHECK_pDef(s_aOpts2, 7);
     CHECK_GETOPT(RTGetOpt(&GetState, &Val), 388, 2);
-    CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, "string3"));
+    CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, "string9"));
 
     /* non-option, option, non-option  */
@@ -282,26 +308,34 @@
     RTTestSub(hTest, "RTGetOpt - Option w/ Index");
     CHECK_GETOPT(RTGetOpt(&GetState, &Val), 400, 2);
-    CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, "string4"));
+    CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, "string10"));
     CHECK(GetState.uIndex == 786);
 
     CHECK_GETOPT(RTGetOpt(&GetState, &Val), 400, 1);
-    CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, "string5"));
+    CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, "string11"));
     CHECK(GetState.uIndex == 786);
 
     CHECK_GETOPT(RTGetOpt(&GetState, &Val), 400, 1);
-    CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, "string6"));
+    CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, "string12"));
     CHECK(GetState.uIndex == 786);
 
     CHECK_GETOPT(RTGetOpt(&GetState, &Val), 400, 2);
-    CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, "string7"));
+    CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, "string13"));
     CHECK(GetState.uIndex == 687);
 
     CHECK_GETOPT(RTGetOpt(&GetState, &Val), 400, 1);
-    CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, "string8"));
+    CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, "string14"));
     CHECK(GetState.uIndex == 687);
 
     CHECK_GETOPT(RTGetOpt(&GetState, &Val), 400, 1);
-    CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, "string9"));
+    CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, "string15"));
     CHECK(GetState.uIndex == 687);
+
+    CHECK_GETOPT(RTGetOpt(&GetState, &Val), 400, 1);
+    CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, ""));
+    CHECK(GetState.uIndex == 688);
+
+    CHECK_GETOPT(RTGetOpt(&GetState, &Val), 400, 1);
+    CHECK(VALID_PTR(Val.psz) && !strcmp(Val.psz, ""));
+    CHECK(GetState.uIndex == 689);
 
     CHECK_GETOPT(RTGetOpt(&GetState, &Val), 401, 2);
@@ -416,6 +450,6 @@
         "foo6",
         "foo7",
-        "-i:",              "-42",
-        "-i=",              "-42",
+        "-i:-42",
+        "-i=-42",
         "foo8",
         "--twovalues",       "firstvalue", "secondvalue",
@@ -449,7 +483,7 @@
     CHECK_GETOPT(RTGetOpt(&GetState, &Val), 'i', 1);
     CHECK(Val.i32 == -42);
-    CHECK_GETOPT(RTGetOpt(&GetState, &Val), 'i', 2);
-    CHECK(Val.i32 == -42);
-    CHECK_GETOPT(RTGetOpt(&GetState, &Val), 'i', 2);
+    CHECK_GETOPT(RTGetOpt(&GetState, &Val), 'i', 1);
+    CHECK(Val.i32 == -42);
+    CHECK_GETOPT(RTGetOpt(&GetState, &Val), 'i', 1);
     CHECK(Val.i32 == -42);
 
@@ -502,6 +536,6 @@
         "foo6",
         "foo7",
-        "-i:",              "-42",
-        "-i=",              "-42",
+        "-i:-42",
+        "-i=-42",
         "foo8",
         "--twovalues",       "firstvalue", "secondvalue",
@@ -533,7 +567,7 @@
     CHECK_GETOPT(RTGetOpt(&GetState, &Val), 'i', 1);
     CHECK(Val.i32 == -42);
-    CHECK_GETOPT(RTGetOpt(&GetState, &Val), 'i', 2);
-    CHECK(Val.i32 == -42);
-    CHECK_GETOPT(RTGetOpt(&GetState, &Val), 'i', 2);
+    CHECK_GETOPT(RTGetOpt(&GetState, &Val), 'i', 1);
+    CHECK(Val.i32 == -42);
+    CHECK_GETOPT(RTGetOpt(&GetState, &Val), 'i', 1);
     CHECK(Val.i32 == -42);
 
