def1cbf57f228064d99b4814decf25b583a027cc
2 * GOTO.C - goto internal batch command.
6 * 16 Jul 1998 (Hans B Pufal)
9 * 16 Jul 1998 (John P Price)
10 * Seperated commands into individual files.
12 * 27-Jul-1998 (John P Price <linux-guru@gcfl.net>)
13 * added config.h include
15 * 28 Jul 1998 (Hans B Pufal) [HBP_003]
16 * Terminate label on first space character, use only first 8 chars of
19 * 24-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
20 * Unicode and redirection safe!
22 * 27-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
23 * Added help text ("/?").
26 #define WIN32_LEAN_AND_MEAN
39 * Perform GOTO command.
41 * Only valid if batch file current.
45 INT
cmd_goto (LPTSTR cmd
, LPTSTR param
)
51 DebugPrintf ("cmd_goto (\'%s\', \'%s\'\n", cmd
, param
);
54 if (!_tcsncmp (param
, _T("/?"), 2))
56 ConOutPuts (_T("Directs CMD to a labeled line in a batch script.\n"
60 " label Specifies a text string used in a batch script as a label.\n"
62 "You type a label on a line by itself, beginning with a colon."));
66 /* if not in batch -- error!! */
72 if (*param
== _T('\0'))
74 ExitBatch (_T("No label specified for GOTO\n"));
78 /* terminate label at first space char */
80 while (*tmp
&& !_istspace (*tmp
))
84 /* set file pointer to the beginning of the batch file */
86 SetFilePointer (bc
->hBatchFile
, 0, &lNewPosHigh
, FILE_BEGIN
);
88 while (FileGetString (bc
->hBatchFile
, textline
, sizeof(textline
)))
90 /* Strip out any trailing spaces or control chars */
91 tmp
= textline
+ _tcslen (textline
) - 1;
92 while (_istcntrl (*tmp
) || _istspace (*tmp
))
94 *(tmp
+ 1) = _T('\0');
96 /* Then leading spaces... */
98 while (_istspace (*tmp
))
101 /* use only 1st 8 chars of label */
102 if ((*tmp
== _T(':')) && (_tcsncmp (++tmp
, param
, 8) == 0))
106 ConErrPrintf (_T("Label '%s' not found\n"), param
);