Coverage Report

Created: 2026-10-28 06:38

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Utilities/cmllpkgc/llpkgc_file.c
Line
Count
Source
1
/* Distributed under the OSI-approved BSD 3-Clause License.
2
   See accompanying file LICENSE.rst for details.  */
3
4
#include "llpkgc_file.h"
5
#include "llpkgc_whitespace__internal.h"
6
7
/* Callback dispatch and EOF recipes are generated from the grammar. Pending
8
 * punctuation is owned by the parser. Deferred whitespace is borrowed only
9
 * under the explicit PFCE_NEED_MORE retention contract. */
10
int llpkgc_file__on_ident(llpkgc_file_t*, const unsigned char*,
11
    const unsigned char*);
12
int llpkgc_file__on_value_literal(llpkgc_file_t*, const unsigned char*,
13
    const unsigned char*);
14
int llpkgc_file__on_value_literal_complete(llpkgc_file_t*, const unsigned char*,
15
    const unsigned char*);
16
17
int llpkgc_file__mark(llpkgc_file_t* s, const unsigned char* p,
18
300k
    const unsigned char* endp) {
19
300k
  s->mark = *p;
20
300k
  return 0;
21
300k
}
22
23
int llpkgc_file__emit_ident_mark(llpkgc_file_t* s, const unsigned char* p,
24
10.0k
    const unsigned char* endp) {
25
10.0k
  const unsigned char* mark = &s->mark;
26
10.0k
  return llpkgc_file__on_ident(s, mark, mark + 1);
27
10.0k
}
28
29
int llpkgc_file__emit_literal_mark(llpkgc_file_t* s, const unsigned char* p,
30
41.2k
    const unsigned char* endp) {
31
41.2k
  const unsigned char* mark = &s->mark;
32
41.2k
  return llpkgc_file__on_value_literal(s, mark, mark + 1);
33
41.2k
}
34
35
int llpkgc_file__clear_whitespace(llpkgc_file_t* s, const unsigned char* p,
36
561k
    const unsigned char* endp) {
37
561k
  s->whitespace_start = NULL;
38
561k
  s->whitespace_end = NULL;
39
561k
  return 0;
40
561k
}
41
42
int llpkgc_file__whitespace(llpkgc_file_t* s, const unsigned char* p,
43
216k
    const unsigned char* endp) {
44
216k
  if(s->whitespace_start == NULL)
45
212k
    s->whitespace_start = (void*) p;
46
216k
  s->whitespace_end = (void*) endp;
47
216k
  return 0;
48
216k
}
49
50
/* The private delivery grammar emits each physical range separately. */
51
int llpkgc_file__deferred_span(llpkgc_whitespace__internal_t* delivery,
52
210k
    const unsigned char* p, const unsigned char* endp) {
53
210k
  llpkgc_file_t* s = delivery->parent;
54
210k
  int err;
55
210k
  if(p == endp)
56
0
    return 0;
57
210k
  err = llpkgc_file__on_value_literal(s, p, endp);
58
210k
  if(err != 0)
59
0
    return err;
60
210k
  return llpkgc_file__on_value_literal_complete(s, p, endp);
61
210k
}
62
63
int llpkgc_file__flush_whitespace_all(llpkgc_file_t* s, const unsigned char* p,
64
209k
    const unsigned char* endp) {
65
209k
  llpkgc_whitespace__internal_t delivery;
66
209k
  int err;
67
209k
  if(s->whitespace_start == NULL)
68
133
    return 0;
69
209k
  llpkgc_whitespace__internal_init(&delivery);
70
209k
  delivery.parent = s;
71
209k
  err = llpkgc_whitespace__internal_execute(&delivery, s->whitespace_start,
72
209k
      s->whitespace_end);
73
209k
  if(err != 0 && s->reason == NULL)
74
0
    s->reason = delivery.reason;
75
209k
  llpkgc_file__clear_whitespace(s, p, endp);
76
209k
  return err;
77
209k
}
78
79
0
const char* llpkgc_file_get_retained_start(const llpkgc_file_t* s) {
80
0
  return s->whitespace_start;
81
0
}
82
83
0
size_t llpkgc_file_get_retained_length(const llpkgc_file_t* s) {
84
0
  if(s->whitespace_start == NULL)
85
0
    return 0;
86
0
  return (size_t) ((const char*) s->end - (const char*) s->whitespace_start);
87
0
}