Make templates work with --disable-x11
authorPavel Labath <pavelo@centrum.sk>
Tue, 2 Jun 2009 14:54:41 +0000 (16:54 +0200)
committerBrenden Matthews <brenden@rty.ca>
Tue, 2 Jun 2009 20:48:59 +0000 (14:48 -0600)
part of the template-handling code was in #ifdef X11, which caused conky to dump core when
compiled without x11.

as a bonus, I changed tests !=' ' to !isspace in two places as it was causing strange effects

Signed-off-by: Brenden Matthews <brenden@rty.ca>

src/conky.c

index ed515f2..d1c5316 100644 (file)
@@ -3024,7 +3024,7 @@ static char *find_and_replace_templates(const char *inbuf)
                if (*(p + 1) == '{') {
                        p += 2;
                        templ = p;
-                       while (*p && *p != ' ' && *p != '{' && *p != '}')
+                       while (*p && !isspace(*p) && *p != '{' && *p != '}')
                                p++;
                        if (*p == '}')
                                args = NULL;
@@ -3048,10 +3048,8 @@ static char *find_and_replace_templates(const char *inbuf)
                        }
                } else {
                        templ = p + 1;
-                       while (*p && *p != ' ')
+                       while (*p && !isspace(*p))
                                p++;
-                       if(*p)
-                               *(p++) = '\0';
                        args = NULL;
                }
                tmpl_out = handle_template(templ, args);
@@ -7109,16 +7107,17 @@ static void clean_up(void)
 
                XFreeGC(display, window.gc);
                free_fonts();
-               for (i = 0; i < 10; i ++) {
-                       if (template[i]) {
-                               free(template[i]);
-                               template[i] = NULL;
-                       }
-               }
        }
 
 #endif /* X11 */
 
+       for (i = 0; i < 10; i ++) {
+               if (template[i]) {
+                       free(template[i]);
+                       template[i] = NULL;
+               }
+       }
+
        free_text_objects(&global_root_object, 0);
        if (tmpstring1) {
                free(tmpstring1);
@@ -7276,16 +7275,6 @@ static void set_default_configurations(void)
 #ifdef X11
        show_graph_scale = 0;
        show_graph_range = 0;
-       template[0] = strdup("");
-       template[1] = strdup("");
-       template[2] = strdup("");
-       template[3] = strdup("");
-       template[4] = strdup("");
-       template[5] = strdup("");
-       template[6] = strdup("");
-       template[7] = strdup("");
-       template[8] = strdup("");
-       template[9] = strdup("");
        draw_shades = 1;
        draw_borders = 0;
        draw_graph_borders = 1;
@@ -7311,6 +7300,17 @@ static void set_default_configurations(void)
        info.x11.monitor.current = 0;
 #endif /* X11 */
 
+       template[0] = strdup("");
+       template[1] = strdup("");
+       template[2] = strdup("");
+       template[3] = strdup("");
+       template[4] = strdup("");
+       template[5] = strdup("");
+       template[6] = strdup("");
+       template[7] = strdup("");
+       template[8] = strdup("");
+       template[9] = strdup("");
+
        free(current_mail_spool);
        {
                char buf[256];
@@ -7591,6 +7591,7 @@ static void load_config_file(const char *f)
                                CONF_ERR;
                        }
                }
+#endif /* X11 */
 #define TEMPLATE_CONF(n) \
                CONF("template"#n) { \
                        if (value) { \
@@ -7610,7 +7611,6 @@ static void load_config_file(const char *f)
                TEMPLATE_CONF(7)
                TEMPLATE_CONF(8)
                TEMPLATE_CONF(9)
-#endif /* X11 */
                CONF("imap") {
                        if (value) {
                                info.mail = parse_mail_args(IMAP_TYPE, value);