HAL_PX4: make PX4 snprintf support %S format

just maps it to %s for normal printf
This commit is contained in:
Andrew Tridgell 2013-05-08 16:17:06 +10:00
parent 223dfe4de5
commit 9cd0af1132
1 changed files with 20 additions and 2 deletions

View File

@ -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"