| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/bash/src/builtins/alias.def |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | - | |||||||||||||
| 6 | - | |||||||||||||
| 7 | - | |||||||||||||
| 8 | - | |||||||||||||
| 9 | - | |||||||||||||
| 10 | - | |||||||||||||
| 11 | - | |||||||||||||
| 12 | - | |||||||||||||
| 13 | - | |||||||||||||
| 14 | - | |||||||||||||
| 15 | - | |||||||||||||
| 16 | static void print_alias (alias_t *, int); | - | ||||||||||||
| 17 | - | |||||||||||||
| 18 | - | |||||||||||||
| 19 | int | - | ||||||||||||
| 20 | alias_builtin (list) | - | ||||||||||||
| 21 | WORD_LIST *list; | - | ||||||||||||
| 22 | { | - | ||||||||||||
| 23 | int any_failed, offset, pflag, dflags; | - | ||||||||||||
| 24 | alias_t **alias_list, *t; | - | ||||||||||||
| 25 | char *name, *value; | - | ||||||||||||
| 26 | - | |||||||||||||
| 27 | dflags = posixly_correct
| 2-115 | ||||||||||||
| 28 | pflag = 0; | - | ||||||||||||
| 29 | reset_internal_getopt (); | - | ||||||||||||
| 30 | while ((
| 10-112 | ||||||||||||
| 31 | { | - | ||||||||||||
| 32 | switch (offset) | - | ||||||||||||
| 33 | { | - | ||||||||||||
| 34 | case executed 5 times by 1 test: 'p':case 'p':Executed by:
executed 5 times by 1 test: case 'p':Executed by:
| 5 | ||||||||||||
| 35 | pflag = 1; | - | ||||||||||||
| 36 | dflags |= 0x01; | - | ||||||||||||
| 37 | break; executed 5 times by 1 test: break;Executed by:
| 5 | ||||||||||||
| 38 | case never executed: -99:case -99:never executed: builtin_help (); returncase -99:never executed: (258);return (258);never executed: return (258); | 0 | ||||||||||||
| 39 | default executed 5 times by 1 test: :default:Executed by:
executed 5 times by 1 test: default:Executed by:
| 5 | ||||||||||||
| 40 | builtin_usage (); | - | ||||||||||||
| 41 | return executed 5 times by 1 test: (258);return (258);Executed by:
executed 5 times by 1 test: return (258);Executed by:
| 5 | ||||||||||||
| 42 | } | - | ||||||||||||
| 43 | } | - | ||||||||||||
| 44 | - | |||||||||||||
| 45 | list = loptend; | - | ||||||||||||
| 46 | - | |||||||||||||
| 47 | if (list == 0
| 0-102 | ||||||||||||
| 48 | { | - | ||||||||||||
| 49 | if (aliases == 0
| 3-7 | ||||||||||||
| 50 | return executed 3 times by 1 test: (0);return (0);Executed by:
executed 3 times by 1 test: return (0);Executed by:
| 3 | ||||||||||||
| 51 | - | |||||||||||||
| 52 | alias_list = all_aliases (); | - | ||||||||||||
| 53 | - | |||||||||||||
| 54 | if (alias_list == 0
| 2-5 | ||||||||||||
| 55 | return executed 2 times by 1 test: (0);return (0);Executed by:
executed 2 times by 1 test: return (0);Executed by:
| 2 | ||||||||||||
| 56 | - | |||||||||||||
| 57 | for (offset = 0; alias_list[offset]
| 5-8 | ||||||||||||
| 58 | print_alias (alias_list[offset], dflags); executed 8 times by 1 test: print_alias (alias_list[offset], dflags);Executed by:
| 8 | ||||||||||||
| 59 | - | |||||||||||||
| 60 | sh_xfree((alias_list), "./alias.def", 110); | - | ||||||||||||
| 61 | - | |||||||||||||
| 62 | if (list == 0
| 0-5 | ||||||||||||
| 63 | return executed 5 times by 1 test: (sh_chkwrite (0));return (sh_chkwrite (0));Executed by:
executed 5 times by 1 test: return (sh_chkwrite (0));Executed by:
| 5 | ||||||||||||
| 64 | } never executed: end of block | 0 | ||||||||||||
| 65 | - | |||||||||||||
| 66 | any_failed = 0; | - | ||||||||||||
| 67 | while (list
| 102 | ||||||||||||
| 68 | { | - | ||||||||||||
| 69 | name = list->word->word; | - | ||||||||||||
| 70 | - | |||||||||||||
| 71 | for (offset = 0; name[offset]
| 9-470 | ||||||||||||
| 72 | ; executed 377 times by 1 test: ;Executed by:
| 377 | ||||||||||||
| 73 | - | |||||||||||||
| 74 | if (offset
| 0-102 | ||||||||||||
| 75 | { | - | ||||||||||||
| 76 | name[offset] = '\0'; | - | ||||||||||||
| 77 | value = name + offset + 1; | - | ||||||||||||
| 78 | - | |||||||||||||
| 79 | if (legal_alias_name (name, 0) == 0
| 0-93 | ||||||||||||
| 80 | { | - | ||||||||||||
| 81 | builtin_error ( | - | ||||||||||||
| 82 | dcgettext (((void *)0), | - | ||||||||||||
| 83 | "`%s': invalid alias name" | - | ||||||||||||
| 84 | , 5) | - | ||||||||||||
| 85 | , name); | - | ||||||||||||
| 86 | any_failed++; | - | ||||||||||||
| 87 | } never executed: end of block | 0 | ||||||||||||
| 88 | else | - | ||||||||||||
| 89 | add_alias (name, value); executed 93 times by 1 test: add_alias (name, value);Executed by:
| 93 | ||||||||||||
| 90 | } | - | ||||||||||||
| 91 | else | - | ||||||||||||
| 92 | { | - | ||||||||||||
| 93 | t = find_alias (name); | - | ||||||||||||
| 94 | if (t
| 4-5 | ||||||||||||
| 95 | print_alias (t, dflags); executed 4 times by 1 test: print_alias (t, dflags);Executed by:
| 4 | ||||||||||||
| 96 | else | - | ||||||||||||
| 97 | { | - | ||||||||||||
| 98 | sh_notfound (name); | - | ||||||||||||
| 99 | any_failed++; | - | ||||||||||||
| 100 | } executed 5 times by 1 test: end of blockExecuted by:
| 5 | ||||||||||||
| 101 | } | - | ||||||||||||
| 102 | list = list->next; | - | ||||||||||||
| 103 | } executed 102 times by 1 test: end of blockExecuted by:
| 102 | ||||||||||||
| 104 | - | |||||||||||||
| 105 | return executed 102 times by 1 test: (any_failed ? 1 : 0);return (any_failed ? 1 : 0);Executed by:
executed 102 times by 1 test: return (any_failed ? 1 : 0);Executed by:
| 102 | ||||||||||||
| 106 | } | - | ||||||||||||
| 107 | - | |||||||||||||
| 108 | - | |||||||||||||
| 109 | - | |||||||||||||
| 110 | int | - | ||||||||||||
| 111 | unalias_builtin (list) | - | ||||||||||||
| 112 | register WORD_LIST *list; | - | ||||||||||||
| 113 | { | - | ||||||||||||
| 114 | register alias_t *alias; | - | ||||||||||||
| 115 | int opt, aflag; | - | ||||||||||||
| 116 | - | |||||||||||||
| 117 | aflag = 0; | - | ||||||||||||
| 118 | reset_internal_getopt (); | - | ||||||||||||
| 119 | while ((
| 23-36 | ||||||||||||
| 120 | { | - | ||||||||||||
| 121 | switch (opt) | - | ||||||||||||
| 122 | { | - | ||||||||||||
| 123 | case executed 18 times by 1 test: 'a':case 'a':Executed by:
executed 18 times by 1 test: case 'a':Executed by:
| 18 | ||||||||||||
| 124 | aflag = 1; | - | ||||||||||||
| 125 | break; executed 18 times by 1 test: break;Executed by:
| 18 | ||||||||||||
| 126 | case never executed: -99:case -99:never executed: builtin_help (); returncase -99:never executed: (258);return (258);never executed: return (258); | 0 | ||||||||||||
| 127 | default executed 5 times by 1 test: :default:Executed by:
executed 5 times by 1 test: default:Executed by:
| 5 | ||||||||||||
| 128 | builtin_usage (); | - | ||||||||||||
| 129 | return executed 5 times by 1 test: (258);return (258);Executed by:
executed 5 times by 1 test: return (258);Executed by:
| 5 | ||||||||||||
| 130 | } | - | ||||||||||||
| 131 | } | - | ||||||||||||
| 132 | - | |||||||||||||
| 133 | list = loptend; | - | ||||||||||||
| 134 | - | |||||||||||||
| 135 | if (aflag
| 18 | ||||||||||||
| 136 | { | - | ||||||||||||
| 137 | delete_all_aliases (); | - | ||||||||||||
| 138 | return executed 18 times by 1 test: (0);return (0);Executed by:
executed 18 times by 1 test: return (0);Executed by:
| 18 | ||||||||||||
| 139 | } | - | ||||||||||||
| 140 | - | |||||||||||||
| 141 | if (list == 0
| 0-18 | ||||||||||||
| 142 | { | - | ||||||||||||
| 143 | builtin_usage (); | - | ||||||||||||
| 144 | return never executed: (258);return (258);never executed: return (258); | 0 | ||||||||||||
| 145 | } | - | ||||||||||||
| 146 | - | |||||||||||||
| 147 | aflag = 0; | - | ||||||||||||
| 148 | while (list
| 18-29 | ||||||||||||
| 149 | { | - | ||||||||||||
| 150 | alias = find_alias (list->word->word); | - | ||||||||||||
| 151 | - | |||||||||||||
| 152 | if (alias
| 14-15 | ||||||||||||
| 153 | remove_alias (alias->name); executed 15 times by 1 test: remove_alias (alias->name);Executed by:
| 15 | ||||||||||||
| 154 | else | - | ||||||||||||
| 155 | { | - | ||||||||||||
| 156 | sh_notfound (list->word->word); | - | ||||||||||||
| 157 | aflag++; | - | ||||||||||||
| 158 | } executed 14 times by 1 test: end of blockExecuted by:
| 14 | ||||||||||||
| 159 | - | |||||||||||||
| 160 | list = list->next; | - | ||||||||||||
| 161 | } executed 29 times by 1 test: end of blockExecuted by:
| 29 | ||||||||||||
| 162 | - | |||||||||||||
| 163 | return executed 18 times by 1 test: (aflag ? 1 : 0);return (aflag ? 1 : 0);Executed by:
executed 18 times by 1 test: return (aflag ? 1 : 0);Executed by:
| 18 | ||||||||||||
| 164 | } | - | ||||||||||||
| 165 | - | |||||||||||||
| 166 | - | |||||||||||||
| 167 | static void | - | ||||||||||||
| 168 | print_alias (alias, flags) | - | ||||||||||||
| 169 | alias_t *alias; | - | ||||||||||||
| 170 | int flags; | - | ||||||||||||
| 171 | { | - | ||||||||||||
| 172 | char *value; | - | ||||||||||||
| 173 | - | |||||||||||||
| 174 | value = sh_single_quote (alias->value); | - | ||||||||||||
| 175 | if (flags & 0x01
| 0-12 | ||||||||||||
| 176 | printf ("alias %s", (alias->name && alias->name[0] == '-') ? "-- " : ""); executed 12 times by 1 test: printf ("alias %s", (alias->name && alias->name[0] == '-') ? "-- " : "");Executed by:
| 12 | ||||||||||||
| 177 | printf ("%s=%s\n", alias->name, value); | - | ||||||||||||
| 178 | sh_xfree((value), "./alias.def", 237); | - | ||||||||||||
| 179 | - | |||||||||||||
| 180 | fflush ( | - | ||||||||||||
| 181 | stdout | - | ||||||||||||
| 182 | ); | - | ||||||||||||
| 183 | } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||||||||
| Switch to Source code | Preprocessed file |