src/jdk.packager/share/native/library/common/Helpers.cpp
branchJDK-8200758-branch
changeset 57012 200666876601
parent 56995 3d5b13207b70
equal deleted inserted replaced
57011:7df1e4bf870a 57012:200666876601
    28 #include "PropertyFile.h"
    28 #include "PropertyFile.h"
    29 
    29 
    30 
    30 
    31 bool Helpers::SplitOptionIntoNameValue(
    31 bool Helpers::SplitOptionIntoNameValue(
    32         TString option, TString& Name, TString& Value) {
    32         TString option, TString& Name, TString& Value) {
    33     bool result = false;
    33     bool hasValue = false;
    34     Name = _T("");
    34     Name = _T("");
    35     Value = _T("");
    35     Value = _T("");
    36     unsigned int index = 0;
    36     unsigned int index = 0;
    37 
    37 
    38     for (; index < option.length(); index++) {
    38     for (; index < option.length(); index++) {
    39         TCHAR c = option[index];
    39         TCHAR c = option[index];
    40 
    40 
    41         switch (c) {
    41         switch (c) {
    42             case '=': {
    42             case '=': {
    43                 index++;
    43                 index++;
    44                 result = true;
    44                 hasValue = true;
    45                 break;
    45                 break;
    46             }
    46             }
    47 
    47 
    48             case '\\': {
    48             case '\\': {
    49                 if (index + 1 < option.length()) {
    49                 if (index + 1 < option.length()) {
    75         }
    75         }
    76 
    76 
    77         break;
    77         break;
    78     }
    78     }
    79 
    79 
    80     if (result) {
    80     if (hasValue) {
    81         Value = option.substr(index, index - option.length());
    81         Value = option.substr(index, index - option.length());
    82     }
    82     }
    83 
    83 
    84     return result;
    84     return (option.length() > 0);
    85 }
    85 }
    86 
    86 
    87 
    87 
    88 TString Helpers::ReplaceString(TString subject, const TString& search,
    88 TString Helpers::ReplaceString(TString subject, const TString& search,
    89                             const TString& replace) {
    89                             const TString& replace) {