www.delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
X-Spam-Check-By: | sourceware.org |
Date: | Fri, 31 Oct 2008 12:17:22 +0100 |
From: | Corinna Vinschen <corinna-cygwin AT cygwin DOT com> |
To: | cygwin AT cygwin DOT com |
Subject: | Re: canonicalize_file_name |
Message-ID: | <20081031111722.GA14239@calimero.vinschen.de> |
Reply-To: | cygwin AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
References: | <001b01c93a65$97134460$4001a8c0 AT mycomputer> <49099F53 DOT 9060105 AT byu DOT net> <20081030121050 DOT GL6478 AT calimero DOT vinschen DOT de> <007f01c93abc$68806f40$4001a8c0 AT mycomputer> <20081031082454 DOT GB12818 AT calimero DOT vinschen DOT de> <f60fe000810310403k287b12few441d09d720f1d24d AT mail DOT gmail DOT com> |
MIME-Version: | 1.0 |
In-Reply-To: | <f60fe000810310403k287b12few441d09d720f1d24d@mail.gmail.com> |
User-Agent: | Mutt/1.5.16 (2007-06-09) |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
On Oct 31 07:03, Mark J. Reed wrote: > John Emmas> Calling 'canonicalize_file_name(path)' is equivalent to calling > JE> 'realpath(path, NULL)' By a stroke of luck, 'realpath()' is defined in > JE> cygwin/stdlib.h so maybe I should use that? > > Corinna Vinschen> Yes, sure. > > Yes, you should use realpath(), but passing it NULL won't necessarily > work. The second argument is supposed to be a pointer to the buffer > in which it should put its result, and according to POSIX the call > should fail if that argument is NULL. > > GNU has extended its version of realpath() to dynamically allocate a > result buffer when the second argument is NULL. I would not assume > that Cygwin does likewise, since it's a libc function and Cygwin > doesn't use GNU libc. Cygwin follows the GNU extension here. NULL as second pointer results in realpath returning a mallocated buffer. > The safest course would be to declare or > preallocate a buffer of size PATH_MAX and pass it to realpath(); that > should work with any POSIX-compliant C library. Neverthless this is good advice if portability is an issue. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Project Co-Leader cygwin AT cygwin DOT com Red Hat -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |