Extract space trimming code from ATA and use in USB and bootorder code.
[seabios.git] / src / util.c
index 579a044e52626ac1b3583c65f3391827ab242c00..ed73d632f11e619d1e83fbba7d7c581f82adc481 100644 (file)
@@ -272,6 +272,16 @@ strchr(const char *s, int c)
     return NULL;
 }
 
+// Remove any trailing blank characters (spaces, new lines, carriage returns)
+void
+nullTrailingSpace(char *buf)
+{
+    int len = strlen(buf);
+    char *end = &buf[len-1];
+    while (end >= buf && *end <= ' ')
+        *(end--) = '\0';
+}
+
 /****************************************************************
  * Keyboard calls
  ****************************************************************/