Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TLMSP curl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CYBER - Cyber Security
TS 103 523 MSP
TLMSP
TLMSP curl
Commits
1d7ce367
Commit
1d7ce367
authored
20 years ago
by
Daniel Stenberg
Browse files
Options
Downloads
Patches
Plain Diff
return faster when we "hit a wall" while printfing
parent
34e8baab
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/mprintf.c
+22
-13
22 additions, 13 deletions
lib/mprintf.c
with
22 additions
and
13 deletions
lib/mprintf.c
+
22
−
13
View file @
1d7ce367
...
...
@@ -82,7 +82,13 @@ static const char lower_digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
/* Upper-case digits. */
static
const
char
upper_digits
[]
=
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
;
#define OUTCHAR(x) done+=(stream(x, (FILE *)data)==-1?0:1)
#define OUTCHAR(x) \
do{ \
if(stream((unsigned char)(x), (FILE *)data) != -1) \
done++; \
else \
return done;
/* return immediately on failure */
\
} while(0)
/* Data type to read from the arglist */
typedef
enum
{
...
...
@@ -582,12 +588,12 @@ static long dprintf_Pass1(char *format, va_stack_t *vto, char **endpos,
}
static
int
dprintf_formatf
(
void
*
data
,
/* untouched by format(), just sent to the
stream() function in the first
argument */
int
(
*
stream
)(
int
,
FILE
*
),
/* function pointer called for each
output character */
const
char
*
format
,
/* %-formatted string */
va_list
ap_save
)
/* list of parameters */
void
*
data
,
/* untouched by format(), just sent to the
stream() function in
the second
argument */
/* function pointer called for each
output character */
int
(
*
stream
)(
int
,
FILE
*
),
const
char
*
format
,
/* %-formatted string */
va_list
ap_save
)
/* list of parameters */
{
/* Base-36 digits for numbers. */
const
char
*
digits
=
lower_digits
;
...
...
@@ -983,13 +989,14 @@ static int dprintf_formatf(
static
int
addbyter
(
int
output
,
FILE
*
data
)
{
struct
nsprintf
*
infop
=
(
struct
nsprintf
*
)
data
;
unsigned
char
outc
=
(
unsigned
char
)
output
;
if
(
infop
->
length
<
infop
->
max
)
{
/* only do this if we haven't reached max length yet */
infop
->
buffer
[
0
]
=
(
char
)
output
;
/* store */
infop
->
buffer
[
0
]
=
outc
;
/* store */
infop
->
buffer
++
;
/* increase pointer */
infop
->
length
++
;
/* we are now one byte larger */
return
out
put
;
/* fputc() returns like this on success */
return
out
c
;
/* fputc() returns like this on success */
}
return
-
1
;
}
...
...
@@ -1030,6 +1037,7 @@ int curl_msnprintf(char *buffer, size_t maxlength, const char *format, ...)
static
int
alloc_addbyter
(
int
output
,
FILE
*
data
)
{
struct
asprintf
*
infop
=
(
struct
asprintf
*
)
data
;
unsigned
char
outc
=
(
unsigned
char
)
output
;
if
(
!
infop
->
buffer
)
{
infop
->
buffer
=
(
char
*
)
malloc
(
32
);
...
...
@@ -1053,11 +1061,11 @@ static int alloc_addbyter(int output, FILE *data)
infop
->
alloc
*=
2
;
}
infop
->
buffer
[
infop
->
len
]
=
(
char
)
output
;
infop
->
buffer
[
infop
->
len
]
=
outc
;
infop
->
len
++
;
return
out
put
;
/* fputc() returns like this on success */
return
out
c
;
/* fputc() returns like this on success */
}
char
*
curl_maprintf
(
const
char
*
format
,
...)
...
...
@@ -1115,9 +1123,10 @@ char *curl_mvaprintf(const char *format, va_list ap_save)
static
int
storebuffer
(
int
output
,
FILE
*
data
)
{
char
**
buffer
=
(
char
**
)
data
;
**
buffer
=
(
char
)
output
;
unsigned
char
outc
=
(
unsigned
char
)
output
;
**
buffer
=
outc
;
(
*
buffer
)
++
;
return
out
put
;
/* act like fputc() ! */
return
out
c
;
/* act like fputc() ! */
}
int
curl_msprintf
(
char
*
buffer
,
const
char
*
format
,
...)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment