diff options
author | Dan Fandrich <dan@coneharvesters.com> | 2009-10-27 11:05:00 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-10-27 11:05:00 +0100 |
commit | 21a542d7d732735a522c413c0c385e577528ec63 (patch) | |
tree | f0873e7eb57524ca9306d12b6dd2ecd5224f8a0a /libbb/xfuncs_printf.c | |
parent | d83bbf41934382631161845302f5d77027383aba (diff) | |
download | busybox-w32-21a542d7d732735a522c413c0c385e577528ec63.tar.gz busybox-w32-21a542d7d732735a522c413c0c385e577528ec63.tar.bz2 busybox-w32-21a542d7d732735a522c413c0c385e577528ec63.zip |
platform compatibility work (by Dan Fandrich)
Signed-off-by: Dan Fandrich <dan@coneharvesters.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/xfuncs_printf.c')
-rw-r--r-- | libbb/xfuncs_printf.c | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c index aaf9989a0..345c84219 100644 --- a/libbb/xfuncs_printf.c +++ b/libbb/xfuncs_printf.c | |||
@@ -283,60 +283,15 @@ char* FAST_FUNC xasprintf(const char *format, ...) | |||
283 | int r; | 283 | int r; |
284 | char *string_ptr; | 284 | char *string_ptr; |
285 | 285 | ||
286 | #if 1 | ||
287 | // GNU extension | ||
288 | va_start(p, format); | 286 | va_start(p, format); |
289 | r = vasprintf(&string_ptr, format, p); | 287 | r = vasprintf(&string_ptr, format, p); |
290 | va_end(p); | 288 | va_end(p); |
291 | #else | ||
292 | // Bloat for systems that haven't got the GNU extension. | ||
293 | va_start(p, format); | ||
294 | r = vsnprintf(NULL, 0, format, p); | ||
295 | va_end(p); | ||
296 | string_ptr = xmalloc(r+1); | ||
297 | va_start(p, format); | ||
298 | r = vsnprintf(string_ptr, r+1, format, p); | ||
299 | va_end(p); | ||
300 | #endif | ||
301 | 289 | ||
302 | if (r < 0) | 290 | if (r < 0) |
303 | bb_error_msg_and_die(bb_msg_memory_exhausted); | 291 | bb_error_msg_and_die(bb_msg_memory_exhausted); |
304 | return string_ptr; | 292 | return string_ptr; |
305 | } | 293 | } |
306 | 294 | ||
307 | #if 0 /* If we will ever meet a libc which hasn't [f]dprintf... */ | ||
308 | int FAST_FUNC fdprintf(int fd, const char *format, ...) | ||
309 | { | ||
310 | va_list p; | ||
311 | int r; | ||
312 | char *string_ptr; | ||
313 | |||
314 | #if 1 | ||
315 | // GNU extension | ||
316 | va_start(p, format); | ||
317 | r = vasprintf(&string_ptr, format, p); | ||
318 | va_end(p); | ||
319 | #else | ||
320 | // Bloat for systems that haven't got the GNU extension. | ||
321 | va_start(p, format); | ||
322 | r = vsnprintf(NULL, 0, format, p) + 1; | ||
323 | va_end(p); | ||
324 | string_ptr = malloc(r); | ||
325 | if (string_ptr) { | ||
326 | va_start(p, format); | ||
327 | r = vsnprintf(string_ptr, r, format, p); | ||
328 | va_end(p); | ||
329 | } | ||
330 | #endif | ||
331 | |||
332 | if (r >= 0) { | ||
333 | full_write(fd, string_ptr, r); | ||
334 | free(string_ptr); | ||
335 | } | ||
336 | return r; | ||
337 | } | ||
338 | #endif | ||
339 | |||
340 | void FAST_FUNC xsetenv(const char *key, const char *value) | 295 | void FAST_FUNC xsetenv(const char *key, const char *value) |
341 | { | 296 | { |
342 | if (setenv(key, value, 1)) | 297 | if (setenv(key, value, 1)) |