OpenCoverage

let.def

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/bash/src/builtins/let.def
Source codeSwitch to Preprocessed file
LineSourceCount
1This file is let.def, from which is created let.c.-
2It implements the builtin "let" 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$BUILTIN let-
22$FUNCTION let_builtin-
23$PRODUCES let.c-
24$SHORT_DOC let arg [arg ...]-
25Evaluate arithmetic expressions.-
26-
27Evaluate each ARG as an arithmetic expression. Evaluation is done in-
28fixed-width integers with no check for overflow, though division by 0-
29is trapped and flagged as an error. The following list of operators is-
30grouped into levels of equal-precedence operators. The levels are listed-
31in order of decreasing precedence.-
32-
33 id++, id-- variable post-increment, post-decrement-
34 ++id, --id variable pre-increment, pre-decrement-
35 -, + unary minus, plus-
36 !, ~ logical and bitwise negation-
37 ** exponentiation-
38 *, /, % multiplication, division, remainder-
39 +, - addition, subtraction-
40 <<, >> left and right bitwise shifts-
41 <=, >=, <, > comparison-
42 ==, != equality, inequality-
43 & bitwise AND-
44 ^ bitwise XOR-
45 | bitwise OR-
46 && logical AND-
47 || logical OR-
48 expr ? expr : expr-
49 conditional operator-
50 =, *=, /=, %=,-
51 +=, -=, <<=, >>=,-
52 &=, ^=, |= assignment-
53-
54Shell variables are allowed as operands. The name of the variable-
55is replaced by its value (coerced to a fixed-width integer) within-
56an expression. The variable need not have its integer attribute-
57turned on to be used in an expression.-
58-
59Operators are evaluated in order of precedence. Sub-expressions in-
60parentheses are evaluated first and may override the precedence-
61rules above.-
62-
63Exit Status:-
64If the last ARG evaluates to 0, let returns 1; let returns 0 otherwise.-
65$END-
66-
67#include <config.h>-
68-
69#if defined (HAVE_UNISTD_H)-
70# ifdef _MINIX-
71# include <sys/types.h>-
72# endif-
73# include <unistd.h>-
74#endif-
75-
76#include "../bashintl.h"-
77-
78#include "../shell.h"-
79#include "common.h"-
80-
81/* Arithmetic LET function. */-
82int-
83let_builtin (list)-
84 WORD_LIST *list;-
85{-
86 intmax_t ret;-
87 int expok;-
88-
89 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 664879 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
(list)->wordDescription
TRUEevaluated 664879 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((list)->word... ("--help")[0]Description
TRUEnever evaluated
FALSEevaluated 664879 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-664879
90-
91 /* Skip over leading `--' argument. */-
92 if (list && list->word && ISOPTION (list->word->word, '-'))
listDescription
TRUEevaluated 664879 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
list->wordDescription
TRUEevaluated 664879 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
list->word->word[0] == '-'Description
TRUEnever evaluated
FALSEevaluated 664879 times by 1 test
Evaluated by:
  • Self test
list->word->word[1] == '-'Description
TRUEnever evaluated
FALSEnever evaluated
!list->word->word[2]Description
TRUEnever evaluated
FALSEnever evaluated
0-664879
93 list = list->next;
never executed: list = list->next;
0
94-
95 if (list == 0)
list == 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 664879 times by 1 test
Evaluated by:
  • Self test
5-664879
96 {-
97 builtin_error (_("expression expected"));-
98 return (EXECUTION_FAILURE);
executed 5 times by 1 test: return (1);
Executed by:
  • Self test
5
99 }-
100-
101 for (; list; list = list->next)
listDescription
TRUEevaluated 664880 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 664863 times by 1 test
Evaluated by:
  • Self test
664863-664880
102 {-
103 ret = evalexp (list->word->word, EXP_EXPANDED, &expok);-
104 if (expok == 0)
expok == 0Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 664864 times by 1 test
Evaluated by:
  • Self test
16-664864
105 return (EXECUTION_FAILURE);
executed 16 times by 1 test: return (1);
Executed by:
  • Self test
16
106 }
executed 664864 times by 1 test: end of block
Executed by:
  • Self test
664864
107-
108 return ((ret == 0) ? EXECUTION_FAILURE : EXECUTION_SUCCESS);
executed 664863 times by 1 test: return ((ret == 0) ? 1 : 0);
Executed by:
  • Self test
664863
109}-
110-
111#ifdef INCLUDE_UNUSED-
112int-
113exp_builtin (list)-
114 WORD_LIST *list;-
115{-
116 char *exp;-
117 intmax_t ret;-
118 int expok;-
119-
120 if (list == 0)-
121 {-
122 builtin_error (_("expression expected"));-
123 return (EXECUTION_FAILURE);-
124 }-
125-
126 exp = string_list (list);-
127 ret = evalexp (exp, EXP_EXPANDED, &expok);-
128 (void)free (exp);-
129 return (((ret == 0) || (expok == 0)) ? EXECUTION_FAILURE : EXECUTION_SUCCESS);-
130}-
131#endif-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.1.2