mirror of
https://github.com/reactos/reactos.git
synced 2024-12-26 17:14:41 +00:00
Various improvements by Carl Nettelblad.
svn path=/trunk/; revision=1651
This commit is contained in:
parent
80ec0821f8
commit
ea6cacb6ed
6 changed files with 46 additions and 15 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: batch.c,v 1.3 1999/10/03 22:20:32 ekohl Exp $
|
/* $Id: batch.c,v 1.4 2001/02/28 22:33:23 ekohl Exp $
|
||||||
*
|
*
|
||||||
* BATCH.C - batch file processor for CMD.EXE.
|
* BATCH.C - batch file processor for CMD.EXE.
|
||||||
*
|
*
|
||||||
|
@ -51,6 +51,9 @@
|
||||||
* 26-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
* 26-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
* Replaced CRT io functions by Win32 io functions.
|
* Replaced CRT io functions by Win32 io functions.
|
||||||
* Unicode safe!
|
* Unicode safe!
|
||||||
|
*
|
||||||
|
* 23-Feb-2001 (Carl Nettelblad <cnettel@hem.passagen.es>)
|
||||||
|
* Fixes made to get "for" working.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -294,7 +297,6 @@ BOOL Batch (LPTSTR fullname, LPTSTR firstword, LPTSTR param)
|
||||||
|
|
||||||
LPTSTR ReadBatchLine (LPBOOL bLocalEcho)
|
LPTSTR ReadBatchLine (LPBOOL bLocalEcho)
|
||||||
{
|
{
|
||||||
HANDLE hFind = INVALID_HANDLE_VALUE;
|
|
||||||
LPTSTR first;
|
LPTSTR first;
|
||||||
LPTSTR ip;
|
LPTSTR ip;
|
||||||
|
|
||||||
|
@ -346,7 +348,8 @@ LPTSTR ReadBatchLine (LPBOOL bLocalEcho)
|
||||||
if (bc->ffind)
|
if (bc->ffind)
|
||||||
{
|
{
|
||||||
/* First already done so do next */
|
/* First already done so do next */
|
||||||
fv = FindNextFile (hFind, bc->ffind) ? bc->ffind->cFileName : NULL;
|
|
||||||
|
fv = FindNextFile (bc->hFind, bc->ffind) ? bc->ffind->cFileName : NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -357,8 +360,9 @@ LPTSTR ReadBatchLine (LPBOOL bLocalEcho)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
hFind = FindFirstFile (fv, bc->ffind);
|
bc->hFind = FindFirstFile (fv, bc->ffind);
|
||||||
fv = !(hFind==INVALID_HANDLE_VALUE) ? bc->ffind->cFileName : NULL;
|
|
||||||
|
fv = !(bc->hFind==INVALID_HANDLE_VALUE) ? bc->ffind->cFileName : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fv == NULL)
|
if (fv == NULL)
|
||||||
|
|
|
@ -16,12 +16,11 @@ typedef struct tagBATCHCONTEXT
|
||||||
LPTSTR forproto;
|
LPTSTR forproto;
|
||||||
LPTSTR params;
|
LPTSTR params;
|
||||||
INT shiftlevel;
|
INT shiftlevel;
|
||||||
BOOL bEcho; /* Preserve echo flag across batch calls [HBP_001] */
|
BOOL bEcho; /* Preserve echo flag across batch calls */
|
||||||
|
HANDLE hFind; /* Preserve find handle when doing a for */
|
||||||
TCHAR forvar;
|
TCHAR forvar;
|
||||||
} BATCH_CONTEXT, *LPBATCH_CONTEXT;
|
} BATCH_CONTEXT, *LPBATCH_CONTEXT;
|
||||||
|
|
||||||
/* HBP_002 } */
|
|
||||||
|
|
||||||
|
|
||||||
/* The stack of current batch contexts.
|
/* The stack of current batch contexts.
|
||||||
* NULL when no batch is active
|
* NULL when no batch is active
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: cmd.c,v 1.23 2001/02/03 10:40:19 ekohl Exp $
|
/* $Id: cmd.c,v 1.24 2001/02/28 22:33:23 ekohl Exp $
|
||||||
*
|
*
|
||||||
* CMD.C - command-line interface.
|
* CMD.C - command-line interface.
|
||||||
*
|
*
|
||||||
|
@ -116,6 +116,9 @@
|
||||||
*
|
*
|
||||||
* 03-Feb-2001 (Eric Kohl <ekohl@rz-online.de>)
|
* 03-Feb-2001 (Eric Kohl <ekohl@rz-online.de>)
|
||||||
* Workaround because argc[0] is NULL under ReactOS
|
* Workaround because argc[0] is NULL under ReactOS
|
||||||
|
*
|
||||||
|
* 23-Feb-2001 (Carl Nettelblad <cnettel@hem.passagen.se>)
|
||||||
|
* %envvar% replacement conflicted with for.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -797,7 +800,7 @@ ProcessInput (BOOL bFlag)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if ((tp = _tcschr (ip, _T('%'))))
|
if ((tp = _tcschr (ip, _T('%'))) && (tp<=(unsigned int)strchr(ip,_T(' '))-1))
|
||||||
{
|
{
|
||||||
char evar[512];
|
char evar[512];
|
||||||
*tp = _T('\0');
|
*tp = _T('\0');
|
||||||
|
@ -809,6 +812,10 @@ ProcessInput (BOOL bFlag)
|
||||||
|
|
||||||
ip = tp + 1;
|
ip = tp + 1;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*cp++ = _T('%');
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -822,8 +829,7 @@ ProcessInput (BOOL bFlag)
|
||||||
*cp = _T('\0');
|
*cp = _T('\0');
|
||||||
|
|
||||||
/* strip trailing spaces */
|
/* strip trailing spaces */
|
||||||
while ((--cp >= commandline) && _istspace (*cp))
|
while ((--cp >= commandline) && _istspace (*cp));
|
||||||
;
|
|
||||||
|
|
||||||
*(cp + 1) = _T('\0');
|
*(cp + 1) = _T('\0');
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: dir.c,v 1.9 1999/12/15 00:50:41 ekohl Exp $
|
/* $Id: dir.c,v 1.10 2001/02/28 22:33:23 ekohl Exp $
|
||||||
*
|
*
|
||||||
* DIR.C - dir internal command.
|
* DIR.C - dir internal command.
|
||||||
*
|
*
|
||||||
|
@ -110,6 +110,9 @@
|
||||||
*
|
*
|
||||||
* 01-Mar-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
* 01-Mar-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
* Replaced all runtime io functions by their Win32 counterparts.
|
* Replaced all runtime io functions by their Win32 counterparts.
|
||||||
|
*
|
||||||
|
* 23-Feb-2001 (Carl Nettelblad <cnettel@hem.passagen.se>)
|
||||||
|
* dir /s now works in deeper trees
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -998,7 +1001,12 @@ DirRead (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags)
|
||||||
|
|
||||||
if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
{
|
{
|
||||||
if (DirList (file.cFileName, szFilespec, pLine, dwFlags))
|
_tcscpy (szFullPath, szPath);
|
||||||
|
if (szFullPath[_tcslen (szFullPath) - 1] != _T('\\'))
|
||||||
|
_tcscat (szFullPath, _T("\\"));
|
||||||
|
_tcscat (szFullPath, file.cFileName);
|
||||||
|
|
||||||
|
if (DirList (szFullPath, szFilespec, pLine, dwFlags))
|
||||||
{
|
{
|
||||||
FindClose (hFile);
|
FindClose (hFile);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1009,9 +1017,12 @@ DirRead (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags)
|
||||||
ConOutPrintf ("\n");
|
ConOutPrintf ("\n");
|
||||||
if (IncLine (pLine, dwFlags) != 0)
|
if (IncLine (pLine, dwFlags) != 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
ConOutPrintf ("\n");
|
||||||
|
if (IncLine (pLine, dwFlags) != 0)
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DirRead (file.cFileName, szFilespec, pLine, dwFlags) == 1)
|
if (DirRead (szFullPath, szFilespec, pLine, dwFlags) == 1)
|
||||||
{
|
{
|
||||||
FindClose (hFile);
|
FindClose (hFile);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -21,6 +21,10 @@
|
||||||
*
|
*
|
||||||
* 01-Sep-1999 (Eric Kohl)
|
* 01-Sep-1999 (Eric Kohl)
|
||||||
* Added help text.
|
* Added help text.
|
||||||
|
*
|
||||||
|
* 23-Feb-2001 (Carl Nettelblad <cnettel@hem.passagen.se>)
|
||||||
|
* Implemented preservation of echo flag. Some other for related
|
||||||
|
* code in other files fixed, too.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -142,6 +146,10 @@ INT cmd_for (LPTSTR cmd, LPTSTR param)
|
||||||
bc->shiftlevel = 0;
|
bc->shiftlevel = 0;
|
||||||
bc->forvar = var;
|
bc->forvar = var;
|
||||||
bc->forproto = _tcsdup (pp);
|
bc->forproto = _tcsdup (pp);
|
||||||
|
if (bc->prev)
|
||||||
|
bc->bEcho = bc->prev->bEcho;
|
||||||
|
else
|
||||||
|
bc->bEcho = bEcho;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,6 +119,9 @@
|
||||||
* 15-Mar-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
* 15-Mar-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||||
* Fixed bug in "cd -" feature. If the previous directory was a root
|
* Fixed bug in "cd -" feature. If the previous directory was a root
|
||||||
* directory, it was ignored.
|
* directory, it was ignored.
|
||||||
|
*
|
||||||
|
* 23-Feb-2001 (Carl Nettelblad <cnettel@hem.passagen.se>)
|
||||||
|
* Improved chdir/cd command.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
Loading…
Reference in a new issue