diff --git a/includes/math-expr.inc b/includes/math-expr.inc index 28b2305..acbdfe9 100644 --- a/includes/math-expr.inc +++ b/includes/math-expr.inc @@ -13,8 +13,7 @@ * ctools_math_expr - safely evaluate math expressions * * SYNOPSIS - * include('ctools_math_expr.class.php'); - * $m = new ctools_math_expr; + * $m = new ctools_math_expr(); * // basic evaluation: * $result = $m->evaluate('2+2'); * // supports: order of operation; parentheses; negation; built-in @@ -98,12 +97,14 @@ class ctools_math_expr { * @var bool */ public $suppress_errors = FALSE; + /** * The last error message reported. * * @var string */ public $last_error = NULL; + /** * List of all errors reported. * @@ -117,18 +118,21 @@ class ctools_math_expr { * @var array */ protected $vars; + /** * User defined functions. * * @var array */ protected $userfuncs; + /** - * The names of constants top prevent overwriting. + * The names of constants, used to make constants read-only. * * @var array */ protected $constvars; + /** * Built in simple (one arg) functions. * Merged into $this->funcs in constructor. @@ -136,18 +140,26 @@ class ctools_math_expr { * @var array */ protected $simplefuncs; + /** - * Other built-in functions. + * Definitions of all built-in functions. * * @var array */ protected $funcs; + /** * Operators and their precedence. * * @var array */ protected $ops; + + /** + * The set of operators using two arguments. + * + * @var array + */ protected $binaryops; /** @@ -421,8 +433,9 @@ class ctools_math_expr { $index = 0; $stack = new ctools_math_expr_stack(); // Postfix form of expression, to be passed to pfx(). - // @var array $output = array(); + + // TODO: Because the expr can contain string operands, using strtolower here is a bug. $expr = trim(strtolower($expr)); // We use this in syntax-checking the expression and determining when @@ -533,7 +546,7 @@ class ctools_math_expr { // Pop the argument expression stuff and push onto the output: while (($o2 = $stack->pop()) !== '(') { - // Oops, never had a (. + // Oops, never had a '('. if (is_null($o2)) { return $this->trigger("unexpected ',' in $expr $o2"); } @@ -809,7 +822,7 @@ class ctools_math_expr { * Message to add to trigger error. * * @return bool - * can trigger error then return FALSE. + * Can trigger error, then returns FALSE. */ protected function trigger($msg) { $this->errors[] = $msg; @@ -921,7 +934,7 @@ function ctools_math_expr_if($expr, $if, $else = NULL) { * Remove any non-digits so that numbers like $4,511.23 still work. * * It might be good for those using the 12,345.67 format, but is awful for - * others. + * those using other conventions. * Use of the php 'intl' module might work here, if the correct locale can be * derived, but that seems unlikely to be true in all cases. * @@ -936,7 +949,7 @@ function ctools_math_expr_if($expr, $if, $else = NULL) { */ function ctools_math_expr_number($arg) { // TODO: A really bad idea: It might be good for those using the 12,345.67 - // format, but is awful for others. + // format, but is awful for those using other conventions. // $arg = preg_replace("/[^0-9\.]/", '', $arg);. return $arg; } diff --git a/includes/uuid.inc b/includes/uuid.inc index 51c15d1..13897f1 100644 --- a/includes/uuid.inc +++ b/includes/uuid.inc @@ -10,7 +10,7 @@ * Pattern for detecting a valid UUID. */ if (!defined('UUID_PATTERN')) { - define('UUID_PATTERN', '[0-9a-userfuncs]{8}-([0-9a-userfuncs]{4}-){3}[0-9a-userfuncs]{12}'); + define('UUID_PATTERN', '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}'); } /**