From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32696 invoked by alias); 24 Nov 2008 20:22:37 -0000 Received: (qmail 32605 invoked by uid 22791); 24 Nov 2008 20:22:36 -0000 X-Spam-Check-By: sourceware.org Received: from NaN.false.org (HELO nan.false.org) (208.75.86.248) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 24 Nov 2008 20:21:56 +0000 Received: from nan.false.org (localhost [127.0.0.1]) by nan.false.org (Postfix) with ESMTP id 9F61010D50; Mon, 24 Nov 2008 20:21:46 +0000 (GMT) Received: from caradoc.them.org (209.195.188.212.nauticom.net [209.195.188.212]) by nan.false.org (Postfix) with ESMTP id 8BC5910AD3; Mon, 24 Nov 2008 20:21:46 +0000 (GMT) Received: from drow by caradoc.them.org with local (Exim 4.69) (envelope-from ) id 1L4hwI-0000c1-3S; Mon, 24 Nov 2008 15:21:46 -0500 Date: Tue, 25 Nov 2008 02:16:00 -0000 From: Daniel Jacobowitz To: Thiago Jung Bauermann Cc: gdb-patches ml Subject: Re: [RFA] Add la_getstr member to language_defn Message-ID: <20081124202146.GA1991@caradoc.them.org> Mail-Followup-To: Thiago Jung Bauermann , gdb-patches ml References: <1227417278.28256.183.camel@localhost.localdomain> <20081123161013.GA15069@caradoc.them.org> <1227490821.8533.25.camel@hotblack.bauerhaus> <20081124022858.GA19331@caradoc.them.org> <1227551659.28256.225.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1227551659.28256.225.camel@localhost.localdomain> User-Agent: Mutt/1.5.17 (2008-05-11) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-11/txt/msg00667.txt.bz2 On Mon, Nov 24, 2008 at 04:34:19PM -0200, Thiago Jung Bauermann wrote: > Would the comment above be clearer if it read as follows? > > If LEN > 0, reads exactly LEN characters (including eventual NULs in > the middle or end of the string). If LEN is -1, stops at the first > null character (not necessarily the first null byte) up to a maximum > of FETCHLIMIT characters. Set FETCHLIMIT to UINT_MAX to read as many > characters as possible from the string. Yes, I do think that's clearer. I didn't realize on a quick read that LEN and FETCHLIMIT were different... sorry for the confusion. > By the way, I just realised that if LEN is 0, BUFFER is not allocated, > contradicting the property I mention in the comment that "unless an > exception is thrown, BUFFER will always be allocated, even on failure". > I'll change it to allocate a 1 byte buffer in this case, to keep the > caller's life simple. Speaking of BUFFER, this is GDB - it's written in a language with null-terminated strings. Would a definition of read_string that always null-terminated the buffer be more useful, or just confusing? Now the result is null-terminated iff the target string is. Of course the string might include zero bytes if it's an array, but the caller knows this. It would make it easier to use the returned buffer when reading a variable-length string, I think. -- Daniel Jacobowitz CodeSourcery