• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

xlnt-community / xlnt / e9004608-a473-4d13-9376-0953a6c90a52

07 Apr 2026 06:59PM UTC coverage: 82.654% (-1.3%) from 83.961%
e9004608-a473-4d13-9376-0953a6c90a52

Pull #147

circleci

doomlaur
Merge branch 'master' into compound_document_improvements
Pull Request #147: Compound document improvements

15404 of 20563 branches covered (74.91%)

412 of 723 new or added lines in 7 files covered. (56.98%)

15 existing lines in 2 files now uncovered.

12599 of 15243 relevant lines covered (82.65%)

12050.02 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.0
./source/detail/utils/error_helpers.cpp
1
// Copyright (c) 2026 xlnt-community
2
//
3
// Permission is hereby granted, free of charge, to any person obtaining a copy
4
// of this software and associated documentation files (the "Software"), to deal
5
// in the Software without restriction, including without limitation the rights
6
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
// copies of the Software, and to permit persons to whom the Software is
8
// furnished to do so, subject to the following conditions:
9
//
10
// The above copyright notice and this permission notice shall be included in
11
// all copies or substantial portions of the Software.
12
//
13
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
// THE SOFTWARE
20
//
21
// @license: http://www.opensource.org/licenses/mit-license.php
22
// @author: see AUTHORS file
23

24
// For compilers implementing the optional Annex K of C11.
25
// MUST be defined before including <cstring>
26
// See https://en.cppreference.com/w/c/header/time.html
27
#if defined(__STDC_LIB_EXT1__) && !defined(__STDC_WANT_LIB_EXT1__)
28
#    define __STDC_WANT_LIB_EXT1__ 1
29
#endif
30

31

32
#include "error_helpers.hpp"
33

34
#include <cstring>
35

36
namespace xlnt {
37
namespace detail {
38

39
std::string strerror_safe(int err_no)
7✔
40
{
41
    constexpr std::size_t BUFF_SIZE = 8192;
7✔
42
    std::string err_msg;
7✔
43

44
#if defined(_MSC_VER) || (defined(__STDC_LIB_EXT1__) && defined(__STDC_WANT_LIB_EXT1__))
45
    char buffer[BUFF_SIZE] = "\0";
46
    errno_t err = strerror_s(buffer, BUFF_SIZE, err_no);
47
    if (err == 0)
48
    {
49
        err_msg = buffer;
50
    }
51

52
// Feature test macros from https://linux.die.net/man/3/strerror_r and https://linux.die.net/man/7/feature_test_macros
53
#elif (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE
54
    char buffer[BUFF_SIZE] = "\0";
55
    int err = strerror_r(err_no, buffer, BUFF_SIZE);
56
    if (err == 0)
57
    {
58
        err_msg = buffer;
59
    }
60

61
// Feature test macros from https://linux.die.net/man/3/strerror_r and https://linux.die.net/man/7/feature_test_macros
62
#elif _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _BSD_SOURCE || _SVID_SOURCE || _POSIX_SOURCE
63
    char buffer[BUFF_SIZE] = "\0";
7✔
64
    // The GNU-specific strerror_r() returns a pointer to a string containing the error message.
65
    // This may be either a pointer to a string that the function stores in buf,
66
    // or a pointer to some (immutable) static string (in which case buf is unused).
67
    const char *ret_buf = strerror_r(err_no, buffer, BUFF_SIZE);
7✔
68
    if (buffer[0] != '\0')
7!
69
    {
NEW
70
        err_msg = buffer;
×
71
    }
72
    else
73
    {
74
        err_msg = ret_buf;
7✔
75
    }
76
#else
77
    err_msg = std::strerror(err_no);
78
#endif
79

80
    return err_msg;
7✔
NEW
81
}
×
82

83
} // namespace detail
84
} // namespace xlnt
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc