this patch adds support for conversion of negative vpiDecStrVal in vpip_dec_str_to_vec4()

This commit is contained in:
Holger Wächtler 2008-07-28 21:40:58 +02:00 committed by Stephen Williams
parent c71e930ffa
commit 484d3ea36b
1 changed files with 10 additions and 0 deletions

View File

@ -229,7 +229,12 @@ void vpip_dec_str_to_vec4(vvp_vector4_t&vec,
input is "1234", str gets "4321". */
unsigned slen = strlen(buf);
char*str = new char[slen + 1];
int is_negative = 0;
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]))
str[idx] = buf[slen-idx-1];
else
@ -266,5 +271,10 @@ void vpip_dec_str_to_vec4(vvp_vector4_t&vec,
}
if (is_negative) {
vec.invert();
vec += 1;
}
delete[]str;
}