diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2005-11-19 22:08:46 +0000 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2005-11-19 22:08:46 +0000 |
commit | d5affecc23554c886d81c4b735dca42ac2fd0bd2 (patch) | |
tree | a8c1ec8a4a0c800e06ae1d930e5c8373d091fc93 /src/plugins/plugins-config.c | |
parent | 967d436a1d85edd2e92d2fc72499b4a7c57de65f (diff) | |
download | weechat-d5affecc23554c886d81c4b735dca42ac2fd0bd2.zip |
Added read marker (indicator for first unread line), added quotes and spaces in config files
Diffstat (limited to 'src/plugins/plugins-config.c')
-rw-r--r-- | src/plugins/plugins-config.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/plugins/plugins-config.c b/src/plugins/plugins-config.c index 830719db0..431c51cb7 100644 --- a/src/plugins/plugins-config.c +++ b/src/plugins/plugins-config.c @@ -219,12 +219,50 @@ plugin_config_read () { pos[0] = '\0'; pos++; + + /* remove spaces before '=' */ + pos2 = pos - 2; + while ((pos2 > line) && (pos2[0] == ' ')) + { + pos2[0] = '\0'; + pos2--; + } + + /* skip spaces after '=' */ + while (pos[0] && (pos[0] == ' ')) + { + pos++; + } + + /* remove CR/LF */ pos2 = strchr (pos, '\r'); if (pos2 != NULL) pos2[0] = '\0'; pos2 = strchr (pos, '\n'); if (pos2 != NULL) pos2[0] = '\0'; + + /* remove simple or double quotes + and spaces at the end */ + if (strlen(pos) > 1) + { + pos2 = pos + strlen (pos) - 1; + while ((pos2 > pos) && (pos2[0] == ' ')) + { + pos2[0] = '\0'; + pos2--; + } + pos2 = pos + strlen (pos) - 1; + if (((pos[0] == '\'') && + (pos2[0] == '\'')) || + ((pos[0] == '"') && + (pos2[0] == '"'))) + { + pos2[0] = '\0'; + pos++; + } + } + plugin_config_set_internal (ptr_line, pos); } } @@ -279,7 +317,7 @@ plugin_config_write () for (ptr_plugin_option = plugin_options; ptr_plugin_option; ptr_plugin_option = ptr_plugin_option->next_option) { - fprintf (file, "%s=%s\n", + fprintf (file, "%s = \"%s\"\n", ptr_plugin_option->option_name, ptr_plugin_option->value); } |