summaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenis Vlasenko2006-10-27 07:17:36 +0000
committerDenis Vlasenko2006-10-27 07:17:36 +0000
commit1340ca8c87d81bf00e604905f25bc04da22e980f (patch)
tree66c8253fb41007c8ef5c8c29cb2930ce00d3d4c7 /libbb
parent2fe7b73d99038d7dd479a6995db358c9a58a6ad9 (diff)
downloadbusybox-1340ca8c87d81bf00e604905f25bc04da22e980f.zip
busybox-1340ca8c87d81bf00e604905f25bc04da22e980f.tar.gz
As usual, I forgot "svn del"...
Diffstat (limited to 'libbb')
-rw-r--r--libbb/printf.c96
1 files changed, 0 insertions, 96 deletions
diff --git a/libbb/printf.c b/libbb/printf.c
deleted file mode 100644
index f0ddb86..0000000
--- a/libbb/printf.c
+++ /dev/null
@@ -1,96 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * *printf implementations for busybox
- *
- * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org>
- *
- * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
- */
-
-/* Mar 12, 2003 Manuel Novoa III
- *
- * While fwrite(), fputc(), fputs(), etc. all set the stream error flag
- * on failure, the *printf functions are unique in that they can fail
- * for reasons not related to the actual output itself. Among the possible
- * reasons for failure which don't set the streams error indicator,
- * SUSv3 lists EILSEQ, EINVAL, and ENOMEM.
- *
- * In some cases, it would be desirable to have a group of *printf()
- * functions available that _always_ set the stream error indicator on
- * failure. That would allow us to defer error checking until applet
- * exit. Unfortunately, there is no standard way of setting a streams
- * error indicator... even though we can clear it with clearerr().
- */
-
-/* Mar 22, 2006 Rich Felker III
- *
- * Actually there is a portable way to set the error indicator. See below.
- * It is not thread-safe as written due to a race condition with file
- * descriptors but since BB is not threaded that does not matter. It can be
- * made thread-safe at the expense of slightly more code, if this is ever
- * needed in the future.
- */
-
-#include <stdio.h>
-#include <stdarg.h>
-#include <unistd.h>
-#include <errno.h>
-#include "libbb.h"
-
-int bb_vfprintf(FILE * __restrict stream,
- const char * __restrict format,
- va_list arg)
-{
- int rv;
-
- if ((rv = vfprintf(stream, format, arg)) < 0) {
- /* The following sequence portably sets the error flag for
- * stream on any remotely POSIX-compliant implementation. */
-
- int errno_save = errno;
- int fd = fileno(stream);
- int tmp = dup(fd);
-
- fflush(stream);
- close(fd);
- /* Force an attempted write to nonexistant fd => EBADF */
- fputc(0, stream);
- fflush(stream);
- /* Restore the stream's original fd */
- dup2(tmp, fd);
- close(tmp);
- errno = errno_save;
- }
-
- return rv;
-}
-
-int bb_vprintf(const char * __restrict format, va_list arg)
-{
- return bb_vfprintf(stdout, format, arg);
-}
-
-int bb_fprintf(FILE * __restrict stream,
- const char * __restrict format, ...)
-{
- va_list arg;
- int rv;
-
- va_start(arg, format);
- rv = bb_vfprintf(stream, format, arg);
- va_end(arg);
-
- return rv;
-}
-
-int bb_printf(const char * __restrict format, ...)
-{
- va_list arg;
- int rv;
-
- va_start(arg, format);
- rv = bb_vfprintf(stdout, format, arg);
- va_end(arg);
-
- return rv;
-}