public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Cc: Pedro Alves <pedro@palves.net>, Tom Tromey <tom@tromey.com>
Subject: Re: [PATCH] gdb: improve command completion for 'print', 'x', and 'display'
Date: Sat, 21 Nov 2020 10:42:15 +0000	[thread overview]
Message-ID: <20201121104215.GW2729@embecosm.com> (raw)
In-Reply-To: <87mtzcggzz.fsf@tromey.com>

* Tom Tromey <tom@tromey.com> [2020-11-20 08:55:28 -0700]:

> >>>>> "Pedro" == Pedro Alves <pedro@palves.net> 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 <andrew.burgess@embecosm.com>
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 <ctype.h>
+#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;
 }

  reply	other threads:[~2020-11-21 10:42 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-16 15:42 Andrew Burgess
2020-11-16 23:53 ` Pedro Alves
2020-11-18 16:11 ` Tom Tromey
2020-11-19 10:14   ` Andrew Burgess
2020-11-20 13:47     ` Pedro Alves
2020-11-20 15:55       ` Tom Tromey
2020-11-21 10:42         ` Andrew Burgess [this message]
2020-12-03 17:03           ` Tom Tromey
2020-12-11 22:07             ` Andrew Burgess
2021-01-06  7:39               ` gdbserver build broken with -fsanitize=address Tom de Vries
2021-01-06 16:29                 ` [PATCH][gdb/build] Fix gdbserver build " Tom de Vries
2021-01-07  9:24                   ` Andrew Burgess
2020-11-26 19:12 ` [PATCH] gdb: improve command completion for 'print', 'x', and 'display' Simon Marchi
2020-11-27 11:13   ` Andrew Burgess
2020-11-27 14:04     ` Simon Marchi
2021-01-08  0:59     ` Pedro Alves
2021-01-08 10:34       ` Andrew Burgess
2021-01-08 15:08         ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201121104215.GW2729@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@palves.net \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).