convert: fix handling of dashless UTF prefix in validate_encoding()
Strip "UTF" and an optional dash from the start of 'upper' without passing a NULL pointer to skip_prefix() in the second call, as it cannot handle that. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Oct 4, 2019 at 21:25 UTC
b181676ce9e8c89a39737f098d9b9c4f774596cf
1 file changed
+4
-4
convert.c
+4
-4
@@ -289,8 +289,8 @@ static int validate_encoding(const char *path, const char *enc,
289
const char *stripped = NULL;
290
char *upper = xstrdup_toupper(enc);
291
upper[strlen(upper)-2] = '\0';
292
- if (!skip_prefix(upper, "UTF-", &stripped))
293
- skip_prefix(stripped, "UTF", &stripped);
292
+ if (skip_prefix(upper, "UTF", &stripped))
293
+ skip_prefix(stripped, "-", &stripped);
294
advise(advise_msg, path, stripped);
295
free(upper);
296
if (die_on_error)
@@ -309,8 +309,8 @@ static int validate_encoding(const char *path, const char *enc,
309
"working-tree-encoding.");
310
const char *stripped = NULL;
311
char *upper = xstrdup_toupper(enc);
312
- if (!skip_prefix(upper, "UTF-", &stripped))
313
- skip_prefix(stripped, "UTF", &stripped);
312
+ if (skip_prefix(upper, "UTF", &stripped))
313
+ skip_prefix(stripped, "-", &stripped);
314
advise(advise_msg, path, stripped, stripped);
315
free(upper);
316
if (die_on_error)