3e285a5074fd003e7a928810232037b57acab54d
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)
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 hardcode string to En.rc
33 * Perform GOTO command.
35 * Only valid if batch file current.
39 INT
cmd_goto (LPTSTR param
)
44 TRACE ("cmd_goto (\'%s\')\n", debugstr_aw(param
));
46 if (!_tcsncmp (param
, _T("/?"), 2))
48 ConOutResPaging(TRUE
,STRING_GOTO_HELP1
);
52 /* if not in batch -- error!! */
58 if (*param
== _T('\0'))
60 ConErrResPrintf(STRING_GOTO_ERROR1
);
65 /* terminate label at first space char */
67 while (!_istcntrl (*tmp
) && !_istspace (*tmp
) && (*tmp
!= _T(':')))
71 /* set file pointer to the beginning of the batch file */
74 /* jump to end of the file */
75 if ( _tcsicmp( param
, _T(":eof"))==0)
77 bc
->mempos
=bc
->memsize
; /* position at the end of the batchfile */
81 /* jump to begin of the file */
84 while (BatchGetString (textline
, sizeof(textline
) / sizeof(textline
[0])))
89 /* Strip out any trailing spaces or control chars */
90 tmp
= textline
+ _tcslen (textline
) - 1;
92 while (_istcntrl (*tmp
) || _istspace (*tmp
) || (*tmp
== _T(':')))
94 *(tmp
+ 1) = _T('\0');
96 /* Then leading spaces... */
98 while (_istspace (*tmp
))
101 /* All space after leading space terminate the string */
102 size
= _tcslen(tmp
) -1;
104 while (tmp
+pos
< tmp
+size
)
106 if (_istspace(tmp
[pos
]))
112 /* use whole label name */
113 if ((*tmp
== _T(':')) && ((_tcsicmp (++tmp
, param
) == 0) || (_tcsicmp (tmp
, ++tmp2
) == 0)))
118 ConErrResPrintf(STRING_GOTO_ERROR2
, param
);