1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1982-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * David Korn <dgk@research.att.com> *
19 ***********************************************************************/
29 * dgk@research.att.com
43 /* for the dictionary generator */
44 int b_exit(int n
, register char *argv
[],void *extra
){}
46 int b_return(register int n
, register char *argv
[],void *extra
)
49 register Shell_t
*shp
= ((Shbltin_t
*)extra
)->shp
;
50 struct checkpt
*pp
= (struct checkpt
*)shp
->jmplist
;
51 const char *options
= (**argv
=='r'?sh_optreturn
:sh_optexit
);
52 while((n
= optget(argv
,options
))) switch(n
)
55 if(!strmatch(argv
[opt_info
.index
],"[+-]+([0-9])"))
56 errormsg(SH_DICT
,2, "%s", opt_info
.arg
);
59 errormsg(SH_DICT
,ERROR_usage(0), "%s", opt_info
.arg
);
64 errormsg(SH_DICT
,ERROR_usage(2),"%s",optusage((char*)0));
65 pp
->mode
= (**argv
=='e'?SH_JMPEXIT
:SH_JMPFUN
);
66 argv
+= opt_info
.index
;
67 n
= (((arg
= *argv
)?(int)strtol(arg
, (char**)0, 10)&SH_EXITMASK
:shp
->oldexit
));
68 /* return outside of function, dotscript and profile is exit */
69 if(shp
->fn_depth
==0 && shp
->dot_depth
==0 && !sh_isstate(SH_PROFILE
))
70 pp
->mode
= SH_JMPEXIT
;
71 sh_exit(shp
->savexit
=n
);
80 /* for the dictionary generator */
81 int b_continue(int n
, register char *argv
[],void *extra
){}
83 int b_break(register int n
, register char *argv
[],void *extra
)
86 register int cont
= **argv
=='c';
87 register Shell_t
*shp
= ((Shbltin_t
*)extra
)->shp
;
88 while((n
= optget(argv
,cont
?sh_optcont
:sh_optbreak
))) switch(n
)
91 errormsg(SH_DICT
,2, "%s", opt_info
.arg
);
94 errormsg(SH_DICT
,ERROR_usage(0), "%s", opt_info
.arg
);
98 errormsg(SH_DICT
,ERROR_usage(2),"%s",optusage((char*)0));
99 argv
+= opt_info
.index
;
103 n
= strtol(arg
,&arg
,10);
105 errormsg(SH_DICT
,ERROR_exit(1),e_nolabels
,*argv
);
109 shp
->st
.execbrk
= shp
->st
.breakcnt
= n
;
110 if(shp
->st
.breakcnt
> shp
->st
.loopcnt
)
111 shp
->st
.breakcnt
= shp
->st
.loopcnt
;
113 shp
->st
.breakcnt
= -shp
->st
.breakcnt
;