[rtsan] Remove mkfifoat interceptor (#116997)
[llvm-project.git] / libcxx / include / __locale_dir / pad_and_output.h
bloba1cb37d0786dabaf8b033dbf8a51dbd761e32d1b
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef _LIBCPP___LOCALE_DIR_PAD_AND_OUTPUT_H
10 #define _LIBCPP___LOCALE_DIR_PAD_AND_OUTPUT_H
12 #include <__config>
14 #if _LIBCPP_HAS_LOCALIZATION
16 # include <ios>
18 # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19 # pragma GCC system_header
20 # endif
22 _LIBCPP_BEGIN_NAMESPACE_STD
24 template <class _CharT, class _OutputIterator>
25 _LIBCPP_HIDE_FROM_ABI _OutputIterator __pad_and_output(
26 _OutputIterator __s, const _CharT* __ob, const _CharT* __op, const _CharT* __oe, ios_base& __iob, _CharT __fl) {
27 streamsize __sz = __oe - __ob;
28 streamsize __ns = __iob.width();
29 if (__ns > __sz)
30 __ns -= __sz;
31 else
32 __ns = 0;
33 for (; __ob < __op; ++__ob, ++__s)
34 *__s = *__ob;
35 for (; __ns; --__ns, ++__s)
36 *__s = __fl;
37 for (; __ob < __oe; ++__ob, ++__s)
38 *__s = *__ob;
39 __iob.width(0);
40 return __s;
43 template <class _CharT, class _Traits>
44 _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator<_CharT, _Traits> __pad_and_output(
45 ostreambuf_iterator<_CharT, _Traits> __s,
46 const _CharT* __ob,
47 const _CharT* __op,
48 const _CharT* __oe,
49 ios_base& __iob,
50 _CharT __fl) {
51 if (__s.__sbuf_ == nullptr)
52 return __s;
53 streamsize __sz = __oe - __ob;
54 streamsize __ns = __iob.width();
55 if (__ns > __sz)
56 __ns -= __sz;
57 else
58 __ns = 0;
59 streamsize __np = __op - __ob;
60 if (__np > 0) {
61 if (__s.__sbuf_->sputn(__ob, __np) != __np) {
62 __s.__sbuf_ = nullptr;
63 return __s;
66 if (__ns > 0) {
67 basic_string<_CharT, _Traits> __sp(__ns, __fl);
68 if (__s.__sbuf_->sputn(__sp.data(), __ns) != __ns) {
69 __s.__sbuf_ = nullptr;
70 return __s;
73 __np = __oe - __op;
74 if (__np > 0) {
75 if (__s.__sbuf_->sputn(__op, __np) != __np) {
76 __s.__sbuf_ = nullptr;
77 return __s;
80 __iob.width(0);
81 return __s;
84 _LIBCPP_END_NAMESPACE_STD
86 #endif // _LIBCPP_HAS_LOCALIZATION
88 #endif // _LIBCPP___LOCALE_DIR_PAD_AND_OUTPUT_H