[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
parse: remove unnecessary casts before using gnulib functions
From: |
Edoardo Sanguineti |
Subject: |
parse: remove unnecessary casts before using gnulib functions |
Date: |
Fri, 4 Nov 2022 13:59:42 +0000 |
Hello All,
As I learned from an email exchange earlier this week with Kaz Kylheku,
these casts to unsigned char are unnecessary.
I had a quick glance at the Gnulib repository it appears that since these
functions were added, there was never a risk in using them without this
specific type of cast.
Furthermore, there is one inconsistent usage of c_isspace where the cast
is absent (see here:
https://git.savannah.gnu.org/cgit/bison.git/tree/src/derivation.c#n166) as
it is not needed.
The goal of this patch is to bring consistent usage of c_space and
c_isprint and possibly avoid confusion in the future as someone else may
think the 'missing' cast in the derivation module is a mistake like I did.
Best,
Edoardo
>From 7e11e89312f06bb5b0a8ee777fd0d41cfb97b7b8 Mon Sep 17 00:00:00 2001
From: Edoardo Sanguineti <edoardo.sanguineti222@gmail.com>
Date: Fri, 4 Nov 2022 13:14:50 +0000
Subject: [PATCH] parse: remove unnecessary casts before using gnulib
functions
To: bison-patches@gnu.org
---
src/parse-gram.c | 4 ++--
src/parse-gram.y | 4 ++--
src/scan-gram.l | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/parse-gram.c b/src/parse-gram.c
index b6ac083e..97fbb925 100644
--- a/src/parse-gram.c
+++ b/src/parse-gram.c
@@ -2945,11 +2945,11 @@ add_param (param_type type, char *decl, location
loc)
/* Strip the surrounding '{' and '}', and any blanks just inside
the braces. */
--p;
- while (c_isspace ((unsigned char) *p))
+ while (c_isspace (*p))
--p;
p[1] = '\0';
++decl;
- while (c_isspace ((unsigned char) *decl))
+ while (c_isspace (*decl))
++decl;
}
diff --git a/src/parse-gram.y b/src/parse-gram.y
index 3006f54c..7e2299f1 100644
--- a/src/parse-gram.y
+++ b/src/parse-gram.y
@@ -928,11 +928,11 @@ add_param (param_type type, char *decl, location loc)
/* Strip the surrounding '{' and '}', and any blanks just inside
the braces. */
--p;
- while (c_isspace ((unsigned char) *p))
+ while (c_isspace (*p))
--p;
p[1] = '\0';
++decl;
- while (c_isspace ((unsigned char) *decl))
+ while (c_isspace (*decl))
++decl;
}
diff --git a/src/scan-gram.l b/src/scan-gram.l
index 3926a4aa..64c2fe8d 100644
--- a/src/scan-gram.l
+++ b/src/scan-gram.l
@@ -683,7 +683,7 @@ eqopt ({sp}=)?
\\(.|{eol}) {
char const *p = yytext + 1;
/* Quote only if escaping won't make the character visible. */
- if (c_isspace ((unsigned char) *p) && c_isprint ((unsigned char) *p))
+ if (c_isspace (*p) && c_isprint (*p))
p = quote (p);
else
p = quotearg_style_mem (escape_quoting_style, p, 1);
--
2.38.1.windows.1
- parse: remove unnecessary casts before using gnulib functions,
Edoardo Sanguineti <=