Genivia / RE-flex

A high-performance C++ regex library and lexical analyzer generator with Unicode support. Extends Flex++ with Unicode support, indent/dedent anchors, lazy quantifiers, functions for lex and syntax error reporting and more. Seamlessly integrates with Bison and other parsers.
https://www.genivia.com/doc/reflex/html
BSD 3-Clause "New" or "Revised" License
507 stars 85 forks source link

Bugfix/signedness issues #106

Closed thorsten-fluegel closed 3 years ago

thorsten-fluegel commented 3 years ago

Fixes #105

genivia-inc commented 3 years ago

Interesting. I think the fix should be:

      else if (std::isprint(*i))
        *out << "'" << *i << "', ";
      else
        *out << static_cast<int>(*i) << ", ";

this takes care of the signedness of char by itself. I tested this with signed chars with some UTF-8 patterns to produce negative ints. Should work fine on systems with unsigned chars, because the C standard says that int and char are convertible.

genivia-inc commented 3 years ago

Thanks!