浏览代码

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";
 }