From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Ryde Newsgroups: gmane.lisp.guile.devel Subject: Re: Guile 1.7.91 has been released. Date: Tue, 14 Feb 2006 11:58:54 +1100 Message-ID: <877j7ysqlt.fsf@zip.com.au> References: <87y80gyxrq.fsf@zagadka.de> <20060213124618.M39651@ccrma.Stanford.EDU> <87wtfzrlfp.fsf@zip.com.au> <20060213223050.M63331@ccrma.Stanford.EDU> <87bqxaswk2.fsf@zip.com.au> <20060213233342.M49809@ccrma.Stanford.EDU> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1139879218 18310 80.91.229.2 (14 Feb 2006 01:06:58 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 14 Feb 2006 01:06:58 +0000 (UTC) Cc: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Feb 14 02:06:57 2006 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1F8oeX-0007AE-Dt for guile-devel@m.gmane.org; Tue, 14 Feb 2006 02:06:49 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1F8oeW-0003N5-Hc for guile-devel@m.gmane.org; Mon, 13 Feb 2006 20:06:48 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1F8oXL-0000Mv-Tj for guile-devel@gnu.org; Mon, 13 Feb 2006 19:59:24 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1F8oXH-0000L4-AL for guile-devel@gnu.org; Mon, 13 Feb 2006 19:59:22 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1F8oXG-0000Km-VY for guile-devel@gnu.org; Mon, 13 Feb 2006 19:59:19 -0500 Original-Received: from [61.8.0.84] (helo=mailout1.pacific.net.au) by monty-python.gnu.org with esmtp (Exim 4.52) id 1F8obp-0001zu-8v for guile-devel@gnu.org; Mon, 13 Feb 2006 20:04:01 -0500 Original-Received: from mailproxy1.pacific.net.au (mailproxy1.pacific.net.au [61.8.0.86]) by mailout1.pacific.net.au (8.13.4/8.13.4/Debian-3) with ESMTP id k1E0xAxf030078; Tue, 14 Feb 2006 11:59:11 +1100 Original-Received: from localhost (ppp230A.dyn.pacific.net.au [61.8.35.10]) by mailproxy1.pacific.net.au (8.13.4/8.13.4/Debian-3) with ESMTP id k1E0x88R026819; Tue, 14 Feb 2006 11:59:09 +1100 Original-Received: from gg by localhost with local (Exim 3.36 #1 (Debian)) id 1F8oWs-00082D-00; Tue, 14 Feb 2006 11:58:54 +1100 Original-To: "Bill Schottstaedt" Mail-Copies-To: never In-Reply-To: <20060213233342.M49809@ccrma.Stanford.EDU> (Bill Schottstaedt's message of "Mon, 13 Feb 2006 15:35:07 -0800") User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:5697 Archived-At: "Bill Schottstaedt" writes: > > I found some examples by Googling for readdir_r and _PC_NAME_MAX. Incomplete bit of code below, it's not pretty but I guess it's what has to be done. #if HAVE_READDIR_R /* On Solaris 2.7, struct dirent only contains "char d_name[1]" and the application is expected to provide a buffer of "sizeof(struct dirent) + NAME_MAX" bytes. The glibc 2.3.2 manual notes this sort of thing too, and advises "offsetof(struct dirent,d_name) + NAME_MAX + 1". On Solaris 2.10, there's no NAME_MAX because it varies according to the filesystem, one is expected to use pathconf(). So the code below tries a plain struct dirent, plus all three of the above possibly bigger sizes, to establish the buffer. If we're not using pathconf then the size is a constant and we don't need to malloc/free, but let's assume for modern systems pathconf is usual so most of the time we'll be wanting a dynamic size. */ size_t bufsize = sizeof (struct dirent); char *buf; int old_errno; #ifdef NAME_MAX bufsize = SCM_MAX (bufsize, sizeof(struct dirent) + NAME_MAX); bufsize = SCM_MAX (bufsize, offsetof (struct dirent, d_name) + NAME_MAX + 1\); #endif #ifdef _PC_NAME_MAX { char *c_dirname = scm_to_locale_string (SCM_FILENAME (port)); long name_max = pathconf (c_dirname, _PC_NAME_MAX); old_errno = errno; free (c_dirname); errno = old_errno; if (name_max == -1) SCM_SYSERROR; bufsize = SCM_MAX (bufsize, name_max); } #endif buf = scm_malloc (bufsize); SCM_SYSCALL (readdir_r ((DIR *) SCM_CELL_WORD_1 (port), (struct dirent *) buf, &rdent)); ... _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://lists.gnu.org/mailman/listinfo/guile-devel