-/* $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.
*
* 26-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
* Replaced CRT io functions by Win32 io functions.
* Unicode safe!
+ *
+ * 23-Feb-2001 (Carl Nettelblad <cnettel@hem.passagen.es>)
+ * Fixes made to get "for" working.
*/
#include "config.h"
LPTSTR ReadBatchLine (LPBOOL bLocalEcho)
{
- HANDLE hFind = INVALID_HANDLE_VALUE;
LPTSTR first;
LPTSTR ip;
if (bc->ffind)
{
/* 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
{
return NULL;
}
- hFind = FindFirstFile (fv, bc->ffind);
- fv = !(hFind==INVALID_HANDLE_VALUE) ? bc->ffind->cFileName : NULL;
+ bc->hFind = FindFirstFile (fv, bc->ffind);
+
+ fv = !(bc->hFind==INVALID_HANDLE_VALUE) ? bc->ffind->cFileName : NULL;
}
if (fv == NULL)
LPTSTR forproto;
LPTSTR params;
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;
} BATCH_CONTEXT, *LPBATCH_CONTEXT;
-/* HBP_002 } */
-
/* The stack of current batch contexts.
* NULL when no batch is active
-/* $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.
*
*
* 03-Feb-2001 (Eric Kohl <ekohl@rz-online.de>)
* 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"
break;
default:
- if ((tp = _tcschr (ip, _T('%'))))
+ if ((tp = _tcschr (ip, _T('%'))) && (tp<=(unsigned int)strchr(ip,_T(' '))-1))
{
char evar[512];
*tp = _T('\0');
ip = tp + 1;
}
+ else
+ {
+ *cp++ = _T('%');
+ }
break;
}
continue;
*cp = _T('\0');
/* strip trailing spaces */
- while ((--cp >= commandline) && _istspace (*cp))
- ;
+ while ((--cp >= commandline) && _istspace (*cp));
*(cp + 1) = _T('\0');
-/* $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.
*
*
* 01-Mar-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
* 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"
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);
return 1;
ConOutPrintf ("\n");
if (IncLine (pLine, dwFlags) != 0)
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);
return 1;
*
* 01-Sep-1999 (Eric Kohl)
* 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"
bc->shiftlevel = 0;
bc->forvar = var;
bc->forproto = _tcsdup (pp);
+ if (bc->prev)
+ bc->bEcho = bc->prev->bEcho;
+ else
+ bc->bEcho = bEcho;
return 0;
}
* 15-Mar-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
* Fixed bug in "cd -" feature. If the previous directory was a root
* directory, it was ignored.
+ *
+ * 23-Feb-2001 (Carl Nettelblad <cnettel@hem.passagen.se>)
+ * Improved chdir/cd command.
*/
#include "config.h"