Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libintl dcngettext: don't return stack garbage when ther...
details: https://anonhg.NetBSD.org/src/rev/d386b82a14a8
branches: trunk
changeset: 580902:d386b82a14a8
user: yamt <yamt%NetBSD.org@localhost>
date: Sun May 15 09:58:06 2005 +0000
description:
dcngettext: don't return stack garbage when there's no usable database.
diffstat:
lib/libintl/gettext.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diffs (47 lines):
diff -r 66aad78bfd3c -r d386b82a14a8 lib/libintl/gettext.c
--- a/lib/libintl/gettext.c Sun May 15 08:01:06 2005 +0000
+++ b/lib/libintl/gettext.c Sun May 15 09:58:06 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gettext.c,v 1.22 2005/05/14 17:58:56 tshiozak Exp $ */
+/* $NetBSD: gettext.c,v 1.23 2005/05/15 09:58:06 yamt Exp $ */
/*-
* Copyright (c) 2000, 2001 Citrus Project,
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: gettext.c,v 1.22 2005/05/14 17:58:56 tshiozak Exp $");
+__RCSID("$NetBSD: gettext.c,v 1.23 2005/05/15 09:58:06 yamt Exp $");
#include <sys/param.h>
#include <sys/stat.h>
@@ -879,6 +879,9 @@
return str;
}
+#define _NGETTEXT_DEFAULT(msgid1, msgid2, n) \
+ ((char *)__UNCONST((n) == 1 ? (msgid1) : (msgid2)))
+
char *
dcngettext(domainname, msgid1, msgid2, n, category)
const char *domainname;
@@ -967,7 +970,7 @@
plural_index = 0;
msgid = msgid1;
} else
- msgid = (n == 1) ? msgid1 : msgid2;
+ msgid = _NGETTEXT_DEFAULT(msgid1, msgid2, n);
if (msgid == NULL)
return NULL;
@@ -995,6 +998,8 @@
msgid = v;
}
+ return (char *)__UNCONST(msgid);
+
fail:
- return (char *)__UNCONST(msgid);
+ return _NGETTEXT_DEFAULT(msgid1, msgid2, n);
}
Home |
Main Index |
Thread Index |
Old Index