src/lib/rqlParse.c 1.4
1.4 2009/12/03 18:19:28 kent
Adding integer unary minus.
Index: src/lib/rqlParse.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/lib/rqlParse.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -b -B -U 4 -r1.3 -r1.4
--- src/lib/rqlParse.c 3 Dec 2009 18:00:21 -0000 1.3
+++ src/lib/rqlParse.c 3 Dec 2009 18:19:28 -0000 1.4
@@ -44,8 +44,10 @@
return "rqlOpBooleanToDouble";
case rqlOpIntToDouble:
return "rqlOpIntToDouble";
+ case rqlOpUnaryMinusInt:
+ return "rqlOpUnaryMinusInt";
case rqlOpUnaryMinusDouble:
return "rqlOpUnaryMinusDouble";
case rqlOpGt:
@@ -275,13 +277,21 @@
char *tok = tokenizerMustHaveNext(tkz);
if (tok[0] == '-')
{
struct rqlParse *c = rqlParseAtom(tkz);
- c = rqlParseCoerce(c, rqlTypeDouble);
struct rqlParse *p;
AllocVar(p);
+ if (c->type == rqlTypeInt)
+ {
+ p->op = rqlOpUnaryMinusInt;
+ p->type = rqlTypeInt;
+ }
+ else
+ {
+ c = rqlParseCoerce(c, rqlTypeDouble);
p->op = rqlOpUnaryMinusDouble;
p->type = rqlTypeDouble;
+ }
p->children = c;
return p;
}
else