On Fri, Nov 08, 2019 at 09:27:34PM +0100, René Scharfe wrote: > @@ -285,15 +289,10 @@ static int validate_encoding(const char *path, const char *enc, > */ > const char *advise_msg = _( > "The file '%s' contains a byte order " > - "mark (BOM). Please use UTF-%s as " > + "mark (BOM). Please use UTF-%.*s as " > "working-tree-encoding."); > - const char *stripped = NULL; > - char *upper = xstrdup_toupper(enc); > - upper[strlen(upper)-2] = '\0'; > - if (skip_prefix(upper, "UTF", &stripped)) > - skip_prefix(stripped, "-", &stripped); > - advise(advise_msg, path, stripped); > - free(upper); > + int stripped_len = strlen(stripped) - strlen("BE"); > + advise(advise_msg, path, stripped_len, stripped); I think we could drop xstrdup_toupper() after this. Of course it _could_ come in handy in another spot, but in most cases you can use xstrdup_tolower() interchangeably (e.g., that would have worked here). And even the tolower() variant is seldom used. -Peff