Coverage Report

Created: 2026-06-09 06:49

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