Changeset 32880


Ignore:
Timestamp:
2019-03-08T09:46:01+13:00 (5 years ago)
Author:
davidb
Message:

Test for version string made a little bit more general to allow for 'openjdk version' rather than 'java version'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/search4j/libsearch4j.cpp

    r30172 r32880  
    245245      bool found = false;
    246246      while (caret < max_search_length && !found) {
    247         if ( strcmp( output.substr( caret, 12 ).c_str() , "java version" ) == 0 ) {
    248           era_ = atoi( output.substr(caret + 14,1).c_str() );
    249           major_ = atoi( output.substr(caret + 16,1).c_str() );
    250           minor_ = atoi( output.substr(caret + 18,1).c_str() );
    251           update_ = atoi( output.substr(caret + 20,2).c_str() );
     247        const int to_match_len = 8;
     248        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() );
    252253          found = true;
    253254        }
     
    318319    if ( verbose ) cout << "Searching for a JVM" << endl;
    319320   
    320     char *javaHomeEnv = "";
     321    char *javaHomeEnv = NULL;
    321322    bool jvmFound = false;
    322323   
Note: See TracChangeset for help on using the changeset viewer.