Changeset 33930
- Timestamp:
- 2020-02-15T19:00:05+13:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/search4j/libsearch4j.cpp
r32880 r33930 176 176 bool Jvm::setVersionFromString( string version ) { 177 177 era_ = atoi( version.substr(0,1).c_str() ); 178 major_ = atoi( version.substr(2,1).c_str() ); 179 if(version.length() >= 5) { 180 minor_ = atoi( version.substr(4,1).c_str() ); 181 } else { 182 minor_ = 0; 183 } 184 if(version.length() >= 7) { 185 update_ = atoi( version.substr(6,2).c_str() ); 186 } else { 187 update_ = 0; 188 } 178 if (version[3] == '.') { 179 // Parsing something like 1.8.0_24 180 major_ = atoi( version.substr(2,1).c_str() ); 181 if(version.length() >= 5) { 182 minor_ = atoi( version.substr(4,1).c_str() ); 183 } else { 184 minor_ = 0; 185 } 186 if(version.length() >= 7) { 187 update_ = atoi( version.substr(6,2).c_str() ); 188 } else { 189 update_ = 0; 190 } 191 } 192 else { 193 // Parsing something like 1.8.0_242 194 major_ = atoi( version.substr(2,2).c_str() ); 195 if(version.length() >= 6) { 196 minor_ = atoi( version.substr(5,1).c_str() ); 197 } else { 198 minor_ = 0; 199 } 200 if(version.length() >= 8) { 201 update_ = atoi( version.substr(7,2).c_str() ); 202 } else { 203 update_ = 0; 204 } 205 206 } 207 189 208 return true; 190 209 } 191 210 192 211 int Jvm::compare( Jvm otherJvm ) { 193 //era 212 //era 194 213 if ( era_ > otherJvm.getEra() ) 195 214 return 1; … … 247 266 const int to_match_len = 8; 248 267 if ( strcmp( output.substr( caret, to_match_len ).c_str() , " version" ) == 0 ) { 249 era_ = atoi( output.substr(caret + to_match_len + 2,1).c_str() ); 250 major_ = atoi( output.substr(caret + to_match_len + 4,1).c_str() ); 251 minor_ = atoi( output.substr(caret + to_match_len + 6,1).c_str() ); 252 update_ = atoi( output.substr(caret + to_match_len + 8,2).c_str() ); 268 if (output[caret+to_match_len+3] == '.') { 269 // Version of the form 1.8.0_24 270 era_ = atoi( output.substr(caret + to_match_len + 2,1).c_str() ); 271 major_ = atoi( output.substr(caret + to_match_len + 4,1).c_str() ); 272 minor_ = atoi( output.substr(caret + to_match_len + 6,1).c_str() ); 273 update_ = atoi( output.substr(caret + to_match_len + 8,2).c_str() ); 274 } 275 else { 276 // Version of the form 11.0.6 277 era_ = 1; 278 major_ = atoi( output.substr(caret + to_match_len + 2,2).c_str() ); 279 minor_ = atoi( output.substr(caret + to_match_len + 5,1).c_str() ); 280 update_ = atoi( output.substr(caret + to_match_len + 7,2).c_str() ); 281 282 } 253 283 found = true; 254 284 }
Note:
See TracChangeset
for help on using the changeset viewer.