Add double type for terminal write in anticipation of future avr-libc extension
This commit is contained in:
parent
feda75b60a
commit
9fe6820236
17
src/term.c
17
src/term.c
|
@ -417,6 +417,7 @@ static int cmd_write(PROGRAMMER * pgm, struct avrpart * p,
|
||||||
// Data union
|
// Data union
|
||||||
union {
|
union {
|
||||||
float f;
|
float f;
|
||||||
|
double d;
|
||||||
int64_t ll;
|
int64_t ll;
|
||||||
uint64_t ull;
|
uint64_t ull;
|
||||||
uint8_t a[8];
|
uint8_t a[8];
|
||||||
|
@ -524,12 +525,19 @@ static int cmd_write(PROGRAMMER * pgm, struct avrpart * p,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!data.size) { // Data item was not recognised as integer
|
if(!data.size) { // Try float
|
||||||
// Try float
|
|
||||||
data.f = strtof(argi, &end_ptr);
|
data.f = strtof(argi, &end_ptr);
|
||||||
if (end_ptr != argi && toupper(*end_ptr) == 'F' && end_ptr[1] == 0) {
|
if (end_ptr != argi && toupper(*end_ptr) == 'F' && end_ptr[1] == 0)
|
||||||
data.size = 4;
|
data.size = 4;
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
if(!data.size) { // Try double
|
||||||
|
data.d = strtod(argi, &end_ptr);
|
||||||
|
if (end_ptr != argi && *end_ptr == 0)
|
||||||
|
data.size = 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!data.size) {
|
||||||
// Try single character
|
// Try single character
|
||||||
if (argi[0] == '\'' && argi[2] == '\'') {
|
if (argi[0] == '\'' && argi[2] == '\'') {
|
||||||
data.ll = argi[1];
|
data.ll = argi[1];
|
||||||
|
@ -555,7 +563,6 @@ static int cmd_write(PROGRAMMER * pgm, struct avrpart * p,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(data.str_ptr) {
|
if(data.str_ptr) {
|
||||||
for(int16_t j = 0; j < strlen(data.str_ptr); j++)
|
for(int16_t j = 0; j < strlen(data.str_ptr); j++)
|
||||||
buf[i - start_offset + data.bytes_grown++] = (uint8_t)data.str_ptr[j];
|
buf[i - start_offset + data.bytes_grown++] = (uint8_t)data.str_ptr[j];
|
||||||
|
|
Loading…
Reference in New Issue