2 * GOTO.C - goto internal batch command.
6 * 16 Jul 1998 (Hans B Pufal)
9 * 16 Jul 1998 (John P Price)
10 * Separated 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)
20 * Unicode and redirection safe!
22 * 27-Jan-1999 (Eric Kohl)
23 * Added help text ("/?").
25 * 28-Apr-2005 (Magnus Olsen <magnus@greatlord.com>)
26 * Remove all hardcoded strings in En.rc
33 * Perform GOTO command.
35 * Only valid if batch file current.
39 INT
cmd_goto (LPTSTR param
)
43 TRACE ("cmd_goto (\'%s\')\n", debugstr_aw(param
));
45 if (!_tcsncmp (param
, _T("/?"), 2))
47 ConOutResPaging(TRUE
,STRING_GOTO_HELP1
);
51 /* if not in batch -- error!! */
57 if (*param
== _T('\0'))
59 ConErrResPrintf(STRING_GOTO_ERROR1
);
64 /* terminate label at first space char */
66 while (!_istcntrl (*tmp
) && !_istspace (*tmp
) && (*tmp
!= _T(':')))
70 /* jump to end of the file */
71 if ( _tcsicmp( param
, _T(":eof"))==0)
73 bc
->mempos
=bc
->memsize
; /* position at the end of the batchfile */
77 /* jump to begin of the file */
80 while (BatchGetString (textline
, sizeof(textline
) / sizeof(textline
[0])))
85 /* Strip out any trailing spaces or control chars */
86 tmp
= textline
+ _tcslen (textline
) - 1;
88 while (tmp
> textline
&& (_istcntrl (*tmp
) || _istspace (*tmp
) || (*tmp
== _T(':'))))
90 *(tmp
+ 1) = _T('\0');
92 /* Then leading spaces... */
94 while (_istspace (*tmp
))
97 /* All space after leading space terminate the string */
98 size
= _tcslen(tmp
) -1;
100 while (tmp
+pos
< tmp
+size
)
102 if (_istspace(tmp
[pos
]))
108 /* use whole label name */
109 if ((*tmp
== _T(':')) && ((_tcsicmp (++tmp
, param
) == 0) || (_tcsicmp (tmp
, ++tmp2
) == 0)))
114 ConErrResPrintf(STRING_GOTO_ERROR2
, param
);