1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-18 02:55:12 +00:00

Merge branch 'master' into lua

This commit is contained in:
Brenden Matthews 2009-05-16 18:37:04 -06:00
commit 72d15db78a

View File

@ -2995,30 +2995,35 @@ static void strfold(char *start, int count)
for (curplace = start + count; *curplace != 0; curplace++) {
*(curplace - count) = *curplace;
}
*(curplace - count) = 0;
*(curplace - count - 1) = 0;
}
static void remove_comments(char *string)
static size_t remove_comments(char *string)
{
char *curplace, *curplace2;
size_t folded = 0;
for (curplace = string; *curplace != 0; curplace++) {
if (*curplace == '\\' && *(curplace + 1) == '#') {
// strcpy can't be used for overlapping strings
strfold(curplace, 1);
folded += 1;
} else if (*curplace == '#') {
// remove everything until we hit a '\n'
curplace2 = curplace;
while (*curplace2 && *curplace2 != '\n') {
while (*curplace2) {
curplace2++;
if (*curplace2 == '\n' &&
*(curplace2 + 1) != '#') break;
}
if (*curplace2) {
strfold(curplace, curplace2 - curplace);
folded += curplace2 - curplace;
} else {
*curplace = 0;
}
}
}
return folded;
}
static int extract_variable_text_internal(struct text_object *retval, const char *const_p, char allow_threaded)
@ -3029,6 +3034,7 @@ static int extract_variable_text_internal(struct text_object *retval, const char
void *ifblock_opaque = NULL;
char *tmp_p;
char *arg = 0;
size_t len = 0;
p = strndup(const_p, max_user_text - 1);
while (text_contains_templates(p)) {
@ -3066,7 +3072,6 @@ static int extract_variable_text_internal(struct text_object *retval, const char
if (*p != '$') {
char buf[256];
const char *var;
unsigned int len;
/* variable is either $foo or ${foo} */
if (*p == '{') {
@ -3153,10 +3158,13 @@ static int extract_variable_text_internal(struct text_object *retval, const char
append_object(retval, obj);
}
}
} else if (*p == '#') {
remove_comments(p);
}
p++;
}
remove_comments(s);
printf("'%s'\n", s);
obj = create_plain_text(s);
if (obj != NULL) {
append_object(retval, obj);
@ -3884,6 +3892,9 @@ static void generate_text_internal(char *p, int p_max_size,
#endif
OBJ(execbar) {
double barnum;
#ifndef X11
int i;
#endif
read_exec(obj->data.s, p, text_buffer_size);
barnum = get_barnum(p);