Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/coreutils/src/lib/str-kmp.h |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | static | - | ||||||||||||
2 | _Bool | - | ||||||||||||
3 | - | |||||||||||||
4 | knuth_morris_pratt (const unsigned char *haystack, | - | ||||||||||||
5 | const unsigned char *needle, size_t needle_len, | - | ||||||||||||
6 | const unsigned char **resultp) | - | ||||||||||||
7 | { | - | ||||||||||||
8 | size_t m = needle_len; | - | ||||||||||||
9 | - | |||||||||||||
10 | - | |||||||||||||
11 | size_t *table = (size_t *) ((__builtin_constant_p (m) && __builtin_constant_p (sizeof (size_t)) ? ((size_t) ( | - | ||||||||||||
12 | (9223372036854775807L) | - | ||||||||||||
13 | < | - | ||||||||||||
14 | (18446744073709551615UL) | - | ||||||||||||
15 | ? | - | ||||||||||||
16 | (9223372036854775807L) | - | ||||||||||||
17 | : | - | ||||||||||||
18 | (18446744073709551615UL) | - | ||||||||||||
19 | - 1) / (sizeof (size_t)) < (m)) : ({ __xalloc_count_type __xalloc_count; __builtin_mul_overflow (m, sizeof (size_t), &__xalloc_count); })) ? | - | ||||||||||||
20 | ((void *)0) | - | ||||||||||||
21 | : (((m) * (sizeof (size_t))) < 4032 - (2 * sa_alignment_max - 1) ? (void *) (((uintptr_t) (char *) __builtin_alloca (((m) * (sizeof (size_t))) + 2 * sa_alignment_max - 1) + (2 * sa_alignment_max - 1)) & ~(uintptr_t)(2 * sa_alignment_max - 1)) : mmalloca ((m) * (sizeof (size_t))))); | - | ||||||||||||
22 | if (table ==
| 0 | ||||||||||||
23 | ((void *)0)
| 0 | ||||||||||||
24 | ) | - | ||||||||||||
25 | return never executed: return 0 ; never executed: return 0 ; | 0 | ||||||||||||
26 | 0 never executed: return 0 ; | 0 | ||||||||||||
27 | ; never executed: return 0 ; | 0 | ||||||||||||
28 | { | - | ||||||||||||
29 | size_t i, j; | - | ||||||||||||
30 | - | |||||||||||||
31 | - | |||||||||||||
32 | table[1] = 1; | - | ||||||||||||
33 | j = 0; | - | ||||||||||||
34 | - | |||||||||||||
35 | for (i = 2; i < m
| 0 | ||||||||||||
36 | { | - | ||||||||||||
37 | - | |||||||||||||
38 | - | |||||||||||||
39 | - | |||||||||||||
40 | - | |||||||||||||
41 | unsigned char b = needle[i - 1]; | - | ||||||||||||
42 | - | |||||||||||||
43 | for (;;) | - | ||||||||||||
44 | { | - | ||||||||||||
45 | - | |||||||||||||
46 | - | |||||||||||||
47 | - | |||||||||||||
48 | if (b == needle[j]
| 0 | ||||||||||||
49 | { | - | ||||||||||||
50 | - | |||||||||||||
51 | table[i] = i - ++j; | - | ||||||||||||
52 | break; never executed: break; | 0 | ||||||||||||
53 | } | - | ||||||||||||
54 | - | |||||||||||||
55 | - | |||||||||||||
56 | - | |||||||||||||
57 | if (j == 0
| 0 | ||||||||||||
58 | { | - | ||||||||||||
59 | - | |||||||||||||
60 | table[i] = i; | - | ||||||||||||
61 | break; never executed: break; | 0 | ||||||||||||
62 | } | - | ||||||||||||
63 | j = j - table[j]; | - | ||||||||||||
64 | } never executed: end of block | 0 | ||||||||||||
65 | - | |||||||||||||
66 | } never executed: end of block | 0 | ||||||||||||
67 | } | - | ||||||||||||
68 | - | |||||||||||||
69 | - | |||||||||||||
70 | { | - | ||||||||||||
71 | size_t j; | - | ||||||||||||
72 | const unsigned char *rhaystack; | - | ||||||||||||
73 | const unsigned char *phaystack; | - | ||||||||||||
74 | - | |||||||||||||
75 | *resultp = | - | ||||||||||||
76 | ((void *)0) | - | ||||||||||||
77 | ; | - | ||||||||||||
78 | j = 0; | - | ||||||||||||
79 | rhaystack = haystack; | - | ||||||||||||
80 | phaystack = haystack; | - | ||||||||||||
81 | - | |||||||||||||
82 | while (*
| 0 | ||||||||||||
83 | if (needle[j] == *phaystack
| 0 | ||||||||||||
84 | { | - | ||||||||||||
85 | j++; | - | ||||||||||||
86 | phaystack++; | - | ||||||||||||
87 | if (j == m
| 0 | ||||||||||||
88 | { | - | ||||||||||||
89 | - | |||||||||||||
90 | *resultp = rhaystack; | - | ||||||||||||
91 | break; never executed: break; | 0 | ||||||||||||
92 | } | - | ||||||||||||
93 | } never executed: end of block | 0 | ||||||||||||
94 | else if (j > 0
| 0 | ||||||||||||
95 | { | - | ||||||||||||
96 | - | |||||||||||||
97 | rhaystack += table[j]; | - | ||||||||||||
98 | j -= table[j]; | - | ||||||||||||
99 | } never executed: end of block | 0 | ||||||||||||
100 | else | - | ||||||||||||
101 | { | - | ||||||||||||
102 | - | |||||||||||||
103 | rhaystack++; | - | ||||||||||||
104 | phaystack++; | - | ||||||||||||
105 | } never executed: end of block | 0 | ||||||||||||
106 | } | - | ||||||||||||
107 | - | |||||||||||||
108 | freea (table); | - | ||||||||||||
109 | return never executed: return 1 ; never executed: return 1 ; | 0 | ||||||||||||
110 | 1 never executed: return 1 ; | 0 | ||||||||||||
111 | ; never executed: return 1 ; | 0 | ||||||||||||
112 | } | - | ||||||||||||
Switch to Source code | Preprocessed file |