Author: hbelusca
Date: Sat Sep 30 14:04:24 2017
New Revision: 75999
URL:
http://svn.reactos.org/svn/reactos?rev=75999&view=rev
Log:
[CMD]: Minor modifications in the files I'm going to touch next:
- Use ARRAYSIZE() instead of hardcoding string buffer max. number of chars.
- Un-globalize a variable; remove dead defines.
- Minor code formatting fixes.
Modified:
trunk/reactos/base/shell/cmd/beep.c
trunk/reactos/base/shell/cmd/cls.c
trunk/reactos/base/shell/cmd/cmd.c
trunk/reactos/base/shell/cmd/cmd.h
trunk/reactos/base/shell/cmd/color.c
Modified: trunk/reactos/base/shell/cmd/beep.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/beep.c?rev=…
==============================================================================
--- trunk/reactos/base/shell/cmd/beep.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/beep.c [iso-8859-1] Sat Sep 30 14:04:24 2017
@@ -28,12 +28,11 @@
#ifdef INCLUDE_CMD_BEEP
-
-INT cmd_beep (LPTSTR param)
+INT cmd_beep(LPTSTR param)
{
- if (_tcsncmp (param, _T("/?"), 2) == 0)
+ if (_tcsncmp(param, _T("/?"), 2) == 0)
{
- ConOutResPaging(TRUE,STRING_BEEP_HELP);
+ ConOutResPaging(TRUE, STRING_BEEP_HELP);
return 0;
}
@@ -46,4 +45,5 @@
return 0;
}
+
#endif
Modified: trunk/reactos/base/shell/cmd/cls.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/cls.c?rev=7…
==============================================================================
--- trunk/reactos/base/shell/cmd/cls.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/cls.c [iso-8859-1] Sat Sep 30 14:04:24 2017
@@ -30,16 +30,16 @@
#ifdef INCLUDE_CMD_CLS
-INT cmd_cls (LPTSTR param)
+INT cmd_cls(LPTSTR param)
{
HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;
COORD coPos;
DWORD dwWritten;
- if (!_tcsncmp (param, _T("/?"), 2))
+ if (!_tcsncmp(param, _T("/?"), 2))
{
- ConOutResPaging(TRUE,STRING_CLS_HELP);
+ ConOutResPaging(TRUE, STRING_CLS_HELP);
return 0;
}
@@ -62,4 +62,5 @@
return 0;
}
+
#endif
Modified: trunk/reactos/base/shell/cmd/cmd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/cmd.c?rev=7…
==============================================================================
--- trunk/reactos/base/shell/cmd/cmd.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/cmd.c [iso-8859-1] Sat Sep 30 14:04:24 2017
@@ -144,10 +144,6 @@
#include "precomp.h"
#include <reactos/buildno.h>
#include <reactos/version.h>
-
-#ifndef NT_SUCCESS
-#define NT_SUCCESS(StatCode) ((NTSTATUS)(StatCode) >= 0)
-#endif
typedef NTSTATUS (WINAPI *NtQueryInformationProcessProc)(HANDLE, PROCESSINFOCLASS,
PVOID, ULONG, PULONG);
@@ -167,7 +163,6 @@
BOOL bTitleSet = FALSE;
DWORD dwChildProcessId = 0;
HANDLE hIn;
-HANDLE hOut;
LPTSTR lpOriginalEnvironment;
HANDLE CMD_ModuleHandle;
@@ -379,6 +374,7 @@
return 1;
}
+ /* Save the original console title and build a new one */
GetConsoleTitle(szWindowTitle, ARRAYSIZE(szWindowTitle));
bTitleSet = FALSE;
_stprintf(szNewTitle, _T("%s - %s%s"), szWindowTitle, First, Rest);
@@ -480,6 +476,8 @@
/* Get code page if it has been changed */
InputCodePage= GetConsoleCP();
OutputCodePage = GetConsoleOutputCP();
+
+ /* Restore the original console title */
if (!bTitleSet)
SetConsoleTitle(szWindowTitle);
@@ -565,7 +563,7 @@
* process the command line and execute the appropriate functions
* full input/output redirection and piping are supported
*/
-INT ParseCommandLine (LPTSTR cmd)
+INT ParseCommandLine(LPTSTR cmd)
{
INT Ret = 0;
PARSED_COMMAND *Cmd = ParseCommand(cmd);
@@ -591,7 +589,7 @@
PROCESS_INFORMATION prci;
/* Get the path to cmd.exe */
- GetModuleFileName(NULL, CmdPath, MAX_PATH);
+ GetModuleFileName(NULL, CmdPath, ARRAYSIZE(CmdPath));
/* Build the parameter string to pass to cmd.exe */
ParamsEnd = _stpcpy(CmdParams, _T("/S/D/C\""));
@@ -1414,7 +1412,7 @@
}
static VOID
-ProcessInput()
+ProcessInput(VOID)
{
PARSED_COMMAND *Cmd;
@@ -1487,15 +1485,15 @@
}
-VOID AddBreakHandler (VOID)
-{
- SetConsoleCtrlHandler ((PHANDLER_ROUTINE)BreakHandler, TRUE);
-}
-
-
-VOID RemoveBreakHandler (VOID)
-{
- SetConsoleCtrlHandler ((PHANDLER_ROUTINE)BreakHandler, FALSE);
+VOID AddBreakHandler(VOID)
+{
+ SetConsoleCtrlHandler(BreakHandler, TRUE);
+}
+
+
+VOID RemoveBreakHandler(VOID)
+{
+ SetConsoleCtrlHandler(BreakHandler, FALSE);
}
@@ -1505,7 +1503,7 @@
*/
#if 0
static VOID
-ShowCommands (VOID)
+ShowCommands(VOID)
{
/* print command list */
ConOutResPuts(STRING_CMD_HELP1);
@@ -1802,6 +1800,8 @@
TCHAR ModuleName[_MAX_PATH + 1];
INT nExitCode;
+ HANDLE hOut;
+
TCHAR *ptr, *cmdLine, option = 0;
BOOL AlwaysStrip = FALSE;
BOOL AutoRun = TRUE;
@@ -1993,29 +1993,29 @@
static VOID Cleanup(VOID)
{
- /* run cmdexit.bat */
- if (IsExistingFile (_T("cmdexit.bat")))
+ /* Run cmdexit.bat */
+ if (IsExistingFile(_T("cmdexit.bat")))
{
ConErrResPuts(STRING_CMD_ERROR5);
- ParseCommandLine (_T("cmdexit.bat"));
- }
- else if (IsExistingFile (_T("\\cmdexit.bat")))
- {
- ConErrResPuts (STRING_CMD_ERROR5);
- ParseCommandLine (_T("\\cmdexit.bat"));
+ ParseCommandLine(_T("cmdexit.bat"));
+ }
+ else if (IsExistingFile(_T("\\cmdexit.bat")))
+ {
+ ConErrResPuts(STRING_CMD_ERROR5);
+ ParseCommandLine(_T("\\cmdexit.bat"));
}
#ifdef FEATURE_DIRECTORY_STACK
- /* destroy directory stack */
- DestroyDirectoryStack ();
+ /* Destroy directory stack */
+ DestroyDirectoryStack();
#endif
#ifdef FEATURE_HISTORY
CleanHistory();
#endif
- /* free GetEnvVar's buffer */
+ /* Free GetEnvVar's buffer */
GetEnvVar(NULL);
/* Remove ctrl break handler */
Modified: trunk/reactos/base/shell/cmd/cmd.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/cmd.h?rev=7…
==============================================================================
--- trunk/reactos/base/shell/cmd/cmd.h [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/cmd.h [iso-8859-1] Sat Sep 30 14:04:24 2017
@@ -52,7 +52,6 @@
#define BUFF_SIZE 16384
/* Global variables */
-extern HANDLE hOut;
extern HANDLE hIn;
extern LPTSTR lpOriginalEnvironment;
extern WORD wColor;
@@ -145,7 +144,7 @@
/* Prototypes for COLOR.C */
BOOL SetScreenColor(WORD wColor, BOOL bNoFill);
-INT CommandColor (LPTSTR);
+INT CommandColor(LPTSTR);
VOID ConInDummy (VOID);
VOID ConInDisable (VOID);
Modified: trunk/reactos/base/shell/cmd/color.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/color.c?rev…
==============================================================================
--- trunk/reactos/base/shell/cmd/color.c [iso-8859-1] (original)
+++ trunk/reactos/base/shell/cmd/color.c [iso-8859-1] Sat Sep 30 14:04:24 2017
@@ -102,7 +102,7 @@
return 1;
}
}
- /* Color string: advanced choice: two-digits, "Color ON Color" ,
"Foreground ON Background" */
+ /* Color string: advanced choice: two-digits, "Color ON Color",
"Foreground ON Background" */
else if (StringToColor(&wColor, &rest) == FALSE)
{
/* Invalid color string */