Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
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
Main
Synchronet
Commits
ff1a27c0
Commit
ff1a27c0
authored
9 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Remove MAX_ARG_LEN usage.
Rename entry_buf to int_buf since it only ever holds an integer now.
parent
a99197da
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/xpdev/xpprintf.c
+8
-24
8 additions, 24 deletions
src/xpdev/xpprintf.c
with
8 additions
and
24 deletions
src/xpdev/xpprintf.c
+
8
−
24
View file @
ff1a27c0
...
@@ -66,12 +66,6 @@ int asprintf(char **strptr, char *format, ...)
...
@@ -66,12 +66,6 @@ int asprintf(char **strptr, char *format, ...)
}
}
#endif
#endif
/* MSVC Sucks - can't tell the required len of a *printf() */
#define MAX_ARG_LEN 1024
/* MAX_ARG_LEN is the maximum length
* possible as a result of a format
* which is not %s
*/
/* Maximum length of a format specifier including the % */
/* Maximum length of a format specifier including the % */
#define MAX_FORMAT_LEN 256
#define MAX_FORMAT_LEN 256
...
@@ -329,7 +323,7 @@ char* DLLCALL xp_asprintf_next(char *format, int type, ...)
...
@@ -329,7 +323,7 @@ char* DLLCALL xp_asprintf_next(char *format, int type, ...)
unsigned
long
offset2
=
0
;
unsigned
long
offset2
=
0
;
size_t
format_len
;
size_t
format_len
;
size_t
this_format_len
;
size_t
this_format_len
;
char
e
nt
ry
_buf
[
MAX_
ARG
_LEN
];
char
i
nt_buf
[
MAX_
FORMAT
_LEN
];
char
*
entry
;
char
*
entry
;
char
this_format
[
MAX_FORMAT_LEN
];
char
this_format
[
MAX_FORMAT_LEN
];
char
*
fmt
;
char
*
fmt
;
...
@@ -388,7 +382,7 @@ char* DLLCALL xp_asprintf_next(char *format, int type, ...)
...
@@ -388,7 +382,7 @@ char* DLLCALL xp_asprintf_next(char *format, int type, ...)
*/
*/
if
(
*
p
==
'*'
)
{
/* The argument is this width */
if
(
*
p
==
'*'
)
{
/* The argument is this width */
va_start
(
vars
,
type
);
va_start
(
vars
,
type
);
i
=
sprintf
(
e
nt
ry
_buf
,
"%d"
,
va_arg
(
vars
,
int
));
i
=
sprintf
(
i
nt_buf
,
"%d"
,
va_arg
(
vars
,
int
));
va_end
(
vars
);
va_end
(
vars
);
if
(
i
>
1
)
{
if
(
i
>
1
)
{
/*
/*
...
@@ -406,11 +400,11 @@ char* DLLCALL xp_asprintf_next(char *format, int type, ...)
...
@@ -406,11 +400,11 @@ char* DLLCALL xp_asprintf_next(char *format, int type, ...)
* is so it can be overwritten
* is so it can be overwritten
*/
*/
memmove
(
p
+
i
,
p
+
1
,
format
-
p
+
format_len
);
memmove
(
p
+
i
,
p
+
1
,
format
-
p
+
format_len
);
memcpy
(
p
,
e
nt
ry
_buf
,
i
);
memcpy
(
p
,
i
nt_buf
,
i
);
*
(
size_t
*
)(
format
+
sizeof
(
size_t
))
+=
i
-
1
;
*
(
size_t
*
)(
format
+
sizeof
(
size_t
))
+=
i
-
1
;
}
}
else
else
*
p
=
e
nt
ry
_buf
[
0
];
*
p
=
i
nt_buf
[
0
];
p
=
format
+
offset
;
p
=
format
+
offset
;
*
(
size_t
*
)
format
=
p
-
format
;
*
(
size_t
*
)
format
=
p
-
format
;
return
(
format
);
return
(
format
);
...
@@ -429,7 +423,7 @@ char* DLLCALL xp_asprintf_next(char *format, int type, ...)
...
@@ -429,7 +423,7 @@ char* DLLCALL xp_asprintf_next(char *format, int type, ...)
*/
*/
if
(
*
p
==
'*'
)
{
if
(
*
p
==
'*'
)
{
va_start
(
vars
,
type
);
va_start
(
vars
,
type
);
i
=
sprintf
(
e
nt
ry
_buf
,
"%d"
,
va_arg
(
vars
,
int
));
i
=
sprintf
(
i
nt_buf
,
"%d"
,
va_arg
(
vars
,
int
));
va_end
(
vars
);
va_end
(
vars
);
if
(
i
>
1
)
{
if
(
i
>
1
)
{
/*
/*
...
@@ -447,11 +441,11 @@ char* DLLCALL xp_asprintf_next(char *format, int type, ...)
...
@@ -447,11 +441,11 @@ char* DLLCALL xp_asprintf_next(char *format, int type, ...)
* is so it can be overwritten
* is so it can be overwritten
*/
*/
memmove
(
p
+
i
,
p
+
1
,
format
-
p
+
format_len
);
memmove
(
p
+
i
,
p
+
1
,
format
-
p
+
format_len
);
memcpy
(
p
,
e
nt
ry
_buf
,
i
);
memcpy
(
p
,
i
nt_buf
,
i
);
*
(
size_t
*
)(
format
+
sizeof
(
size_t
))
+=
i
-
1
;
*
(
size_t
*
)(
format
+
sizeof
(
size_t
))
+=
i
-
1
;
}
}
else
else
*
p
=
e
nt
ry
_buf
[
0
];
*
p
=
i
nt_buf
[
0
];
p
=
format
+
offset
;
p
=
format
+
offset
;
*
(
size_t
*
)
format
=
p
-
format
;
*
(
size_t
*
)
format
=
p
-
format
;
return
(
format
);
return
(
format
);
...
@@ -1205,18 +1199,8 @@ char* DLLCALL xp_asprintf_next(char *format, int type, ...)
...
@@ -1205,18 +1199,8 @@ char* DLLCALL xp_asprintf_next(char *format, int type, ...)
case
XP_PRINTF_TYPE_CHARP
:
case
XP_PRINTF_TYPE_CHARP
:
if
(
cp
==
NULL
)
if
(
cp
==
NULL
)
j
=
asprintf
(
&
entry
,
this_format
,
"<null>"
);
j
=
asprintf
(
&
entry
,
this_format
,
"<null>"
);
else
{
else
/*s=strlen(cp);
if(s<width)
s=width;
if(s<precision)
s=precision;
if(s>=MAX_ARG_LEN)
entry=(char *)alloca(s+1);
if(entry==NULL)
return(NULL);*/
j
=
asprintf
(
&
entry
,
this_format
,
cp
);
j
=
asprintf
(
&
entry
,
this_format
,
cp
);
}
break
;
break
;
case
XP_PRINTF_TYPE_DOUBLE
:
case
XP_PRINTF_TYPE_DOUBLE
:
j
=
asprintf
(
&
entry
,
this_format
,
d
);
j
=
asprintf
(
&
entry
,
this_format
,
d
);
...
...
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