Coverage Report

Created: 2026-12-01 06:16

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libgit2/deps/xdiff/git-xdiff.h
Line
Count
Source
1
/*
2
 * Copyright (C) the libgit2 contributors. All rights reserved.
3
 *
4
 * This file is part of libgit2, distributed under the GNU GPL v2 with
5
 * a Linking Exception. For full terms see the included COPYING file.
6
 */
7
8
/*
9
 * This file provides the necessary indirection between xdiff and
10
 * libgit2.  libgit2-specific functionality should live here, so
11
 * that git and libgit2 can share a common xdiff implementation.
12
 */
13
14
#ifndef INCLUDE_git_xdiff_h__
15
#define INCLUDE_git_xdiff_h__
16
17
#include "cc-compat.h"
18
#include "regexp.h"
19
20
/* Work around C90-conformance issues */
21
#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
22
# if defined(_MSC_VER)
23
#  define inline __inline
24
# elif defined(__GNUC__)
25
#  define inline __inline__
26
# else
27
#  define inline
28
# endif
29
#endif
30
31
#define XDL_UNUSED GIT_UNUSED_ARG
32
33
0
#define xdl_malloc(x) git__malloc(x)
34
0
#define xdl_calloc(n, sz) git__calloc(n, sz)
35
0
#define xdl_free(ptr) git__free(ptr)
36
0
#define xdl_realloc(ptr, x) git__realloc(ptr, x)
37
38
#if (defined(_DEBUG) || defined(GIT_ASSERT_HARD)) && GIT_ASSERT_HARD != 0
39
# define XDL_BUG(...) assert(0)
40
#else
41
0
# define XDL_BUG(ret, ...) do { \
42
0
    git_error_set(GIT_ERROR_INVALID, __VA_ARGS__); \
43
0
    return ret; \
44
0
  } while(0)
45
#endif
46
47
static inline bool xdl_signed_add_overflows(long a, long b)
48
0
{
49
0
  return (((b) > 0 && (a) > (LONG_MAX - (b))) ||
50
0
          ((b) < 0 && (a) < (LONG_MAX - (b))));
51
0
}
Unexecuted instantiation: merge_file.c:xdl_signed_add_overflows
Unexecuted instantiation: xmerge.c:xdl_signed_add_overflows
Unexecuted instantiation: xprepare.c:xdl_signed_add_overflows
Unexecuted instantiation: xutils.c:xdl_signed_add_overflows
Unexecuted instantiation: checkout.c:xdl_signed_add_overflows
Unexecuted instantiation: patch_generate.c:xdl_signed_add_overflows
Unexecuted instantiation: xdiffi.c:xdl_signed_add_overflows
Unexecuted instantiation: xemit.c:xdl_signed_add_overflows
Unexecuted instantiation: xhistogram.c:xdl_signed_add_overflows
Unexecuted instantiation: xpatience.c:xdl_signed_add_overflows
Unexecuted instantiation: diff_xdiff.c:xdl_signed_add_overflows
52
53
0
#define xdl_st_add_overflow(a, b, out) git__add_sizet_overflow(out, a, b)
54
#define xdl_st_add3_overflow(a, b, c, out) \
55
0
  xdl_st_add_overflow((a), (b), (out)) || \
56
0
  xdl_st_add_overflow(*(out), (c), (out))
57
#define xdl_st_add4_overflow(a, b, c, d, out) \
58
0
  xdl_st_add3_overflow((a), (b), (c), (out)) || \
59
0
  xdl_st_add_overflow(*(out), (d), (out))
60
#define xdl_st_add5_overflow(a, b, c, d, e, out) \
61
0
  xdl_st_add4_overflow((a), (b), (c), (d), (out)) || \
62
0
  xdl_st_add_overflow(*(out), (e), (out))
63
64
65
#define xdl_regex_t git_regexp
66
0
#define xdl_regmatch_t git_regmatch
67
68
GIT_INLINE(int) xdl_regexec_buf(
69
  const xdl_regex_t *preg, const char *buf, size_t size,
70
  size_t nmatch, xdl_regmatch_t pmatch[], int eflags)
71
0
{
72
0
  GIT_UNUSED(preg);
73
0
  GIT_UNUSED(buf);
74
0
  GIT_UNUSED(size);
75
0
  GIT_UNUSED(nmatch);
76
0
  GIT_UNUSED(pmatch);
77
0
  GIT_UNUSED(eflags);
78
0
  GIT_ASSERT("not implemented");
79
0
  return -1;
80
0
}
Unexecuted instantiation: merge_file.c:xdl_regexec_buf
Unexecuted instantiation: xmerge.c:xdl_regexec_buf
Unexecuted instantiation: xprepare.c:xdl_regexec_buf
Unexecuted instantiation: xutils.c:xdl_regexec_buf
Unexecuted instantiation: checkout.c:xdl_regexec_buf
Unexecuted instantiation: patch_generate.c:xdl_regexec_buf
Unexecuted instantiation: xdiffi.c:xdl_regexec_buf
Unexecuted instantiation: xemit.c:xdl_regexec_buf
Unexecuted instantiation: xhistogram.c:xdl_regexec_buf
Unexecuted instantiation: xpatience.c:xdl_regexec_buf
Unexecuted instantiation: diff_xdiff.c:xdl_regexec_buf
81
82
#endif