OpenCoverage

shmatch.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/bash/src/lib/sh/shmatch.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11extern int glob_ignore_case, match_ignore_case;-
12-
13int-
14sh_regmatch (string, pattern, flags)-
15 const char *string;-
16 const char *pattern;-
17 int flags;-
18{-
19 regex_t regex = { 0 };-
20 regmatch_t *matches;-
21 int rflags;-
22-
23 SHELL_VAR *rematch;-
24 ARRAY *amatch;-
25 int subexp_ind;-
26 char *subexp_str;-
27 int subexp_len;-
28-
29 int result;-
30-
31-
32 rematch = (SHELL_VAR *)-
33 ((void *)0)-
34 ;-
35-
36-
37 rflags = -
38 1-
39 ;-
40 if (glob_ignore_case
glob_ignore_caseDescription
TRUEnever evaluated
FALSEevaluated 89 times by 1 test
Evaluated by:
  • Self test
|| match_ignore_case
match_ignore_caseDescription
TRUEnever evaluated
FALSEevaluated 89 times by 1 test
Evaluated by:
  • Self test
)
0-89
41 rflags |=
never executed: rflags |= (1 << 1) ;
0
42 (1 << 1)
never executed: rflags |= (1 << 1) ;
0
43 ;
never executed: rflags |= (1 << 1) ;
0
44-
45-
46-
47-
48 if (regcomp (&regex, pattern, rflags)
regcomp (&rege...ttern, rflags)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 88 times by 1 test
Evaluated by:
  • Self test
)
1-88
49 return
executed 1 time by 1 test: return 2;
Executed by:
  • Self test
2;
executed 1 time by 1 test: return 2;
Executed by:
  • Self test
1
50-
51-
52 matches = (regmatch_t *)malloc (sizeof (regmatch_t) * (regex.re_nsub + 1));-
53-
54-
55-
56-
57-
58 if (regexec (&regex, string, matches ? regex.re_nsub + 1 : 0, matches, 0)
regexec (&rege...0, matches, 0)Description
TRUEevaluated 35 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 53 times by 1 test
Evaluated by:
  • Self test
)
35-53
59 result = 1;
executed 35 times by 1 test: result = 1;
Executed by:
  • Self test
35
60 else-
61 result = 0;
executed 53 times by 1 test: result = 0;
Executed by:
  • Self test
53
62-
63-
64 subexp_len = strlen (string) + 10;-
65 subexp_str = malloc (subexp_len + 1);-
66-
67-
68-
69-
70 unbind_variable_noref ("BASH_REMATCH");-
71 rematch = make_new_array_variable ("BASH_REMATCH");-
72 amatch = (ARRAY *)((rematch)->value);-
73-
74 if (matches
matchesDescription
TRUEevaluated 88 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& (
(flags & 0x001)Description
TRUEevaluated 88 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
flags & 0x001)
(flags & 0x001)Description
TRUEevaluated 88 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
&& result == 0
result == 0Description
TRUEevaluated 53 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 35 times by 1 test
Evaluated by:
  • Self test
&& subexp_str
subexp_strDescription
TRUEevaluated 53 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
)
0-88
75 {-
76 for (subexp_ind = 0; subexp_ind <= regex.re_nsub
subexp_ind <= regex.re_nsubDescription
TRUEevaluated 71 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 53 times by 1 test
Evaluated by:
  • Self test
; subexp_ind++)
53-71
77 {-
78 memset (subexp_str, 0, subexp_len);-
79 -
80 __builtin_strncpy (-
81 subexp_str-
82 , -
83 string + matches[subexp_ind].rm_so-
84 , -
85 matches[subexp_ind].rm_eo - matches[subexp_ind].rm_so-
86 )-
87 -
88 ;-
89 array_insert (amatch, subexp_ind, subexp_str);-
90 }
executed 71 times by 1 test: end of block
Executed by:
  • Self test
71
91 }
executed 53 times by 1 test: end of block
Executed by:
  • Self test
53
92-
93 ((rematch)->attributes |= (0x0000002));-
94-
95 sh_xfree((subexp_str), "shmatch.c", 112);-
96 sh_xfree((matches), "shmatch.c", 113);-
97-
98-
99 regfree (&regex);-
100-
101 return
executed 88 times by 1 test: return result;
Executed by:
  • Self test
result;
executed 88 times by 1 test: return result;
Executed by:
  • Self test
88
102}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2