Skip to content
GitLab
About GitLab
GitLab: the DevOps platform
Explore GitLab
Install GitLab
How GitLab compares
Get started
GitLab docs
GitLab Learn
Pricing
Talk to an expert
/
Help
What's new
2
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Projects
Groups
Snippets
Sign up now
Login
Sign in / Register
Toggle navigation
Menu
Open sidebar
fetchmail
fetchmail
Commits
414a3809
Commit
414a3809
authored
Apr 18, 2010
by
Matthias Andree
Browse files
Factor out stdarg.h-based common code from report_build and _complete to _vbuild.
Note: varargs.h and non-*args.h stuff is untested.
parent
25446433
Changes
1
Hide whitespace changes
Inline
Side-by-side
report.c
View file @
414a3809
...
...
@@ -203,23 +203,11 @@ static void rep_ensuresize(void) {
}
}
void
#ifdef HAVE_STDARG_H
report_build
(
FILE
*
errfp
,
const
char
*
message
,
...)
#else
report_build
(
FILE
*
errfp
,
message
,
va_alist
)
const
char
*
message
;
va_dcl
#endif
static
void
report_vbuild
(
const
char
*
message
,
va_list
args
)
{
#ifdef VA_START
va_list
args
;
int
n
;
#endif
rep_ensuresize
();
#if defined(VA_START)
for
(
;
;
)
{
/*
...
...
@@ -227,10 +215,11 @@ report_build (FILE *errfp, message, va_alist)
* because vsnprintf() invokes va_arg macro and thus args is
* undefined after the call.
*/
VA_START
(
args
,
message
);
n
=
vsnprintf
(
partial_message
+
partial_message_size_used
,
partial_message_size
-
partial_message_size_used
,
message
,
args
);
va_end
(
args
);
/* output error, f. i. EILSEQ */
if
(
n
<
0
)
break
;
if
(
n
>=
0
&&
(
unsigned
)
n
<
partial_message_size
-
partial_message_size_used
)
...
...
@@ -242,6 +231,30 @@ report_build (FILE *errfp, message, va_alist)
partial_message_size
+=
2048
;
partial_message
=
(
char
*
)
REALLOC
(
partial_message
,
partial_message_size
);
}
}
#endif
void
#ifdef HAVE_STDARG_H
report_build
(
FILE
*
errfp
,
const
char
*
message
,
...)
#else
report_build
(
FILE
*
errfp
,
message
,
va_alist
)
const
char
*
message
;
va_dcl
#endif
{
#ifdef VA_START
va_list
args
;
#else
int
n
;
#endif
rep_ensuresize
();
#if defined(VA_START)
VA_START
(
args
,
message
);
report_vbuild
(
message
,
args
);
va_end
(
args
);
#else
for
(
;
;
)
{
...
...
@@ -249,6 +262,9 @@ report_build (FILE *errfp, message, va_alist)
partial_message_size
-
partial_message_size_used
,
message
,
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
);
/* output error, f. i. EILSEQ */
if
(
n
<
0
)
break
;
if
(
n
>=
0
&&
(
unsigned
)
n
<
partial_message_size
-
partial_message_size_used
)
{
...
...
@@ -294,48 +310,16 @@ report_complete (FILE *errfp, message, va_alist)
{
#ifdef VA_START
va_list
args
;
int
n
;
#endif
rep_ensuresize
();
#if defined(VA_START)
for
(
;
;
)
{
VA_START
(
args
,
message
);
n
=
vsnprintf
(
partial_message
+
partial_message_size_used
,
partial_message_size
-
partial_message_size_used
,
message
,
args
);
va_end
(
args
);
/* old glibc versions return -1 for truncation */
if
(
n
>=
0
&&
(
unsigned
)
n
<
partial_message_size
-
partial_message_size_used
)
{
partial_message_size_used
+=
n
;
break
;
}
partial_message_size
+=
2048
;
partial_message
=
(
char
*
)
REALLOC
(
partial_message
,
partial_message_size
);
}
VA_START
(
args
,
message
);
report_vbuild
(
message
,
args
);
va_end
(
args
);
#else
for
(
;
;
)
{
n
=
snprintf
(
partial_message
+
partial_message_size_used
,
partial_message_size
-
partial_message_size_used
,
message
,
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
);
if
(
n
>=
0
&&
(
unsigned
)
n
<
partial_message_size
-
partial_message_size_used
)
{
partial_message_size_used
+=
n
;
break
;
}
partial_message_size
+=
2048
;
partial_message
=
REALLOC
(
partial_message
,
partial_message_size
);
}
report_build
(
errfp
,
message
,
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
);
#endif
/* Finally... print it. */
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment