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>
This commit is contained in:

committed by
Junio C Hamano

parent
aeb582a983
commit
b181676ce9
@ -289,8 +289,8 @@ static int validate_encoding(const char *path, const char *enc,
|
|||||||
const char *stripped = NULL;
|
const char *stripped = NULL;
|
||||||
char *upper = xstrdup_toupper(enc);
|
char *upper = xstrdup_toupper(enc);
|
||||||
upper[strlen(upper)-2] = '\0';
|
upper[strlen(upper)-2] = '\0';
|
||||||
if (!skip_prefix(upper, "UTF-", &stripped))
|
if (skip_prefix(upper, "UTF", &stripped))
|
||||||
skip_prefix(stripped, "UTF", &stripped);
|
skip_prefix(stripped, "-", &stripped);
|
||||||
advise(advise_msg, path, stripped);
|
advise(advise_msg, path, stripped);
|
||||||
free(upper);
|
free(upper);
|
||||||
if (die_on_error)
|
if (die_on_error)
|
||||||
@ -309,8 +309,8 @@ static int validate_encoding(const char *path, const char *enc,
|
|||||||
"working-tree-encoding.");
|
"working-tree-encoding.");
|
||||||
const char *stripped = NULL;
|
const char *stripped = NULL;
|
||||||
char *upper = xstrdup_toupper(enc);
|
char *upper = xstrdup_toupper(enc);
|
||||||
if (!skip_prefix(upper, "UTF-", &stripped))
|
if (skip_prefix(upper, "UTF", &stripped))
|
||||||
skip_prefix(stripped, "UTF", &stripped);
|
skip_prefix(stripped, "-", &stripped);
|
||||||
advise(advise_msg, path, stripped, stripped);
|
advise(advise_msg, path, stripped, stripped);
|
||||||
free(upper);
|
free(upper);
|
||||||
if (die_on_error)
|
if (die_on_error)
|
||||||
|
Reference in New Issue
Block a user