summaryrefslogtreecommitdiff
path: root/include/o3tl/sprintf.hxx
blob: 373fff744c910344ebbc5a9ee04d4f1398e83adc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#pragma once

#include <sal/config.h>

#include <cassert>
#include <cstddef>
#include <cstdio>
#include <utility>

#include <o3tl/safeint.hxx>

namespace o3tl
{
// A drop-in replacement for safe uses of std::sprintf where it is statically known that the
// provided buffer is large enough.  Compared to a plain use of std::sprintf, using o3tl::sprintf
// for one makes it explicit that the call is considered safe and for another avoids deprecation
// warnings on platforms like the macOS 13 SDK that mark std::sprintf as deprecated.  Many simple
// uses of std::sprintf across the code base can be replaced with alternative code using e.g.
// OString::number.  This is for the remaining formatting-rich cases for which there is no easy
// replacement yet in our C++17 baseline.  Ultimately, it should be removed again once alternatives
// for those remaining cases, like C++20 std::format, are available.
template <std::size_t N, typename... T>
int sprintf(char (&s)[N], char const* format, T&&... arguments)
{
    auto const n = std::snprintf(s, N, format, std::forward<T>(arguments)...);
    assert(n < 0 || o3tl::make_unsigned(n) < N);
    (void)n;
    return n;
}
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
>Khaled Hosny 2023-09-26tdf#124591: Update Noto Serif Armenian to v2.008Khaled Hosny 2023-09-26tdf#124591: Update Noto Sans Armenian to v2.008Khaled Hosny 2023-09-26tdf#124591: Update Noto Serif Hebrew to v2.003Khaled Hosny 2023-09-26tdf#124591: Update Noto Sans Hebrew to v2.003Khaled Hosny 2023-09-26tdf#124591: Update Noto Sans Arabic to v2.010Khaled Hosny 2023-09-26tdf#124591: Update Noto Serif to v2.012Khaled Hosny 2023-09-26tdf#124591: Update Noto Sans to v2.012Khaled Hosny 2022-12-31tdf#136604: Remove Source Sans Pro fontsKhaled Hosny 2022-12-05tdf#152376: Remove Kacst Book and Kacst Office fontsKhaled Hosny 2022-12-05tdf#136604: Remove Source Serif Pro and Source Code Pro fontsKhaled Hosny 2022-12-04more_fonts: Update Amiri to version 1.000Khaled Hosny 2022-09-27tdf#144348: Remove EmojiOne Color fontKhaled Hosny 2022-08-02more_fonts: Update Reem KufiKhaled Hosny 2021-04-28Resolves tdf#141553 - Update David CLM fontHeiko Tietze 2019-03-27Do not include KACST fonts (GPLv2) into MPL subsetAndras Timar 2019-03-26Do not include Culmus fonts (GPLv2) into MPL subsetAndras Timar 2018-09-03tdf#79022 - Please bundle Source Serif Proheiko tietze 2018-04-26Update Reem Kufi font to version 0.7Khaled Hosny 2018-03-31tdf#115226 Update bundled Amiri to 0.111Andras Timar 2017-12-21tdf#113532 Add Arabic fonts into default installationYousuf Philips 2017-12-18tdf#103080 October 2017 update to Noto fontsYousuf Philips 2017-12-16tdf#113538 Add Hebrew fonts into default installationYousuf Philips 2017-12-16tdf#103080 Dont package Open Sans and PT_Serif fontsYousuf Philips 2017-11-10tdf#103080 Add Noto fonts into default installationYousuf Philips 2017-09-24Compensate for loss of Type 1 "Standard Symbols L" substitute for "Symbol"Stephan Bergmann 2017-06-02more_fonts: stop building that fontconfig file on WNTMichael Stahl 2016-11-30Remove Noto Emoji fontAkshay Deep 2016-11-29EMOJI CONTROL: Add EmojiOne font for Emoji SupportAkshay Deep 2016-09-11tdf#101949 update Source Code Pro fonts to 2.030 and 1.050Andras Timar 2016-09-10DejaVu fonts version 2.37Andras Timar 2016-07-19Add Noto Emoji font for emoji supportAkshay Deep 2014-07-10fdo#81095 update our copy of Source Sans ProAndras Timar 2013-10-28gbuild: set Package default target to INSTDIRMichael Stahl 2013-10-24bundle Carlito and CaladeaCaolán McNamara 2013-10-19fdo#70393: move more_fonts to a subdir of externalKhaled Hosny