this patch adds support for conversion of negative vpiDecStrVal in vpip_dec_str_to_vec4()
This commit is contained in:
parent
c71e930ffa
commit
484d3ea36b
|
|
@ -229,7 +229,12 @@ void vpip_dec_str_to_vec4(vvp_vector4_t&vec,
|
||||||
input is "1234", str gets "4321". */
|
input is "1234", str gets "4321". */
|
||||||
unsigned slen = strlen(buf);
|
unsigned slen = strlen(buf);
|
||||||
char*str = new char[slen + 1];
|
char*str = new char[slen + 1];
|
||||||
|
int is_negative = 0;
|
||||||
for (unsigned idx = 0 ; idx < slen ; idx += 1) {
|
for (unsigned idx = 0 ; idx < slen ; idx += 1) {
|
||||||
|
if (idx == slen-1 && buf[slen-idx-1] == '-') {
|
||||||
|
is_negative = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (isdigit(buf[slen-idx-1]))
|
if (isdigit(buf[slen-idx-1]))
|
||||||
str[idx] = buf[slen-idx-1];
|
str[idx] = buf[slen-idx-1];
|
||||||
else
|
else
|
||||||
|
|
@ -266,5 +271,10 @@ void vpip_dec_str_to_vec4(vvp_vector4_t&vec,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_negative) {
|
||||||
|
vec.invert();
|
||||||
|
vec += 1;
|
||||||
|
}
|
||||||
|
|
||||||
delete[]str;
|
delete[]str;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue