mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-31 02:01:35 +08:00
Merge branch 'px4io-i2c' of github.com:PX4/Firmware into px4io-i2c-throttle
This commit is contained in:
@@ -117,7 +117,23 @@ load(const char *devname, const char *fname)
|
|||||||
if ((strlen(line) < 2) || !isupper(line[0]) || (line[1] != ':'))
|
if ((strlen(line) < 2) || !isupper(line[0]) || (line[1] != ':'))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* XXX an optimisation here would be to strip extra whitespace */
|
/* compact whitespace in the buffer */
|
||||||
|
char *t, *f;
|
||||||
|
for (f = buf; *f != '\0'; f++) {
|
||||||
|
/* scan for space characters */
|
||||||
|
if (*f == ' ') {
|
||||||
|
/* look for additional spaces */
|
||||||
|
t = f + 1;
|
||||||
|
while (*t == ' ')
|
||||||
|
t++;
|
||||||
|
if (*t == '\0') {
|
||||||
|
/* strip trailing whitespace */
|
||||||
|
*f = '\0';
|
||||||
|
} else if (t > (f + 1)) {
|
||||||
|
memmove(f + 1, t, strlen(t) + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* if the line is too long to fit in the buffer, bail */
|
/* if the line is too long to fit in the buffer, bail */
|
||||||
if ((strlen(line) + strlen(buf) + 1) >= sizeof(buf))
|
if ((strlen(line) + strlen(buf) + 1) >= sizeof(buf))
|
||||||
|
|||||||
Reference in New Issue
Block a user