| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/bash/src/lib/sh/shmatch.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||||||||
| 5 | - | |||||||||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||||||||
| 7 | - | |||||||||||||||||||||||||||||||
| 8 | - | |||||||||||||||||||||||||||||||
| 9 | - | |||||||||||||||||||||||||||||||
| 10 | - | |||||||||||||||||||||||||||||||
| 11 | extern int glob_ignore_case, match_ignore_case; | - | ||||||||||||||||||||||||||||||
| 12 | - | |||||||||||||||||||||||||||||||
| 13 | int | - | ||||||||||||||||||||||||||||||
| 14 | sh_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
| 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 (®ex, pattern, rflags)
| 1-88 | ||||||||||||||||||||||||||||||
| 49 | return executed 1 time by 1 test: 2;return 2;Executed by:
executed 1 time by 1 test: return 2;Executed by:
| 1 | ||||||||||||||||||||||||||||||
| 50 | - | |||||||||||||||||||||||||||||||
| 51 | - | |||||||||||||||||||||||||||||||
| 52 | matches = (regmatch_t *)malloc (sizeof (regmatch_t) * (regex.re_nsub + 1)); | - | ||||||||||||||||||||||||||||||
| 53 | - | |||||||||||||||||||||||||||||||
| 54 | - | |||||||||||||||||||||||||||||||
| 55 | - | |||||||||||||||||||||||||||||||
| 56 | - | |||||||||||||||||||||||||||||||
| 57 | - | |||||||||||||||||||||||||||||||
| 58 | if (regexec (®ex, string, matches ? regex.re_nsub + 1 : 0, matches, 0)
| 35-53 | ||||||||||||||||||||||||||||||
| 59 | result = 1; executed 35 times by 1 test: result = 1;Executed by:
| 35 | ||||||||||||||||||||||||||||||
| 60 | else | - | ||||||||||||||||||||||||||||||
| 61 | result = 0; executed 53 times by 1 test: result = 0;Executed by:
| 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
| 0-88 | ||||||||||||||||||||||||||||||
| 75 | { | - | ||||||||||||||||||||||||||||||
| 76 | for (subexp_ind = 0; subexp_ind <= regex.re_nsub
| 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 blockExecuted by:
| 71 | ||||||||||||||||||||||||||||||
| 91 | } executed 53 times by 1 test: end of blockExecuted by:
| 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 (®ex); | - | ||||||||||||||||||||||||||||||
| 100 | - | |||||||||||||||||||||||||||||||
| 101 | return executed 88 times by 1 test: result;return result;Executed by:
executed 88 times by 1 test: return result;Executed by:
| 88 | ||||||||||||||||||||||||||||||
| 102 | } | - | ||||||||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |