Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
spdlog
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
spdlog
Commits
fced34e3
Commit
fced34e3
authored
Aug 19, 2017
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bumped fmt version to 4.0.0
parent
268222e4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
184 additions
and
125 deletions
+184
-125
format.cc
include/spdlog/fmt/bundled/format.cc
+0
-0
format.h
include/spdlog/fmt/bundled/format.h
+0
-0
ostream.cc
include/spdlog/fmt/bundled/ostream.cc
+3
-11
ostream.h
include/spdlog/fmt/bundled/ostream.h
+54
-75
posix.cc
include/spdlog/fmt/bundled/posix.cc
+4
-1
posix.h
include/spdlog/fmt/bundled/posix.h
+0
-0
time.h
include/spdlog/fmt/bundled/time.h
+123
-38
No files found.
include/spdlog/fmt/bundled/format.cc
View file @
fced34e3
This diff is collapsed.
Click to expand it.
include/spdlog/fmt/bundled/format.h
View file @
fced34e3
This diff is collapsed.
Click to expand it.
include/spdlog/fmt/bundled/ostream.cc
View file @
fced34e3
...
@@ -11,9 +11,8 @@
...
@@ -11,9 +11,8 @@
namespace
fmt
{
namespace
fmt
{
namespace
{
namespace
internal
{
// Write the content of w to os.
FMT_FUNC
void
write
(
std
::
ostream
&
os
,
Writer
&
w
)
{
void
write
(
std
::
ostream
&
os
,
Writer
&
w
)
{
const
char
*
data
=
w
.
data
();
const
char
*
data
=
w
.
data
();
typedef
internal
::
MakeUnsigned
<
std
::
streamsize
>::
Type
UnsignedStreamSize
;
typedef
internal
::
MakeUnsigned
<
std
::
streamsize
>::
Type
UnsignedStreamSize
;
UnsignedStreamSize
size
=
w
.
size
();
UnsignedStreamSize
size
=
w
.
size
();
...
@@ -31,13 +30,6 @@ void write(std::ostream &os, Writer &w) {
...
@@ -31,13 +30,6 @@ void write(std::ostream &os, Writer &w) {
FMT_FUNC
void
print
(
std
::
ostream
&
os
,
CStringRef
format_str
,
ArgList
args
)
{
FMT_FUNC
void
print
(
std
::
ostream
&
os
,
CStringRef
format_str
,
ArgList
args
)
{
MemoryWriter
w
;
MemoryWriter
w
;
w
.
write
(
format_str
,
args
);
w
.
write
(
format_str
,
args
);
write
(
os
,
w
);
internal
::
write
(
os
,
w
);
}
FMT_FUNC
int
fprintf
(
std
::
ostream
&
os
,
CStringRef
format
,
ArgList
args
)
{
MemoryWriter
w
;
printf
(
w
,
format
,
args
);
write
(
os
,
w
);
return
static_cast
<
int
>
(
w
.
size
());
}
}
}
// namespace fmt
}
// namespace fmt
include/spdlog/fmt/bundled/ostream.h
View file @
fced34e3
...
@@ -13,85 +13,76 @@
...
@@ -13,85 +13,76 @@
#include "format.h"
#include "format.h"
#include <ostream>
#include <ostream>
namespace
fmt
namespace
fmt
{
{
namespace
internal
namespace
internal
{
{
template
<
class
Char
>
template
<
class
Char
>
class
FormatBuf
:
public
std
::
basic_streambuf
<
Char
>
class
FormatBuf
:
public
std
::
basic_streambuf
<
Char
>
{
{
private
:
private
:
typedef
typename
std
::
basic_streambuf
<
Char
>::
int_type
int_type
;
typedef
typename
std
::
basic_streambuf
<
Char
>::
int_type
int_type
;
typedef
typename
std
::
basic_streambuf
<
Char
>::
traits_type
traits_type
;
typedef
typename
std
::
basic_streambuf
<
Char
>::
traits_type
traits_type
;
Buffer
<
Char
>
&
buffer_
;
Buffer
<
Char
>
&
buffer_
;
Char
*
start_
;
public
:
FormatBuf
(
Buffer
<
Char
>
&
buffer
)
:
buffer_
(
buffer
)
{}
public
:
FormatBuf
(
Buffer
<
Char
>
&
buffer
)
:
buffer_
(
buffer
),
start_
(
&
buffer
[
0
])
protected
:
{
// The put-area is actually always empty. This makes the implementation
this
->
setp
(
start_
,
start_
+
buffer_
.
capacity
());
// 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
int_type
overflow
(
int_type
ch
=
traits_type
::
eof
())
// to overflow. There is no disadvantage here for sputn since this always
{
// results in a call to xsputn.
if
(
!
traits_type
::
eq_int_type
(
ch
,
traits_type
::
eof
()))
{
int_type
overflow
(
int_type
ch
=
traits_type
::
eof
())
FMT_OVERRIDE
{
size_t
buf_size
=
size
();
if
(
!
traits_type
::
eq_int_type
(
ch
,
traits_type
::
eof
()))
buffer_
.
resize
(
buf_size
);
buffer_
.
push_back
(
static_cast
<
Char
>
(
ch
));
buffer_
.
reserve
(
buf_size
*
2
);
return
ch
;
}
start_
=
&
buffer_
[
0
];
start_
[
buf_size
]
=
traits_type
::
to_char_type
(
ch
);
std
::
streamsize
xsputn
(
const
Char
*
s
,
std
::
streamsize
count
)
FMT_OVERRIDE
{
this
->
setp
(
start_
+
buf_size
+
1
,
start_
+
buf_size
*
2
);
buffer_
.
append
(
s
,
s
+
count
);
}
return
count
;
return
ch
;
}
}
size_t
size
()
const
{
return
to_unsigned
(
this
->
pptr
()
-
start_
);
}
};
};
Yes
&
convert
(
std
::
ostream
&
);
Yes
&
convert
(
std
::
ostream
&
);
struct
DummyStream
:
std
::
ostream
struct
DummyStream
:
std
::
ostream
{
{
DummyStream
();
// Suppress a bogus warning in MSVC.
DummyStream
();
// Suppress a bogus warning in MSVC.
// Hide all operator<< overloads from std::ostream.
// Hide all operator<< overloads from std::ostream.
void
operator
<<
(
Null
<>
);
void
operator
<<
(
Null
<>
);
};
};
No
&
operator
<<
(
std
::
ostream
&
,
int
);
No
&
operator
<<
(
std
::
ostream
&
,
int
);
template
<
typename
T
>
template
<
typename
T
>
struct
ConvertToIntImpl
<
T
,
true
>
struct
ConvertToIntImpl
<
T
,
true
>
{
{
// Convert to int only if T doesn't have an overloaded operator<<.
// Convert to int only if T doesn't have an overloaded operator<<.
enum
{
enum
value
=
sizeof
(
convert
(
get
<
DummyStream
>
()
<<
get
<
T
>
()))
==
sizeof
(
No
)
{
};
value
=
sizeof
(
convert
(
get
<
DummyStream
>
()
<<
get
<
T
>
()))
==
sizeof
(
No
)
};
};
};
// Write the content of w to os.
FMT_API
void
write
(
std
::
ostream
&
os
,
Writer
&
w
);
}
// namespace internal
}
// namespace internal
// Formats a value.
// Formats a value.
template
<
typename
Char
,
typename
ArgFormatter
,
typename
T
>
template
<
typename
Char
,
typename
ArgFormatter_
,
typename
T
>
void
format
(
BasicFormatter
<
Char
,
ArgFormatter
>
&
f
,
void
format_arg
(
BasicFormatter
<
Char
,
ArgFormatter_
>
&
f
,
const
Char
*&
format_str
,
const
T
&
value
)
const
Char
*&
format_str
,
const
T
&
value
)
{
{
internal
::
MemoryBuffer
<
Char
,
internal
::
INLINE_BUFFER_SIZE
>
buffer
;
internal
::
MemoryBuffer
<
Char
,
internal
::
INLINE_BUFFER_SIZE
>
buffer
;
internal
::
FormatBuf
<
Char
>
format_buf
(
buffer
);
internal
::
FormatBuf
<
Char
>
format_buf
(
buffer
);
std
::
basic_ostream
<
Char
>
output
(
&
format_buf
);
std
::
basic_ostream
<
Char
>
output
(
&
format_buf
);
output
<<
value
;
output
<<
value
;
BasicStringRef
<
Char
>
str
(
&
buffer
[
0
],
buffer
.
size
());
BasicStringRef
<
Char
>
str
(
&
buffer
[
0
],
format_buf
.
size
());
typedef
internal
::
MakeArg
<
BasicFormatter
<
Char
>
>
MakeArg
;
typedef
internal
::
MakeArg
<
BasicFormatter
<
Char
>
>
MakeArg
;
format_str
=
f
.
format
(
format_str
,
MakeArg
(
str
));
format_str
=
f
.
format
(
format_str
,
MakeArg
(
str
));
}
}
/**
/**
...
@@ -105,18 +96,6 @@ void format(BasicFormatter<Char, ArgFormatter> &f,
...
@@ -105,18 +96,6 @@ void format(BasicFormatter<Char, ArgFormatter> &f,
*/
*/
FMT_API
void
print
(
std
::
ostream
&
os
,
CStringRef
format_str
,
ArgList
args
);
FMT_API
void
print
(
std
::
ostream
&
os
,
CStringRef
format_str
,
ArgList
args
);
FMT_VARIADIC
(
void
,
print
,
std
::
ostream
&
,
CStringRef
)
FMT_VARIADIC
(
void
,
print
,
std
::
ostream
&
,
CStringRef
)
/**
\rst
Prints formatted data to the stream *os*.
**Example**::
fprintf(cerr, "Don't %s!", "panic");
\endrst
*/
FMT_API
int
fprintf
(
std
::
ostream
&
os
,
CStringRef
format_str
,
ArgList
args
);
FMT_VARIADIC
(
int
,
fprintf
,
std
::
ostream
&
,
CStringRef
)
}
// namespace fmt
}
// namespace fmt
#ifdef FMT_HEADER_ONLY
#ifdef FMT_HEADER_ONLY
...
...
include/spdlog/fmt/bundled/posix.cc
View file @
fced34e3
...
@@ -21,6 +21,9 @@
...
@@ -21,6 +21,9 @@
#ifndef _WIN32
#ifndef _WIN32
# include <unistd.h>
# include <unistd.h>
#else
#else
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
# include <windows.h>
# include <windows.h>
# include <io.h>
# include <io.h>
...
@@ -79,7 +82,7 @@ void fmt::BufferedFile::close() {
...
@@ -79,7 +82,7 @@ void fmt::BufferedFile::close() {
if
(
!
file_
)
if
(
!
file_
)
return
;
return
;
int
result
=
FMT_SYSTEM
(
fclose
(
file_
));
int
result
=
FMT_SYSTEM
(
fclose
(
file_
));
file_
=
0
;
file_
=
FMT_NULL
;
if
(
result
!=
0
)
if
(
result
!=
0
)
FMT_THROW
(
SystemError
(
errno
,
"cannot close file"
));
FMT_THROW
(
SystemError
(
errno
,
"cannot close file"
));
}
}
...
...
include/spdlog/fmt/bundled/posix.h
View file @
fced34e3
This diff is collapsed.
Click to expand it.
include/spdlog/fmt/bundled/time.h
View file @
fced34e3
...
@@ -13,46 +13,131 @@
...
@@ -13,46 +13,131 @@
#include "format.h"
#include "format.h"
#include <ctime>
#include <ctime>
namespace
fmt
#ifdef _MSC_VER
{
# pragma warning(push)
# pragma warning(disable: 4702) // unreachable code
# pragma warning(disable: 4996) // "deprecated" functions
#endif
namespace
fmt
{
template
<
typename
ArgFormatter
>
template
<
typename
ArgFormatter
>
void
format
(
BasicFormatter
<
char
,
ArgFormatter
>
&
f
,
void
format_arg
(
BasicFormatter
<
char
,
ArgFormatter
>
&
f
,
const
char
*&
format_str
,
const
std
::
tm
&
tm
)
const
char
*&
format_str
,
const
std
::
tm
&
tm
)
{
{
if
(
*
format_str
==
':'
)
if
(
*
format_str
==
':'
)
++
format_str
;
++
format_str
;
const
char
*
end
=
format_str
;
const
char
*
end
=
format_str
;
while
(
*
end
&&
*
end
!=
'}'
)
while
(
*
end
&&
*
end
!=
'}'
)
++
end
;
++
end
;
if
(
*
end
!=
'}'
)
if
(
*
end
!=
'}'
)
FMT_THROW
(
FormatError
(
"missing '}' in format string"
));
FMT_THROW
(
FormatError
(
"missing '}' in format string"
));
internal
::
MemoryBuffer
<
char
,
internal
::
INLINE_BUFFER_SIZE
>
format
;
internal
::
MemoryBuffer
<
char
,
internal
::
INLINE_BUFFER_SIZE
>
format
;
format
.
append
(
format_str
,
end
+
1
);
format
.
append
(
format_str
,
end
+
1
);
format
[
format
.
size
()
-
1
]
=
'\0'
;
format
[
format
.
size
()
-
1
]
=
'\0'
;
Buffer
<
char
>
&
buffer
=
f
.
writer
().
buffer
();
Buffer
<
char
>
&
buffer
=
f
.
writer
().
buffer
();
std
::
size_t
start
=
buffer
.
size
();
std
::
size_t
start
=
buffer
.
size
();
for
(;;)
{
for
(;;)
std
::
size_t
size
=
buffer
.
capacity
()
-
start
;
{
std
::
size_t
count
=
std
::
strftime
(
&
buffer
[
start
],
size
,
&
format
[
0
],
&
tm
);
std
::
size_t
size
=
buffer
.
capacity
()
-
start
;
if
(
count
!=
0
)
{
std
::
size_t
count
=
std
::
strftime
(
&
buffer
[
start
],
size
,
&
format
[
0
],
&
tm
);
buffer
.
resize
(
start
+
count
);
if
(
count
!=
0
)
break
;
{
}
buffer
.
resize
(
start
+
count
);
if
(
size
>=
format
.
size
()
*
256
)
{
break
;
// 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
if
(
size
>=
format
.
size
()
*
256
)
// better way to distinguish the two cases:
{
// https://github.com/fmtlib/fmt/issues/367
// If the buffer is 256 times larger than the format string, assume
break
;
// that `strftime` gives an empty result. There doesn't seem to be a
}
// better way to distinguish the two cases:
const
std
::
size_t
MIN_GROWTH
=
10
;
// https://github.com/fmtlib/fmt/issues/367
buffer
.
reserve
(
buffer
.
capacity
()
+
(
size
>
MIN_GROWTH
?
size
:
MIN_GROWTH
));
break
;
}
}
format_str
=
end
+
1
;
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
<>
();
}
}
}
// 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
();
}
// 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
();
}
}
//namespace fmt
#ifdef _MSC_VER
# pragma warning(pop)
#endif
#endif // FMT_TIME_H_
#endif // FMT_TIME_H_
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