mirror of https://github.com/ArduPilot/ardupilot
HAL_PX4: make PX4 snprintf support %S format
just maps it to %s for normal printf
This commit is contained in:
parent
223dfe4de5
commit
9cd0af1132
|
@ -12,9 +12,27 @@
|
|||
|
||||
extern const AP_HAL::HAL& hal;
|
||||
|
||||
static int libc_vsnprintf(char* str, size_t size, const char *format, va_list ap)
|
||||
/*
|
||||
implement vsnprintf with support for %S meaning a progmem string
|
||||
*/
|
||||
static int libc_vsnprintf(char* str, size_t size, const char *fmt, va_list ap)
|
||||
{
|
||||
return vsnprintf(str, size, format, ap);
|
||||
int i, ret;
|
||||
char *fmt2 = (char *)fmt;
|
||||
if (strstr(fmt2, "%S") != NULL) {
|
||||
fmt2 = strdup(fmt);
|
||||
for (i=0; fmt2[i]; i++) {
|
||||
// cope with %S
|
||||
if (fmt2[i] == '%' && fmt2[i+1] == 'S') {
|
||||
fmt2[i+1] = 's';
|
||||
}
|
||||
}
|
||||
}
|
||||
ret = vsnprintf(str, size, fmt2, ap);
|
||||
if (fmt2 != fmt) {
|
||||
free(fmt2);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#include "Util.h"
|
||||
|
|
Loading…
Reference in New Issue