diff --git a/src/dehacked.c b/src/dehacked.c index 627a3a119..b5ba248ce 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -769,7 +769,8 @@ static void readthing(MYFILE *f, INT32 num) static void readskincolor(MYFILE *f, INT32 num) { char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); - char *word, *word2, *word3; + char *word = s; + char *word2; char *tmp; Color_cons_t[num].value = num; @@ -781,32 +782,31 @@ static void readskincolor(MYFILE *f, INT32 num) if (s[0] == '\n') break; + // First remove trailing newline, if there is one + tmp = strchr(s, '\n'); + if (tmp) + *tmp = '\0'; + tmp = strchr(s, '#'); if (tmp) *tmp = '\0'; if (s == tmp) continue; // Skip comment lines, but don't break. - word = strtok(s, " "); - if (word) - strupr(word); + // Get the part before the " = " + tmp = strchr(s, '='); + if (tmp) + *(tmp-1) = '\0'; else break; + strupr(word); - word2 = strtok(NULL, " = "); - if (word2) { - word3 = Z_StrDup(word2); - strupr(word2); - } else - break; - if (word2[strlen(word2)-1] == '\n') - word2[strlen(word2)-1] = '\0'; - if (word3[strlen(word3)-1] == '\n') - word3[strlen(word3)-1] = '\0'; + // Now get the part after + word2 = tmp += 2; if (fastcmp(word, "NAME")) { - deh_strlcpy(skincolors[num].name, word3, + deh_strlcpy(skincolors[num].name, word2, sizeof (skincolors[num].name), va("Skincolor %d: name", num)); } else if (fastcmp(word, "RAMP"))