Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
spdlog
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
spdlog
Commits
3826ac14
Commit
3826ac14
authored
Feb 23, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bumped bundled fmt version to 4.1.0
parent
d650fa24
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
3219 additions
and
3957 deletions
+3219
-3957
include/spdlog/fmt/bundled/format.cc
include/spdlog/fmt/bundled/format.cc
+12
-52
include/spdlog/fmt/bundled/format.h
include/spdlog/fmt/bundled/format.h
+2412
-2898
include/spdlog/fmt/bundled/ostream.h
include/spdlog/fmt/bundled/ostream.h
+51
-57
include/spdlog/fmt/bundled/posix.h
include/spdlog/fmt/bundled/posix.h
+218
-275
include/spdlog/fmt/bundled/printf.h
include/spdlog/fmt/bundled/printf.h
+423
-532
include/spdlog/fmt/bundled/time.h
include/spdlog/fmt/bundled/time.h
+103
-143
No files found.
include/spdlog/fmt/bundled/format.cc
View file @
3826ac14
...
...
@@ -72,9 +72,11 @@
// Dummy implementations of strerror_r and strerror_s called if corresponding
// system functions are not available.
FMT_MAYBE_UNUSED
static
inline
fmt
::
internal
::
Null
<>
strerror_r
(
int
,
char
*
,
...)
{
return
fmt
::
internal
::
Null
<>
();
}
FMT_MAYBE_UNUSED
static
inline
fmt
::
internal
::
Null
<>
strerror_s
(
char
*
,
std
::
size_t
,
...)
{
return
fmt
::
internal
::
Null
<>
();
}
...
...
@@ -121,7 +123,7 @@ typedef void (*FormatFunc)(Writer &, int, StringRef);
// Buffer should be at least of size 1.
int
safe_strerror
(
int
error_code
,
char
*&
buffer
,
std
::
size_t
buffer_size
)
FMT_NOEXCEPT
{
FMT_ASSERT
(
buffer
!=
0
&&
buffer_size
!=
0
,
"invalid buffer"
);
FMT_ASSERT
(
buffer
!=
FMT_NULL
&&
buffer_size
!=
0
,
"invalid buffer"
);
class
StrError
{
private:
...
...
@@ -159,6 +161,11 @@ int safe_strerror(
ERANGE
:
result
;
}
#ifdef __c2__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
// Fallback to strerror if strerror_r and strerror_s are not available.
int
fallback
(
internal
::
Null
<>
)
{
errno
=
0
;
...
...
@@ -166,13 +173,15 @@ int safe_strerror(
return
errno
;
}
#ifdef __c2__
# pragma clang diagnostic pop
#endif
public:
StrError
(
int
err_code
,
char
*&
buf
,
std
::
size_t
buf_size
)
:
error_code_
(
err_code
),
buffer_
(
buf
),
buffer_size_
(
buf_size
)
{}
int
run
()
{
// Suppress a warning about unused strerror_r.
strerror_r
(
0
,
FMT_NULL
,
""
);
return
handle
(
strerror_r
(
error_code_
,
buffer_
,
buffer_size_
));
}
};
...
...
@@ -396,51 +405,6 @@ FMT_FUNC void format_system_error(
fmt
::
format_error_code
(
out
,
error_code
,
message
);
// 'fmt::' is for bcc32.
}
template
<
typename
Char
>
void
internal
::
ArgMap
<
Char
>::
init
(
const
ArgList
&
args
)
{
if
(
!
map_
.
empty
())
return
;
typedef
internal
::
NamedArg
<
Char
>
NamedArg
;
const
NamedArg
*
named_arg
=
FMT_NULL
;
bool
use_values
=
args
.
type
(
ArgList
::
MAX_PACKED_ARGS
-
1
)
==
internal
::
Arg
::
NONE
;
if
(
use_values
)
{
for
(
unsigned
i
=
0
;
/*nothing*/
;
++
i
)
{
internal
::
Arg
::
Type
arg_type
=
args
.
type
(
i
);
switch
(
arg_type
)
{
case
internal
:
:
Arg
::
NONE
:
return
;
case
internal
:
:
Arg
::
NAMED_ARG
:
named_arg
=
static_cast
<
const
NamedArg
*>
(
args
.
values_
[
i
].
pointer
);
map_
.
push_back
(
Pair
(
named_arg
->
name
,
*
named_arg
));
break
;
default:
/*nothing*/
;
}
}
return
;
}
for
(
unsigned
i
=
0
;
i
!=
ArgList
::
MAX_PACKED_ARGS
;
++
i
)
{
internal
::
Arg
::
Type
arg_type
=
args
.
type
(
i
);
if
(
arg_type
==
internal
::
Arg
::
NAMED_ARG
)
{
named_arg
=
static_cast
<
const
NamedArg
*>
(
args
.
args_
[
i
].
pointer
);
map_
.
push_back
(
Pair
(
named_arg
->
name
,
*
named_arg
));
}
}
for
(
unsigned
i
=
ArgList
::
MAX_PACKED_ARGS
;
/*nothing*/
;
++
i
)
{
switch
(
args
.
args_
[
i
].
type
)
{
case
internal
:
:
Arg
::
NONE
:
return
;
case
internal
:
:
Arg
::
NAMED_ARG
:
named_arg
=
static_cast
<
const
NamedArg
*>
(
args
.
args_
[
i
].
pointer
);
map_
.
push_back
(
Pair
(
named_arg
->
name
,
*
named_arg
));
break
;
default:
/*nothing*/
;
}
}
}
template
<
typename
Char
>
void
internal
::
FixedBuffer
<
Char
>::
grow
(
std
::
size_t
)
{
FMT_THROW
(
std
::
runtime_error
(
"buffer overflow"
));
...
...
@@ -502,8 +466,6 @@ template struct internal::BasicData<void>;
template
void
internal
::
FixedBuffer
<
char
>
::
grow
(
std
::
size_t
);
template
void
internal
::
ArgMap
<
char
>
::
init
(
const
ArgList
&
args
);
template
FMT_API
int
internal
::
CharTraits
<
char
>
::
format_float
(
char
*
buffer
,
std
::
size_t
size
,
const
char
*
format
,
unsigned
width
,
int
precision
,
double
value
);
...
...
@@ -516,8 +478,6 @@ template FMT_API int internal::CharTraits<char>::format_float(
template
void
internal
::
FixedBuffer
<
wchar_t
>
::
grow
(
std
::
size_t
);
template
void
internal
::
ArgMap
<
wchar_t
>
::
init
(
const
ArgList
&
args
);
template
FMT_API
int
internal
::
CharTraits
<
wchar_t
>
::
format_float
(
wchar_t
*
buffer
,
std
::
size_t
size
,
const
wchar_t
*
format
,
unsigned
width
,
int
precision
,
double
value
);
...
...
include/spdlog/fmt/bundled/format.h
View file @
3826ac14
This diff is collapsed.
Click to expand it.
include/spdlog/fmt/bundled/ostream.h
View file @
3826ac14
...
...
@@ -13,65 +13,59 @@
#include "format.h"
#include <ostream>
namespace
fmt
{
namespace
fmt
{
namespace
internal
{
namespace
internal
{
template
<
class
Char
>
class
FormatBuf
:
public
std
::
basic_streambuf
<
Char
>
{
private:
typedef
typename
std
::
basic_streambuf
<
Char
>::
int_type
int_type
;
typedef
typename
std
::
basic_streambuf
<
Char
>::
traits_type
traits_type
;
Buffer
<
Char
>
&
buffer_
;
public:
FormatBuf
(
Buffer
<
Char
>
&
buffer
)
:
buffer_
(
buffer
)
{}
protected:
// The put-area is actually always empty. This makes the implementation
// simpler and has the advantage that the streambuf and the buffer are always
// in sync and sputc never writes into uninitialized memory. The obvious
// disadvantage is that each call to sputc always results in a (virtual) call
// to overflow. There is no disadvantage here for sputn since this always
// results in a call to xsputn.
int_type
overflow
(
int_type
ch
=
traits_type
::
eof
())
FMT_OVERRIDE
{
if
(
!
traits_type
::
eq_int_type
(
ch
,
traits_type
::
eof
()))
buffer_
.
push_back
(
static_cast
<
Char
>
(
ch
));
return
ch
;
}
std
::
streamsize
xsputn
(
const
Char
*
s
,
std
::
streamsize
count
)
FMT_OVERRIDE
{
buffer_
.
append
(
s
,
s
+
count
);
return
count
;
}
class
FormatBuf
:
public
std
::
basic_streambuf
<
Char
>
{
private:
typedef
typename
std
::
basic_streambuf
<
Char
>::
int_type
int_type
;
typedef
typename
std
::
basic_streambuf
<
Char
>::
traits_type
traits_type
;
Buffer
<
Char
>
&
buffer_
;
public:
FormatBuf
(
Buffer
<
Char
>
&
buffer
)
:
buffer_
(
buffer
)
{}
protected:
// The put-area is actually always empty. This makes the implementation
// simpler and has the advantage that the streambuf and the buffer are always
// in sync and sputc never writes into uninitialized memory. The obvious
// disadvantage is that each call to sputc always results in a (virtual) call
// to overflow. There is no disadvantage here for sputn since this always
// results in a call to xsputn.
int_type
overflow
(
int_type
ch
=
traits_type
::
eof
())
FMT_OVERRIDE
{
if
(
!
traits_type
::
eq_int_type
(
ch
,
traits_type
::
eof
()))
buffer_
.
push_back
(
static_cast
<
Char
>
(
ch
));
return
ch
;
}
std
::
streamsize
xsputn
(
const
Char
*
s
,
std
::
streamsize
count
)
FMT_OVERRIDE
{
buffer_
.
append
(
s
,
s
+
count
);
return
count
;
}
};
Yes
&
convert
(
std
::
ostream
&
);
struct
DummyStream
:
std
::
ostream
{
DummyStream
();
// Suppress a bogus warning in MSVC.
// Hide all operator<< overloads from std::ostream.
void
operator
<<
(
Null
<>
);
struct
DummyStream
:
std
::
ostream
{
DummyStream
();
// Suppress a bogus warning in MSVC.
// Hide all operator<< overloads from std::ostream.
template
<
typename
T
>
typename
EnableIf
<
sizeof
(
T
)
==
0
>::
type
operator
<<
(
const
T
&
);
};
No
&
operator
<<
(
std
::
ostream
&
,
int
);
template
<
typename
T
>
struct
ConvertToIntImpl
<
T
,
true
>
{
// Convert to int only if T doesn't have an overloaded operator<<.
enum
{
value
=
sizeof
(
convert
(
get
<
DummyStream
>
()
<<
get
<
T
>
()))
==
sizeof
(
No
)
};
template
<
typename
T
>
struct
ConvertToIntImpl
<
T
,
true
>
{
// Convert to int only if T doesn't have an overloaded operator<<.
enum
{
value
=
sizeof
(
convert
(
get
<
DummyStream
>
()
<<
get
<
T
>
()))
==
sizeof
(
No
)
};
};
// Write the content of w to os.
...
...
@@ -81,17 +75,17 @@ FMT_API void write(std::ostream &os, Writer &w);
// Formats a value.
template
<
typename
Char
,
typename
ArgFormatter_
,
typename
T
>
void
format_arg
(
BasicFormatter
<
Char
,
ArgFormatter_
>
&
f
,
const
Char
*&
format_str
,
const
T
&
value
)
{
internal
::
MemoryBuffer
<
Char
,
internal
::
INLINE_BUFFER_SIZE
>
buffer
;
const
Char
*&
format_str
,
const
T
&
value
)
{
internal
::
MemoryBuffer
<
Char
,
internal
::
INLINE_BUFFER_SIZE
>
buffer
;
internal
::
FormatBuf
<
Char
>
format_buf
(
buffer
);
std
::
basic_ostream
<
Char
>
output
(
&
format_buf
);
output
<<
value
;
internal
::
FormatBuf
<
Char
>
format_buf
(
buffer
);
std
::
basic_ostream
<
Char
>
output
(
&
format_buf
);
output
.
exceptions
(
std
::
ios_base
::
failbit
|
std
::
ios_base
::
badbit
);
output
<<
value
;
BasicStringRef
<
Char
>
str
(
&
buffer
[
0
],
buffer
.
size
());
typedef
internal
::
MakeArg
<
BasicFormatter
<
Char
>
>
MakeArg
;
format_str
=
f
.
format
(
format_str
,
MakeArg
(
str
));
BasicStringRef
<
Char
>
str
(
&
buffer
[
0
],
buffer
.
size
());
typedef
internal
::
MakeArg
<
BasicFormatter
<
Char
>
>
MakeArg
;
format_str
=
f
.
format
(
format_str
,
MakeArg
(
str
));
}
/**
...
...
include/spdlog/fmt/bundled/posix.h
View file @
3826ac14
This diff is collapsed.
Click to expand it.
include/spdlog/fmt/bundled/printf.h
View file @
3826ac14
This diff is collapsed.
Click to expand it.
include/spdlog/fmt/bundled/time.h
View file @
3826ac14
...
...
@@ -19,160 +19,120 @@
# pragma warning(disable: 4996) // "deprecated" functions
#endif
namespace
fmt
{
namespace
fmt
{
template
<
typename
ArgFormatter
>
void
format_arg
(
BasicFormatter
<
char
,
ArgFormatter
>
&
f
,
const
char
*&
format_str
,
const
std
::
tm
&
tm
)
{
if
(
*
format_str
==
':'
)
++
format_str
;
const
char
*
end
=
format_str
;
while
(
*
end
&&
*
end
!=
'}'
)
++
end
;
if
(
*
end
!=
'}'
)
FMT_THROW
(
FormatError
(
"missing '}' in format string"
));
internal
::
MemoryBuffer
<
char
,
internal
::
INLINE_BUFFER_SIZE
>
format
;
format
.
append
(
format_str
,
end
+
1
);
format
[
format
.
size
()
-
1
]
=
'\0'
;
Buffer
<
char
>
&
buffer
=
f
.
writer
().
buffer
();
std
::
size_t
start
=
buffer
.
size
();
for
(;;)
{
std
::
size_t
size
=
buffer
.
capacity
()
-
start
;
std
::
size_t
count
=
std
::
strftime
(
&
buffer
[
start
],
size
,
&
format
[
0
],
&
tm
);
if
(
count
!=
0
)
{
buffer
.
resize
(
start
+
count
);
break
;
}
if
(
size
>=
format
.
size
()
*
256
)
{
// If the buffer is 256 times larger than the format string, assume
// that `strftime` gives an empty result. There doesn't seem to be a
// better way to distinguish the two cases:
// https://github.com/fmtlib/fmt/issues/367
break
;
}
const
std
::
size_t
MIN_GROWTH
=
10
;
buffer
.
reserve
(
buffer
.
capacity
()
+
(
size
>
MIN_GROWTH
?
size
:
MIN_GROWTH
));
const
char
*&
format_str
,
const
std
::
tm
&
tm
)
{
if
(
*
format_str
==
':'
)
++
format_str
;
const
char
*
end
=
format_str
;
while
(
*
end
&&
*
end
!=
'}'
)
++
end
;
if
(
*
end
!=
'}'
)
FMT_THROW
(
FormatError
(
"missing '}' in format string"
));
internal
::
MemoryBuffer
<
char
,
internal
::
INLINE_BUFFER_SIZE
>
format
;
format
.
append
(
format_str
,
end
+
1
);
format
[
format
.
size
()
-
1
]
=
'\0'
;
Buffer
<
char
>
&
buffer
=
f
.
writer
().
buffer
();
std
::
size_t
start
=
buffer
.
size
();
for
(;;)
{
std
::
size_t
size
=
buffer
.
capacity
()
-
start
;
std
::
size_t
count
=
std
::
strftime
(
&
buffer
[
start
],
size
,
&
format
[
0
],
&
tm
);
if
(
count
!=
0
)
{
buffer
.
resize
(
start
+
count
);
break
;
}
format_str
=
end
+
1
;
if
(
size
>=
format
.
size
()
*
256
)
{
// If the buffer is 256 times larger than the format string, assume
// that `strftime` gives an empty result. There doesn't seem to be a
// better way to distinguish the two cases:
// https://github.com/fmtlib/fmt/issues/367
break
;
}
const
std
::
size_t
MIN_GROWTH
=
10
;
buffer
.
reserve
(
buffer
.
capacity
()
+
(
size
>
MIN_GROWTH
?
size
:
MIN_GROWTH
));
}
format_str
=
end
+
1
;
}
namespace
internal
{
inline
Null
<>
localtime_r
(...)
{
return
Null
<>
();
}
inline
Null
<>
localtime_s
(...)
{
return
Null
<>
();
}
inline
Null
<>
gmtime_r
(...)
{
return
Null
<>
();
}
inline
Null
<>
gmtime_s
(...)
{
return
Null
<>
();
}
namespace
internal
{
inline
Null
<>
localtime_r
(...)
{
return
Null
<>
();
}
inline
Null
<>
localtime_s
(...)
{
return
Null
<>
();
}
inline
Null
<>
gmtime_r
(...)
{
return
Null
<>
();
}
inline
Null
<>
gmtime_s
(...)
{
return
Null
<>
();
}
}
// Thread-safe replacement for std::localtime
inline
std
::
tm
localtime
(
std
::
time_t
time
)
{
struct
LocalTime
{
std
::
time_t
time_
;
std
::
tm
tm_
;
LocalTime
(
std
::
time_t
t
)
:
time_
(
t
)
{}
bool
run
()
{
using
namespace
fmt
::
internal
;
return
handle
(
localtime_r
(
&
time_
,
&
tm_
));
}
bool
handle
(
std
::
tm
*
tm
)
{
return
tm
!=
FMT_NULL
;
}
bool
handle
(
internal
::
Null
<>
)
{
using
namespace
fmt
::
internal
;
return
fallback
(
localtime_s
(
&
tm_
,
&
time_
));
}
bool
fallback
(
int
res
)
{
return
res
==
0
;
}
bool
fallback
(
internal
::
Null
<>
)
{
using
namespace
fmt
::
internal
;
std
::
tm
*
tm
=
std
::
localtime
(
&
time_
);
if
(
tm
)
tm_
=
*
tm
;
return
tm
!=
FMT_NULL
;
}
};
LocalTime
lt
(
time
);
if
(
lt
.
run
())
return
lt
.
tm_
;
// Too big time values may be unsupported.
FMT_THROW
(
fmt
::
FormatError
(
"time_t value out of range"
));
return
std
::
tm
();
inline
std
::
tm
localtime
(
std
::
time_t
time
)
{
struct
LocalTime
{
std
::
time_t
time_
;
std
::
tm
tm_
;
LocalTime
(
std
::
time_t
t
)
:
time_
(
t
)
{}
bool
run
()
{
using
namespace
fmt
::
internal
;
return
handle
(
localtime_r
(
&
time_
,
&
tm_
));
}
bool
handle
(
std
::
tm
*
tm
)
{
return
tm
!=
FMT_NULL
;
}
bool
handle
(
internal
::
Null
<>
)
{
using
namespace
fmt
::
internal
;
return
fallback
(
localtime_s
(
&
tm_
,
&
time_
));
}
bool
fallback
(
int
res
)
{
return
res
==
0
;
}
bool
fallback
(
internal
::
Null
<>
)
{
using
namespace
fmt
::
internal
;
std
::
tm
*
tm
=
std
::
localtime
(
&
time_
);
if
(
tm
)
tm_
=
*
tm
;
return
tm
!=
FMT_NULL
;
}
};
LocalTime
lt
(
time
);
if
(
lt
.
run
())
return
lt
.
tm_
;
// Too big time values may be unsupported.
FMT_THROW
(
fmt
::
FormatError
(
"time_t value out of range"
));
return
std
::
tm
();
}
// Thread-safe replacement for std::gmtime
inline
std
::
tm
gmtime
(
std
::
time_t
time
)
{
struct
GMTime
{
std
::
time_t
time_
;
std
::
tm
tm_
;
GMTime
(
std
::
time_t
t
)
:
time_
(
t
)
{}
bool
run
()
{
using
namespace
fmt
::
internal
;
return
handle
(
gmtime_r
(
&
time_
,
&
tm_
));
}
bool
handle
(
std
::
tm
*
tm
)
{
return
tm
!=
FMT_NULL
;
}
bool
handle
(
internal
::
Null
<>
)
{
using
namespace
fmt
::
internal
;
return
fallback
(
gmtime_s
(
&
tm_
,
&
time_
));
}
bool
fallback
(
int
res
)
{
return
res
==
0
;
}
bool
fallback
(
internal
::
Null
<>
)
{
std
::
tm
*
tm
=
std
::
gmtime
(
&
time_
);
if
(
tm
!=
FMT_NULL
)
tm_
=
*
tm
;
return
tm
!=
FMT_NULL
;
}
};
GMTime
gt
(
time
);
if
(
gt
.
run
())
return
gt
.
tm_
;
// Too big time values may be unsupported.
FMT_THROW
(
fmt
::
FormatError
(
"time_t value out of range"
));
return
std
::
tm
();
inline
std
::
tm
gmtime
(
std
::
time_t
time
)
{
struct
GMTime
{
std
::
time_t
time_
;
std
::
tm
tm_
;
GMTime
(
std
::
time_t
t
)
:
time_
(
t
)
{}
bool
run
()
{
using
namespace
fmt
::
internal
;
return
handle
(
gmtime_r
(
&
time_
,
&
tm_
));
}
bool
handle
(
std
::
tm
*
tm
)
{
return
tm
!=
FMT_NULL
;
}
bool
handle
(
internal
::
Null
<>
)
{
using
namespace
fmt
::
internal
;
return
fallback
(
gmtime_s
(
&
tm_
,
&
time_
));
}
bool
fallback
(
int
res
)
{
return
res
==
0
;
}
bool
fallback
(
internal
::
Null
<>
)
{
std
::
tm
*
tm
=
std
::
gmtime
(
&
time_
);
if
(
tm
!=
FMT_NULL
)
tm_
=
*
tm
;
return
tm
!=
FMT_NULL
;
}
};
GMTime
gt
(
time
);
if
(
gt
.
run
())
return
gt
.
tm_
;
// Too big time values may be unsupported.
FMT_THROW
(
fmt
::
FormatError
(
"time_t value out of range"
));
return
std
::
tm
();
}
}
//namespace fmt
...
...
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