]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/src/cmd/fplot.c
sshfs: usage
[plan9front.git] / sys / src / cmd / fplot.c
index 9d6dd5301c825d66660e47d04057c41a87e3bcce..c51dc86422fcbf5b742e277215840ae5733a400d 100644 (file)
@@ -49,6 +49,7 @@ void add(void) { sp--; *sp += *(sp+1); }
 void sub(void) { sp--; *sp -= *(sp+1); }
 void mul(void) { sp--; *sp *= *(sp+1); }
 void div(void) { sp--; *sp /= *(sp+1); }
+void mod(void) { sp--; *sp = fmod(*sp, *(sp+1)); }
 void pot(void) { sp--; *sp = pow(*sp, *(sp+1)); }
 void osin(void) { *sp = sin(*sp); }
 void ocos(void) { *sp = cos(*sp); }
@@ -57,6 +58,7 @@ void oasin(void) { *sp = asin(*sp); }
 void oacos(void) { *sp = acos(*sp); }
 void oatan(void) { *sp = atan(*sp); }
 void osqrt(void) { *sp = sqrt(*sp); }
+void oexp(void) { *sp = exp(*sp); }
 void olog(void) { *sp = log10(*sp); }
 void oln(void) { *sp = log(*sp); }
 
@@ -71,6 +73,7 @@ struct Operator {
        "-",    OBINARY,        0,      0,      sub,
        "*",    OBINARY,        0,      100,    mul,
        "/",    OBINARY,        0,      100,    div,
+       "%",    OBINARY,        0,      100,    mod,
        "^",    OBINARY,        1,      200,    pot,
        "sin",  OUNARY,         0,      50,     osin,
        "cos",  OUNARY,         0,      50,     ocos,
@@ -79,6 +82,7 @@ struct Operator {
        "acos", OUNARY,         0,      50,     oacos,
        "atan", OUNARY,         0,      50,     oatan,
        "sqrt", OUNARY,         0,      50,     osqrt,
+       "exp",  OUNARY,         0,      50,     oexp,
        "log",  OUNARY,         0,      50,     olog,
        "ln",   OUNARY,         0,      50,     oln,
 };
@@ -428,7 +432,7 @@ zoom(void)
        
        m.buttons = 7;
        r = egetrect(1, &m);
-       if(r.min.x == 0 && r.min.y == 0 && r.max.x == 0 && r.max.y == 0)
+       if(Dx(r) < 1 || Dy(r) < 1)
                return;
        xmin_ = convx(&screen->r, r.min.x);
        xmax_ = convx(&screen->r, r.max.x);
@@ -462,16 +466,16 @@ parsefns(int n, char **s)
 void
 parserange(char *s)
 {
-       while(*s && !isdigit(*s)) s++;
+       while(*s && !isdigit(*s) && *s != '-') s++;
        if(*s == 0) return;
        xmin = strtod(s, &s);
-       while(*s && !isdigit(*s)) s++;
+       while(*s && !isdigit(*s) && *s != '-') s++;
        if(*s == 0) return;
        xmax = strtod(s, &s);
-       while(*s && !isdigit(*s)) s++;
+       while(*s && !isdigit(*s) && *s != '-') s++;
        if(*s == 0) return;
        ymin = strtod(s, &s);
-       while(*s && !isdigit(*s)) s++;
+       while(*s && !isdigit(*s) && *s != '-') s++;
        if(*s == 0) return;
        ymax = strtod(s, &s);
 }