OpenCoverage

break.def

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/bash/src/builtins/break.def
Source codeSwitch to Preprocessed file
LineSourceCount
1This file is break.def, from which is created break.c.-
2It implements the builtins "break" and "continue" in Bash.-
3-
4Copyright (C) 1987-2009 Free Software Foundation, Inc.-
5-
6This file is part of GNU Bash, the Bourne Again SHell.-
7-
8Bash is free software: you can redistribute it and/or modify-
9it under the terms of the GNU General Public License as published by-
10the Free Software Foundation, either version 3 of the License, or-
11(at your option) any later version.-
12-
13Bash is distributed in the hope that it will be useful,-
14but WITHOUT ANY WARRANTY; without even the implied warranty of-
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-
16GNU General Public License for more details.-
17-
18You should have received a copy of the GNU General Public License-
19along with Bash. If not, see <http://www.gnu.org/licenses/>.-
20-
21$PRODUCES break.c-
22-
23$BUILTIN break-
24$FUNCTION break_builtin-
25$SHORT_DOC break [n]-
26Exit for, while, or until loops.-
27-
28Exit a FOR, WHILE or UNTIL loop. If N is specified, break N enclosing-
29loops.-
30-
31Exit Status:-
32The exit status is 0 unless N is not greater than or equal to 1.-
33$END-
34#include <config.h>-
35-
36#if defined (HAVE_UNISTD_H)-
37# ifdef _MINIX-
38# include <sys/types.h>-
39# endif-
40# include <unistd.h>-
41#endif-
42-
43#include "../bashintl.h"-
44-
45#include "../shell.h"-
46#include "../execute_cmd.h"-
47#include "common.h"-
48-
49static int check_loop_level __P((void));-
50-
51/* The depth of while's and until's. */-
52int loop_level = 0;-
53-
54/* Non-zero when a "break" instruction is encountered. */-
55int breaking = 0;-
56-
57/* Non-zero when we have encountered a continue instruction. */-
58int continuing = 0;-
59-
60/* Set up to break x levels, where x defaults to 1, but can be specified-
61 as the first argument. */-
62int-
63break_builtin (list)-
64 WORD_LIST *list;-
65{-
66 intmax_t newbreak;-
67-
68 CHECK_HELPOPT (list);
never executed: __result = (((const unsigned char *) (const char *) ( ((list)->word->word) ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "--help" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: return (258);
(list)Description
TRUEevaluated 23 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3230236 times by 1 test
Evaluated by:
  • Self test
(list)->wordDescription
TRUEevaluated 23 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((list)->word... ("--help")[0]Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 22 times by 1 test
Evaluated by:
  • Self test
__extension__ ... )))); }) == 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-3230236
69-
70 if (check_loop_level () == 0)
check_loop_level () == 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3230254 times by 1 test
Evaluated by:
  • Self test
5-3230254
71 return (EXECUTION_SUCCESS);
executed 5 times by 1 test: return (0);
Executed by:
  • Self test
5
72-
73 (void)get_numeric_arg (list, 1, &newbreak);-
74-
75 if (newbreak <= 0)
newbreak <= 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3230251 times by 1 test
Evaluated by:
  • Self test
2-3230251
76 {-
77 sh_erange (list->word->word, _("loop count"));-
78 breaking = loop_level;-
79 return (EXECUTION_FAILURE);
executed 2 times by 1 test: return (1);
Executed by:
  • Self test
2
80 }-
81-
82 if (newbreak > loop_level)
newbreak > loop_levelDescription
TRUEnever evaluated
FALSEevaluated 3230251 times by 1 test
Evaluated by:
  • Self test
0-3230251
83 newbreak = loop_level;
never executed: newbreak = loop_level;
0
84-
85 breaking = newbreak;-
86-
87 return (EXECUTION_SUCCESS);
executed 3230251 times by 1 test: return (0);
Executed by:
  • Self test
3230251
88}-
89-
90$BUILTIN continue-
91$FUNCTION continue_builtin-
92$SHORT_DOC continue [n]-
93Resume for, while, or until loops.-
94-
95Resumes the next iteration of the enclosing FOR, WHILE or UNTIL loop.-
96If N is specified, resumes the Nth enclosing loop.-
97-
98Exit Status:-
99The exit status is 0 unless N is not greater than or equal to 1.-
100$END-
101-
102/* Set up to continue x levels, where x defaults to 1, but can be specified-
103 as the first argument. */-
104int-
105continue_builtin (list)-
106 WORD_LIST *list;-
107{-
108 intmax_t newcont;-
109-
110 CHECK_HELPOPT (list);
never executed: __result = (((const unsigned char *) (const char *) ( ((list)->word->word) ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "--help" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: return (258);
(list)Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 70548 times by 1 test
Evaluated by:
  • Self test
(list)->wordDescription
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((list)->word... ("--help")[0]Description
TRUEnever evaluated
FALSEevaluated 61 times by 1 test
Evaluated by:
  • Self test
__extension__ ... )))); }) == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-70548
111-
112 if (check_loop_level () == 0)
check_loop_level () == 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 70604 times by 1 test
Evaluated by:
  • Self test
5-70604
113 return (EXECUTION_SUCCESS);
executed 5 times by 1 test: return (0);
Executed by:
  • Self test
5
114-
115 (void)get_numeric_arg (list, 1, &newcont);-
116-
117 if (newcont <= 0)
newcont <= 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 70603 times by 1 test
Evaluated by:
  • Self test
1-70603
118 {-
119 sh_erange (list->word->word, _("loop count"));-
120 breaking = loop_level;-
121 return (EXECUTION_FAILURE);
executed 1 time by 1 test: return (1);
Executed by:
  • Self test
1
122 }-
123-
124 if (newcont > loop_level)
newcont > loop_levelDescription
TRUEnever evaluated
FALSEevaluated 70603 times by 1 test
Evaluated by:
  • Self test
0-70603
125 newcont = loop_level;
never executed: newcont = loop_level;
0
126-
127 continuing = newcont;-
128-
129 return (EXECUTION_SUCCESS);
executed 70603 times by 1 test: return (0);
Executed by:
  • Self test
70603
130}-
131-
132/* Return non-zero if a break or continue command would be okay.-
133 Print an error message if break or continue is meaningless here. */-
134static int-
135check_loop_level ()-
136{-
137#if defined (BREAK_COMPLAINS)-
138 if (loop_level == 0 && posixly_correct == 0)
loop_level == 0Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3300858 times by 1 test
Evaluated by:
  • Self test
posixly_correct == 0Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3300858
139 builtin_error (_("only meaningful in a `for', `while', or `until' loop"));
executed 10 times by 1 test: builtin_error ( dcgettext (((void *)0), "only meaningful in a `for', `while', or `until' loop" , 5) );
Executed by:
  • Self test
10
140#endif /* BREAK_COMPLAINS */-
141-
142 return (loop_level);
executed 3300868 times by 1 test: return (loop_level);
Executed by:
  • Self test
3300868
143}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.1.2