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 ("/?").
38 * Perform GOTO command.
40 * Only valid if batch file current.
44 INT cmd_goto (LPTSTR cmd, LPTSTR param)
50 DebugPrintf ("cmd_goto (\'%s\', \'%s\'\n", cmd, param);
53 if (!_tcsncmp (param, _T("/?"), 2))
55 ConOutPuts (_T("Directs CMD to a labeled line in a batch script.\n"
59 " label Specifies a text string used in a batch script as a label.\n"
61 "You type a label on a line by itself, beginning with a colon."));
65 /* if not in batch -- error!! */
71 if (*param == _T('\0'))
73 ExitBatch (_T("No label specified for GOTO\n"));
77 /* terminate label at first space char */
79 while (*tmp && !_istspace (*tmp))
83 /* set file pointer to the beginning of the batch file */
85 SetFilePointer (bc->hBatchFile, 0, &lNewPosHigh, FILE_BEGIN);
87 while (FileGetString (bc->hBatchFile, textline, sizeof(textline)))
89 /* Strip out any trailing spaces or control chars */
90 tmp = textline + _tcslen (textline) - 1;
91 while (_istcntrl (*tmp) || _istspace (*tmp))
93 *(tmp + 1) = _T('\0');
95 /* Then leading spaces... */
97 while (_istspace (*tmp))
100 /* use only 1st 8 chars of label */
101 if ((*tmp == _T(':')) && (_tcsncmp (++tmp, param, 8) == 0))
105 ConErrPrintf (_T("Label '%s' not found\n"), param);