[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] use locale-indep. c_is* functions for parsing, not isspace, ispr
From: |
Jim Meyering |
Subject: |
[PATCH] use locale-indep. c_is* functions for parsing, not isspace, isprint etc |
Date: |
Sun, 05 Aug 2012 13:37:47 +0200 |
Hi Akim,
On bison's master, building on Fedora 17 with gcc version 4.8.0 20120803
failed due to a missing declaration of isspace in parse-gram.y.
It's best when parsing, to avoid using isspace and the other is*
macros, because they use locale-dependent tables. Do you want a
grammar to be accepted in one locale and rejected in another?
Or worse: to succeed but generate a parser with subtly different semantics?
There was one other use of isspace in scan-gram.l, along with
a use of isprint. This switches all of them to use gnulib's
locale-independent c_-prefixed functions:
>From 8dfc22f329a709293a1b0c73160daa17ce8efa90 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sun, 5 Aug 2012 13:28:01 +0200
Subject: [PATCH] use locale-indep. c_is* functions for parsing, not isspace,
isprint etc
* src/parse-gram.y: Include "c-ctype.h".
(add_param): Parse with c_isspace, not isspace.
* src/parse-gram.c: Likewise.
* src/scan-gram.l: Include c-ctype.h, not ctype.h.
(SC_ESCAPED_STRING,SC_ESCAPED_CHARACTER): Use c_isspace and c_isprint,
not ctype.h's locale-dependent functions.
---
src/parse-gram.c | 5 +++--
src/parse-gram.y | 5 +++--
src/scan-gram.l | 4 ++--
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/parse-gram.c b/src/parse-gram.c
index 7a19cf1..5910861 100644
--- a/src/parse-gram.c
+++ b/src/parse-gram.c
@@ -94,6 +94,7 @@
#include <config.h>
#include "system.h"
+#include "c-ctype.h"
#include "complain.h"
#include "conflicts.h"
#include "files.h"
@@ -3255,11 +3256,11 @@ add_param (param_type type, char *decl, location loc)
/* Strip the surrounding '{' and '}', and any blanks just inside
the braces. */
--p;
- while (isspace ((unsigned char) *p))
+ while (c_isspace ((unsigned char) *p))
--p;
p[1] = '\0';
++decl;
- while (isspace ((unsigned char) *decl))
+ while (c_isspace ((unsigned char) *decl))
++decl;
}
diff --git a/src/parse-gram.y b/src/parse-gram.y
index fbb9b54..bd38b39 100644
--- a/src/parse-gram.y
+++ b/src/parse-gram.y
@@ -20,6 +20,7 @@
#include <config.h>
#include "system.h"
+#include "c-ctype.h"
#include "complain.h"
#include "conflicts.h"
#include "files.h"
@@ -776,11 +777,11 @@ add_param (param_type type, char *decl, location loc)
/* Strip the surrounding '{' and '}', and any blanks just inside
the braces. */
--p;
- while (isspace ((unsigned char) *p))
+ while (c_isspace ((unsigned char) *p))
--p;
p[1] = '\0';
++decl;
- while (isspace ((unsigned char) *decl))
+ while (c_isspace ((unsigned char) *decl))
++decl;
}
diff --git a/src/scan-gram.l b/src/scan-gram.l
index 084796c..2275d02 100644
--- a/src/scan-gram.l
+++ b/src/scan-gram.l
@@ -36,7 +36,7 @@
#include <src/reader.h>
#include <src/uniqstr.h>
-#include <ctype.h>
+#include <c-ctype.h>
#include <mbswidth.h>
#include <quote.h>
@@ -637,7 +637,7 @@ splice (\\[ \f\t\v]*\n)*
\\(.|\n) {
char const *p = yytext + 1;
/* Quote only if escaping won't make the character visible. */
- if (isspace ((unsigned char) *p) && isprint ((unsigned char) *p))
+ if (c_isspace ((unsigned char) *p) && c_isprint ((unsigned char) *p))
p = quote (p);
else
p = quotearg_style_mem (escape_quoting_style, p, 1);
--
1.7.12.rc1.10.g97c7934
- [PATCH] use locale-indep. c_is* functions for parsing, not isspace, isprint etc,
Jim Meyering <=