Lines Matching refs:ret

79 int get_int(struct value *v, long long *ret)
84 *ret = strtoll(v->s, &endp, 10);
87 } else *ret = v->i;
105 // 'ret' is filled with a string capture or int match position.
106 static void re(char *target, char *pattern, struct value *ret)
116 ret->s = xmprintf("%.*s", (int)(m[1].rm_eo-m[1].rm_so),
119 TT.refree = ret->s;
120 } else assign_int(ret, m[0].rm_eo);
122 if (pat.re_nsub>0) ret->s = "";
123 else assign_int(ret, 0);
154 void eval_op(struct op_def *o, struct value *ret, struct value *rhs)
164 case OR: if (is_false(ret)) *ret = *rhs; break;
165 case AND: if (is_false(ret) || is_false(rhs)) assign_int(ret, 0); break;
170 if (get_int(ret, &a) && get_int(rhs, &b)) { // both are ints
173 cmp = strcmp(s = get_str(ret), t = get_str(rhs));
174 if (ret->s != s) free(s);
185 assign_int(ret, x);
189 if (!get_int(ret, &a) || !get_int(rhs, &b))
198 assign_int(ret, x);
202 s = get_str(ret);
203 cmp = ret->s!=s; // ret overwritten by re so check now
204 re(s, t = get_str(rhs), ret);
212 // algorithm, setting 'ret'.
213 static void eval_expr(struct value *ret, int min_prec)
217 // Evaluate LHS atom, setting 'ret'.
221 eval_expr(ret, 1); // We're inside ( ), so min_prec = 1
222 if (ret->s && !strcmp(ret->s, ")")) error_exit("empty ( )");
225 } else ret->s = *TT.tok; // simple literal, all values start as strings
242 eval_op(o, ret, &rhs); // Apply operator, setting 'ret'
248 struct value ret = {0};
252 eval_expr(&ret, 1);
255 if (ret.s) printf("%s\n", ret.s);
256 else printf("%lld\n", ret.i);
258 toys.exitval = is_false(&ret);