Преглед изворни кода

bind_textdomain_codeset: fix return value

this function is documented as returning a null pointer on failure and
the current textdomain encoding, which is always UTF-8 in our
implementation, on success. there was some confusion over whether it's
expected to also return a null pointer in the case where it's using
the locale's encoding by default, rather than an explicitly bound one,
but it does not seem like that behavior would match applications'
expectations, and it would require gratuitously storing a meaningless
1-bit state for the textdomain.
Rich Felker пре 3 месеци
родитељ
комит
cabbd8697d
1 измењених фајлова са 4 додато и 2 уклоњено
  1. 4 2
      src/locale/bind_textdomain_codeset.c

+ 4 - 2
src/locale/bind_textdomain_codeset.c

@@ -5,7 +5,9 @@
 
 char *bind_textdomain_codeset(const char *domainname, const char *codeset)
 {
-	if (codeset && strcasecmp(codeset, "UTF-8"))
+	if (codeset && strcasecmp(codeset, "UTF-8")) {
 		errno = EINVAL;
-	return NULL;
+		return 0;
+	}
+	return "UTF-8";
 }