This should fix sf.net #2953283
const char *p, *e;
p = arg;
const char *p, *e;
p = arg;
+ e = arg + strlen(arg)-1;
- if (*(e - 1) == ' ')
- e--;
- while (*e && *e == ' ')
+ while (p != e && *e && *e == ' ')
e--;
while (p != e && *p == ' ')
p++;
e--;
while (p != e && *p == ' ')
p++;
if (*p == '-') //allow negative values
p++;
if (*p == '-') //allow negative values
p++;
if (!isdigit(*p))
break;
p++;
}
if (!isdigit(*p))
break;
p++;
}
return ARG_LONG;
if (*p == '.') {
p++;
return ARG_LONG;
if (*p == '.') {
p++;
p++;
}
return ARG_DOUBLE;
}
p++;
}
return ARG_DOUBLE;
}
}
char *arg_to_string(const char *arg)
}
char *arg_to_string(const char *arg)
type1 = get_arg_type(expr_dup);
type2 = get_arg_type(expr_dup + idx + 1);
type1 = get_arg_type(expr_dup);
type2 = get_arg_type(expr_dup + idx + 1);
+ if (type1 == ARG_BAD || type2 == ARG_BAD) {
+ NORM_ERR("Bad arguments: '%s' and '%s'", expr_dup, (expr_dup + idx + 1));
+ return -2;
+ }
if (type1 == ARG_LONG && type2 == ARG_DOUBLE)
type1 = ARG_DOUBLE;
if (type1 == ARG_DOUBLE && type2 == ARG_LONG)
if (type1 == ARG_LONG && type2 == ARG_DOUBLE)
type1 = ARG_DOUBLE;
if (type1 == ARG_DOUBLE && type2 == ARG_LONG)
case ARG_DOUBLE:
return dcompare(arg_to_double(expr_dup), mtype,
arg_to_double(expr_dup + idx + 1));
case ARG_DOUBLE:
return dcompare(arg_to_double(expr_dup), mtype,
arg_to_double(expr_dup + idx + 1));
+ case ARG_BAD: /* make_gcc_happy() */;
}
/* not reached */
return -2;
}
/* not reached */
return -2;
+ ARG_BAD = 0, /* something strange */
ARG_STRING = 1, /* "asdf" */
ARG_LONG = 2, /* 123456 */
ARG_DOUBLE = 3, /* 12.456 */
ARG_STRING = 1, /* "asdf" */
ARG_LONG = 2, /* 123456 */
ARG_DOUBLE = 3, /* 12.456 */