@@ -49,32 +49,33 @@ bool PmFromFile::init(const std::string &config, std::string *error) {
4949 std::vector<std::string> tokens = split (m_param, ' ' );
5050
5151 for (const auto & token : tokens) {
52- if (! token.empty ()) {
52+ if (token.empty ()) {
53+ continue ;
54+ }
5355
54- std::unique_ptr<std::istream> iss;
56+ std::unique_ptr<std::istream> iss;
5557
56- if (token.compare (0 , 8 , " https://" ) == 0 ) {
57- Utils::HttpsClient client;
58- bool ret = client.download (token);
59- if (ret == false ) {
60- error->assign (client.error );
61- return false ;
62- }
63- iss = std::make_unique<std::stringstream>(client.content );
64- } else {
65- std::string err;
66- std::string resource = utils::find_resource (token, config, &err);
67- auto file = std::make_unique<std::ifstream>(resource, std::ios::in);
68- if (file->is_open () == false ) {
69- error->assign (" Failed to open file: '" + token + " '. " + err);
70- return false ;
71- }
72- iss = std::move (file);
58+ if (token.compare (0 , 8 , " https://" ) == 0 ) {
59+ Utils::HttpsClient client;
60+ bool ret = client.download (token);
61+ if (ret == false ) {
62+ error->assign (client.error );
63+ return false ;
64+ }
65+ iss = std::make_unique<std::stringstream>(client.content );
66+ } else {
67+ std::string err;
68+ std::string resource = utils::find_resource (token, config, &err);
69+ auto file = std::make_unique<std::ifstream>(resource, std::ios::in);
70+ if (file->is_open () == false ) {
71+ error->assign (" Failed to open file: '" + token + " '. " + err);
72+ return false ;
7373 }
74- for (std::string line; std::getline (*iss, line); ) {
75- if (isComment (line) == false ) {
76- acmp_add_pattern (m_p, line.c_str (), NULL , NULL , line.length ());
77- }
74+ iss = std::move (file);
75+ }
76+ for (std::string line; std::getline (*iss, line); ) {
77+ if (isComment (line) == false ) {
78+ acmp_add_pattern (m_p, line.c_str (), NULL , NULL , line.length ());
7879 }
7980 }
8081 }
0 commit comments