aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/curl/lib/mprintf.c
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.ru>2022-02-10 16:45:08 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:08 +0300
commit4e839db24a3bbc9f1c610c43d6faaaa99824dcca (patch)
tree506dac10f5df94fab310584ee51b24fc5a081c22 /contrib/libs/curl/lib/mprintf.c
parent2d37894b1b037cf24231090eda8589bbb44fb6fc (diff)
downloadydb-4e839db24a3bbc9f1c610c43d6faaaa99824dcca.tar.gz
Restoring authorship annotation for <thegeorg@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/curl/lib/mprintf.c')
-rw-r--r--contrib/libs/curl/lib/mprintf.c134
1 files changed, 67 insertions, 67 deletions
diff --git a/contrib/libs/curl/lib/mprintf.c b/contrib/libs/curl/lib/mprintf.c
index c681248dee..4a32ad4609 100644
--- a/contrib/libs/curl/lib/mprintf.c
+++ b/contrib/libs/curl/lib/mprintf.c
@@ -5,11 +5,11 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1999 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1999 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
- * are also available at https://curl.se/docs/copyright.html.
+ * are also available at https://curl.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
@@ -36,7 +36,7 @@
*/
#include "curl_setup.h"
-#include "dynbuf.h"
+#include "dynbuf.h"
#include <curl/mprintf.h>
#include "curl_memory.h"
@@ -99,13 +99,13 @@ static const char lower_digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
/* Upper-case digits. */
static const char upper_digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-#define OUTCHAR(x) \
- do { \
+#define OUTCHAR(x) \
+ do { \
if(stream((unsigned char)(x), (FILE *)data) != -1) \
- done++; \
- else \
- return done; /* return immediately on failure */ \
- } while(0)
+ done++; \
+ else \
+ return done; /* return immediately on failure */ \
+ } while(0)
/* Data type to read from the arglist */
typedef enum {
@@ -146,7 +146,7 @@ enum {
FLAGS_FLOATG = 1<<19 /* %g or %G */
};
-struct va_stack {
+struct va_stack {
FormatType type;
int flags;
long width; /* width OR width parameter number */
@@ -160,7 +160,7 @@ struct va_stack {
} num;
double dnum;
} data;
-};
+};
struct nsprintf {
char *buffer;
@@ -169,23 +169,23 @@ struct nsprintf {
};
struct asprintf {
- struct dynbuf *b;
- bool fail; /* if an alloc has failed and thus the output is not the complete
- data */
+ struct dynbuf *b;
+ bool fail; /* if an alloc has failed and thus the output is not the complete
+ data */
};
static long dprintf_DollarString(char *input, char **end)
{
int number = 0;
while(ISDIGIT(*input)) {
- if(number < MAX_PARAMETERS) {
- number *= 10;
- number += *input - '0';
- }
+ if(number < MAX_PARAMETERS) {
+ number *= 10;
+ number += *input - '0';
+ }
input++;
}
- if(number <= MAX_PARAMETERS && ('$' == *input)) {
- *end = ++input;
+ if(number <= MAX_PARAMETERS && ('$' == *input)) {
+ *end = ++input;
return number;
}
return 0;
@@ -225,8 +225,8 @@ static bool dprintf_IsQualifierNoDollar(const char *fmt)
*
******************************************************************/
-static int dprintf_Pass1(const char *format, struct va_stack *vto,
- char **endpos, va_list arglist)
+static int dprintf_Pass1(const char *format, struct va_stack *vto,
+ char **endpos, va_list arglist)
{
char *fmt = (char *)format;
int param_num = 0;
@@ -379,8 +379,8 @@ static int dprintf_Pass1(const char *format, struct va_stack *vto,
if(width > max_param)
max_param = width;
break;
- case '\0':
- fmt--;
+ case '\0':
+ fmt--;
default:
break;
}
@@ -462,9 +462,9 @@ static int dprintf_Pass1(const char *format, struct va_stack *vto,
/* we have the width specified from a parameter, so we make that
parameter's info setup properly */
long k = width - 1;
- if((k < 0) || (k >= MAX_PARAMETERS))
- /* out of allowed range */
- return 1;
+ if((k < 0) || (k >= MAX_PARAMETERS))
+ /* out of allowed range */
+ return 1;
vto[i].width = k;
vto[k].type = FORMAT_WIDTH;
vto[k].flags = FLAGS_NEW;
@@ -476,9 +476,9 @@ static int dprintf_Pass1(const char *format, struct va_stack *vto,
/* we have the precision specified from a parameter, so we make that
parameter's info setup properly */
long k = precision - 1;
- if((k < 0) || (k >= MAX_PARAMETERS))
- /* out of allowed range */
- return 1;
+ if((k < 0) || (k >= MAX_PARAMETERS))
+ /* out of allowed range */
+ return 1;
vto[i].precision = k;
vto[k].type = FORMAT_WIDTH;
vto[k].flags = FLAGS_NEW;
@@ -486,7 +486,7 @@ static int dprintf_Pass1(const char *format, struct va_stack *vto,
vto[k].width = 0;
vto[k].precision = 0;
}
- *endpos++ = fmt + ((*fmt == '\0') ? 0 : 1); /* end of this sequence */
+ *endpos++ = fmt + ((*fmt == '\0') ? 0 : 1); /* end of this sequence */
}
}
@@ -580,11 +580,11 @@ static int dprintf_formatf(
long param; /* current parameter to read */
long param_num = 0; /* parameter counter */
- struct va_stack vto[MAX_PARAMETERS];
+ struct va_stack vto[MAX_PARAMETERS];
char *endpos[MAX_PARAMETERS];
char **end;
char work[BUFFSIZE];
- struct va_stack *p;
+ struct va_stack *p;
/* 'workend' points to the final buffer byte position, but with an extra
byte as margin to avoid the (false?) warning Coverity gives us
@@ -764,7 +764,7 @@ static int dprintf_formatf(
if(prec > 0) {
width -= prec;
- while(prec-- > 0 && w >= work)
+ while(prec-- > 0 && w >= work)
*w-- = '0';
}
@@ -878,7 +878,7 @@ static int dprintf_formatf(
OUTCHAR(' ');
for(point = strnil; *point != '\0'; ++point)
OUTCHAR(*point);
- if(!(p->flags & FLAGS_LEFT))
+ if(!(p->flags & FLAGS_LEFT))
while(width-- > 0)
OUTCHAR(' ');
}
@@ -928,8 +928,8 @@ static int dprintf_formatf(
precision */
size_t maxprec = sizeof(work) - 2;
double val = p->data.dnum;
- if(width > 0 && prec <= width)
- maxprec -= width;
+ if(width > 0 && prec <= width)
+ maxprec -= width;
while(val >= 10.0) {
val /= 10;
maxprec--;
@@ -937,8 +937,8 @@ static int dprintf_formatf(
if(prec > (long)maxprec)
prec = (long)maxprec-1;
- if(prec < 0)
- prec = 0;
+ if(prec < 0)
+ prec = 0;
/* RECURSIVE USAGE */
len = curl_msnprintf(fptr, left, ".%ld", prec);
fptr += len;
@@ -1042,61 +1042,61 @@ static int alloc_addbyter(int output, FILE *data)
struct asprintf *infop = (struct asprintf *)data;
unsigned char outc = (unsigned char)output;
- if(Curl_dyn_addn(infop->b, &outc, 1)) {
- infop->fail = 1;
- return -1; /* fail */
+ if(Curl_dyn_addn(infop->b, &outc, 1)) {
+ infop->fail = 1;
+ return -1; /* fail */
}
return outc; /* fputc() returns like this on success */
}
-extern int Curl_dyn_vprintf(struct dynbuf *dyn,
- const char *format, va_list ap_save);
-
-/* appends the formatted string, returns 0 on success, 1 on error */
-int Curl_dyn_vprintf(struct dynbuf *dyn, const char *format, va_list ap_save)
+extern int Curl_dyn_vprintf(struct dynbuf *dyn,
+ const char *format, va_list ap_save);
+
+/* appends the formatted string, returns 0 on success, 1 on error */
+int Curl_dyn_vprintf(struct dynbuf *dyn, const char *format, va_list ap_save)
{
int retcode;
struct asprintf info;
- info.b = dyn;
+ info.b = dyn;
info.fail = 0;
retcode = dprintf_formatf(&info, alloc_addbyter, format, ap_save);
if((-1 == retcode) || info.fail) {
- Curl_dyn_free(info.b);
- return 1;
+ Curl_dyn_free(info.b);
+ return 1;
}
- return 0;
+ return 0;
}
char *curl_mvaprintf(const char *format, va_list ap_save)
{
int retcode;
struct asprintf info;
- struct dynbuf dyn;
- info.b = &dyn;
- Curl_dyn_init(info.b, DYN_APRINTF);
+ struct dynbuf dyn;
+ info.b = &dyn;
+ Curl_dyn_init(info.b, DYN_APRINTF);
info.fail = 0;
retcode = dprintf_formatf(&info, alloc_addbyter, format, ap_save);
if((-1 == retcode) || info.fail) {
- Curl_dyn_free(info.b);
+ Curl_dyn_free(info.b);
return NULL;
}
- if(Curl_dyn_len(info.b))
- return Curl_dyn_ptr(info.b);
+ if(Curl_dyn_len(info.b))
+ return Curl_dyn_ptr(info.b);
return strdup("");
}
-char *curl_maprintf(const char *format, ...)
-{
- va_list ap_save;
- char *s;
- va_start(ap_save, format);
- s = curl_mvaprintf(format, ap_save);
- va_end(ap_save);
- return s;
-}
-
+char *curl_maprintf(const char *format, ...)
+{
+ va_list ap_save;
+ char *s;
+ va_start(ap_save, format);
+ s = curl_mvaprintf(format, ap_save);
+ va_end(ap_save);
+ return s;
+}
+
static int storebuffer(int output, FILE *data)
{
char **buffer = (char **)data;