diff options
author | Karel Klic <kklic@redhat.com> | 2010-04-20 22:15:03 +0200 |
---|---|---|
committer | Karel Klic <kklic@redhat.com> | 2010-04-20 22:15:03 +0200 |
commit | ab2bfe1bd24f231ea46c9b59163e2d931d99fce9 (patch) | |
tree | 6e618ac956bb0cabdee48b5ab722df29a80d7489 /src | |
parent | 6c0ca2136289c5f1b351056501dce0ef69b6a07c (diff) | |
download | abrt-ab2bfe1bd24f231ea46c9b59163e2d931d99fce9.tar.gz abrt-ab2bfe1bd24f231ea46c9b59163e2d931d99fce9.tar.xz abrt-ab2bfe1bd24f231ea46c9b59163e2d931d99fce9.zip |
Changes to abrt-cli made by Denys Vlasenko on 2010-03-18.
Reviewed by Karel Klic.
Diffstat (limited to 'src')
-rw-r--r-- | src/CLI/report.cpp | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/src/CLI/report.cpp b/src/CLI/report.cpp index 60ed3c85..bff6a9a0 100644 --- a/src/CLI/report.cpp +++ b/src/CLI/report.cpp @@ -431,29 +431,24 @@ static void read_from_stdin(const char *question, char *result, int result_size) if (NULL == fgets(result, result_size, stdin)) result[0] = '\0'; // Remove the newline from the login. - char *newline = strchr(result, '\n'); - if (newline) - *newline = '\0'; + strchrnul(result, '\n')[0] = '\0'; } /** Splits a string into substrings using chosen delimiters. * @param delim - * Specifies a set of characters that delimit the + * Specifies a set of characters that delimit the * tokens in the parsed string */ -static vector_string_t split(const std::string &s, const char *delim) +static vector_string_t split(const char *s, const char delim) { std::vector<std::string> elems; - char str[s.length() + 1]; - /* str is modified by the following strtok_r, - so s.c_str() cannot be used directly */ - strcpy(str, s.c_str()); - char *saveptr, *token; - token = strtok_r(str, delim, &saveptr); - while (token != NULL) + while (1) { - elems.push_back(token); - token = strtok_r(NULL, delim, &saveptr); + const char *end = strchrnul(s, delim); + elems.push_back(std::string(s, end - s)); + if (*end == '\0') + break; + s = end + 1; } return elems; } @@ -499,7 +494,7 @@ static vector_string_t get_enabled_reporters(map_crash_data_t &crash_data) } /* Reporters found, now parse the list. */ - vector_string_t reporter_vec = split(reporters_iter->second, ","); + vector_string_t reporter_vec = split(reporters_iter->second.c_str(), ','); // Get informations about all plugins. map_map_string_t plugins = call_GetPluginsInfo(); @@ -508,7 +503,7 @@ static vector_string_t get_enabled_reporters(map_crash_data_t &crash_data) for (it = plugins.begin(); it != itend; ++it) { // Skip disabled plugins. - if (0 != strcmp(it->second["Enabled"].c_str(), "yes")) + if (string_to_bool(it->second["Enabled"].c_str()) != true) continue; // Skip nonReporter plugins. if (0 != strcmp(it->second["Type"].c_str(), "Reporter")) |