-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsx_goto.c
81 lines (56 loc) · 1.59 KB
/
sx_goto.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* sx_goto.c
GOTO for Samarux.
Jump to a batch label.
Copyright (c) 2007 - 2015 Miguel I. Garcia Lopez.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2, or (at your option) any
later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
Usage:
goto label
Options:
None.
Examples:
goto quit
...
# quit:
Changes:
15 Feb 2015 : 1.00 : 1st version.
23 Feb 2015 : 1.01 : Now uses BatchJump().
*/
#define SX_GOTO
#define GOTO_LAB_LEN 8 /* Max. length of label name */
#define GOTO_LAB_SIZ 12 /* '# 12345678:',0 */
GotoMain(argc, argv)
int argc, argv[];
{
int i;
char lab[GOTO_LAB_SIZ];
/* Run only within a batch file */
if(!sv_batch)
return Error("Batch is not running");
/* Two arguments, please */
if(argc != 2)
return ErrorPars();
/* Check argument length */
if(strlen(argv[1]) > GOTO_LAB_LEN)
return Error("Label too long");
/* Build label to search */
strcpy(lab, "# ");
strcat(lab, argv[1]);
strcat(lab, ":");
/* Search label */
if(BatchJump(lab))
return Error("Label not found");
/* Success */
return 0;
}
#undef GOTO_LAB_LEN
#undef GOTO_LAB_SIZ