|
0 |
Description: Fix FTBFS with clang instead of GCC
|
|
1 |
Author: Alexander Ovchinnikov <sanek23994@gmail.com>
|
|
2 |
Bug-Debian: http://bugs.debian.org/758453
|
|
3 |
|
|
4 |
--- a/examples/hcal/hcal.c
|
|
5 |
+++ b/examples/hcal/hcal.c
|
|
6 |
@@ -677,13 +677,6 @@ void print_header_month_line_stdout( con
|
|
7 |
}
|
|
8 |
|
|
9 |
|
|
10 |
-/**************************************************
|
|
11 |
-* print column headings for days of weeks
|
|
12 |
-**************************************************/
|
|
13 |
-void print_header_dow_line_stdout( const int colorize )
|
|
14 |
-{
|
|
15 |
- int column;
|
|
16 |
-
|
|
17 |
void print_dow_column( int column )
|
|
18 |
{
|
|
19 |
if (hdate_is_hebrew_locale())
|
|
20 |
@@ -701,6 +694,13 @@ void print_header_dow_line_stdout( const
|
|
21 |
if (column != 7) printf (" ");
|
|
22 |
}
|
|
23 |
|
|
24 |
+/**************************************************
|
|
25 |
+* print column headings for days of weeks
|
|
26 |
+**************************************************/
|
|
27 |
+void print_header_dow_line_stdout( const int colorize )
|
|
28 |
+{
|
|
29 |
+ int column;
|
|
30 |
+
|
|
31 |
if (colorize) colorize_element(ELEMENT_WEEKDAY_NAMES);
|
|
32 |
for (column = 1; column < 7; column++) print_dow_column(column);
|
|
33 |
if (colorize) colorize_element(ELEMENT_SHABBAT_NAME);
|
|
34 |
@@ -1149,27 +1149,15 @@ void print_week( int jd, const int month
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
-/**************************************************
|
|
39 |
-* print month table
|
|
40 |
-*************************************************/
|
|
41 |
-int print_calendar ( const int current_month, const int current_year, const option_list opt)
|
|
42 |
-{
|
|
43 |
- hdate_struct h;
|
|
44 |
- int calendar_line;
|
|
45 |
- int max_calendar_lines = 4;
|
|
46 |
- int previous_month, next_month;
|
|
47 |
- int previous_year, next_year;
|
|
48 |
- int jd_current_month, jd_previous_month, jd_next_month;
|
|
49 |
-
|
|
50 |
- void how_many_calendar_lines( int month, int start_dow )
|
|
51 |
+void how_many_calendar_lines( int month, int start_dow, int *max_calendar_lines )
|
|
52 |
{
|
|
53 |
switch (month)
|
|
54 |
{
|
|
55 |
case 4:
|
|
56 |
case 6:
|
|
57 |
case 9:
|
|
58 |
- case 11: if (start_dow == 7) max_calendar_lines = 6;
|
|
59 |
- else if (max_calendar_lines == 4) max_calendar_lines = 5;
|
|
60 |
+ case 11: if (start_dow == 7) *max_calendar_lines = 6;
|
|
61 |
+ else if (*max_calendar_lines == 4) *max_calendar_lines = 5;
|
|
62 |
break;
|
|
63 |
case 1:
|
|
64 |
case 3:
|
|
65 |
@@ -1177,12 +1165,24 @@ int print_calendar ( const int current_m
|
|
66 |
case 7:
|
|
67 |
case 8:
|
|
68 |
case 10:
|
|
69 |
- case 12: if (start_dow > 5) max_calendar_lines = 6;
|
|
70 |
- else if (max_calendar_lines == 4) max_calendar_lines = 5;
|
|
71 |
+ case 12: if (start_dow > 5) *max_calendar_lines = 6;
|
|
72 |
+ else if (*max_calendar_lines == 4) *max_calendar_lines = 5;
|
|
73 |
break;
|
|
74 |
}
|
|
75 |
}
|
|
76 |
|
|
77 |
+/**************************************************
|
|
78 |
+* print month table
|
|
79 |
+*************************************************/
|
|
80 |
+int print_calendar ( const int current_month, const int current_year, const option_list opt)
|
|
81 |
+{
|
|
82 |
+ hdate_struct h;
|
|
83 |
+ int calendar_line;
|
|
84 |
+ int max_calendar_lines = 4;
|
|
85 |
+ int previous_month, next_month;
|
|
86 |
+ int previous_year, next_year;
|
|
87 |
+ int jd_current_month, jd_previous_month, jd_next_month;
|
|
88 |
+
|
|
89 |
/*********************************************************
|
|
90 |
* Preliminaries:
|
|
91 |
* - Find the first sunday(s) of each calendar
|
|
92 |
@@ -1190,7 +1190,7 @@ int print_calendar ( const int current_m
|
|
93 |
*********************************************************/
|
|
94 |
hdate_set_gdate (&h, 1, current_month, current_year);
|
|
95 |
jd_current_month = h.hd_jd - h.hd_dw + 1;
|
|
96 |
- how_many_calendar_lines( h.gd_mon, h.hd_dw );
|
|
97 |
+ how_many_calendar_lines( h.gd_mon, h.hd_dw, &max_calendar_lines );
|
|
98 |
|
|
99 |
/*********************************************************
|
|
100 |
* three months, side-by-side
|
|
101 |
@@ -1212,7 +1212,7 @@ int print_calendar ( const int current_m
|
|
102 |
}
|
|
103 |
hdate_set_gdate (&h, 1, previous_month, previous_year);
|
|
104 |
jd_previous_month = h.hd_jd - h.hd_dw + 1;
|
|
105 |
- how_many_calendar_lines( h.gd_mon, h.hd_dw );
|
|
106 |
+ how_many_calendar_lines( h.gd_mon, h.hd_dw, &max_calendar_lines );
|
|
107 |
|
|
108 |
/*********************************************************
|
|
109 |
* next month
|
|
110 |
@@ -1229,7 +1229,7 @@ int print_calendar ( const int current_m
|
|
111 |
}
|
|
112 |
hdate_set_gdate (&h, 1, next_month, next_year);
|
|
113 |
jd_next_month = h.hd_jd - h.hd_dw + 1;
|
|
114 |
- how_many_calendar_lines( h.gd_mon, h.hd_dw );
|
|
115 |
+ how_many_calendar_lines( h.gd_mon, h.hd_dw, &max_calendar_lines );
|
|
116 |
}
|
|
117 |
|
|
118 |
|
|
119 |
--- a/examples/hcal/local_functions.c
|
|
120 |
+++ b/examples/hcal/local_functions.c
|
|
121 |
@@ -646,62 +646,50 @@ file. Attempting to create a config file
|
|
122 |
#include <sys/stat.h>
|
|
123 |
#include <sys/types.h> // for mkdir,
|
|
124 |
|
|
125 |
-/************************************************************
|
|
126 |
-* Open config file, or create one
|
|
127 |
-* - returns filepointer or NULL
|
|
128 |
-* - if file does not exist, attempt to create it
|
|
129 |
-************************************************************/
|
|
130 |
-FILE* get_config_file( const char* config_dir_name,
|
|
131 |
- const char* config_file_name,
|
|
132 |
- const char* default_config_file_text )
|
|
133 |
-{
|
|
134 |
- size_t path_len;
|
|
135 |
-
|
|
136 |
- char* config_home_path_name = "";
|
|
137 |
- char* config_sub_path_name = "";
|
|
138 |
-
|
|
139 |
- char* config_dir_path;
|
|
140 |
- char* config_file_path;
|
|
141 |
-
|
|
142 |
- FILE* config_file;
|
|
143 |
|
|
144 |
/************************************************************
|
|
145 |
* sub-function to get_config_file: create_config_file
|
|
146 |
************************************************************/
|
|
147 |
- void create_config_file()
|
|
148 |
+ void create_config_file(FILE** config_file, char* config_file_path,
|
|
149 |
+ const char* default_config_file_text, const char* config_file_name)
|
|
150 |
{
|
|
151 |
- config_file = fopen(config_file_path, "a");
|
|
152 |
- if (config_file == NULL)
|
|
153 |
+ *config_file = fopen(config_file_path, "a");
|
|
154 |
+ if (*config_file == NULL)
|
|
155 |
{
|
|
156 |
error(0, errno, "%s: %s", N_("failure attempting to create config file"), config_file_path);
|
|
157 |
return;
|
|
158 |
}
|
|
159 |
- fprintf(config_file, "%s", default_config_file_text);
|
|
160 |
+ fprintf(*config_file, "%s", default_config_file_text);
|
|
161 |
error(0,0,"%s: %s",N_("config file created"), config_file_path);
|
|
162 |
- if (fclose(config_file) != 0) error(0,errno,"%s %s",N_("failure closing"),config_file_name);
|
|
163 |
+ if (fclose(*config_file) != 0) error(0,errno,"%s %s",N_("failure closing"),config_file_name);
|
|
164 |
}
|
|
165 |
|
|
166 |
/************************************************************
|
|
167 |
* sub-function to get_config_file: open_config_file
|
|
168 |
************************************************************/
|
|
169 |
- int open_config_file()
|
|
170 |
+ int open_config_file(FILE** config_file, char* config_file_path,
|
|
171 |
+ size_t *path_len, const char* config_home_path_name,
|
|
172 |
+ const char* config_sub_path_name, const char* config_dir_name,
|
|
173 |
+ const char* default_config_file_text, const char* config_file_name)
|
|
174 |
{
|
|
175 |
- config_file = fopen(config_file_path, "r");
|
|
176 |
- if (config_file == NULL)
|
|
177 |
+ char* config_dir_path;
|
|
178 |
+
|
|
179 |
+ *config_file = fopen(config_file_path, "r");
|
|
180 |
+ if (*config_file == NULL)
|
|
181 |
{
|
|
182 |
if (errno != ENOENT) return FALSE;
|
|
183 |
// maybe replace all this with a single line asprintf()
|
|
184 |
- path_len = strlen(config_home_path_name)
|
|
185 |
+ *path_len = strlen(config_home_path_name)
|
|
186 |
+ strlen(config_sub_path_name)
|
|
187 |
+ strlen(config_dir_name) +1;
|
|
188 |
- if (path_len < 1) return FALSE;
|
|
189 |
- config_dir_path = malloc(path_len);
|
|
190 |
+ if (*path_len < 1) return FALSE;
|
|
191 |
+ config_dir_path = malloc(*path_len);
|
|
192 |
if (config_dir_path == NULL)
|
|
193 |
{
|
|
194 |
error(0,errno,"%s",N_("memory allocation failure"));
|
|
195 |
return FALSE;
|
|
196 |
}
|
|
197 |
- snprintf(config_dir_path, path_len, "%s%s%s",
|
|
198 |
+ snprintf(config_dir_path, *path_len, "%s%s%s",
|
|
199 |
config_home_path_name, config_sub_path_name,
|
|
200 |
config_dir_name);
|
|
201 |
|
|
202 |
@@ -712,13 +700,30 @@ FILE* get_config_file( const char* confi
|
|
203 |
return FALSE;
|
|
204 |
}
|
|
205 |
greetings_to_version_16();
|
|
206 |
- create_config_file();
|
|
207 |
+ create_config_file(config_file, config_file_path, default_config_file_text, config_file_name);
|
|
208 |
free(config_dir_path);
|
|
209 |
return FALSE;
|
|
210 |
}
|
|
211 |
return TRUE;
|
|
212 |
}
|
|
213 |
|
|
214 |
+/************************************************************
|
|
215 |
+* Open config file, or create one
|
|
216 |
+* - returns filepointer or NULL
|
|
217 |
+* - if file does not exist, attempt to create it
|
|
218 |
+************************************************************/
|
|
219 |
+FILE* get_config_file( const char* config_dir_name,
|
|
220 |
+ const char* config_file_name,
|
|
221 |
+ const char* default_config_file_text )
|
|
222 |
+{
|
|
223 |
+ size_t path_len;
|
|
224 |
+
|
|
225 |
+ char* config_home_path_name = "";
|
|
226 |
+ char* config_sub_path_name = "";
|
|
227 |
+
|
|
228 |
+ char* config_file_path;
|
|
229 |
+
|
|
230 |
+ FILE* config_file;
|
|
231 |
|
|
232 |
/************************************************************
|
|
233 |
* main part of function get_config_file
|
|
234 |
@@ -750,7 +755,9 @@ FILE* get_config_file( const char* confi
|
|
235 |
config_home_path_name, config_sub_path_name,
|
|
236 |
config_dir_name, config_file_name);
|
|
237 |
|
|
238 |
- if (open_config_file() == TRUE)
|
|
239 |
+ if (open_config_file(&config_file, config_file_path, &path_len, config_home_path_name,
|
|
240 |
+ config_sub_path_name, config_dir_name,
|
|
241 |
+ default_config_file_text, config_file_name) == TRUE)
|
|
242 |
{
|
|
243 |
free(config_file_path);
|
|
244 |
return config_file;
|