summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJun He <jun.he@linaro.org>2020-09-17 14:03:09 +0800
committerJun He <jun.he@linaro.org>2020-09-17 14:32:22 +0800
commite2650a71a1af9711fd07e213988db4b3c6d7fa71 (patch)
tree4c31853b5855a1e37bce79c7656e60e870a04bbb
parent401cb0041f5871215d83c64ab5e021149078e426 (diff)
downloadragel-e2650a71a1af9711fd07e213988db4b3c6d7fa71.tar.gz
common: Fix ambiguous CHAR_MIN/MAX definition
According to C/C++ standards, char is implementation-defined whether it could hold negative values. See: http://www.cplusplus.com/reference/climits/ In ragel char is treated as a signed value with range as [-128, 127]. This means that the CHAR_MIN/CHAR_MAX should be replaced with a more accurate definition to align across different systems and library implementations. Change-Id: I10668f2d2550b603101dc68f4cc1121035022abd Signed-off-by: Jun He <jun.he@linaro.org>
-rw-r--r--src/common.cc4
-rw-r--r--src/host-csharp/main.cc2
-rw-r--r--src/host-d/main.cc2
-rw-r--r--src/host-java/main.cc2
-rw-r--r--src/host-js/main.cc2
-rw-r--r--src/host-ruby/main.cc2
6 files changed, 7 insertions, 7 deletions
diff --git a/src/common.cc b/src/common.cc
index 548d094f..6c789d77 100644
--- a/src/common.cc
+++ b/src/common.cc
@@ -42,8 +42,8 @@ const char *defaultOutFnC( const char *inputFileName )
HostType hostTypesC[] =
{
- { "char", 0, "char", true, true, false, CHAR_MIN, CHAR_MAX, 0, 0, sizeof(char) },
- { "signed", "char", "char", true, true, false, CHAR_MIN, CHAR_MAX, 0, 0, sizeof(char) },
+ { "char", 0, "char", true, true, false, SCHAR_MIN, SCHAR_MAX, 0, 0, sizeof(char) },
+ { "signed", "char", "char", true, true, false, SCHAR_MIN, SCHAR_MAX, 0, 0, sizeof(char) },
{ "unsigned", "char", "uchar", false, true, false, 0, 0, 0, UCHAR_MAX, sizeof(unsigned char) },
{ "short", 0, "short", true, true, false, SHRT_MIN, SHRT_MAX, 0, 0, sizeof(short) },
{ "signed", "short", "short", true, true, false, SHRT_MIN, SHRT_MAX, 0, 0, sizeof(short) },
diff --git a/src/host-csharp/main.cc b/src/host-csharp/main.cc
index fa5cb5a9..330e6b37 100644
--- a/src/host-csharp/main.cc
+++ b/src/host-csharp/main.cc
@@ -40,7 +40,7 @@ const char *defaultOutFnCSharp( const char *inputFileName )
HostType hostTypesCSharp[] =
{
- { "sbyte", 0, "sbyte", true, true, false, CHAR_MIN, CHAR_MAX, 0, 0, 1 },
+ { "sbyte", 0, "sbyte", true, true, false, SCHAR_MIN, SCHAR_MAX, 0, 0, 1 },
{ "byte", 0, "byte", false, true, false, 0, 0, 0, UCHAR_MAX, 1 },
{ "short", 0, "short", true, true, false, SHRT_MIN, SHRT_MAX, 0, 0, 2 },
{ "ushort", 0, "ushort", false, true, false, 0, 0, 0, USHRT_MAX, 2 },
diff --git a/src/host-d/main.cc b/src/host-d/main.cc
index f6eb7cbe..6841f2e9 100644
--- a/src/host-d/main.cc
+++ b/src/host-d/main.cc
@@ -40,7 +40,7 @@ const char *defaultOutFnD( const char *inputFileName )
HostType hostTypesD[] =
{
- { "byte", 0, "byte", true, true, false, CHAR_MIN, CHAR_MAX, 0, 0, 1 },
+ { "byte", 0, "byte", true, true, false, SCHAR_MIN, SCHAR_MAX, 0, 0, 1 },
{ "ubyte", 0, "ubyte", false, true, false, 0, 0, 0, UCHAR_MAX, 1 },
{ "char", 0, "char", false, true, false, 0, 0, 0, UCHAR_MAX, 1 },
{ "short", 0, "short", true, true, false, SHRT_MIN, SHRT_MAX, 0, 0, 2 },
diff --git a/src/host-java/main.cc b/src/host-java/main.cc
index d4efd3fc..9899a053 100644
--- a/src/host-java/main.cc
+++ b/src/host-java/main.cc
@@ -36,7 +36,7 @@ const char *defaultOutFnJava( const char *inputFileName )
HostType hostTypesJava[] =
{
- { "byte", 0, "byte", true, true, false, CHAR_MIN, CHAR_MAX, 0, 0, 1 },
+ { "byte", 0, "byte", true, true, false, SCHAR_MIN, SCHAR_MAX, 0, 0, 1 },
{ "short", 0, "short", true, true, false, SHRT_MIN, SHRT_MAX, 0, 0, 2 },
{ "char", 0, "char", false, true, false, 0, 0, 0, USHRT_MAX, 2 },
{ "int", 0, "int", true, true, false, INT_MIN, INT_MAX, 0, 0, 4 },
diff --git a/src/host-js/main.cc b/src/host-js/main.cc
index 44796436..e52c02df 100644
--- a/src/host-js/main.cc
+++ b/src/host-js/main.cc
@@ -36,7 +36,7 @@ const char *defaultOutFnJs( const char *inputFileName )
HostType hostTypesJS[] =
{
- { "s8", 0, "int8", true, true, false, CHAR_MIN, CHAR_MAX, 0, 0, 1 },
+ { "s8", 0, "int8", true, true, false, SCHAR_MIN, SCHAR_MAX, 0, 0, 1 },
{ "u8", 0, "uint8", false, true, false, 0, 0, 0, UCHAR_MAX, 1 },
{ "s16", 0, "int16", true, true, false, SHRT_MIN, SHRT_MAX, 0, 0, 2 },
{ "u16", 0, "uint16", false, true, false, 0, 0, 0, USHRT_MAX, 2 },
diff --git a/src/host-ruby/main.cc b/src/host-ruby/main.cc
index 3fed52e3..0398cafd 100644
--- a/src/host-ruby/main.cc
+++ b/src/host-ruby/main.cc
@@ -28,7 +28,7 @@ extern struct colm_sections rlhcRuby;
/* What are the appropriate types for ruby? */
static HostType hostTypesRuby[] =
{
- { "char", 0, "char", true, true, false, CHAR_MIN, CHAR_MAX, 0, 0, 1 },
+ { "char", 0, "char", true, true, false, SCHAR_MIN, SCHAR_MAX, 0, 0, 1 },
{ "int", 0, "int", true, true, false, INT_MIN, INT_MAX, 0, 0, 4 },
};