aboutsummaryrefslogtreecommitdiffstats
path: root/util/stream/printf.cpp
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:17 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:17 +0300
commitd3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch)
treedd4bd3ca0f36b817e96812825ffaf10d645803f2 /util/stream/printf.cpp
parent72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff)
downloadydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'util/stream/printf.cpp')
-rw-r--r--util/stream/printf.cpp94
1 files changed, 47 insertions, 47 deletions
diff --git a/util/stream/printf.cpp b/util/stream/printf.cpp
index a7f7c0db4f..f3eeca7afc 100644
--- a/util/stream/printf.cpp
+++ b/util/stream/printf.cpp
@@ -1,51 +1,51 @@
#include "output.h"
-#include "printf.h"
-
-#include <util/generic/scope.h>
-#include <util/memory/tempbuf.h>
-#include <util/generic/yexception.h>
-
+#include "printf.h"
+
+#include <util/generic/scope.h>
+#include <util/memory/tempbuf.h>
+#include <util/generic/yexception.h>
+
size_t Printf(IOutputStream& out, const char* fmt, ...) {
- va_list lst;
- va_start(lst, fmt);
-
- Y_DEFER {
- va_end(lst);
- };
-
- return Printf(out, fmt, lst);
-}
-
+ va_list lst;
+ va_start(lst, fmt);
+
+ Y_DEFER {
+ va_end(lst);
+ };
+
+ return Printf(out, fmt, lst);
+}
+
static inline size_t TryPrintf(void* ptr, size_t len, IOutputStream& out, const char* fmt, va_list params) {
- va_list lst;
- va_copy(lst, params);
- const int ret = vsnprintf((char*)ptr, len, fmt, lst);
- va_end(lst);
-
- if (ret < 0) {
- return len;
- }
-
- if ((size_t)ret < len) {
- out.Write(ptr, (size_t)ret);
- }
-
- return (size_t)ret;
-}
-
+ va_list lst;
+ va_copy(lst, params);
+ const int ret = vsnprintf((char*)ptr, len, fmt, lst);
+ va_end(lst);
+
+ if (ret < 0) {
+ return len;
+ }
+
+ if ((size_t)ret < len) {
+ out.Write(ptr, (size_t)ret);
+ }
+
+ return (size_t)ret;
+}
+
size_t Printf(IOutputStream& out, const char* fmt, va_list params) {
- size_t guess = 0;
-
- while (true) {
- TTempBuf tmp(guess);
- const size_t ret = TryPrintf(tmp.Data(), tmp.Size(), out, fmt, params);
-
- if (ret < tmp.Size()) {
- return ret;
- }
-
- guess = Max(tmp.Size() * 2, ret + 1);
- }
-
- return 0;
-}
+ size_t guess = 0;
+
+ while (true) {
+ TTempBuf tmp(guess);
+ const size_t ret = TryPrintf(tmp.Data(), tmp.Size(), out, fmt, params);
+
+ if (ret < tmp.Size()) {
+ return ret;
+ }
+
+ guess = Max(tmp.Size() * 2, ret + 1);
+ }
+
+ return 0;
+}