diff options
author | mongo <andmarti@gmail.com> | 2018-03-21 10:06:36 -0300 |
---|---|---|
committer | mongo <andmarti@gmail.com> | 2018-03-21 10:06:36 -0300 |
commit | fcec375fd41e3f9a5503c82cfe17030ecd309584 (patch) | |
tree | ee7db688e6c7a92c15a963c266298b399ce4f26a /src/utils | |
parent | 6f5029eae048dadbb3bb6389de8393b0f4ac6b68 (diff) |
changed parse_str function so can handle white spaces
Diffstat (limited to 'src/utils')
-rwxr-xr-x | src/utils/dictionary.c | 6 | ||||
-rwxr-xr-x | src/utils/dictionary.h | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/utils/dictionary.c b/src/utils/dictionary.c index af3305d..5133a0a 100755 --- a/src/utils/dictionary.c +++ b/src/utils/dictionary.c @@ -259,11 +259,12 @@ char * get_key_name(struct dictionary * d, char * value) { * * \param[in] d * \param[in] str + * \param[in] blank_space * * \return dictionary */ -void parse_str(struct dictionary * d, char * str) { +void parse_str(struct dictionary * d, char * str, int blank_space) { char c = str[0]; char key[30]; char value[30]; @@ -278,8 +279,9 @@ void parse_str(struct dictionary * d, char * str) { } if (c == '\0') break; c = *++str; - while (c != ' ' && c != '\0') { //while (c != '\0') { + while (c != ' ' && c != '\0') { + if (blank_space && c == ' ') break; add_char(value, c, strlen(value)); c = *++str; } diff --git a/src/utils/dictionary.h b/src/utils/dictionary.h index d4ea63c..47a7f55 100755 --- a/src/utils/dictionary.h +++ b/src/utils/dictionary.h @@ -59,6 +59,6 @@ void destroy_dictionary(struct dictionary * d); char * get(struct dictionary * d, char * key); //char * get_key_name(struct dictionary * d, char * value); struct nlist * get_nl(struct dictionary * d, char * key); -void parse_str(struct dictionary * d, char * str); +void parse_str(struct dictionary * d, char * str, int blank_space); int get_maxkey_length(struct dictionary * d); int get_maxvalue_length(struct dictionary * d); |