MCPcopy Create free account
hub / github.com/F-Stack/f-stack / db_mult_expr

Function db_mult_expr

freebsd/ddb/db_expr.c:160–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158}
159
160static bool
161db_mult_expr(db_expr_t *valuep)
162{
163 db_expr_t lhs, rhs;
164 int t;
165
166 if (!db_unary(&lhs))
167 return (false);
168
169 t = db_read_token();
170 while (t == tSTAR || t == tSLASH || t == tPCT || t == tHASH ||
171 t == tBIT_AND ) {
172 if (!db_term(&rhs)) {
173 db_printf("Expression syntax error after '%c'\n",
174 t == tSTAR ? '*' : t == tSLASH ? '/' : t == tPCT ? '%' :
175 t == tHASH ? '#' : '&');
176 db_error(NULL);
177 /*NOTREACHED*/
178 }
179 switch(t) {
180 case tSTAR:
181 lhs *= rhs;
182 break;
183 case tBIT_AND:
184 lhs &= rhs;
185 break;
186 default:
187 if (rhs == 0) {
188 db_error("Division by 0\n");
189 /*NOTREACHED*/
190 }
191 if (t == tSLASH)
192 lhs /= rhs;
193 else if (t == tPCT)
194 lhs %= rhs;
195 else
196 lhs = roundup(lhs, rhs);
197 }
198 t = db_read_token();
199 }
200 db_unread_token(t);
201 *valuep = lhs;
202 return (true);
203}
204
205static bool
206db_add_expr(db_expr_t *valuep)

Callers 1

db_add_exprFunction · 0.85

Calls 6

db_unaryFunction · 0.85
db_read_tokenFunction · 0.85
db_termFunction · 0.85
db_printfFunction · 0.85
db_errorFunction · 0.85
db_unread_tokenFunction · 0.85

Tested by

no test coverage detected