Comments (2)
Below is patch to cast string size as int and initialize both values of struct value to 0.
diff --git a/toys/pending/expr.c b/toys/pending/expr.c index 743a953..2aacd08 100644 --- a/toys/pending/expr.c +++ b/toys/pending/expr.c @@ -113,7 +113,8 @@ static void re(char *target, char *pattern, struct value *ret) if (!regexec(&pat, target, 2, m, 0) && !m[0].rm_so) { // Return first parenthesized subexpression as string, or length of match if (pat.re_nsub>0) { - ret->s = xmprintf("%.*s", m[1].rm_eo-m[1].rm_so, target+m[1].rm_so); + ret->s = xmprintf("%.*s", (int)(m[1].rm_eo-m[1].rm_so), + target+m[1].rm_so); if (TT.refree) free(TT.refree); TT.refree = ret->s; } else assign_int(ret, m[0].rm_eo); @@ -141,7 +142,7 @@ static struct op_def { // comparison ops, precedence 3, signature SI_TO_I {"=", 3, SI_TO_I, EQ }, {"==", 3, SI_TO_I, EQ }, {"!=", 3, SI_TO_I, NE }, {">", 3, SI_TO_I, GT }, {">=", 3, SI_TO_I, GTE }, - {"<", 3, SI_TO_I, LT }, {"<=", 3, SI_TO_I, LTE }, + {"<", 3, SI_TO_I, LT }, {"<=", 3, SI_TO_I, LTE }, // arithmetic ops, precedence 4 and 5, signature I_TO_I {"+", 4, I_TO_I, ADD }, {"-", 4, I_TO_I, SUB }, {"*", 5, I_TO_I, MUL }, {"/", 5, I_TO_I, DIVI }, {"%", 5, I_TO_I, MOD }, @@ -163,7 +164,7 @@ void eval_op(struct op_def *o, struct value *ret, struct value *rhs) case OR: if (is_false(ret)) *ret = *rhs; break; case AND: if (is_false(ret) || is_false(rhs)) assign_int(ret, 0); break; } - break; + break; case SI_TO_I: if (get_int(ret, &a) && get_int(rhs, &b)) { // both are ints @@ -244,7 +245,7 @@ static void eval_expr(struct value *ret, int min_prec) void expr_main(void) { - struct value ret = {0}; + struct value ret = {0, 0LL}; toys.exitval = 2; // if exiting early, indicate error TT.tok = toys.optargs; // initialize global tokenfrom toybox.
the missing cast was added by 352efdf and the initialization was fixed by 14c91c1.
from toybox.
Related Issues (20)
- diff from stdin HOT 2
- find crash on invalid argument HOT 2
- Why is bash hardcoded in scripts and tests? HOT 1
- UTF-8 character support in Android's `sed` HOT 5
- tar: `--sort=name` Does not follow symlinks with `-h` HOT 1
- `xxd -p` adds an extra space at the end of each line HOT 2
- `kill` command shouldn't assume process name has no spaces in it HOT 2
- cpio does not support -L / --dereference HOT 2
- cp: `cp $(readlink x) x` does not work
- bunzip2 deletes files on error HOT 3
- date: segfault with `-s+` HOT 2
- patch: heap-buffer-overflow HOT 2
- "grep -A -m" missing lines on last match HOT 2
- Pathological patch can't be re-apply to original source without loose match HOT 7
- patch tests fail under (hw)asan HOT 3
- test/true help menu HOT 3
- strings applet proposal HOT 2
- mdev: `-d` and `-f` flags are missing HOT 1
- Unable to build Toybox with Android NDK HOT 1
- Feature request: sh to run toys if external command with than tame is not found HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from toybox.