]> git.pld-linux.org Git - packages/conky.git/blob - conky-ncurses.patch
- ncurses patch, stolen from from gentoo. More details here
[packages/conky.git] / conky-ncurses.patch
1 diff -burNp conky-1.8.0/configure.ac.in conky-1.8.0-dud/configure.ac.in
2 --- conky-1.8.0/configure.ac.in 2010-03-30 19:47:30.000000000 +0200
3 +++ conky-1.8.0-dud/configure.ac.in     2010-04-08 22:13:46.056130555 +0200
4 @@ -1011,6 +1011,7 @@ dnl  OpenMP:           $want_openmp
5    ALSA mixer:       $want_alsa
6    apcupsd:          $want_apcupsd
7    I/O stats:        $want_iostats
8 +  ncurses:          $want_ncurses
9  
10   * Lua ($want_lua) bindings:
11    Cairo:            $want_lua_cairo
12 diff -burNp conky-1.8.0/src/conky.c conky-1.8.0-dud/src/conky.c
13 --- conky-1.8.0/src/conky.c     2010-03-25 21:27:32.000000000 +0100
14 +++ conky-1.8.0-dud/src/conky.c 2010-04-08 22:25:15.789443783 +0200
15 @@ -3119,36 +3119,48 @@ int draw_each_line_inner(char *s, int sp
16                                                 if (seconds != 0) {
17                                                         timeunits = seconds / 86400; seconds %= 86400;
18                                                         if (timeunits > 0) {
19 -                                                               asprintf(&tmp_day_str, "%dd", timeunits);
20 +                                                               if (asprintf(&tmp_day_str, "%dd", timeunits) < 0) {
21 +                                                                       tmp_day_str = 0;
22 +                                                               }
23                                                         } else {
24                                                                 tmp_day_str = strdup("");
25                                                         }
26                                                         timeunits = seconds / 3600; seconds %= 3600;
27                                                         if (timeunits > 0) {
28 -                                                               asprintf(&tmp_hour_str, "%dh", timeunits);
29 +                                                               if (asprintf(&tmp_hour_str, "%dh", timeunits) < 0) {
30 +                                                                       tmp_day_str = 0;
31 +                                                               }       
32                                                         } else {
33                                                                 tmp_hour_str = strdup("");
34                                                         }
35                                                         timeunits = seconds / 60; seconds %= 60;
36                                                         if (timeunits > 0) {
37 -                                                               asprintf(&tmp_min_str, "%dm", timeunits);
38 +                                                               if (asprintf(&tmp_min_str, "%dm", timeunits) < 0) {
39 +                                                                       tmp_min_str = 0;
40 +                                                               }
41                                                         } else {
42                                                                 tmp_min_str = strdup("");
43                                                         }
44                                                         if (seconds > 0) {
45 -                                                               asprintf(&tmp_sec_str, "%ds", seconds);
46 +                                                               if (asprintf(&tmp_sec_str, "%ds", seconds) < 0) {
47 +                                                                       tmp_sec_str = 0;
48 +                                                               }
49                                                         } else {
50                                                                 tmp_sec_str = strdup("");
51                                                         }
52 -                                                       asprintf(&tmp_str, "%s%s%s%s", tmp_day_str, tmp_hour_str, tmp_min_str, tmp_sec_str);
53 -                                                       free(tmp_day_str); free(tmp_hour_str); free(tmp_min_str); free(tmp_sec_str);
54 +                                                       if (asprintf(&tmp_str, "%s%s%s%s", tmp_day_str, tmp_hour_str, tmp_min_str, tmp_sec_str) < 0) {
55 +                                                               tmp_str = 0;
56 +                                                       }
57 +#define FREE(a) if ((a)) free((a));
58 +                                                       FREE(tmp_day_str); FREE(tmp_hour_str); FREE(tmp_min_str); FREE(tmp_sec_str);
59                                                 } else {
60 -                                                       asprintf(&tmp_str, "Range not possible"); // should never happen, but better safe then sorry
61 +                                                       tmp_str = strdup("Range not possible"); /* should never happen, but better safe then sorry */
62                                                 }
63                                                 cur_x += (w / 2) - (font_ascent() * (strlen(tmp_str) / 2));
64                                                 cur_y += font_h / 2;
65                                                 draw_string(tmp_str);
66 -                                               free(tmp_str);
67 +                                               FREE(tmp_str);
68 +#undef FREE
69                                                 cur_x = tmp_x;
70                                                 cur_y = tmp_y;
71                                         }
72 @@ -4518,13 +4530,13 @@ void setalignment(int* ltext_alignment,
73                 int a = string_to_alignment(value);
74  
75                 if (a <= 0) {
76 -                       if(setbyconffile == true) {
77 +                       if (setbyconffile) {
78                                 CONF_ERR;
79                         } else NORM_ERR("'%s' is not a alignment setting", value);
80                 } else {
81                         *ltext_alignment = a;
82                 }
83 -       } else if(setbyconffile == true) {
84 +       } else if (setbyconffile) {
85                 CONF_ERR;
86         }
87  }
88 @@ -4573,7 +4585,7 @@ char load_config_file(const char *f)
89                         }
90                 }
91                 CONF("alignment") {
92 -                       setalignment(&text_alignment, window.type, value, f, line, true);
93 +                       setalignment(&text_alignment, window.type, value, f, line, 1);
94                 }
95                 CONF("background") {
96                         fork_to_background = string_to_bool(value);
97 @@ -5696,7 +5708,7 @@ void initialisation(int argc, char **arg
98                                 set_first_font(optarg);
99                                 break;
100                         case 'a':
101 -                               setalignment(&text_alignment, window.type, optarg, NULL, 0, false);
102 +                               setalignment(&text_alignment, window.type, optarg, NULL, 0, 0);
103                                 break;
104  
105  #ifdef OWN_WINDOW
106 @@ -5895,7 +5907,9 @@ int main(int argc, char **argv)
107                                 current_config = strndup(optarg, max_user_text);
108                                 break;
109                         case 'q':
110 -                               freopen("/dev/null", "w", stderr);
111 +                               if (!freopen("/dev/null", "w", stderr)) {
112 +                                       NORM_ERR("unable to redirect stderr to /dev/null");
113 +                               }
114                                 break;
115                         case 'h':
116                                 print_help(argv[0]);
117 diff -burNp conky-1.8.0/src/conky.c conky-1.8.0-dud/src/conky.c
118 --- conky-1.8.0/src/conky.c     2010-03-25 21:27:32.000000000 +0100
119 +++ conky-1.8.0-dud/src/conky.c 2010-04-08 22:30:40.745051008 +0200
120 @@ -65,7 +65,7 @@
121  #include <fcntl.h>
122  #include <getopt.h>
123  #ifdef NCURSES
124 -#include <ncurses.h>
125 +#include <ncurses/ncurses.h>
126  #endif
127  #ifdef XOAP
128  #include <libxml/parser.h>
129 diff -burNp conky-1.8.0/src/core.c conky-1.8.0-dud/src/core.c
130 --- conky-1.8.0/src/core.c      2010-03-25 21:27:32.000000000 +0100
131 +++ conky-1.8.0-dud/src/core.c  2010-04-09 10:24:30.287419400 +0200
132 @@ -65,7 +65,7 @@
133  #include "top.h"
134  
135  #ifdef NCURSES
136 -#include <ncurses.h>
137 +#include <ncurses/ncurses.h>
138  #endif
139  
140  /* check for OS and include appropriate headers */
This page took 0.066106 seconds and 3 git commands to generate.