From 2b4c331e70f1f8eaae33537df12c5744dd8e8b09 Mon Sep 17 00:00:00 2001
From: Hartmut Kaiser <hartmut.kaiser@gmail.com>
Date: Sat, 16 Mar 2013 14:39:51 +0000
Subject: [PATCH] Fix #8291: Lexer fails to work on ARM
[SVN r83462]
---
include/boost/spirit/home/support/detail/lexer/generator.hpp | 3 ++-
include/boost/spirit/home/support/detail/lexer/string_token.hpp | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/include/boost/spirit/home/support/detail/lexer/generator.hpp b/include/boost/spirit/home/support/detail/lexer/generator.hpp
index 49bea2f..9541f6f 100644
--- a/include/boost/spirit/home/support/detail/lexer/generator.hpp
+++ b/include/boost/spirit/home/support/detail/lexer/generator.hpp
@@ -12,6 +12,7 @@
#include "partition/charset.hpp"
#include "partition/equivset.hpp"
#include <memory>
+#include <limits>
#include "parser/tree/node.hpp"
#include "parser/parser.hpp"
#include "containers/ptr_list.hpp"
@@ -560,7 +561,7 @@ class basic_generator
if (token_._negated)
{
- CharT curr_char_ = sizeof (CharT) == 1 ? -128 : 0;
+ CharT curr_char_ = (std::numeric_limits<CharT>::min)();
std::size_t i_ = 0;
while (curr_ < chars_end_)
diff --git a/include/boost/spirit/home/support/detail/lexer/string_token.hpp b/include/boost/spirit/home/support/detail/lexer/string_token.hpp
index 6bfa6ff..e972a95 100644
--- a/include/boost/spirit/home/support/detail/lexer/string_token.hpp
+++ b/include/boost/spirit/home/support/detail/lexer/string_token.hpp
@@ -10,6 +10,7 @@
#include "size_t.hpp"
#include "consts.hpp" // num_chars, num_wchar_ts
#include <string>
+#include <limits>
namespace boost
{
@@ -71,7 +72,7 @@ struct basic_string_token
{
const std::size_t max_chars_ = sizeof (CharT) == 1 ?
num_chars : num_wchar_ts;
- CharT curr_char_ = sizeof (CharT) == 1 ? -128 : 0;
+ CharT curr_char_ = (std::numeric_limits<CharT>::min)();
string temp_;
const CharT *curr_ = _charset.c_str ();
const CharT *chars_end_ = curr_ + _charset.size ();
From c480d6c7fcadf3cb5fbaad756ac370275a75e601 Mon Sep 17 00:00:00 2001
From: Joel de Guzman <djowel@gmail.com>
Date: Sat, 19 Jul 2014 08:12:53 +0800
Subject: [PATCH] workaround for lexertl bug on platforms where wchar_t is
signed (can be negative).
---
include/boost/spirit/home/support/detail/lexer/generator.hpp | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/boost/spirit/home/support/detail/lexer/generator.hpp b/include/boost/spirit/home/support/detail/lexer/generator.hpp
index a3b7290..daa06e7 100644
--- a/include/boost/spirit/home/support/detail/lexer/generator.hpp
+++ b/include/boost/spirit/home/support/detail/lexer/generator.hpp
@@ -561,7 +561,12 @@ class basic_generator
if (token_._negated)
{
- CharT curr_char_ = (std::numeric_limits<CharT>::min)();
+ // $$$ FIXME JDG July 2014 $$$
+ // this code is problematic on platforms where wchar_t is signed
+ // with min generating negative numbers. This crashes with BAD_ACCESS
+ // because of the vector index below:
+ // ptr_[static_cast<typename Traits::index_type>(curr_char_)]
+ CharT curr_char_ = 0; // (std::numeric_limits<CharT>::min)();
std::size_t i_ = 0;
while (curr_ < chars_end_)