From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id AB1D53857C75 for ; Sat, 21 Nov 2020 10:42:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org AB1D53857C75 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=andrew.burgess@embecosm.com Received: by mail-wr1-x431.google.com with SMTP id 23so13452510wrc.8 for ; Sat, 21 Nov 2020 02:42:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Ffl7p40yFxNhyUcdg/d1mkYHhGz56Esv5lpyyWFLoyE=; b=Gvz3y03xZiqO+zUreSN9hgNhvj70j2q5cu2kdGrtoG5exuMlyBUu7wFAJJ3Y6/+Ip9 FmhFISc/5u1/1h50RycCOnZpTDdFcGk1qaEkOWgBqirmQOiKw7mCHDEGEmxPI5r+uvuA PJ3r+RJSLR2OIemex38vMsZxxPHBM+9E/ZuGZQrBcLFCtz5FgLKpvTRvEn1XDY+9pTfx O9VxvYyAH5WeSXMsipXp2FkXVdyWaJ5bkmzJp+pFpunO0ZcofpsbTSIw7CW05B2+FcjS Gj7GM6iloNmFe2O3Ih2NsRRFIIcawTbGWQCXL1ynJseu2yPhMqNWO5WQHu3qMvaA2tW8 ZXog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Ffl7p40yFxNhyUcdg/d1mkYHhGz56Esv5lpyyWFLoyE=; b=XN+MeSSc2NaXjrIZzanyfP4Yj92XOhjTnGo89PHuejt9VISFDjlSfFjXnqn3/NlSoN 2hx0gKZCHo6+8gLFWjQlSzjvWK8NWE0fuCBxAtteH85Sri8Z+Vbpi75knT5jym9d5jNh b4ZuHIICUMpr2IeuD/zG7+20B2wA6FtGOt4DlRBdMnLuxGbiywq1vtL0wLfNU7hvKTbC VK4CxJPElbDWsKEpGhyMr19z8mEaGrzwQCoDksPJYUDdgrPCclu6gIL/vy71N5iLiNP1 FSiWeXmbwab4lLoOzotPjJMSS19yg3nbL+0bw2sf034OewulKDXh9Sc80y6Ndfjp/AZv vvWg== X-Gm-Message-State: AOAM531hj/lx6OxSs+Y3KPH6emTbM5O8UPwKFdcOhKk6DWkwWnnFlBns wCONRTZ6uQWplvRdwWmWkfSnP0cUIcb3VQ== X-Google-Smtp-Source: ABdhPJxjEx3/T9YKgwldQ3MDQWZCoVAP/+eWyk/ccS4vAIDx0Xci92cHWtIqceO605HXfgf/Pw2mYQ== X-Received: by 2002:adf:e611:: with SMTP id p17mr21897653wrm.180.1605955337534; Sat, 21 Nov 2020 02:42:17 -0800 (PST) Received: from localhost (host86-128-12-89.range86-128.btcentralplus.com. [86.128.12.89]) by smtp.gmail.com with ESMTPSA id z8sm1072522wrv.0.2020.11.21.02.42.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Nov 2020 02:42:16 -0800 (PST) Date: Sat, 21 Nov 2020 10:42:15 +0000 From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Pedro Alves , Tom Tromey Subject: Re: [PATCH] gdb: improve command completion for 'print', 'x', and 'display' Message-ID: <20201121104215.GW2729@embecosm.com> References: <20201116154221.240877-1-andrew.burgess@embecosm.com> <87r1oqk5kj.fsf@tromey.com> <20201119101431.GU2729@embecosm.com> <87mtzcggzz.fsf@tromey.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87mtzcggzz.fsf@tromey.com> X-Operating-System: Linux/5.8.13-100.fc31.x86_64 (x86_64) X-Uptime: 17:24:47 up 26 days, 8:27, X-Editor: GNU Emacs [ http://www.gnu.org/software/emacs ] X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Nov 2020 10:42:20 -0000 * Tom Tromey [2020-11-20 08:55:28 -0700]: > >>>>> "Pedro" == Pedro Alves writes: > > Pedro> I assumed it was on purpose that those weren't used, since you've > Pedro> included safe-ctype.h and are (rightfully IMO) using ISSPACE and not > Pedro> isspace. skip_spaces/skip_to_space use isspace not ISSPACE. > Pedro> Probably doesn't make a difference in practice. Not sure there's > Pedro> any locale where isspace/ISSPACE return a different result. > Pedro> ISSPACE is cheaper, so maybe we should make skip_spaces/skip_to_space > Pedro> use it. > > skip_* are intended for use by gdb commands -- they originally lived in > gdb/cli/ -- so if they do the wrong thing in some situation, they should > definitely be changed. Like this? Thanks, Andrew --- commit e3a987aa1906be82aee0d777a92e7ac8d6502c22 Author: Andrew Burgess Date: Fri Nov 20 17:23:03 2020 +0000 gdbsupport: make use of safe-ctype functions from libiberty Make use of the safe-ctype replacements for the standard ctype character checking functions. gdbsupport/ChangeLog: * gdbsupport/common-utils.cc: Change 'ctype.h' include to 'safe-ctype.h'. (extract_string_maybe_quoted): Use safe-ctype function versions. (is_digit_in_base): Likewise. (digit_to_int): Likewise. (strtoulst): Likewise. (skip_spaces): Likewise. (skip_to_space): Likewise. diff --git a/gdbsupport/common-utils.cc b/gdbsupport/common-utils.cc index b5e4d2928ec..4f5c26d075c 100644 --- a/gdbsupport/common-utils.cc +++ b/gdbsupport/common-utils.cc @@ -20,7 +20,7 @@ #include "common-defs.h" #include "common-utils.h" #include "host-defs.h" -#include +#include "safe-ctype.h" void * xzalloc (size_t size) @@ -177,7 +177,7 @@ extract_string_maybe_quoted (const char **arg) /* Parse p similarly to gdb_argv buildargv function. */ while (*p != '\0') { - if (isspace (*p) && !squote && !dquote && !bsquote) + if (ISSPACE (*p) && !squote && !dquote && !bsquote) break; else { @@ -230,21 +230,21 @@ extract_string_maybe_quoted (const char **arg) static int is_digit_in_base (unsigned char digit, int base) { - if (!isalnum (digit)) + if (!ISALNUM (digit)) return 0; if (base <= 10) - return (isdigit (digit) && digit < base + '0'); + return (ISDIGIT (digit) && digit < base + '0'); else - return (isdigit (digit) || tolower (digit) < base - 10 + 'a'); + return (ISDIGIT (digit) || TOLOWER (digit) < base - 10 + 'a'); } static int digit_to_int (unsigned char c) { - if (isdigit (c)) + if (ISDIGIT (c)) return c - '0'; else - return tolower (c) - 'a' + 10; + return TOLOWER (c) - 'a' + 10; } /* As for strtoul, but for ULONGEST results. */ @@ -258,7 +258,7 @@ strtoulst (const char *num, const char **trailer, int base) int i = 0; /* Skip leading whitespace. */ - while (isspace (num[i])) + while (ISSPACE (num[i])) i++; /* Handle prefixes. */ @@ -325,7 +325,7 @@ skip_spaces (char *chp) { if (chp == NULL) return NULL; - while (*chp && isspace (*chp)) + while (*chp && ISSPACE (*chp)) chp++; return chp; } @@ -337,7 +337,7 @@ skip_spaces (const char *chp) { if (chp == NULL) return NULL; - while (*chp && isspace (*chp)) + while (*chp && ISSPACE (*chp)) chp++; return chp; } @@ -349,7 +349,7 @@ skip_to_space (const char *chp) { if (chp == NULL) return NULL; - while (*chp && !isspace (*chp)) + while (*chp && !ISSPACE (*chp)) chp++; return chp; }