Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split/fuse xlocinfo.h to fix unintentional export in format.cpp #1927

Merged
merged 3 commits into from
Jun 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set(HEADERS
${CMAKE_CURRENT_LIST_DIR}/inc/__msvc_all_public_headers.hpp
${CMAKE_CURRENT_LIST_DIR}/inc/__msvc_system_error_abi.hpp
${CMAKE_CURRENT_LIST_DIR}/inc/__msvc_tzdb.hpp
${CMAKE_CURRENT_LIST_DIR}/inc/__msvc_xlocinfo_types.hpp
${CMAKE_CURRENT_LIST_DIR}/inc/algorithm
${CMAKE_CURRENT_LIST_DIR}/inc/any
${CMAKE_CURRENT_LIST_DIR}/inc/array
Expand Down Expand Up @@ -220,7 +221,6 @@ set(HEADERS
${CMAKE_CURRENT_LIST_DIR}/inc/xlocale
${CMAKE_CURRENT_LIST_DIR}/inc/xlocbuf
${CMAKE_CURRENT_LIST_DIR}/inc/xlocinfo
${CMAKE_CURRENT_LIST_DIR}/inc/xlocinfo.h
${CMAKE_CURRENT_LIST_DIR}/inc/xlocmes
${CMAKE_CURRENT_LIST_DIR}/inc/xlocmon
${CMAKE_CURRENT_LIST_DIR}/inc/xlocnum
Expand Down
47 changes: 47 additions & 0 deletions stl/inc/__msvc_xlocinfo_types.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// __msvc_xlocinfo_types.hpp internal header (core)

// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#pragma once
#ifndef __MSVC_XLOCINFO_TYPES_HPP
#define __MSVC_XLOCINFO_TYPES_HPP
#include <yvals_core.h>
#if _STL_COMPILER_PREPROCESSOR

#pragma pack(push, _CRT_PACKING)
#pragma warning(push, _STL_WARNING_LEVEL)
#pragma warning(disable : _STL_DISABLED_WARNINGS)
_STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new

_EXTERN_C_UNLESS_PURE

struct _Collvec { // stuff needed by _Strcoll, etc.
unsigned int _Page; // UINT
wchar_t* _LocaleName;
};

struct _Ctypevec { // stuff needed by _Tolower, etc.
unsigned int _Page; // UINT
const short* _Table;
int _Delfl;
wchar_t* _LocaleName;
};

struct _Cvtvec { // stuff needed by _Mbrtowc, etc.
unsigned int _Page; // UINT
unsigned int _Mbcurmax;
int _Isclocale; // LCID == _CLOCALEHANDLE
unsigned char _Isleadbyte[32]; // 256 bits
};

_END_EXTERN_C_UNLESS_PURE

#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
#pragma pack(pop)
#endif // _STL_COMPILER_PREPROCESSOR
#endif // __MSVC_XLOCINFO_TYPES_HPP
2 changes: 1 addition & 1 deletion stl/inc/header-units.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// "__msvc_all_public_headers.hpp", // for testing, not production
"__msvc_system_error_abi.hpp",
"__msvc_tzdb.hpp",
"__msvc_xlocinfo_types.hpp",
"algorithm",
"any",
"array",
Expand Down Expand Up @@ -130,7 +131,6 @@
"xlocale",
"xlocbuf",
"xlocinfo",
"xlocinfo.h",
"xlocmes",
"xlocmon",
"xlocnum",
Expand Down
100 changes: 98 additions & 2 deletions stl/inc/xlocinfo
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
#pragma once
#ifndef _XLOCINFO_
#define _XLOCINFO_
#include <yvals_core.h>
#include <yvals.h>
#if _STL_COMPILER_PREPROCESSOR
#include <__msvc_xlocinfo_types.hpp>
#include <cctype>
#include <clocale>
#include <cstdio> // TRANSITION, VSO-661721
#include <cstdlib>
#include <xlocinfo.h>
#include <cwchar>
#include <xstddef>
#include <xstring>

Expand All @@ -20,6 +24,98 @@ _STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new

_EXTERN_C_UNLESS_PURE

// SUPPLEMENTAL LOCALE MACROS AND DECLARATIONS
#define _X_ALL LC_ALL
#define _X_COLLATE LC_COLLATE
#define _X_CTYPE LC_CTYPE
#define _X_MONETARY LC_MONETARY
#define _X_NUMERIC LC_NUMERIC
#define _X_TIME LC_TIME
#define _X_MAX LC_MAX
#define _X_MESSAGES 6
#define _NCAT (_X_MESSAGES + 1) // maximum + 1

#define _CATMASK(n) ((1 << (n)) >> 1)
#define _M_COLLATE _CATMASK(_X_COLLATE)
#define _M_CTYPE _CATMASK(_X_CTYPE)
#define _M_MONETARY _CATMASK(_X_MONETARY)
#define _M_NUMERIC _CATMASK(_X_NUMERIC)
#define _M_TIME _CATMASK(_X_TIME)
#define _M_MESSAGES _CATMASK(_X_MESSAGES)
#define _M_ALL (_CATMASK(_NCAT) - 1)

// FUNCTION DECLARATIONS
_CRTIMP2_PURE _Collvec __CLRCALL_PURE_OR_CDECL _Getcoll();
_CRTIMP2_PURE _Ctypevec __CLRCALL_PURE_OR_CDECL _Getctype();
_CRTIMP2_PURE _Cvtvec __CLRCALL_PURE_OR_CDECL _Getcvt();
_CRTIMP2_PURE int __CLRCALL_PURE_OR_CDECL _Getdateorder();

#ifdef _M_CEE_PURE
[System::Runtime::InteropServices::DllImport(_CRT_MSVCP_CURRENT, EntryPoint = "_Mbrtowc",
CallingConvention = System::Runtime::InteropServices::CallingConvention::Cdecl)] extern "C" int
_Mbrtowc(_Out_opt_ wchar_t*, const char*, size_t, mbstate_t*, const _Cvtvec*);

#else // _M_CEE_PURE
_MRTIMP2 _Success_(return >= 0) int __cdecl _Mbrtowc(
_When_(_Max_multibyte != 0, _Out_) wchar_t*, const char*, size_t _Max_multibyte, mbstate_t*, const _Cvtvec*);
#endif // _M_CEE_PURE

_CRTIMP2_PURE float __CLRCALL_PURE_OR_CDECL _Stof(const char*, _Out_opt_ _Deref_post_opt_valid_ char**, long);
_CRTIMP2_PURE double __CLRCALL_PURE_OR_CDECL _Stod(const char*, _Out_opt_ _Deref_post_opt_valid_ char**, long);
_CRTIMP2_PURE long double __CLRCALL_PURE_OR_CDECL _Stold(const char*, _Out_opt_ _Deref_post_opt_valid_ char**, long);

_CRTIMP2_PURE int __CLRCALL_PURE_OR_CDECL _Strcoll(const char*, const char*, const char*, const char*, const _Collvec*);
_CRTIMP2_PURE size_t __CLRCALL_PURE_OR_CDECL _Strxfrm(_Out_writes_(_End1 - _String1)
_Post_readable_size_(return ) char* _String1,
_In_z_ char* _End1, const char*, const char*, const _Collvec*);
_CRTIMP2_PURE int __CLRCALL_PURE_OR_CDECL _Tolower(int, const _Ctypevec*);
_CRTIMP2_PURE int __CLRCALL_PURE_OR_CDECL _Toupper(int, const _Ctypevec*);
_CRTIMP2_PURE _Success_(return != -1) int __CLRCALL_PURE_OR_CDECL
_Wcrtomb(_Out_ char*, wchar_t, mbstate_t*, const _Cvtvec*);
_CRTIMP2_PURE int __CLRCALL_PURE_OR_CDECL _Wcscoll(
const wchar_t*, const wchar_t*, const wchar_t*, const wchar_t*, const _Collvec*);
_CRTIMP2_PURE size_t __CLRCALL_PURE_OR_CDECL _Wcsxfrm(_Out_writes_(_End1 - _String1) _Post_readable_size_(return )
wchar_t* _String1,
_In_z_ wchar_t* _End1, const wchar_t*, const wchar_t*, const _Collvec*);

_CRTIMP2_PURE short __CLRCALL_PURE_OR_CDECL _Getwctype(wchar_t, const _Ctypevec*);
_CRTIMP2_PURE const wchar_t* __CLRCALL_PURE_OR_CDECL _Getwctypes(
const wchar_t*, const wchar_t*, short*, const _Ctypevec*);
_CRTIMP2_PURE wchar_t __CLRCALL_PURE_OR_CDECL _Towlower(wchar_t, const _Ctypevec*);
_CRTIMP2_PURE wchar_t __CLRCALL_PURE_OR_CDECL _Towupper(wchar_t, const _Ctypevec*);

_END_EXTERN_C_UNLESS_PURE

_EXTERN_C
_Success_(return != 0) _Ret_z_ _ACRTIMP char* __cdecl _Getdays();

_Success_(return != 0) _Ret_z_ _ACRTIMP char* __cdecl _Getmonths();

_ACRTIMP void* __cdecl _Gettnames();

_Success_(return > 0) _ACRTIMP size_t __cdecl _Strftime(
_Out_writes_z_(_Maxsize) char*, _In_ size_t _Maxsize, _In_z_ const char*, _In_ const tm*, _In_opt_ void*);

_Success_(return != 0) _Ret_z_ _ACRTIMP wchar_t* __cdecl _W_Getdays();

_Success_(return != 0) _Ret_z_ _ACRTIMP wchar_t* __cdecl _W_Getmonths();

_ACRTIMP void* __cdecl _W_Gettnames();

_Success_(return > 0) _ACRTIMP size_t __cdecl _Wcsftime(
_Out_writes_z_(_Maxsize) wchar_t*, _In_ size_t _Maxsize, _In_z_ const wchar_t*, _In_ const tm*, _In_opt_ void*);
_END_EXTERN_C

#ifdef _M_CEE_PURE
[System::Runtime::InteropServices::DllImport(_CRT_MSVCP_CURRENT, EntryPoint = "_GetLocaleForCP",
CallingConvention = System::Runtime::InteropServices::CallingConvention::Cdecl)] extern "C" _locale_t
_GetLocaleForCP(unsigned int);
#else // _M_CEE_PURE
_MRTIMP2 _locale_t __cdecl _GetLocaleForCP(unsigned int);
#endif // _M_CEE_PURE

_STD_BEGIN
// CLASS _Timevec
class _CRTIMP2_PURE_IMPORT _Timevec { // smart pointer to information used by _Strftime
Expand Down
140 changes: 0 additions & 140 deletions stl/inc/xlocinfo.h

This file was deleted.

2 changes: 1 addition & 1 deletion stl/src/_tolower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

#include <yvals.h>

#include <__msvc_xlocinfo_types.hpp>
#include <cctype>
#include <clocale>
#include <cstdlib>
#include <internal_shared.h>
#include <xlocinfo.h>

#include "awint.hpp"

Expand Down
2 changes: 1 addition & 1 deletion stl/src/_toupper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

#include <yvals.h>

#include <__msvc_xlocinfo_types.hpp>
#include <cctype>
#include <clocale>
#include <cstddef>
#include <xlocinfo.h>

#include "awint.hpp"

Expand Down
2 changes: 1 addition & 1 deletion stl/src/format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
// Do not include or define anything else here.
// In particular, basic_string must not be included here.

#include <__msvc_xlocinfo_types.hpp>
#include <xfilesystem_abi.h>
#include <xlocinfo.h>

#include <Windows.h>

Expand Down
2 changes: 1 addition & 1 deletion stl/src/xgetwctype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

#include <yvals.h>

#include <__msvc_xlocinfo_types.hpp>
#include <cwchar>
#include <xlocinfo.h>

#include "awint.hpp"

Expand Down
4 changes: 3 additions & 1 deletion stl/src/xmbtowc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@

// Convert multibyte char to wide char.

#include <yvals.h>

#include <__msvc_xlocinfo_types.hpp>
#include <cctype>
#include <cerrno>
#include <climits> // for INT_MAX
#include <crtdbg.h>
#include <internal_shared.h>
#include <xlocinfo.h> // for _Cvtvec, _Mbrtowc

_EXTERN_C_UNLESS_PURE

Expand Down
Loading