diff --git a/src/sc_man.cpp b/src/sc_man.cpp index de668ee42..05abe1784 100644 --- a/src/sc_man.cpp +++ b/src/sc_man.cpp @@ -530,8 +530,19 @@ bool FScanner::GetToken () else if (TokenType == TK_IntConst) { char *stopper; - Number = strtol(String, &stopper, 0); - Float = Number; + // Check for unsigned + if (String[StringLen - 1] == 'u' || String[StringLen - 1] == 'U' || + String[StringLen - 2] == 'u' || String[StringLen - 2] == 'U') + { + TokenType = TK_UIntConst; + Number = strtoul(String, &stopper, 0); + Float = (unsigned)Number; + } + else + { + Number = strtol(String, &stopper, 0); + Float = Number; + } } else if (TokenType == TK_FloatConst) { diff --git a/src/sc_man_scanner.re b/src/sc_man_scanner.re index 328e7afdb..4da98736e 100644 --- a/src/sc_man_scanner.re +++ b/src/sc_man_scanner.re @@ -188,7 +188,7 @@ std2: L (L|D)* { RET(TK_Identifier); } - ("0" [xX] H+ IS?) | ("0" D+ IS?) | (D+ IS?) + ("0" [xX] H+ IS?IS?) | ("0" D+ IS?IS?) | (D+ IS?IS?) { RET(TK_IntConst); } (D+ E FS?) | (D* "." D+ E? FS?) | (D+ "." D* E? FS?) diff --git a/src/sc_man_tokens.h b/src/sc_man_tokens.h index e98c457b5..6bc01c184 100644 --- a/src/sc_man_tokens.h +++ b/src/sc_man_tokens.h @@ -2,6 +2,7 @@ xx(TK_Identifier, "identifier") xx(TK_StringConst, "string constant") xx(TK_NameConst, "name constant") xx(TK_IntConst, "integer constant") +xx(TK_UIntConst, "unsigned constant") xx(TK_FloatConst, "float constant") xx(TK_NonWhitespace, "non-whitespace") xx(TK_ColonColon, "'::'")