From 0c36fb149811576df1cb831916d8fd65568c2cb0 Mon Sep 17 00:00:00 2001 From: yamt Date: Sun, 9 Dec 2001 11:11:01 +0000 Subject: [PATCH] allow relative pathnames as a dirname argument of bindtextdomain(3) since some autoconf configure scripts depends on this behavior. --- lib/libintl/gettext.c | 18 ++++++++++++++++-- lib/libintl/textdomain.c | 7 +++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/libintl/gettext.c b/lib/libintl/gettext.c index 72a32c6ed6aa..09c0a1fe5d25 100644 --- a/lib/libintl/gettext.c +++ b/lib/libintl/gettext.c @@ -1,4 +1,4 @@ -/* $NetBSD: gettext.c,v 1.10 2001/09/27 15:29:06 yamt Exp $ */ +/* $NetBSD: gettext.c,v 1.11 2001/12/09 11:11:01 yamt Exp $ */ /*- * Copyright (c) 2000, 2001 Citrus Project, @@ -30,7 +30,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: gettext.c,v 1.10 2001/09/27 15:29:06 yamt Exp $"); +__RCSID("$NetBSD: gettext.c,v 1.11 2001/12/09 11:11:01 yamt Exp $"); #endif /* LIBC_SCCS and not lint */ #include @@ -587,6 +587,20 @@ dcngettext(domainname, msgid1, msgid2, n, category) db = __bindings; } + /* resolve relative path */ + /* XXX not necessary? */ + if (db->path[0] != '/') { + char buf[PATH_MAX]; + + if (getcwd(buf, sizeof(buf)) == 0) + goto fail; + if (strlcat(buf, "/", sizeof(buf)) >= sizeof(buf)) + goto fail; + if (strlcat(buf, db->path, sizeof(buf)) >= sizeof(buf)) + goto fail; + strcpy(db->path, buf); + } + /* don't bother looking it up if the values are the same */ if (odomainname && strcmp(domainname, odomainname) == 0 && ocname && strcmp(cname, ocname) == 0 && strcmp(lpath, olpath) == 0 && diff --git a/lib/libintl/textdomain.c b/lib/libintl/textdomain.c index 78046849ee4d..61a8275c2c40 100644 --- a/lib/libintl/textdomain.c +++ b/lib/libintl/textdomain.c @@ -1,4 +1,4 @@ -/* $NetBSD: textdomain.c,v 1.5 2001/02/16 07:20:35 minoura Exp $ */ +/* $NetBSD: textdomain.c,v 1.6 2001/12/09 11:11:01 yamt Exp $ */ /*- * Copyright (c) 2000, 2001 Citrus Project, @@ -28,7 +28,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: textdomain.c,v 1.5 2001/02/16 07:20:35 minoura Exp $"); +__RCSID("$NetBSD: textdomain.c,v 1.6 2001/12/09 11:11:01 yamt Exp $"); #endif /* LIBC_SCCS and not lint */ #include @@ -83,9 +83,12 @@ bindtextdomain(domainname, dirname) if (strlen(dirname) + 1 > sizeof(p->path)) return NULL; + +#if 0 /* disallow relative path */ if (dirname[0] != '/') return NULL; +#endif if (strlen(domainname) + 1 > sizeof(p->domainname)) return NULL;