diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2014-12-21 08:17:45 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2014-12-21 08:17:45 +0000 |
commit | b3ded48d866f59df3c9e8634eabe6e62596ad2d5 (patch) | |
tree | a7a9f2cdd1a9846b7445e8ec6babbecee79c8c0b /plugins/Popup/src/formula.cpp | |
parent | b2ba573600e650273800774c7fad23268019a353 (diff) |
Popup: changed warning level to w4
git-svn-id: http://svn.miranda-ng.org/main/trunk@11550 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Popup/src/formula.cpp')
-rw-r--r-- | plugins/Popup/src/formula.cpp | 181 |
1 files changed, 98 insertions, 83 deletions
diff --git a/plugins/Popup/src/formula.cpp b/plugins/Popup/src/formula.cpp index f4f1a1b2f1..cbd59163fd 100644 --- a/plugins/Popup/src/formula.cpp +++ b/plugins/Popup/src/formula.cpp @@ -2,9 +2,9 @@ Popup Plus plugin for Miranda IM
Copyright © 2002 Luca Santarelli,
- © 2004-2007 Victor Pavlychko
- © 2010 MPK
- © 2010 Merlin_de
+© 2004-2007 Victor Pavlychko
+© 2010 MPK
+© 2010 Merlin_de
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@@ -36,22 +36,25 @@ int Formula::eval_neq(TCHAR *&s, Args *args, bool *vars) const if (myisspace(*s))
{
++s;
- } else
- if (*s == '<')
- {
- // this is needed due to side effects caused by min() macro...
- int tmp = eval_sum(++s, args, vars);
- left = min(left, tmp);
- } else
- if (*s == '>')
- {
- // this is needed due to side effects caused by max() macro...
- int tmp = eval_sum(++s, args, vars);
- left = max(left, tmp);
- } else
- {
- break;
}
+ else
+ if (*s == '<')
+ {
+ // this is needed due to side effects caused by min() macro...
+ int tmp = eval_sum(++s, args, vars);
+ left = min(left, tmp);
+ }
+ else
+ if (*s == '>')
+ {
+ // this is needed due to side effects caused by max() macro...
+ int tmp = eval_sum(++s, args, vars);
+ left = max(left, tmp);
+ }
+ else
+ {
+ break;
+ }
}
return left;
}
@@ -64,18 +67,21 @@ int Formula::eval_sum(TCHAR *&s, Args *args, bool *vars) const if (myisspace(*s))
{
++s;
- } else
- if (*s == '+')
- {
- left += eval_mul(++s, args, vars);
- } else
- if (*s == '-')
- {
- left -= eval_mul(++s, args, vars);
- } else
- {
- break;
}
+ else
+ if (*s == '+')
+ {
+ left += eval_mul(++s, args, vars);
+ }
+ else
+ if (*s == '-')
+ {
+ left -= eval_mul(++s, args, vars);
+ }
+ else
+ {
+ break;
+ }
}
return left;
}
@@ -88,24 +94,28 @@ int Formula::eval_mul(TCHAR *&s, Args *args, bool *vars) const if (myisspace(*s))
{
++s;
- } else
- if (*s == '*')
- {
- left *= eval_atom(++s, args, vars);
- } else
- if (*s == '/')
- {
- if (int right = eval_atom(++s, args, vars))
- left /= right;
- } else
- if (*s == '%')
- {
- if (int right = eval_atom(++s, args, vars))
- left %= right;
- } else
- {
- break;
}
+ else
+ if (*s == '*')
+ {
+ left *= eval_atom(++s, args, vars);
+ }
+ else
+ if (*s == '/')
+ {
+ if (int right = eval_atom(++s, args, vars))
+ left /= right;
+ }
+ else
+ if (*s == '%')
+ {
+ if (int right = eval_atom(++s, args, vars))
+ left %= right;
+ }
+ else
+ {
+ break;
+ }
}
return left;
}
@@ -117,44 +127,49 @@ int Formula::eval_atom(TCHAR *&s, Args *args, bool *vars) const if (myisspace(*s))
{
++s;
- } else
- if (*s == '(')
- {
- int res = eval_neq(++s, args, vars);
- if (*s == ')')
- ++s;
- return res;
- } else
- if ((*s == '+') || (*s == '-'))
- {
- int sign = 1;
- if (*s == '-')
- sign = -1;
- return sign * eval_neq(++s, args, vars);
- } else
- if (*s == '!')
- {
- return !eval_neq(++s, args, vars);
- } else
- if ((*s >= '0') && (*s <= '9'))
- {
- int res = 0;
- while ((*s >= '0') && (*s <= '9'))
- res = res * 10 + *s++ - '0';
- return res;
- } else
- {
- if (!args)
- return 0;
- char buf[1024];
- char *bufptr = buf;
- while (((*s >= '0') && (*s <= '9')) || ((*s >= 'a') && (*s <= 'z')) || ((*s >= 'A') && (*s <= 'A')) || (*s == '_') || (*s == '.'))
- *bufptr++ = *s++;
- *bufptr = 0;
- int res = args->get(buf);
- if (vars) *vars = true;
- return res;
}
+ else
+ if (*s == '(')
+ {
+ int res = eval_neq(++s, args, vars);
+ if (*s == ')')
+ ++s;
+ return res;
+ }
+ else
+ if ((*s == '+') || (*s == '-'))
+ {
+ int sign = 1;
+ if (*s == '-')
+ sign = -1;
+ return sign * eval_neq(++s, args, vars);
+ }
+ else
+ if (*s == '!')
+ {
+ return !eval_neq(++s, args, vars);
+ }
+ else
+ if ((*s >= '0') && (*s <= '9'))
+ {
+ int res = 0;
+ while ((*s >= '0') && (*s <= '9'))
+ res = res * 10 + *s++ - '0';
+ return res;
+ }
+ else
+ {
+ if (!args)
+ return 0;
+ char buf[1024];
+ char *bufptr = buf;
+ while (((*s >= '0') && (*s <= '9')) || ((*s >= 'a') && (*s <= 'z')) || ((*s >= 'A') && (*s <= 'A')) || (*s == '_') || (*s == '.'))
+ *bufptr++ = *s++;
+ *bufptr = 0;
+ int res = args->get(buf);
+ if (vars) *vars = true;
+ return res;
+ }
}
return 0;
}
|