Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Joshua
wendelin.core
Commits
b721b6fd
Commit
b721b6fd
authored
Oct 23, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
c0dd86b9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
10 deletions
+18
-10
wcfs/internal/wcfs_misc.cpp
wcfs/internal/wcfs_misc.cpp
+18
-10
No files found.
wcfs/internal/wcfs_misc.cpp
View file @
b721b6fd
...
...
@@ -72,24 +72,32 @@ error File::_errno(const char *op) {
// fmt::
namespace
fmt
{
string
sprintf
(
const
string
&
format
,
...
)
{
string
_vsprintf
(
const
string
&
format
,
va_list
argp
)
{
// based on https://stackoverflow.com/a/26221725/9456786
va_list
ap
;
va_start
(
ap
,
format
);
size_t
size
=
vsnprintf
(
NULL
,
0
,
format
.
c_str
(),
ap
);
va_end
(
ap
);
va_list
argp2
;
va_copy
(
argp2
,
argp
);
size_t
size
=
vsnprintf
(
NULL
,
0
,
format
.
c_str
(),
argp2
);
va_end
(
argp2
);
std
::
unique_ptr
<
char
[]
>
buf
(
new
char
[
size
]
);
va_start
(
ap
,
format
);
vsnprintf
(
buf
.
get
(),
size
,
format
.
c_str
(),
ap
);
va_end
(
ap
);
vsnprintf
(
buf
.
get
(),
size
,
format
.
c_str
(),
argp
);
return
string
(
buf
.
get
(),
buf
.
get
()
+
size
-
1
);
// without trailing '\0'
}
string
sprintf
(
const
string
&
format
,
...)
{
va_list
argp
;
va_start
(
argp
,
format
);
string
str
=
fmt
::
_vsprintf
(
format
,
argp
);
va_end
(
argp
);
return
str
;
}
error
errorf
(
const
string
&
format
,
...)
{
error
err
;
err
.
err
=
fmt
::
sprintf
(
format
,
...);
// XXX
va_list
argp
;
va_start
(
argp
,
format
);
err
.
err
=
fmt
::
sprintf
(
format
,
argp
);
va_end
(
argp
);
return
err
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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