X-Recipient: archive-cygwin@delorie.com
X-Spam-Check-By: sourceware.org
Message-ID: <f60fe000810310403k287b12few441d09d720f1d24d@mail.gmail.com>
Date: Fri, 31 Oct 2008 07:03:28 -0400
From: "Mark J. Reed" <markjreed@gmail.com>
To: cygwin@cygwin.com
Subject: Re: canonicalize_file_name
In-Reply-To: <20081031082454.GB12818@calimero.vinschen.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
References: <001b01c93a65$97134460$4001a8c0@mycomputer> 	 <49099F53.9060105@byu.net> 	 <20081030121050.GL6478@calimero.vinschen.de> 	 <007f01c93abc$68806f40$4001a8c0@mycomputer> 	 <20081031082454.GB12818@calimero.vinschen.de>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

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.  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.

-- 
Mark J. Reed <markjreed@gmail.com>

--
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/

