From owner-freebsd-hackers Thu Dec 11 01:13:34 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id BAA22143 for hackers-outgoing; Thu, 11 Dec 1997 01:13:34 -0800 (PST) (envelope-from owner-freebsd-hackers) Received: from wafu.netgate.net (wafu.netgate.net [204.145.147.80]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id BAA22127 for ; Thu, 11 Dec 1997 01:13:27 -0800 (PST) (envelope-from shigio@wafu.netgate.net) Received: from chiota.signet.or.jp (INS62.tama.dti.ne.jp [210.159.144.16]) by wafu.netgate.net (8.7.5/8.7.3) with ESMTP id BAA10321; Thu, 11 Dec 1997 01:15:38 GMT Message-Id: <199712110115.BAA10321@wafu.netgate.net> Received: from chiota.signet.or.jp (localhost.signet.or.jp [127.0.0.1]) by chiota.signet.or.jp (8.8.5/) with ESMTP id SAA04060; Thu, 11 Dec 1997 18:13:12 +0900 (JST) To: John Polstra cc: shigio@wafu.netgate.net, hackers@freebsd.org Subject: Re: [RFC] path converting functions. Date: Thu, 11 Dec 1997 18:13:11 +0900 From: Shigio Yamaguchi Sender: owner-freebsd-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk In article <199712110527.VAA24691@austin.polstra.com>, John Polstra wrote: > Well, in my opinion the example set by realpath(3) is bad and it > shouldn't be copied in new code. I say again, if a function writes > into a caller-supplied buffer then the caller should also specify > how large the buffer is. Using a compiled in assumption such as > MAXPATHLEN is risky at best. What if you build your program on one > machine and then run it on a machine where MAXPATHLEN has a different > value? Or, for that matter, on the same machine after some wiz has > decided to change the value of MAXPATHLEN? You are right. It seems your style is better and I understood getcwd(3) which is the new interface of getwd(3) uses your style. I'll change the interface like this. SYNOPSIS #include char * abs2rel(const char *path, const char *base, char result[MAXPATHLEN]) | v SYNOPSIS char * abs2rel(const char *path, const char *base, char *result, size_t size) ~~~~~~~~~~~~ ~~~~~~~~~~~ buffer address, buffer size > > Anyway, that's all the arguing I want to do. You asked for opinions > and I gave you mine. :-) It's precious to me. Thank you. :) -- Shigio Yamaguchi (Freelance programmer) Mail: shigio@wafu.netgate.net, WWW: http://wafu.netgate.net/tama/