Don't strip trailing spaces from the command line
[reactos.git] / reactos / base / shell / cmd / cmd.c
index 56a5623..3b310b1 100644 (file)
@@ -790,7 +790,6 @@ VOID ParseCommandLine (LPTSTR cmd)
                _tcscpy(err, bc->Err);
        }
 
-
        /* Set up the initial conditions ... */
        /* preserve STDIN, STDOUT and STDERR handles */
        hOldConIn  = GetStdHandle (STD_INPUT_HANDLE);
@@ -811,18 +810,9 @@ VOID ParseCommandLine (LPTSTR cmd)
                                    FILE_ATTRIBUTE_NORMAL, NULL);
                if (hFile == INVALID_HANDLE_VALUE)
                {
-                       if (bc)
-                       {
-                               /* will fail for windows gui apps */
-                               num = 0;
-                               bc->hBatchFile = INVALID_HANDLE_VALUE;
-                       }
-                       else
-                       {
-                               LoadString(CMD_ModuleHandle, STRING_CMD_ERROR1, szMsg, RC_STRING_MAX_SIZE);
-                               ConErrPrintf(szMsg, in);
-                               return;
-                       }
+                       LoadString(CMD_ModuleHandle, STRING_CMD_ERROR1, szMsg, RC_STRING_MAX_SIZE);
+                       ConErrPrintf(szMsg, in);
+                       return;
                }
 
                if (!SetStdHandle (STD_INPUT_HANDLE, hFile))
@@ -901,7 +891,7 @@ VOID ParseCommandLine (LPTSTR cmd)
 
        /* Now set up the end conditions... */
        /* redirect STDOUT */
-       if ((bc) && (bc->hBatchFile != INVALID_HANDLE_VALUE) && (out[0]))
+       if (out[0])
        {
                /* Final output to here */
                HANDLE hFile;
@@ -968,7 +958,7 @@ VOID ParseCommandLine (LPTSTR cmd)
        }
 
        /* redirect STDERR */
-       if ((bc) && (bc->hBatchFile != INVALID_HANDLE_VALUE) && (err[0]))
+       if (err[0])
        {
                /* Final output to here */
                HANDLE hFile;
@@ -1186,7 +1176,7 @@ GetEnvVarOrSpecial ( LPCTSTR varName )
                                if (i > 0)
                                {
                                        if (StringPart[1] < 0)
-                                               StringPart[1] = _tcslen(ret + StringPart[0]) - 1 + StringPart[1];
+                                               StringPart[1] = _tcslen(ret + StringPart[0]) + StringPart[1];
                                        _tcsncpy(ReturnValue, ret + StringPart[0], StringPart[1]);
                                        _tcscpy(ret, ReturnValue);
                                }
@@ -1305,8 +1295,7 @@ GetParsedEnvVar ( LPCTSTR varName, UINT* varNameLen, BOOL ModeSetA )
                if (_tcsncicmp(varName, _T("dp0"), 3) == 0)
                {
                        if ( varNameLen )
-                               *varNameLen = 4;
-                       varName += 2;
+                               *varNameLen = 5;
                        return bc->BatchFilePath;
                }
        case _T('0'):
@@ -1466,7 +1455,7 @@ ProcessInput (BOOL bFlag)
                                }
                        }
 
-                       if (_istcntrl (*ip))
+                       if (*ip != _T('\0') && (_istcntrl (*ip)))
                                *ip = _T(' ');
                        *cp++ = *ip++;
 
@@ -1540,11 +1529,6 @@ ProcessInput (BOOL bFlag)
 
                *cp = _T('\0');
 
-               /* strip trailing spaces */
-               while ((--cp >= commandline) && _istspace (*cp));
-
-               *(cp + 1) = _T('\0');
-
                /* JPP 19980807 */
                /* Echo batch file line */
                if (bEchoThisLine)
@@ -1775,10 +1759,6 @@ Initialize (int argc, const TCHAR* argv[])
        InitLastPath ();
 #endif
 
-#ifdef FATURE_ALIASES
-       InitializeAlias ();
-#endif
-
        if (argc >= 2)
        {
                for (i = 1; i < argc; i++)
@@ -1856,7 +1836,7 @@ Initialize (int argc, const TCHAR* argv[])
             _T(KERNEL_RELEASE_STR),
             _T(KERNEL_VERSION_BUILD_STR));
 
-           ConOutPuts (_T("(C) Copyright 1998-" COPYRIGHT_YEAR " ReactOS Team.\n"));
+           ConOutPuts (_T("(C) Copyright 1998-") _T(COPYRIGHT_YEAR) _T(" ReactOS Team.\n"));
     }
 
     ExecuteAutoRunFile ();
@@ -1899,10 +1879,6 @@ static VOID Cleanup (int argc, const TCHAR *argv[])
                ParseCommandLine (_T("\\cmdexit.bat"));
        }
 
-#ifdef FEATURE_ALIASES
-       DestroyAlias ();
-#endif
-
 #ifdef FEATURE_DIECTORY_STACK
        /* destroy directory stack */
        DestroyDirectoryStack ();