1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-01-12 19:06:36 +00:00

Patch to allow escaping newlines in the config.

This commit is contained in:
Itai Zukerman 2008-12-15 21:17:56 -07:00 committed by Brenden Matthews
parent 621bad14f8
commit bb817b2cf7
3 changed files with 21 additions and 2 deletions

View File

@ -1,5 +1,6 @@
2008-12-15
* Have a maximum width for all variable length mpd vars
* Patch to allow escaping newlines in the config (thanks Itai)
2008-12-14
* Fix disk_protect for linux-2.6.27 (and hopefully above)

View File

@ -433,7 +433,7 @@
<varlistentry>
<term><command><option>TEXT</option></command></term>
<listitem>
After this begins text to be formatted on screen
After this begins text to be formatted on screen. Backslash (\) escapes newlines in the text section. This can be useful for cleaning up config files where conky is used to pipe input to dzen2.
<para></para></listitem>
</varlistentry>

View File

@ -7917,11 +7917,29 @@ static void load_config_file(const char *f)
while (!feof(fp)) {
unsigned int l = strlen(global_text);
unsigned int bl;
if (fgets(buf, 256, fp) == NULL) {
break;
}
global_text = (char *) realloc(global_text, l + strlen(buf) + 1);
/* Remove \\-\n. */
bl = strlen(buf);
if (bl >= 2 && buf[bl-2] == '\\' && buf[bl-1] == '\n') {
buf[bl-2] = '\0';
bl -= 2;
if (bl == 0) {
continue;
}
}
/* Check for continuation of \\-\n. */
if (l > 0 && buf[0] == '\n' && global_text[l-1] == '\\') {
global_text[l-1] = '\0';
continue;
}
global_text = (char *) realloc(global_text, l + bl + 1);
strcat(global_text, buf);
if (strlen(global_text) > max_user_text) {