From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 0439C3858D28; Fri, 4 Feb 2022 14:42:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0439C3858D28 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Remove host_hex_value X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: fd3c53675c01472caaa4eb976781b9d6d2d3c53d X-Git-Newrev: 2b531492447d10de27e6210117509097f6cbc9e0 Message-Id: <20220204144220.0439C3858D28@sourceware.org> Date: Fri, 4 Feb 2022 14:42:20 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Feb 2022 14:42:20 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D2b531492447d= 10de27e6210117509097f6cbc9e0 commit 2b531492447d10de27e6210117509097f6cbc9e0 Author: Tom Tromey Date: Thu Feb 3 11:45:59 2022 -0700 Remove host_hex_value =20 I noticed that host_hex_value is redundant, because gdbsupport already has fromhex. This patch removes the former in favor of the latter. =20 Regression tested on x86-64 Fedora 34. Diff: --- gdb/c-lang.c | 6 +++--- gdb/charset.c | 14 -------------- gdb/charset.h | 5 ----- gdb/mi/mi-parse.c | 4 ++-- gdb/python/py-objfile.c | 2 +- gdb/utils.c | 4 ++-- 6 files changed, 8 insertions(+), 27 deletions(-) diff --git a/gdb/c-lang.c b/gdb/c-lang.c index ed7554fadea..1f7cac7bef1 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -410,7 +410,7 @@ convert_ucn (const char *p, const char *limit, const ch= ar *dest_charset, int i; =20 for (i =3D 0; i < length && p < limit && ISXDIGIT (*p); ++i, ++p) - result =3D (result << 4) + host_hex_value (*p); + result =3D (result << 4) + fromhex (*p); =20 for (i =3D 3; i >=3D 0; --i) { @@ -454,7 +454,7 @@ convert_octal (struct type *type, const char *p, i < 3 && p < limit && ISDIGIT (*p) && *p !=3D '8' && *p !=3D '9'; ++i) { - value =3D 8 * value + host_hex_value (*p); + value =3D 8 * value + fromhex (*p); ++p; } =20 @@ -476,7 +476,7 @@ convert_hex (struct type *type, const char *p, =20 while (p < limit && ISXDIGIT (*p)) { - value =3D 16 * value + host_hex_value (*p); + value =3D 16 * value + fromhex (*p); ++p; } =20 diff --git a/gdb/charset.c b/gdb/charset.c index bf205ae087c..84c60a4e5d6 100644 --- a/gdb/charset.c +++ b/gdb/charset.c @@ -463,20 +463,6 @@ host_letter_to_control_character (char c) return c & 0237; } =20 -/* Convert a host character, C, to its hex value. C must already have - been validated using isxdigit. */ - -int -host_hex_value (char c) -{ - if (isdigit (c)) - return c - '0'; - if (c >=3D 'a' && c <=3D 'f') - return 10 + c - 'a'; - gdb_assert (c >=3D 'A' && c <=3D 'F'); - return 10 + c - 'A'; -} - =0C /* Public character management functions. */ =20 diff --git a/gdb/charset.h b/gdb/charset.h index 871f0d856ac..7a7041f10f2 100644 --- a/gdb/charset.h +++ b/gdb/charset.h @@ -159,9 +159,4 @@ class wchar_iterator character. */ char host_letter_to_control_character (char c); =20 -/* Convert a hex digit character to its numeric value. E.g., 'f' is - converted to 15. This function assumes that C is a valid hex - digit. Both upper- and lower-case letters are recognized. */ -int host_hex_value (char c); - #endif /* CHARSET_H */ diff --git a/gdb/mi/mi-parse.c b/gdb/mi/mi-parse.c index d5febced153..dfa7b462714 100644 --- a/gdb/mi/mi-parse.c +++ b/gdb/mi/mi-parse.c @@ -57,7 +57,7 @@ mi_parse_escape (const char **string_ptr) case '6': case '7': { - int i =3D host_hex_value (c); + int i =3D fromhex (c); int count =3D 0; =20 while (++count < 3) @@ -67,7 +67,7 @@ mi_parse_escape (const char **string_ptr) { (*string_ptr)++; i *=3D 8; - i +=3D host_hex_value (c); + i +=3D fromhex (c); } else { diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c index 48d2eb306d1..8c568799843 100644 --- a/gdb/python/py-objfile.c +++ b/gdb/python/py-objfile.c @@ -550,7 +550,7 @@ objfpy_build_id_matches (const struct bfd_build_id *bui= ld_id, for (i =3D 0; i < build_id->size; ++i) { char c1 =3D string[i * 2], c2 =3D string[i * 2 + 1]; - int byte =3D (host_hex_value (c1) << 4) | host_hex_value (c2); + int byte =3D (fromhex (c1) << 4) | fromhex (c2); =20 if (byte !=3D build_id->data[i]) return 0; diff --git a/gdb/utils.c b/gdb/utils.c index 152fa9b630a..dcb42138d39 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -1078,7 +1078,7 @@ parse_escape (struct gdbarch *gdbarch, const char **s= tring_ptr) case '6': case '7': { - int i =3D host_hex_value (c); + int i =3D fromhex (c); int count =3D 0; while (++count < 3) { @@ -1087,7 +1087,7 @@ parse_escape (struct gdbarch *gdbarch, const char **s= tring_ptr) { (*string_ptr)++; i *=3D 8; - i +=3D host_hex_value (c); + i +=3D fromhex (c); } else {