MCPcopy Create free account
hub / github.com/ZDoom/Raze / IsInt

Method IsInt

source/common/utility/zstring.cpp:1081–1144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1079}
1080
1081bool FString::IsInt () const
1082{
1083 // String must match: [whitespace] [{+ | �}] [0 [{ x | X }]] [digits] [whitespace]
1084
1085/* This state machine is based on a simplification of re2c's output for this input:
1086digits = [0-9];
1087hexdigits = [0-9a-fA-F];
1088octdigits = [0-7];
1089
1090("0" octdigits+ | "0" [xX] hexdigits+ | (digits \ '0') digits*) { return true; }
1091[\000-\377] { return false; }*/
1092
1093 //FIX for "0" returning false, doesn't fix 0 with whitespace, but that isn't necessary for savegame loading, so it'll need to be fixed later
1094 if(Len() == 1 && Chars[0] == '0') return true;
1095
1096
1097
1098 const char *YYCURSOR = Chars;
1099 char yych;
1100
1101 yych = *YYCURSOR;
1102
1103 // Skip preceding whitespace
1104 while (yych != '\0' && isspace((unsigned char)yych)) { yych = *++YYCURSOR; }
1105
1106 // Check for sign
1107 if (yych == '+' || yych == '-') { yych = *++YYCURSOR; }
1108
1109 if (yych == '0')
1110 {
1111 yych = *++YYCURSOR;
1112 if (yych >= '0' && yych <= '7')
1113 {
1114 do { yych = *++YYCURSOR; } while (yych >= '0' && yych <= '7');
1115 }
1116 else if (yych == 'X' || yych == 'x')
1117 {
1118 bool gothex = false;
1119 yych = *++YYCURSOR;
1120 while ((yych >= '0' && yych <= '9') || (yych >= 'A' && yych <= 'F') || (yych >= 'a' && yych <= 'f'))
1121 {
1122 gothex = true;
1123 yych = *++YYCURSOR;
1124 }
1125 if (!gothex) return false;
1126 }
1127 else
1128 {
1129 return false;
1130 }
1131 }
1132 else if (yych >= '1' && yych <= '9')
1133 {
1134 do { yych = *++YYCURSOR; } while (yych >= '0' && yych <= '9');
1135 }
1136 else
1137 {
1138 return false;

Callers 6

GetIntMemberFunction · 0.80
serializer.cppFile · 0.80
ReadOptionalIntMethod · 0.80
UNSAFE_CCMDFunction · 0.80
FStringFormatFunction · 0.80
PMapValueReaderFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected