From owner-freebsd-current@FreeBSD.ORG Tue Jul 10 15:42:29 2007 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2857216A421; Tue, 10 Jul 2007 15:42:29 +0000 (UTC) (envelope-from ache@nagual.pp.ru) Received: from nagual.pp.ru (nagual.pp.ru [194.87.13.69]) by mx1.freebsd.org (Postfix) with ESMTP id 99C7D13C4C2; Tue, 10 Jul 2007 15:42:28 +0000 (UTC) (envelope-from ache@nagual.pp.ru) Received: from nagual.pp.ru (ache@localhost [127.0.0.1]) by nagual.pp.ru (8.14.1/8.14.1) with ESMTP id l6AFfo5M022922; Tue, 10 Jul 2007 19:41:50 +0400 (MSD) (envelope-from ache@nagual.pp.ru) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nagual.pp.ru; s=default; t=1184082110; bh=u/IwOmJsWQwumAl5y1fHQgyZCYD6v2BwKBviive Z1VM=; l=878; h=Received:Date:From:To:Cc:Subject:Message-ID: Mail-Followup-To:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To:User-Agent; b=ABQpZJEdAyF4tR34TT9r aJIalXDZ/GaV3WBeFz1qdzZ3HG9RJETqHSewrV1/5R6UJoClNAnAEGq9sBkN+/Cgsgu aZBfsoyrTeqBbuUT4WJoTgKHLm7dVV+Gy0xh59VnN9P2lMQ02wuHfjEVhRBULnb4jAg ZE6NoFzMljkZDglpA= Received: (from ache@localhost) by nagual.pp.ru (8.14.1/8.14.1/Submit) id l6AFfnXA022921; Tue, 10 Jul 2007 19:41:49 +0400 (MSD) (envelope-from ache) Date: Tue, 10 Jul 2007 19:41:48 +0400 From: Andrey Chernov To: "Sean C. Farley" Message-ID: <20070710154148.GA22873@nagual.pp.ru> Mail-Followup-To: Andrey Chernov , "Sean C. Farley" , Dirk Meyer , freebsd-current@freebsd.org References: <20070703182400.Q1449@baba.farley.org> <20070709145418.T52164@thor.farley.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20070709145418.T52164@thor.farley.org> User-Agent: Mutt/1.5.16 (2007-06-09) Cc: Dirk Meyer , freebsd-current@freebsd.org Subject: Re: HEADS UP: getenv() and family API change X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jul 2007 15:42:29 -0000 On Mon, Jul 09, 2007 at 03:07:42PM -0500, Sean C. Farley wrote: > On Sun, 8 Jul 2007, Dirk Meyer wrote: > >> Hallo Sean C. Farley, >> >>> Changes in moving to POSIX from historic BSD API: >>> b. putenv takes a char * instead of const char *. >>> c. putenv no longer makes a copy of the input string. >> >> Can you give more details? >> >> An application will break in using this: >> putenv("PATH=/bin") >> >> now taking a char *, this will break with gcc42. > > True. As Andrey said, you should pass a copy of a const string into > putenv(). putenv() is designed to allow changing a value at any time by > manipulating the string. This is why I really wish the Open Group would To say strictly, copying somewhere is not neccessary since this way works too: static char *s = "PATH=/bin"; putenv(s); (don't forget static) -- http://ache.pp.ru/