update for HEAD-2003091401
[reactos.git] / lib / msvcrt / misc / getargs.c
index 9ce3a2c..c1cf4ec 100644 (file)
@@ -48,7 +48,7 @@ int add(char* name)
 int expand(char* name, int flag)
 {
     char* s;
-    WIN32_FIND_DATA fd;
+    WIN32_FIND_DATAA fd;
     HANDLE hFile;
     BOOLEAN first = TRUE;
     char buffer[256];
@@ -56,7 +56,7 @@ int expand(char* name, int flag)
 
     s = strpbrk(name, "*?");
     if (s && flag) {
-        hFile = FindFirstFile(name, &fd);
+        hFile = FindFirstFileA(name, &fd);
         if (hFile != INVALID_HANDLE_VALUE) {
             while(s != name && *s != '/' && *s != '\\')
                 s--;
@@ -74,7 +74,7 @@ int expand(char* name, int flag)
                     first = FALSE;
                 }
             }
-            while(FindNextFile(hFile, &fd));
+            while(FindNextFileA(hFile, &fd));
             FindClose(hFile);
         }
     }
@@ -87,17 +87,38 @@ int expand(char* name, int flag)
     return 0;
 }
 
+/*
+ * @unimplemented
+ */
 int __getmainargs(int* argc, char*** argv, char*** env, int flag)
 {
-    int i, afterlastspace;
+    int i, afterlastspace, ignorespace, len;
 
     /* missing threading init */
 
     i = 0;
     afterlastspace = 0;
+    ignorespace = 0;
+    len = strlen(_acmdln);
 
     while (_acmdln[i]) {
-        if (_acmdln[i] == ' ') {
+       if (_acmdln[i] == '"') {
+           if (_acmdln[i + 1] == '"') {
+               memmove(_acmdln + i, _acmdln + i + 1, len - i);
+               len--;
+           } else {
+               if(ignorespace) {
+                   ignorespace = 0;
+               } else {
+                   ignorespace = 1;
+               }
+               memmove(_acmdln + i, _acmdln + i + 1, len - i);
+               len--;
+               continue;
+           }
+       }
+
+        if (_acmdln[i] == ' ' && !ignorespace) {
             expand(strndup(_acmdln + afterlastspace, i - afterlastspace), flag);
             i++;
             while (_acmdln[i]==' ')
@@ -119,11 +140,17 @@ int __getmainargs(int* argc, char*** argv, char*** env, int flag)
     return 0;
 }
 
+/*
+ * @implemented
+ */
 int* __p___argc(void)
 {
     return &__argc;
 }
 
+/*
+ * @implemented
+ */
 char*** __p___argv(void)
 {
     return &__argv;