- static const char *lastArg = NULL;
- char op, *s, *e, *p;
- double val;
- int i, *map[] = { &bx, &by, &bw, &bh,
- &wx, &wy, &ww, &wh,
- &mx, &my, &mw, &mh,
- &tx, &ty, &tw, &th,
- &mox, &moy, &mow, &moh };
-
- if(!arg)
- arg = lastArg;
- else
- lastArg = arg;
- if(!lastArg)
- return;
- strncpy(buf, arg, sizeof buf);
- for(i = 0, e = s = buf; e && *e; e++)
- if(*e == ' ') {
- *e = 0;
- fprintf(stderr, "next geom arg='%s'\n", s);
- op = 0;
- /* check if there is an operator */
- for(p = s; *p && *p != '-' && *p != '+' && *p != '*' && *p != ':'; p++);
- if(*p) {
- op = *p;
- *p = 0;
- }
- val = getdouble(s);
- fprintf(stderr, "val1: %d\n", val);
- if(p > s) { /* intermediate operand, e.g. H-B */
- *(map[i]) = val;
- s = ++p;
- val = getdouble(s);
- fprintf(stderr, "val2: %d\n", val);
- }
- switch(op) {
- default: *(map[i]) = val; break;
- case '-': *(map[i]) -= val; break;
- case '+': *(map[i]) += val; break;
- case '*': *(map[i]) *= val; break;
- case ':': if(val != 0) *(map[i]) /= val; break;
- }
- fprintf(stderr, "map[i]='%d'\n", val);
- s = ++e;
- i++;
- }