+
+char *strip(char *name)
+{
+ // Trim leading whitespace
+ while(isspace((unsigned char)*name))
+ name++; // LCOV_EXCL_LINE
+ if(*name != '\0') {
+ // Trim trailing whitespace;
+ // might be left there by autocomplete
+ char *end = name + strlen(name) - 1;
+ while(end > name && isspace((unsigned char)*end))
+ end--;
+ // Write new null terminator character
+ end[1] = '\0';
+ }
+
+ return name;
+}
+