aboutsummaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2013-03-06 22:36:53 +0100
committerLorenz Meier <lm@inf.ethz.ch>2013-03-06 22:36:53 +0100
commit84f9599cb3074a3a3e53fffa55e825c82232c911 (patch)
tree83f4111be410b074c036e721eea64256b5cfa7a0 /apps
parentae98836db8948edbcf59333627b25f69df4127d4 (diff)
parentb526bab1748f8a74202caf42966a5a719bba28ad (diff)
downloadpx4-firmware-84f9599cb3074a3a3e53fffa55e825c82232c911.tar.gz
px4-firmware-84f9599cb3074a3a3e53fffa55e825c82232c911.tar.bz2
px4-firmware-84f9599cb3074a3a3e53fffa55e825c82232c911.zip
Merge branch 'px4io-i2c' of github.com:PX4/Firmware into px4io-i2c-throttle
Diffstat (limited to 'apps')
-rw-r--r--apps/systemcmds/mixer/mixer.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/apps/systemcmds/mixer/mixer.c b/apps/systemcmds/mixer/mixer.c
index e2f7b5bd5..55c4f0836 100644
--- a/apps/systemcmds/mixer/mixer.c
+++ b/apps/systemcmds/mixer/mixer.c
@@ -117,7 +117,23 @@ load(const char *devname, const char *fname)
if ((strlen(line) < 2) || !isupper(line[0]) || (line[1] != ':'))
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 ((strlen(line) + strlen(buf) + 1) >= sizeof(buf))