Coverage Report

Created: 2026-07-16 07:09

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/pigeonhole/src/lib-sieve/tst-not.c
Line
Count
Source
1
/* Copyright (c) Pigeonhole authors, see top-level COPYING file */
2
3
#include "sieve-common.h"
4
#include "sieve-commands.h"
5
#include "sieve-validator.h"
6
#include "sieve-generator.h"
7
8
/*
9
 * Not test
10
 *
11
 * Syntax:
12
 *   not <tests: test-list>
13
 */
14
15
static bool
16
tst_not_generate(const struct sieve_codegen_env *cgenv,
17
     struct sieve_command *ctx, struct sieve_jumplist *jumps,
18
     bool jump_true);
19
static bool
20
tst_not_validate_const(struct sieve_validator *valdtr,
21
           struct sieve_command *tst, int *const_current,
22
           int const_next);
23
24
const struct sieve_command_def tst_not = {
25
  .identifier = "not",
26
  .type = SCT_TEST,
27
  .positional_args = 0,
28
  .subtests = 1,
29
  .block_allowed = FALSE,
30
  .block_required = FALSE,
31
  .validate_const = tst_not_validate_const,
32
  .control_generate = tst_not_generate
33
};
34
35
/*
36
 * Code validation
37
 */
38
39
static bool
40
tst_not_validate_const(struct sieve_validator *valdtr ATTR_UNUSED,
41
           struct sieve_command *tst ATTR_UNUSED,
42
           int *const_current, int const_next)
43
0
{
44
0
  if (const_next < 0)
45
0
    *const_current = -1;
46
0
  else if (const_next > 0)
47
0
    *const_current = 0;
48
0
  else
49
0
    *const_current = 1;
50
0
  return TRUE;
51
0
}
52
53
/*
54
 * Code generation
55
 */
56
57
static bool
58
tst_not_generate(const struct sieve_codegen_env *cgenv,
59
     struct sieve_command *ctx, struct sieve_jumplist *jumps,
60
     bool jump_true)
61
0
{
62
0
  struct sieve_ast_node *test;
63
64
  /* Validator verified the existance of the single test already */
65
0
  test = sieve_ast_test_first(ctx->ast_node);
66
67
0
  return sieve_generate_test(cgenv, test, jumps, !jump_true);
68
0
}