Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
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
fmt
Commits
afbcf1e8
Commit
afbcf1e8
authored
Feb 05, 2022
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove legacy C locale wrapper
parent
90325d09
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
0 additions
and
146 deletions
+0
-146
CMakeLists.txt
CMakeLists.txt
+0
-16
include/fmt/os.h
include/fmt/os.h
+0
-46
test/CMakeLists.txt
test/CMakeLists.txt
+0
-3
test/posix-mock-test.cc
test/posix-mock-test.cc
+0
-81
No files found.
CMakeLists.txt
View file @
afbcf1e8
...
...
@@ -209,18 +209,6 @@ if (FMT_MASTER_PROJECT AND CMAKE_GENERATOR MATCHES "Visual Studio")
${
CMAKE_MAKE_PROGRAM
}
-p:FrameworkPathOverride=
\"
${
netfxpath
}
\"
%*"
)
endif
()
set
(
strtod_l_headers stdlib.h
)
if
(
APPLE
)
set
(
strtod_l_headers
${
strtod_l_headers
}
xlocale.h
)
endif
()
include
(
CheckSymbolExists
)
if
(
WIN32
)
check_symbol_exists
(
_strtod_l
"
${
strtod_l_headers
}
"
HAVE_STRTOD_L
)
else
()
check_symbol_exists
(
strtod_l
"
${
strtod_l_headers
}
"
HAVE_STRTOD_L
)
endif
()
function
(
add_headers VAR
)
set
(
headers
${${
VAR
}}
)
foreach
(
header
${
ARGN
}
)
...
...
@@ -244,10 +232,6 @@ endif ()
add_library
(
fmt
${
FMT_SOURCES
}
${
FMT_HEADERS
}
README.rst ChangeLog.rst
)
add_library
(
fmt::fmt ALIAS fmt
)
if
(
HAVE_STRTOD_L
)
target_compile_definitions
(
fmt PUBLIC FMT_LOCALE
)
endif
()
if
(
FMT_WERROR
)
target_compile_options
(
fmt PRIVATE
${
WERROR_FLAG
}
)
endif
()
...
...
include/fmt/os.h
View file @
afbcf1e8
...
...
@@ -9,10 +9,8 @@
#define FMT_OS_H_
#include <cerrno>
#include <clocale> // locale_t
#include <cstddef>
#include <cstdio>
#include <cstdlib> // strtod_l
#include <system_error> // std::system_error
#if defined __APPLE__ || defined(__FreeBSD__)
...
...
@@ -477,50 +475,6 @@ inline ostream output_file(cstring_view path, T... params) {
}
#endif // FMT_USE_FCNTL
#ifdef FMT_LOCALE
// A "C" numeric locale.
class
locale
{
private:
# ifdef _WIN32
using
locale_t
=
_locale_t
;
static
void
freelocale
(
locale_t
loc
)
{
_free_locale
(
loc
);
}
static
double
strtod_l
(
const
char
*
nptr
,
char
**
endptr
,
_locale_t
loc
)
{
return
_strtod_l
(
nptr
,
endptr
,
loc
);
}
# endif
locale_t
locale_
;
public:
using
type
=
locale_t
;
locale
(
const
locale
&
)
=
delete
;
void
operator
=
(
const
locale
&
)
=
delete
;
locale
()
{
# ifndef _WIN32
locale_
=
FMT_SYSTEM
(
newlocale
(
LC_NUMERIC_MASK
,
"C"
,
nullptr
));
# else
locale_
=
_create_locale
(
LC_NUMERIC
,
"C"
);
# endif
if
(
!
locale_
)
FMT_THROW
(
system_error
(
errno
,
"cannot create locale"
));
}
~
locale
()
{
freelocale
(
locale_
);
}
type
get
()
const
{
return
locale_
;
}
// Converts string to floating-point number and advances str past the end
// of the parsed input.
FMT_DEPRECATED
double
strtod
(
const
char
*&
str
)
const
{
char
*
end
=
nullptr
;
double
result
=
strtod_l
(
str
,
&
end
,
locale_
);
str
=
end
;
return
result
;
}
};
using
Locale
FMT_DEPRECATED_ALIAS
=
locale
;
#endif // FMT_LOCALE
FMT_MODULE_EXPORT_END
FMT_END_NAMESPACE
...
...
test/CMakeLists.txt
View file @
afbcf1e8
...
...
@@ -128,9 +128,6 @@ if (NOT MSVC_STATIC_RUNTIME)
if
(
FMT_PEDANTIC
)
target_compile_options
(
posix-mock-test PRIVATE
${
PEDANTIC_COMPILE_FLAGS
}
)
endif
()
if
(
HAVE_STRTOD_L
)
target_compile_definitions
(
posix-mock-test PRIVATE FMT_LOCALE
)
endif
()
add_test
(
NAME posix-mock-test COMMAND posix-mock-test
)
add_fmt_test
(
os-test
)
endif
()
...
...
test/posix-mock-test.cc
View file @
afbcf1e8
...
...
@@ -457,84 +457,3 @@ TEST(scoped_mock, scope) {
}
EXPECT_EQ
(
nullptr
,
test_mock
::
instance
);
}
#ifdef FMT_LOCALE
using
locale_type
=
fmt
::
locale
::
type
;
struct
locale_mock
{
static
locale_mock
*
instance
;
MOCK_METHOD3
(
newlocale
,
locale_type
(
int
category_mask
,
const
char
*
locale
,
locale_type
base
));
MOCK_METHOD1
(
freelocale
,
void
(
locale_type
locale
));
}
*
locale_mock
::
instance
;
# ifdef _MSC_VER
# pragma warning(push)
# pragma warning(disable : 4273)
# ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Winconsistent-dllimport"
# endif
_locale_t
_create_locale
(
int
category
,
const
char
*
locale
)
{
return
locale_mock
::
instance
->
newlocale
(
category
,
locale
,
0
);
}
void
_free_locale
(
_locale_t
locale
)
{
locale_mock
::
instance
->
freelocale
(
locale
);
}
# ifdef __clang__
# pragma clang diagnostic pop
# endif
# pragma warning(pop)
# endif
# if defined(__THROW) && \
((FMT_GCC_VERSION > 0 && FMT_GCC_VERSION <= 408) || defined(__e2k__))
# define FMT_LOCALE_THROW __THROW
# else
# define FMT_LOCALE_THROW
# endif
# if defined(__APPLE__) || \
(defined(__FreeBSD__) && __FreeBSD_version < 1200002)
typedef
int
FreeLocaleResult
;
# else
typedef
void
FreeLocaleResult
;
# endif
FreeLocaleResult
freelocale
(
locale_type
locale
)
FMT_LOCALE_THROW
{
locale_mock
::
instance
->
freelocale
(
locale
);
return
FreeLocaleResult
();
}
# undef FMT_LOCALE_THROW
# ifndef _WIN32
locale_t
test
::
newlocale
(
int
category_mask
,
const
char
*
locale
,
locale_t
base
)
{
return
locale_mock
::
instance
->
newlocale
(
category_mask
,
locale
,
base
);
}
TEST
(
locale_test
,
locale_mock
)
{
scoped_mock
<
locale_mock
>
mock
;
auto
locale
=
reinterpret_cast
<
locale_type
>
(
11
);
EXPECT_CALL
(
mock
,
newlocale
(
222
,
StrEq
(
"foo"
),
locale
));
FMT_SYSTEM
(
newlocale
(
222
,
"foo"
,
locale
));
}
# endif
TEST
(
locale_test
,
locale
)
{
# ifndef LC_NUMERIC_MASK
enum
{
LC_NUMERIC_MASK
=
LC_NUMERIC
};
# endif
scoped_mock
<
locale_mock
>
mock
;
auto
impl
=
reinterpret_cast
<
locale_type
>
(
42
);
EXPECT_CALL
(
mock
,
newlocale
(
LC_NUMERIC_MASK
,
StrEq
(
"C"
),
nullptr
))
.
WillOnce
(
Return
(
impl
));
EXPECT_CALL
(
mock
,
freelocale
(
impl
));
fmt
::
locale
loc
;
EXPECT_EQ
(
impl
,
loc
.
get
());
}
#endif // FMT_LOCALE
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