From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 100512 invoked by alias); 21 May 2015 23:33:56 -0000 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 Received: (qmail 100502 invoked by uid 89); 21 May 2015 23:33:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 21 May 2015 23:33:55 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 3B434306019; Thu, 21 May 2015 23:33:54 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t4LNXqcS008449; Thu, 21 May 2015 19:33:53 -0400 Message-ID: <555E6B60.8040802@redhat.com> Date: Thu, 21 May 2015 23:33:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Patrick Palka , gdb-patches@sourceware.org Subject: Re: [PATCH] Tweak the handling of $HISTSIZE edge cases [PR gdb/16999] References: <1432248648-7402-1-git-send-email-patrick@parcs.ath.cx> In-Reply-To: <1432248648-7402-1-git-send-email-patrick@parcs.ath.cx> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2015-05/txt/msg00580.txt.bz2 On 05/21/2015 11:50 PM, Patrick Palka wrote: The test is OK. Good use of with_test_prefix. Minor nit: I found no other use of with_test_prefix with spaces around the '='. > diff --git a/gdb/top.c b/gdb/top.c > index 74e1e07..38b4e5d 100644 > --- a/gdb/top.c > +++ b/gdb/top.c > @@ -1684,17 +1684,21 @@ init_history (void) > if (tmpenv) > { > int var; > + char *endptr; > > - var = atoi (tmpenv); > - if (var < 0) > - { > - /* Prefer ending up with no history rather than overflowing > - readline's history interface, which uses signed 'int' > - everywhere. */ > - var = 0; > - } > + var = strtol (tmpenv, &endptr, 10); > > - history_size_setshow_var = var; > + /* If HISTSIZE is the empty string, negative, or non-numeric then set the > + history size to unlimited. This behavior is mostly consistent with > + that of bash. Whereas bash ignores a non-numeric HISTSIZE, we set the > + history to unlimited in that case to avoid potentially truncating the > + user's history. */ > + if (strlen (tmpenv) == 0 > + || var < 0 > + || *endptr != '\0') If I'm reading correctly, this treats HISTSIZE=" " as "disable history". Is that intended? Also, a nit: I find it a bit odd to see strlen to check empty string in one case, and != '\0' in another, instead of: if (*tmpenv == '\0' || var < 0 || *endptr != '\0') > + history_size_setshow_var = -1; > + else > + history_size_setshow_var = var; > } > /* If the init file hasn't set a size yet, pick the default. */ > else if (history_size_setshow_var == -2) Thanks, Pedro Alves