|
|
@@ -472,19 +472,29 @@ static inline int sp_parse_param_assign_intfloat(struct shader_parser *sp,
|
|
|
struct shader_var *param, bool is_float)
|
|
|
{
|
|
|
int code;
|
|
|
+ bool is_negative = false;
|
|
|
|
|
|
if (!cf_next_valid_token(&sp->cfp))
|
|
|
return PARSE_EOF;
|
|
|
|
|
|
+ if (cf_token_is(&sp->cfp, "-")) {
|
|
|
+ is_negative = true;
|
|
|
+
|
|
|
+ if (!cf_next_token(&sp->cfp))
|
|
|
+ return PARSE_EOF;
|
|
|
+ }
|
|
|
+
|
|
|
code = cf_token_is_type(&sp->cfp, CFTOKEN_NUM, "numeric value", ";");
|
|
|
if (code != PARSE_SUCCESS)
|
|
|
return code;
|
|
|
|
|
|
if (is_float) {
|
|
|
float f = (float)strtod(sp->cfp.cur_token->str.array, NULL);
|
|
|
+ if (is_negative) f = -f;
|
|
|
da_push_back_array(param->default_val, &f, sizeof(float));
|
|
|
} else {
|
|
|
long l = strtol(sp->cfp.cur_token->str.array, NULL, 10);
|
|
|
+ if (is_negative) l = -l;
|
|
|
da_push_back_array(param->default_val, &l, sizeof(long));
|
|
|
}
|
|
|
|