ref: b17c5254eeac1bff7e4b613c151e0232c2cba646
parent: 32c9bb420240cac2120e7e01c2683df88d1dc1ac
author: Chris Moeller <kode54@gmail.com>
date: Sun Nov 25 22:49:04 EST 2012
Remove trailing whitespace from all song, instrument, and sample names
--- a/dumb/src/it/readxm.c
+++ b/dumb/src/it/readxm.c
@@ -114,6 +114,14 @@
+/* Trims off trailing white space, usually added by the tracker on file creation
+ */
+static void trim_whitespace(char *ptr, size_t size)
+{
+ char *p = ptr + size - 1;
+ while (p >= ptr && *p <= 0x20) *p-- = '\0';
+}
+
/* Frees the original block if it can't resize it or if size is 0, and acts
* as malloc if ptr is NULL.
*/
@@ -494,6 +502,7 @@
dumbfile_getnc(instrument->name, 22, f);
instrument->name[22] = 0;
+ trim_whitespace(instrument->name, 22);
instrument->filename[0] = 0;
dumbfile_skip(f, 1); /* Instrument type. Should be 0, but seems random. */
extra->n_samples = dumbfile_igetw(f);
@@ -654,6 +663,7 @@
dumbfile_getnc(sample->name, 22, f);
sample->name[22] = 0;
+ trim_whitespace(sample->name, 22);
sample->filename[0] = 0;
@@ -819,6 +829,7 @@
return NULL;
}
sigdata->name[20] = 0;
+ trim_whitespace(sigdata->name, 20);
if (dumbfile_getc(f) != 0x1A) {
TRACE("XM error: 0x1A not found\n");