Browse code

core: LOG() gcc 2.9x fixes

In gcc versions older then 3.0 ## before a variable argument
when the argument is empty will "eat" the _entire_ preceding
sequence of non-whitespace characters (not only the ',').
The fix just adds a space in front of ',' in all the macros calls
that use var args and ##.

Andrei Pelinescu-Onciul authored on 30/09/2009 22:58:15
Showing 1 changed files
... ...
@@ -212,33 +212,34 @@ int log_facility_fixup(void *handle, str *gname, str *name, void **val);
212 212
 						if (unlikely(log_stderr)) { \
213 213
 							fprintf(stderr, "%2d(%d) %s: %s" fmt, \
214 214
 									process_no, my_pid(), \
215
-									LOG_LEVEL2NAME(level),(prefix), ## args);\
215
+									LOG_LEVEL2NAME(level), \
216
+									(prefix) , ## args);\
216 217
 						} else { \
217 218
 							syslog(LOG2SYSLOG_LEVEL(level) |\
218 219
 								   (((facility) != DEFAULT_FACILITY) ? \
219 220
 									(facility) : \
220 221
 									cfg_get(core, core_cfg, log_facility)), \
221 222
 									"%s: %s" fmt, LOG_LEVEL2NAME(level),\
222
-									(prefix), ## args); \
223
+									(prefix) , ## args); \
223 224
 						} \
224 225
 					} else { \
225 226
 						if (log_stderr) { \
226 227
 							fprintf(stderr, "%2d(%d) %s" fmt, \
227 228
 										process_no, my_pid(), \
228
-										(prefix), ## args); \
229
+										(prefix) , ## args); \
229 230
 						} else { \
230 231
 							if ((level)<L_ALERT) \
231 232
 								syslog(LOG2SYSLOG_LEVEL(L_ALERT) | \
232 233
 									   (((facility) != DEFAULT_FACILITY) ? \
233 234
 										(facility) : \
234 235
 										cfg_get(core, core_cfg, log_facility)),\
235
-										"%s" fmt, (prefix), ## args); \
236
+										"%s" fmt, (prefix) , ## args); \
236 237
 							else \
237 238
 								syslog(LOG2SYSLOG_LEVEL(L_DBG) | \
238 239
 									   (((facility) != DEFAULT_FACILITY) ? \
239 240
 										(facility) : \
240 241
 										cfg_get(core, core_cfg, log_facility)),\
241
-										"%s" fmt, (prefix), ## args); \
242
+										"%s" fmt, (prefix) , ## args); \
242 243
 						} \
243 244
 					} \
244 245
 					DPRINT_CRIT_EXIT; \
... ...
@@ -246,9 +247,9 @@ int log_facility_fixup(void *handle, str *gname, str *name, void **val);
246 247
 			} while(0)
247 248
 			
248 249
 #		define LOG(level, fmt, args...) \
249
-	LOG_(DEFAULT_FACILITY, (level), LOC_INFO, fmt, ## args)
250
+	LOG_(DEFAULT_FACILITY, (level), LOC_INFO, fmt , ## args)
250 251
 #		define LOG_FC(facility, level, fmt, args...) \
251
-	LOG_((facility), (level), LOC_INFO, fmt, ## args)
252
+	LOG_((facility), (level), LOC_INFO, fmt , ## args)
252 253
 		
253 254
 #	endif /* __SUNPRO_C */
254 255
 #endif /* NO_LOG */
... ...
@@ -276,22 +277,22 @@ int log_facility_fixup(void *handle, str *gname, str *name, void **val);
276 277
 #	define DEBUG(...) DBG(__VA_ARGS__)
277 278
 
278 279
 #else /* ! __SUNPRO_C */
279
-#	define ALERT(fmt, args...)  LOG(L_ALERT,  fmt, ## args)
280
-#	define BUG(fmt, args...)    LOG(L_BUG,   fmt, ## args)
281
-#	define ERR(fmt, args...)    LOG(L_ERR,    fmt, ## args)
282
-#	define WARN(fmt, args...)   LOG(L_WARN,   fmt, ## args)
283
-#	define NOTICE(fmt, args...) LOG(L_NOTICE, fmt, ## args)
284
-#	define INFO(fmt, args...)   LOG(L_INFO,   fmt, ## args)
285
-#	define CRIT(fmt, args...)   LOG(L_CRIT2,   fmt, ## args)
280
+#	define ALERT(fmt, args...)  LOG(L_ALERT,  fmt , ## args)
281
+#	define BUG(fmt, args...)    LOG(L_BUG,   fmt , ## args)
282
+#	define ERR(fmt, args...)    LOG(L_ERR,    fmt , ## args)
283
+#	define WARN(fmt, args...)   LOG(L_WARN,   fmt , ## args)
284
+#	define NOTICE(fmt, args...) LOG(L_NOTICE, fmt , ## args)
285
+#	define INFO(fmt, args...)   LOG(L_INFO,   fmt , ## args)
286
+#	define CRIT(fmt, args...)   LOG(L_CRIT2,   fmt , ## args)
286 287
 
287 288
 #	ifdef NO_DEBUG
288 289
 #		define DBG(fmt, args...)
289 290
 #	else
290
-#		define DBG(fmt, args...)    LOG(L_DBG, fmt, ## args)
291
+#		define DBG(fmt, args...)    LOG(L_DBG, fmt , ## args)
291 292
 #	endif		
292 293
 
293 294
 /* obsolete, do not use */
294
-#	define DEBUG(fmt, args...) DBG(fmt, ## args)
295
+#	define DEBUG(fmt, args...) DBG(fmt , ## args)
295 296
 		
296 297
 #endif /* __SUNPRO_C */
297 298