| Line | Source | Count |
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | | - |
| 8 | | - |
| 9 | | - |
| 10 | | - |
| 11 | | - |
| 12 | | - |
| 13 | | - |
| 14 | | - |
| 15 | | - |
| 16 | | - |
| 17 | | - |
| 18 | | - |
| 19 | | - |
| 20 | | - |
| 21 | | - |
| 22 | | - |
| 23 | #include "config.h" | - |
| 24 | | - |
| 25 | #if defined (BRACE_EXPANSION) | - |
| 26 | | - |
| 27 | #if defined (HAVE_UNISTD_H) | - |
| 28 | # ifdef _MINIX | - |
| 29 | # include <sys/types.h> | - |
| 30 | # endif | - |
| 31 | # include <unistd.h> | - |
| 32 | #endif | - |
| 33 | | - |
| 34 | #include <errno.h> | - |
| 35 | | - |
| 36 | #include "bashansi.h" | - |
| 37 | #include "bashintl.h" | - |
| 38 | | - |
| 39 | #if defined (SHELL) | - |
| 40 | # include "shell.h" | - |
| 41 | #else | - |
| 42 | # if defined (TEST) | - |
| 43 | typedef char *WORD_DESC; | - |
| 44 | typedef char **WORD_LIST; | - |
| 45 | #define _(X) X | - |
| 46 | # endif /* TEST */ | - |
| 47 | #endif /* SHELL */ | - |
| 48 | | - |
| 49 | #include "typemax.h" /* INTMAX_MIN, INTMAX_MAX */ | - |
| 50 | #include "general.h" | - |
| 51 | #include "shmbutil.h" | - |
| 52 | #include "chartypes.h" | - |
| 53 | | - |
| 54 | #ifndef errno | - |
| 55 | extern int errno; | - |
| 56 | #endif | - |
| 57 | | - |
| 58 | #define brace_whitespace(c) (!(c) || (c) == ' ' || (c) == '\t' || (c) == '\n') | - |
| 59 | | - |
| 60 | #define BRACE_SEQ_SPECIFIER ".." | - |
| 61 | | - |
| 62 | extern int asprintf __P((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3))); | - |
| 63 | | - |
| 64 | #if defined (NOTDEF) | - |
| 65 | extern int last_command_exit_value; | - |
| 66 | #endif | - |
| 67 | | - |
| 68 | | - |
| 69 | | - |
| 70 | | - |
| 71 | | - |
| 72 | | - |
| 73 | | - |
| 74 | | - |
| 75 | | - |
| 76 | | - |
| 77 | | - |
| 78 | static const int brace_arg_separator = ','; | - |
| 79 | | - |
| 80 | #if defined (__P) | - |
| 81 | static int brace_gobbler __P((char *, size_t, int *, int)); | - |
| 82 | static char **expand_amble __P((char *, size_t, int)); | - |
| 83 | static char **expand_seqterm __P((char *, size_t)); | - |
| 84 | static char **mkseq __P((intmax_t, intmax_t, intmax_t, int, int)); | - |
| 85 | static char **array_concat __P((char **, char **)); | - |
| 86 | #else | - |
| 87 | static int brace_gobbler (); | - |
| 88 | static char **expand_amble (); | - |
| 89 | static char **expand_seqterm (); | - |
| 90 | static char **mkseq(); | - |
| 91 | static char **array_concat (); | - |
| 92 | #endif | - |
| 93 | | - |
| 94 | #if 0 | - |
| 95 | static void | - |
| 96 | dump_result (a) | - |
| 97 | char **a; | - |
| 98 | { | - |
| 99 | int i; | - |
| 100 | | - |
| 101 | for (i = 0; a[i]; i++) | - |
| 102 | printf ("dump_result: a[%d] = -%s-\n", i, a[i]); | - |
| 103 | } | - |
| 104 | #endif | - |
| 105 | | - |
| 106 | | - |
| 107 | char ** | - |
| 108 | brace_expand (text) | - |
| 109 | char *text; | - |
| 110 | { | - |
| 111 | register int start; | - |
| 112 | size_t tlen; | - |
| 113 | char *preamble, *postamble, *amble; | - |
| 114 | size_t alen; | - |
| 115 | char **tack, **result; | - |
| 116 | int i, j, c, c1; | - |
| 117 | | - |
| 118 | DECLARE_MBSTATE; | - |
| 119 | | - |
| 120 | | - |
| 121 | tlen = strlen (text); | - |
| 122 | i = 0; | - |
| 123 | #if defined (CSH_BRACE_COMPAT) | - |
| 124 | c = brace_gobbler (text, tlen, &i, '{'); | - |
| 125 | #else | - |
| 126 | | - |
| 127 | | - |
| 128 | do | - |
| 129 | { | - |
| 130 | c = brace_gobbler (text, tlen, &i, '{'); | - |
| 131 | c1 = c; | - |
| 132 | | - |
| 133 | | - |
| 134 | if (c)| TRUE | evaluated 151 times by 1 test | | FALSE | evaluated 39197 times by 1 test |
| 151-39197 |
| 135 | { | - |
| 136 | start = j = i + 1; | - |
| 137 | c = brace_gobbler (text, tlen, &j, '}'); | - |
| 138 | if (c == 0) | TRUE | evaluated 33 times by 1 test | | FALSE | evaluated 118 times by 1 test |
| 33-118 |
| 139 | { | - |
| 140 | i++; | - |
| 141 | c = c1; | - |
| 142 | continue;executed 33 times by 1 test: continue; | 33 |
| 143 | } | - |
| 144 | else | - |
| 145 | { | - |
| 146 | c = c1; | - |
| 147 | break;executed 118 times by 1 test: break; | 118 |
| 148 | } | - |
| 149 | } | - |
| 150 | else | - |
| 151 | break;executed 39197 times by 1 test: break; | 39197 |
| 152 | } | - |
| 153 | while (c);| TRUE | evaluated 33 times by 1 test | | FALSE | never evaluated |
| 0-33 |
| 154 | #endif /* !CSH_BRACE_COMPAT */ | - |
| 155 | | - |
| 156 | preamble = (char *)xmalloc (i + 1); | - |
| 157 | if (i > 0)| TRUE | evaluated 39244 times by 1 test | | FALSE | evaluated 71 times by 1 test |
| 71-39244 |
| 158 | strncpy (preamble, text, i);executed 39244 times by 1 test: __builtin_strncpy ( preamble , text , i ) ; | 39244 |
| 159 | preamble[i] = '\0'; | - |
| 160 | | - |
| 161 | result = (char **)xmalloc (2 * sizeof (char *)); | - |
| 162 | result[0] = preamble; | - |
| 163 | result[1] = (char *)NULL; | - |
| 164 | | - |
| 165 | | - |
| 166 | | - |
| 167 | if (c != '{')| TRUE | evaluated 39197 times by 1 test | | FALSE | evaluated 118 times by 1 test |
| 118-39197 |
| 168 | return (result);executed 39197 times by 1 test: return (result); | 39197 |
| 169 | | - |
| 170 | | - |
| 171 | start = ++i; | - |
| 172 | c = brace_gobbler (text, tlen, &i, '}'); | - |
| 173 | | - |
| 174 | | - |
| 175 | if (c == 0)| TRUE | never evaluated | | FALSE | evaluated 118 times by 1 test |
| 0-118 |
| 176 | { | - |
| 177 | #if defined (NOTDEF) | - |
| 178 | | - |
| 179 | | - |
| 180 | j = start; | - |
| 181 | while (j < i) | - |
| 182 | { | - |
| 183 | if (text[j] == '\\') | - |
| 184 | { | - |
| 185 | j++; | - |
| 186 | ADVANCE_CHAR (text, tlen, j); | - |
| 187 | continue; | - |
| 188 | } | - |
| 189 | | - |
| 190 | if (text[j] == brace_arg_separator) | - |
| 191 | { | - |
| 192 | strvec_dispose (result); | - |
| 193 | last_command_exit_value = 1; | - |
| 194 | report_error ("no closing `%c' in %s", '}', text); | - |
| 195 | throw_to_top_level (); | - |
| 196 | } | - |
| 197 | ADVANCE_CHAR (text, tlen, j); | - |
| 198 | } | - |
| 199 | #endif | - |
| 200 | free (preamble); | - |
| 201 | result[0] = savestring (text); | - |
| 202 | return (result); never executed: return (result); | 0 |
| 203 | } | - |
| 204 | | - |
| 205 | #if defined (SHELL) | - |
| 206 | amble = substring (text, start, i); | - |
| 207 | alen = i - start; | - |
| 208 | #else | - |
| 209 | amble = (char *)xmalloc (1 + (i - start)); | - |
| 210 | strncpy (amble, &text[start], (i - start)); | - |
| 211 | alen = i - start; | - |
| 212 | amble[alen] = '\0'; | - |
| 213 | #endif | - |
| 214 | | - |
| 215 | #if defined (SHELL) | - |
| 216 | INITIALIZE_MBSTATE; | - |
| 217 | | - |
| 218 | | - |
| 219 | | - |
| 220 | j = 0; | - |
| 221 | while (amble[j])| TRUE | evaluated 594 times by 1 test | | FALSE | evaluated 53 times by 1 test |
| 53-594 |
| 222 | { | - |
| 223 | if (amble[j] == '\\')| TRUE | evaluated 5 times by 1 test | | FALSE | evaluated 589 times by 1 test |
| 5-589 |
| 224 | { | - |
| 225 | j++; | - |
| 226 | ADVANCE_CHAR (amble, alen, j);executed 5 times by 1 test: mblength = 1; never executed: mblength = 1; never executed: end of block never executed: end of block never executed: (j)++; executed 5 times by 1 test: (j) += mblength; never executed: (j)++; | TRUE | evaluated 5 times by 1 test | | FALSE | never evaluated |
| TRUE | evaluated 5 times by 1 test | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | evaluated 5 times by 1 test |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | evaluated 5 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 5 times by 1 test |
| 0-5 |
| 227 | continue;executed 5 times by 1 test: continue; | 5 |
| 228 | } | - |
| 229 | | - |
| 230 | if (amble[j] == brace_arg_separator)| TRUE | evaluated 65 times by 1 test | | FALSE | evaluated 524 times by 1 test |
| 65-524 |
| 231 | break;executed 65 times by 1 test: break; | 65 |
| 232 | | - |
| 233 | ADVANCE_CHAR (amble, alen, j);executed 516 times by 1 test: mblength = 1; never executed: mblength = 1; never executed: end of block never executed: end of block never executed: (j)++; executed 516 times by 1 test: (j) += mblength; executed 8 times by 1 test: (j)++; | TRUE | evaluated 516 times by 1 test | | FALSE | evaluated 8 times by 1 test |
| TRUE | evaluated 516 times by 1 test | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | evaluated 516 times by 1 test |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | evaluated 516 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 516 times by 1 test |
| 0-516 |
| 234 | }executed 524 times by 1 test: end of block | 524 |
| 235 | | - |
| 236 | if (amble[j] == 0)| TRUE | evaluated 53 times by 1 test | | FALSE | evaluated 65 times by 1 test |
| 53-65 |
| 237 | { | - |
| 238 | tack = expand_seqterm (amble, alen); | - |
| 239 | if (tack)| TRUE | evaluated 37 times by 1 test | | FALSE | evaluated 16 times by 1 test |
| 16-37 |
| 240 | goto add_tack;executed 37 times by 1 test: goto add_tack; | 37 |
| 241 | else if (text[i + 1])| TRUE | never evaluated | | FALSE | evaluated 16 times by 1 test |
| 0-16 |
| 242 | { | - |
| 243 | | - |
| 244 | | - |
| 245 | | - |
| 246 | | - |
| 247 | | - |
| 248 | tack = strvec_create (2); | - |
| 249 | tack[0] = savestring (text+start-1); | - |
| 250 | tack[0][i-start+2] = '\0'; | - |
| 251 | tack[1] = (char *)0; | - |
| 252 | goto add_tack; never executed: goto add_tack; | 0 |
| 253 | } | - |
| 254 | else | - |
| 255 | { | - |
| 256 | free (amble); | - |
| 257 | free (preamble); | - |
| 258 | result[0] = savestring (text); | - |
| 259 | return (result);executed 16 times by 1 test: return (result); | 16 |
| 260 | } | - |
| 261 | } | - |
| 262 | #endif /* SHELL */ | - |
| 263 | | - |
| 264 | tack = expand_amble (amble, alen, 0); | - |
| 265 | add_tack:code before this statement executed 65 times by 1 test: add_tack: | 65 |
| 266 | result = array_concat (result, tack); | - |
| 267 | free (amble); | - |
| 268 | if (tack != result)| TRUE | evaluated 49 times by 1 test | | FALSE | evaluated 53 times by 1 test |
| 49-53 |
| 269 | strvec_dispose (tack);executed 49 times by 1 test: strvec_dispose (tack); | 49 |
| 270 | | - |
| 271 | postamble = text + i + 1; | - |
| 272 | | - |
| 273 | if (postamble && *postamble)| TRUE | evaluated 102 times by 1 test | | FALSE | never evaluated |
| TRUE | evaluated 27 times by 1 test | | FALSE | evaluated 75 times by 1 test |
| 0-102 |
| 274 | { | - |
| 275 | tack = brace_expand (postamble); | - |
| 276 | result = array_concat (result, tack); | - |
| 277 | if (tack != result)| TRUE | evaluated 27 times by 1 test | | FALSE | never evaluated |
| 0-27 |
| 278 | strvec_dispose (tack);executed 27 times by 1 test: strvec_dispose (tack); | 27 |
| 279 | }executed 27 times by 1 test: end of block | 27 |
| 280 | | - |
| 281 | return (result);executed 102 times by 1 test: return (result); | 102 |
| 282 | } | - |
| 283 | | - |
| 284 | | - |
| 285 | | - |
| 286 | | - |
| 287 | | - |
| 288 | static char ** | - |
| 289 | expand_amble (text, tlen, flags) | - |
| 290 | char *text; | - |
| 291 | size_t tlen; | - |
| 292 | int flags; | - |
| 293 | { | - |
| 294 | char **result, **partial, **tresult; | - |
| 295 | char *tem; | - |
| 296 | int start, i, c; | - |
| 297 | | - |
| 298 | #if defined (SHELL) | - |
| 299 | DECLARE_MBSTATE; | - |
| 300 | #endif | - |
| 301 | | - |
| 302 | result = (char **)NULL; | - |
| 303 | | - |
| 304 | start = i = 0; | - |
| 305 | c = 1; | - |
| 306 | while (c)| TRUE | evaluated 181 times by 1 test | | FALSE | evaluated 65 times by 1 test |
| 65-181 |
| 307 | { | - |
| 308 | c = brace_gobbler (text, tlen, &i, brace_arg_separator); | - |
| 309 | #if defined (SHELL) | - |
| 310 | tem = substring (text, start, i); | - |
| 311 | #else | - |
| 312 | tem = (char *)xmalloc (1 + (i - start)); | - |
| 313 | strncpy (tem, &text[start], (i - start)); | - |
| 314 | tem[i - start] = '\0'; | - |
| 315 | #endif | - |
| 316 | | - |
| 317 | partial = brace_expand (tem); | - |
| 318 | | - |
| 319 | if (!result)| TRUE | evaluated 65 times by 1 test | | FALSE | evaluated 116 times by 1 test |
| 65-116 |
| 320 | result = partial;executed 65 times by 1 test: result = partial; | 65 |
| 321 | else | - |
| 322 | { | - |
| 323 | register int lr, lp, j; | - |
| 324 | | - |
| 325 | lr = strvec_len (result); | - |
| 326 | lp = strvec_len (partial); | - |
| 327 | | - |
| 328 | tresult = strvec_mresize (result, lp + lr + 1); | - |
| 329 | if (tresult == 0)| TRUE | never evaluated | | FALSE | evaluated 116 times by 1 test |
| 0-116 |
| 330 | { | - |
| 331 | internal_error (_("brace expansion: cannot allocate memory for %s"), tem); | - |
| 332 | free (tem); | - |
| 333 | strvec_dispose (partial); | - |
| 334 | strvec_dispose (result); | - |
| 335 | result = (char **)NULL; | - |
| 336 | return result; never executed: return result; | 0 |
| 337 | } | - |
| 338 | else | - |
| 339 | result = tresult;executed 116 times by 1 test: result = tresult; | 116 |
| 340 | | - |
| 341 | for (j = 0; j < lp; j++)| TRUE | evaluated 122 times by 1 test | | FALSE | evaluated 116 times by 1 test |
| 116-122 |
| 342 | result[lr + j] = partial[j];executed 122 times by 1 test: result[lr + j] = partial[j]; | 122 |
| 343 | | - |
| 344 | result[lr + j] = (char *)NULL; | - |
| 345 | free (partial); | - |
| 346 | }executed 116 times by 1 test: end of block | 116 |
| 347 | free (tem); | - |
| 348 | #if defined (SHELL) | - |
| 349 | ADVANCE_CHAR (text, tlen, i);executed 97 times by 1 test: mblength = 1; executed 55 times by 1 test: mblength = 1; never executed: end of block never executed: end of block never executed: (i)++; executed 152 times by 1 test: (i) += mblength; executed 29 times by 1 test: (i)++; | TRUE | evaluated 152 times by 1 test | | FALSE | evaluated 29 times by 1 test |
| TRUE | evaluated 97 times by 1 test | | FALSE | evaluated 55 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 152 times by 1 test |
| TRUE | evaluated 55 times by 1 test | | FALSE | never evaluated |
| TRUE | evaluated 55 times by 1 test | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | evaluated 152 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 152 times by 1 test |
| 0-152 |
| 350 | #else | - |
| 351 | i++; | - |
| 352 | #endif | - |
| 353 | start = i; | - |
| 354 | }executed 181 times by 1 test: end of block | 181 |
| 355 | return (result);executed 65 times by 1 test: return (result); | 65 |
| 356 | } | - |
| 357 | | - |
| 358 | #define ST_BAD 0 | - |
| 359 | #define ST_INT 1 | - |
| 360 | #define ST_CHAR 2 | - |
| 361 | #define ST_ZINT 3 | - |
| 362 | | - |
| 363 | #ifndef sh_imaxabs | - |
| 364 | # define sh_imaxabs(x) (((x) >= 0) ? (x) : -(x)) | - |
| 365 | #endif | - |
| 366 | | - |
| 367 | | - |
| 368 | | - |
| 369 | | - |
| 370 | | - |
| 371 | | - |
| 372 | #define ADDOVERFLOW(a,b,minv,maxv) \ | - |
| 373 | ((((a) > 0) && ((b) > ((maxv) - (a)))) || \ | - |
| 374 | (((a) < 0) && ((b) < ((minv) - (a))))) | - |
| 375 | | - |
| 376 | | - |
| 377 | | - |
| 378 | #define SUBOVERFLOW(a,b,minv,maxv) \ | - |
| 379 | ((((b) > 0) && ((a) < ((minv) + (b)))) || \ | - |
| 380 | (((b) < 0) && ((a) > ((maxv) + (b))))) | - |
| 381 | | - |
| 382 | static char ** | - |
| 383 | mkseq (start, end, incr, type, width) | - |
| 384 | intmax_t start, end, incr; | - |
| 385 | int type, width; | - |
| 386 | { | - |
| 387 | intmax_t n, prevn; | - |
| 388 | int i, nelem; | - |
| 389 | char **result, *t; | - |
| 390 | | - |
| 391 | if (incr == 0)| TRUE | never evaluated | | FALSE | evaluated 37 times by 1 test |
| 0-37 |
| 392 | incr = 1; never executed: incr = 1; | 0 |
| 393 | | - |
| 394 | if (start > end && incr > 0)| TRUE | evaluated 15 times by 1 test | | FALSE | evaluated 22 times by 1 test |
| TRUE | evaluated 10 times by 1 test | | FALSE | evaluated 5 times by 1 test |
| 5-22 |
| 395 | incr = -incr;executed 10 times by 1 test: incr = -incr; | 10 |
| 396 | else if (start < end && incr < 0)| TRUE | evaluated 19 times by 1 test | | FALSE | evaluated 8 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 19 times by 1 test |
| 0-19 |
| 397 | { | - |
| 398 | if (incr == INTMAX_MIN) | TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 399 | return ((char **)NULL); never executed: return ((char **) ((void *)0) ); | 0 |
| 400 | incr = -incr; | - |
| 401 | } never executed: end of block | 0 |
| 402 | | - |
| 403 | | - |
| 404 | | - |
| 405 | | - |
| 406 | if (SUBOVERFLOW (end, start, INTMAX_MIN+3, INTMAX_MAX-2))| TRUE | evaluated 30 times by 1 test | | FALSE | evaluated 7 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 30 times by 1 test |
| TRUE | evaluated 5 times by 1 test | | FALSE | evaluated 32 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 5 times by 1 test |
| 0-32 |
| 407 | return ((char **)NULL); never executed: return ((char **) ((void *)0) ); | 0 |
| 408 | | - |
| 409 | prevn = sh_imaxabs (end - start);| TRUE | evaluated 22 times by 1 test | | FALSE | evaluated 15 times by 1 test |
| 15-22 |
| 410 | | - |
| 411 | if (INT_MAX == INTMAX_MAX && (ADDOVERFLOW (prevn, 2, INT_MIN, INT_MAX)))| TRUE | never evaluated | | FALSE | evaluated 37 times by 1 test |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0-37 |
| 412 | return ((char **)NULL); never executed: return ((char **) ((void *)0) ); | 0 |
| 413 | | - |
| 414 | | - |
| 415 | else if (ADDOVERFLOW ((prevn/sh_imaxabs(incr)), 1, INTMAX_MIN, INTMAX_MAX))| TRUE | evaluated 22 times by 1 test | | FALSE | evaluated 15 times by 1 test |
| TRUE | evaluated 22 times by 1 test | | FALSE | evaluated 15 times by 1 test |
| TRUE | evaluated 33 times by 1 test | | FALSE | evaluated 4 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 33 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 37 times by 1 test |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0-37 |
| 416 | return ((char **)NULL); never executed: return ((char **) ((void *)0) ); | 0 |
| 417 | | - |
| 418 | | - |
| 419 | | - |
| 420 | | - |
| 421 | | - |
| 422 | | - |
| 423 | nelem = (prevn / sh_imaxabs(incr)) + 1;| TRUE | evaluated 22 times by 1 test | | FALSE | evaluated 15 times by 1 test |
| 15-22 |
| 424 | if (nelem > INT_MAX - 2) | TRUE | never evaluated | | FALSE | evaluated 37 times by 1 test |
| 0-37 |
| 425 | return ((char **)NULL); never executed: return ((char **) ((void *)0) ); | 0 |
| 426 | result = strvec_mcreate (nelem + 1); | - |
| 427 | if (result == 0)| TRUE | never evaluated | | FALSE | evaluated 37 times by 1 test |
| 0-37 |
| 428 | { | - |
| 429 | internal_error (_("brace expansion: failed to allocate memory for %u elements"), (unsigned int)nelem); | - |
| 430 | return ((char **)NULL); never executed: return ((char **) ((void *)0) ); | 0 |
| 431 | } | - |
| 432 | | - |
| 433 | | - |
| 434 | i = 0; | - |
| 435 | n = start; | - |
| 436 | do | - |
| 437 | { | - |
| 438 | #if defined (SHELL) | - |
| 439 | if (ISINTERRUPT)| TRUE | never evaluated | | FALSE | evaluated 10375 times by 1 test |
| 0-10375 |
| 440 | { | - |
| 441 | strvec_dispose (result); | - |
| 442 | result = (char **)NULL; | - |
| 443 | } never executed: end of block | 0 |
| 444 | QUIT; never executed: termsig_handler (terminating_signal); never executed: throw_to_top_level (); | TRUE | never evaluated | | FALSE | evaluated 10375 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 10375 times by 1 test |
| 0-10375 |
| 445 | #endif | - |
| 446 | if (type == ST_INT)| TRUE | evaluated 10244 times by 1 test | | FALSE | evaluated 131 times by 1 test |
| 131-10244 |
| 447 | result[i++] = t = itos (n);executed 10244 times by 1 test: result[i++] = t = itos (n); | 10244 |
| 448 | else if (type == ST_ZINT)| TRUE | never evaluated | | FALSE | evaluated 131 times by 1 test |
| 0-131 |
| 449 | { | - |
| 450 | int len, arg; | - |
| 451 | arg = n; | - |
| 452 | len = asprintf (&t, "%0*d", width, arg); | - |
| 453 | result[i++] = t; | - |
| 454 | } never executed: end of block | 0 |
| 455 | else | - |
| 456 | { | - |
| 457 | if (t = (char *)malloc (2))| TRUE | evaluated 131 times by 1 test | | FALSE | never evaluated |
| 0-131 |
| 458 | { | - |
| 459 | t[0] = n; | - |
| 460 | t[1] = '\0'; | - |
| 461 | }executed 131 times by 1 test: end of block | 131 |
| 462 | result[i++] = t; | - |
| 463 | }executed 131 times by 1 test: end of block | 131 |
| 464 | | - |
| 465 | | - |
| 466 | if (t == 0)| TRUE | never evaluated | | FALSE | evaluated 10375 times by 1 test |
| 0-10375 |
| 467 | { | - |
| 468 | char *p, lbuf[INT_STRLEN_BOUND(intmax_t) + 1]; | - |
| 469 | | - |
| 470 | | - |
| 471 | | - |
| 472 | p = inttostr (n, lbuf, sizeof (lbuf)); | - |
| 473 | internal_error (_("brace expansion: failed to allocate memory for `%s'"), p); | - |
| 474 | strvec_dispose (result); | - |
| 475 | return ((char **)NULL); never executed: return ((char **) ((void *)0) ); | 0 |
| 476 | } | - |
| 477 | | - |
| 478 | | - |
| 479 | if (ADDOVERFLOW (n, incr, INTMAX_MIN, INTMAX_MAX))| TRUE | evaluated 10317 times by 1 test | | FALSE | evaluated 58 times by 1 test |
| TRUE | evaluated 1 time by 1 test | | FALSE | evaluated 10316 times by 1 test |
| TRUE | evaluated 50 times by 1 test | | FALSE | evaluated 10324 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 50 times by 1 test |
| 0-10324 |
| 480 | break;executed 1 time by 1 test: break; | 1 |
| 481 | | - |
| 482 | n += incr; | - |
| 483 | | - |
| 484 | if ((incr < 0 && n < end) || (incr > 0 && n > end))| TRUE | evaluated 166 times by 1 test | | FALSE | evaluated 10208 times by 1 test |
| TRUE | evaluated 15 times by 1 test | | FALSE | evaluated 151 times by 1 test |
| TRUE | evaluated 10208 times by 1 test | | FALSE | evaluated 151 times by 1 test |
| TRUE | evaluated 21 times by 1 test | | FALSE | evaluated 10187 times by 1 test |
| 15-10208 |
| 485 | break;executed 36 times by 1 test: break; | 36 |
| 486 | }executed 10338 times by 1 test: end of block | 10338 |
| 487 | while (1); | - |
| 488 | | - |
| 489 | result[i] = (char *)0; | - |
| 490 | return (result);executed 37 times by 1 test: return (result); | 37 |
| 491 | } | - |
| 492 | | - |
| 493 | static char ** | - |
| 494 | expand_seqterm (text, tlen) | - |
| 495 | char *text; | - |
| 496 | size_t tlen; | - |
| 497 | { | - |
| 498 | char *t, *lhs, *rhs; | - |
| 499 | int lhs_t, rhs_t, lhs_l, rhs_l, width; | - |
| 500 | intmax_t lhs_v, rhs_v, incr; | - |
| 501 | intmax_t tl, tr; | - |
| 502 | char **result, *ep, *oep; | - |
| 503 | | - |
| 504 | t = strstr (text, BRACE_SEQ_SPECIFIER); | - |
| 505 | if (t == 0)| TRUE | never evaluated | | FALSE | evaluated 53 times by 1 test |
| 0-53 |
| 506 | return ((char **)NULL); never executed: return ((char **) ((void *)0) ); | 0 |
| 507 | | - |
| 508 | lhs_l = t - text; | - |
| 509 | lhs = substring (text, 0, lhs_l); | - |
| 510 | rhs = substring (text, lhs_l + sizeof(BRACE_SEQ_SPECIFIER) - 1, tlen); | - |
| 511 | | - |
| 512 | if (lhs[0] == 0 || rhs[0] == 0)| TRUE | never evaluated | | FALSE | evaluated 53 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 53 times by 1 test |
| 0-53 |
| 513 | { | - |
| 514 | free (lhs); | - |
| 515 | free (rhs); | - |
| 516 | return ((char **)NULL); never executed: return ((char **) ((void *)0) ); | 0 |
| 517 | } | - |
| 518 | | - |
| 519 | | - |
| 520 | | - |
| 521 | lhs_t = (legal_number (lhs, &tl)) ? ST_INT :| TRUE | evaluated 43 times by 1 test | | FALSE | evaluated 10 times by 1 test |
| 10-43 |
| 522 | ((ISALPHA (lhs[0]) && lhs[1] == 0) ? ST_CHAR : ST_BAD);| TRUE | evaluated 9 times by 1 test | | FALSE | evaluated 1 time by 1 test |
| TRUE | evaluated 9 times by 1 test | | FALSE | never evaluated |
| 0-9 |
| 523 | | - |
| 524 | | - |
| 525 | | - |
| 526 | ep = 0; | - |
| 527 | if (ISDIGIT (rhs[0]) || ((rhs[0] == '+' || rhs[0] == '-') && ISDIGIT (rhs[1])))| TRUE | evaluated 36 times by 1 test | | FALSE | evaluated 17 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 17 times by 1 test |
| TRUE | evaluated 4 times by 1 test | | FALSE | evaluated 13 times by 1 test |
| TRUE | evaluated 4 times by 1 test | | FALSE | never evaluated |
| 0-36 |
| 528 | { | - |
| 529 | rhs_t = ST_INT; | - |
| 530 | errno = 0; | - |
| 531 | tr = strtoimax (rhs, &ep, 10); | - |
| 532 | if (errno == ERANGE || (ep && *ep != 0 && *ep != '.'))| TRUE | never evaluated | | FALSE | evaluated 40 times by 1 test |
| TRUE | evaluated 40 times by 1 test | | FALSE | never evaluated |
| TRUE | evaluated 21 times by 1 test | | FALSE | evaluated 19 times by 1 test |
| TRUE | evaluated 3 times by 1 test | | FALSE | evaluated 18 times by 1 test |
| 0-40 |
| 533 | rhs_t = ST_BAD; executed 3 times by 1 test: rhs_t = 0; | 3 |
| 534 | }executed 40 times by 1 test: end of block | 40 |
| 535 | else if (ISALPHA (rhs[0]) && (rhs[1] == 0 || rhs[1] == '.'))| TRUE | evaluated 13 times by 1 test | | FALSE | never evaluated |
| TRUE | evaluated 8 times by 1 test | | FALSE | evaluated 5 times by 1 test |
| TRUE | evaluated 2 times by 1 test | | FALSE | evaluated 3 times by 1 test |
| 0-13 |
| 536 | { | - |
| 537 | rhs_t = ST_CHAR; | - |
| 538 | ep = rhs + 1; | - |
| 539 | }executed 10 times by 1 test: end of block | 10 |
| 540 | else | - |
| 541 | { | - |
| 542 | rhs_t = ST_BAD; | - |
| 543 | ep = 0; | - |
| 544 | }executed 3 times by 1 test: end of block | 3 |
| 545 | | - |
| 546 | incr = 1; | - |
| 547 | if (rhs_t != ST_BAD)| TRUE | evaluated 47 times by 1 test | | FALSE | evaluated 6 times by 1 test |
| 6-47 |
| 548 | { | - |
| 549 | oep = ep; | - |
| 550 | errno = 0; | - |
| 551 | if (ep && *ep == '.' && ep[1] == '.' && ep[2])| TRUE | evaluated 47 times by 1 test | | FALSE | never evaluated |
| TRUE | evaluated 20 times by 1 test | | FALSE | evaluated 27 times by 1 test |
| TRUE | evaluated 17 times by 1 test | | FALSE | evaluated 3 times by 1 test |
| TRUE | evaluated 17 times by 1 test | | FALSE | never evaluated |
| 0-47 |
| 552 | incr = strtoimax (ep + 2, &ep, 10);executed 17 times by 1 test: incr = strtoimax (ep + 2, &ep, 10); | 17 |
| 553 | if (*ep != 0 || errno == ERANGE)| TRUE | evaluated 6 times by 1 test | | FALSE | evaluated 41 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 41 times by 1 test |
| 0-41 |
| 554 | rhs_t = ST_BAD; executed 6 times by 1 test: rhs_t = 0; | 6 |
| 555 | tlen -= ep - oep; | - |
| 556 | }executed 47 times by 1 test: end of block | 47 |
| 557 | | - |
| 558 | if (lhs_t != rhs_t || lhs_t == ST_BAD || rhs_t == ST_BAD)| TRUE | evaluated 16 times by 1 test | | FALSE | evaluated 37 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 37 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 37 times by 1 test |
| 0-37 |
| 559 | { | - |
| 560 | free (lhs); | - |
| 561 | free (rhs); | - |
| 562 | return ((char **)NULL);executed 16 times by 1 test: return ((char **) ((void *)0) ); | 16 |
| 563 | } | - |
| 564 | | - |
| 565 | | - |
| 566 | | - |
| 567 | | - |
| 568 | | - |
| 569 | if (lhs_t == ST_CHAR)| TRUE | evaluated 8 times by 1 test | | FALSE | evaluated 29 times by 1 test |
| 8-29 |
| 570 | { | - |
| 571 | lhs_v = (unsigned char)lhs[0]; | - |
| 572 | rhs_v = (unsigned char)rhs[0]; | - |
| 573 | width = 1; | - |
| 574 | }executed 8 times by 1 test: end of block | 8 |
| 575 | else | - |
| 576 | { | - |
| 577 | lhs_v = tl; | - |
| 578 | rhs_v = tr; | - |
| 579 | | - |
| 580 | | - |
| 581 | rhs_l = tlen - lhs_l - sizeof (BRACE_SEQ_SPECIFIER) + 1; | - |
| 582 | width = 0; | - |
| 583 | if (lhs_l > 1 && lhs[0] == '0')| TRUE | evaluated 17 times by 1 test | | FALSE | evaluated 12 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 17 times by 1 test |
| 0-17 |
| 584 | width = lhs_l, lhs_t = ST_ZINT; never executed: width = lhs_l, lhs_t = 3; | 0 |
| 585 | if (lhs_l > 2 && lhs[0] == '-' && lhs[1] == '0')| TRUE | evaluated 6 times by 1 test | | FALSE | evaluated 23 times by 1 test |
| TRUE | evaluated 2 times by 1 test | | FALSE | evaluated 4 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 2 times by 1 test |
| 0-23 |
| 586 | width = lhs_l, lhs_t = ST_ZINT; never executed: width = lhs_l, lhs_t = 3; | 0 |
| 587 | if (rhs_l > 1 && rhs[0] == '0' && width < rhs_l)| TRUE | evaluated 16 times by 1 test | | FALSE | evaluated 13 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 16 times by 1 test |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0-16 |
| 588 | width = rhs_l, lhs_t = ST_ZINT; never executed: width = rhs_l, lhs_t = 3; | 0 |
| 589 | if (rhs_l > 2 && rhs[0] == '-' && rhs[1] == '0' && width < rhs_l)| TRUE | evaluated 7 times by 1 test | | FALSE | evaluated 22 times by 1 test |
| TRUE | evaluated 3 times by 1 test | | FALSE | evaluated 4 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 3 times by 1 test |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0-22 |
| 590 | width = rhs_l, lhs_t = ST_ZINT; never executed: width = rhs_l, lhs_t = 3; | 0 |
| 591 | | - |
| 592 | if (width < lhs_l && lhs_t == ST_ZINT)| TRUE | evaluated 29 times by 1 test | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | evaluated 29 times by 1 test |
| 0-29 |
| 593 | width = lhs_l; never executed: width = lhs_l; | 0 |
| 594 | if (width < rhs_l && lhs_t == ST_ZINT)| TRUE | evaluated 29 times by 1 test | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | evaluated 29 times by 1 test |
| 0-29 |
| 595 | width = rhs_l; never executed: width = rhs_l; | 0 |
| 596 | }executed 29 times by 1 test: end of block | 29 |
| 597 | | - |
| 598 | result = mkseq (lhs_v, rhs_v, incr, lhs_t, width); | - |
| 599 | | - |
| 600 | free (lhs); | - |
| 601 | free (rhs); | - |
| 602 | | - |
| 603 | return (result);executed 37 times by 1 test: return (result); | 37 |
| 604 | } | - |
| 605 | | - |
| 606 | | - |
| 607 | | - |
| 608 | | - |
| 609 | | - |
| 610 | | - |
| 611 | | - |
| 612 | | - |
| 613 | | - |
| 614 | | - |
| 615 | static int | - |
| 616 | brace_gobbler (text, tlen, indx, satisfy) | - |
| 617 | char *text; | - |
| 618 | size_t tlen; | - |
| 619 | int *indx; | - |
| 620 | int satisfy; | - |
| 621 | { | - |
| 622 | register int i, c, quoted, level, commas, pass_next; | - |
| 623 | #if defined (SHELL) | - |
| 624 | int si; | - |
| 625 | char *t; | - |
| 626 | #endif | - |
| 627 | DECLARE_MBSTATE; | - |
| 628 | | - |
| 629 | level = quoted = pass_next = 0; | - |
| 630 | #if defined (CSH_BRACE_COMPAT) | - |
| 631 | commas = 1; | - |
| 632 | #else | - |
| 633 | commas = (satisfy == '}') ? 0 : 1;| TRUE | evaluated 269 times by 1 test | | FALSE | evaluated 39529 times by 1 test |
| 269-39529 |
| 634 | #endif | - |
| 635 | | - |
| 636 | i = *indx; | - |
| 637 | while (c = text[i])| TRUE | evaluated 708171 times by 1 test | | FALSE | evaluated 39295 times by 1 test |
| 39295-708171 |
| 638 | { | - |
| 639 | if (pass_next)| TRUE | evaluated 36454 times by 1 test | | FALSE | evaluated 671717 times by 1 test |
| 36454-671717 |
| 640 | { | - |
| 641 | pass_next = 0; | - |
| 642 | #if defined (SHELL) | - |
| 643 | ADVANCE_CHAR (text, tlen, i);executed 36036 times by 1 test: mblength = 1; executed 75 times by 1 test: mblength = 1; never executed: end of block never executed: end of block never executed: (i)++; executed 36111 times by 1 test: (i) += mblength; executed 343 times by 1 test: (i)++; | TRUE | evaluated 36111 times by 1 test | | FALSE | evaluated 343 times by 1 test |
| TRUE | evaluated 36036 times by 1 test | | FALSE | evaluated 75 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 36111 times by 1 test |
| TRUE | evaluated 75 times by 1 test | | FALSE | never evaluated |
| TRUE | evaluated 75 times by 1 test | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | evaluated 36111 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 36111 times by 1 test |
| 0-36111 |
| 644 | #else | - |
| 645 | i++; | - |
| 646 | #endif | - |
| 647 | continue;executed 36454 times by 1 test: continue; | 36454 |
| 648 | } | - |
| 649 | | - |
| 650 | | - |
| 651 | | - |
| 652 | if (c == '\\' && (quoted == 0 || quoted == '"' || quoted == '`'))| TRUE | evaluated 1337 times by 1 test | | FALSE | evaluated 670380 times by 1 test |
| TRUE | evaluated 396 times by 1 test | | FALSE | evaluated 941 times by 1 test |
| TRUE | evaluated 867 times by 1 test | | FALSE | evaluated 74 times by 1 test |
| TRUE | evaluated 8 times by 1 test | | FALSE | evaluated 66 times by 1 test |
| 8-670380 |
| 653 | { | - |
| 654 | pass_next = 1; | - |
| 655 | i++; | - |
| 656 | continue;executed 1271 times by 1 test: continue; | 1271 |
| 657 | } | - |
| 658 | | - |
| 659 | #if defined (SHELL) | - |
| 660 | | - |
| 661 | if (c == '$' && text[i+1] == '{' && quoted != '\'') | TRUE | evaluated 59700 times by 1 test | | FALSE | evaluated 610746 times by 1 test |
| TRUE | evaluated 44796 times by 1 test | | FALSE | evaluated 14904 times by 1 test |
| TRUE | evaluated 35183 times by 1 test | | FALSE | evaluated 9613 times by 1 test |
| 9613-610746 |
| 662 | { | - |
| 663 | pass_next = 1; | - |
| 664 | i++; | - |
| 665 | if (quoted == 0)| TRUE | evaluated 12140 times by 1 test | | FALSE | evaluated 23043 times by 1 test |
| 12140-23043 |
| 666 | level++;executed 12140 times by 1 test: level++; | 12140 |
| 667 | continue;executed 35183 times by 1 test: continue; | 35183 |
| 668 | } | - |
| 669 | #endif | - |
| 670 | | - |
| 671 | if (quoted)| TRUE | evaluated 513331 times by 1 test | | FALSE | evaluated 121932 times by 1 test |
| 121932-513331 |
| 672 | { | - |
| 673 | if (c == quoted)| TRUE | evaluated 34749 times by 1 test | | FALSE | evaluated 478582 times by 1 test |
| 34749-478582 |
| 674 | quoted = 0;executed 34749 times by 1 test: quoted = 0; | 34749 |
| 675 | #if defined (SHELL) | - |
| 676 | | - |
| 677 | if (quoted == '"' && c == '$' && text[i+1] == '(') | TRUE | evaluated 243185 times by 1 test | | FALSE | evaluated 270146 times by 1 test |
| TRUE | evaluated 6553 times by 1 test | | FALSE | evaluated 236632 times by 1 test |
| TRUE | evaluated 95 times by 1 test | | FALSE | evaluated 6458 times by 1 test |
| 95-270146 |
| 678 | goto comsub;executed 95 times by 1 test: goto comsub; | 95 |
| 679 | #endif | - |
| 680 | #if defined (SHELL) | - |
| 681 | ADVANCE_CHAR (text, tlen, i);executed 483994 times by 1 test: mblength = 1; executed 27685 times by 1 test: mblength = 1; never executed: end of block never executed: end of block never executed: (i)++; executed 511679 times by 1 test: (i) += mblength; executed 1557 times by 1 test: (i)++; | TRUE | evaluated 511679 times by 1 test | | FALSE | evaluated 1557 times by 1 test |
| TRUE | evaluated 483994 times by 1 test | | FALSE | evaluated 27685 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 511679 times by 1 test |
| TRUE | evaluated 27685 times by 1 test | | FALSE | never evaluated |
| TRUE | evaluated 27685 times by 1 test | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | evaluated 511679 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 511679 times by 1 test |
| 0-511679 |
| 682 | #else | - |
| 683 | i++; | - |
| 684 | #endif | - |
| 685 | continue;executed 513236 times by 1 test: continue; | 513236 |
| 686 | } | - |
| 687 | | - |
| 688 | if (c == '"' || c == '\'' || c == '`')| TRUE | evaluated 24854 times by 1 test | | FALSE | evaluated 97078 times by 1 test |
| TRUE | evaluated 9849 times by 1 test | | FALSE | evaluated 87229 times by 1 test |
| TRUE | evaluated 78 times by 1 test | | FALSE | evaluated 87151 times by 1 test |
| 78-97078 |
| 689 | { | - |
| 690 | quoted = c; | - |
| 691 | i++; | - |
| 692 | continue;executed 34781 times by 1 test: continue; | 34781 |
| 693 | } | - |
| 694 | | - |
| 695 | #if defined (SHELL) | - |
| 696 | | - |
| 697 | if ((c == '$' || c == '<' || c == '>') && text[i+1] == '(') | TRUE | evaluated 2244 times by 1 test | | FALSE | evaluated 84907 times by 1 test |
| TRUE | evaluated 1890 times by 1 test | | FALSE | evaluated 83017 times by 1 test |
| TRUE | evaluated 1 time by 1 test | | FALSE | evaluated 83016 times by 1 test |
| TRUE | evaluated 64 times by 1 test | | FALSE | evaluated 4071 times by 1 test |
| 1-84907 |
| 698 | { | - |
| 699 | comsub: | - |
| 700 | si = i + 2; | - |
| 701 | t = extract_command_subst (text, &si, 0); | - |
| 702 | i = si; | - |
| 703 | free (t); | - |
| 704 | i++; | - |
| 705 | continue;executed 159 times by 1 test: continue; | 159 |
| 706 | } | - |
| 707 | #endif | - |
| 708 | | - |
| 709 | if (c == satisfy && level == 0 && quoted == 0 && commas > 0)| TRUE | evaluated 592 times by 1 test | | FALSE | evaluated 86495 times by 1 test |
| TRUE | evaluated 535 times by 1 test | | FALSE | evaluated 57 times by 1 test |
| TRUE | evaluated 535 times by 1 test | | FALSE | never evaluated |
| TRUE | evaluated 506 times by 1 test | | FALSE | evaluated 29 times by 1 test |
| 0-86495 |
| 710 | { | - |
| 711 | | - |
| 712 | | - |
| 713 | | - |
| 714 | if (c == '{' &&| TRUE | evaluated 154 times by 1 test | | FALSE | evaluated 352 times by 1 test |
| 154-352 |
| 715 | ((!i || brace_whitespace (text[i - 1])) &&| TRUE | evaluated 84 times by 1 test | | FALSE | evaluated 70 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 70 times by 1 test |
| TRUE | evaluated 1 time by 1 test | | FALSE | evaluated 69 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 69 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 69 times by 1 test |
| 0-84 |
| 716 | (brace_whitespace (text[i + 1]) || text[i + 1] == '}')))| TRUE | evaluated 2 times by 1 test | | FALSE | evaluated 83 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 83 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 83 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 83 times by 1 test |
| TRUE | evaluated 1 time by 1 test | | FALSE | evaluated 82 times by 1 test |
| 0-83 |
| 717 | { | - |
| 718 | i++; | - |
| 719 | continue;executed 3 times by 1 test: continue; | 3 |
| 720 | } | - |
| 721 | | - |
| 722 | break;executed 503 times by 1 test: break; | 503 |
| 723 | } | - |
| 724 | | - |
| 725 | if (c == '{')| TRUE | evaluated 53 times by 1 test | | FALSE | evaluated 86528 times by 1 test |
| 53-86528 |
| 726 | level++;executed 53 times by 1 test: level++; | 53 |
| 727 | else if (c == '}' && level)| TRUE | evaluated 12296 times by 1 test | | FALSE | evaluated 74232 times by 1 test |
| TRUE | evaluated 12186 times by 1 test | | FALSE | evaluated 110 times by 1 test |
| 110-74232 |
| 728 | level--;executed 12186 times by 1 test: level--; | 12186 |
| 729 | #if !defined (CSH_BRACE_COMPAT) | - |
| 730 | else if (satisfy == '}' && c == brace_arg_separator && level == 0)| TRUE | evaluated 2132 times by 1 test | | FALSE | evaluated 72210 times by 1 test |
| TRUE | evaluated 258 times by 1 test | | FALSE | evaluated 1874 times by 1 test |
| TRUE | evaluated 232 times by 1 test | | FALSE | evaluated 26 times by 1 test |
| 26-72210 |
| 731 | commas++;executed 232 times by 1 test: commas++; | 232 |
| 732 | else if (satisfy == '}' && STREQN (text+i, BRACE_SEQ_SPECIFIER, 2) && never executed: __result = (((const unsigned char *) (const char *) ( text+i ))[3] - __s2[3]); never executed: end of block never executed: end of block never executed: __result = (((const unsigned char *) (const char *) ( ".." ))[3] - __s2[3]); never executed: end of block never executed: end of block | TRUE | never evaluated | | FALSE | evaluated 1900 times by 1 test |
| TRUE | evaluated 1900 times by 1 test | | FALSE | evaluated 72210 times by 1 test |
| TRUE | evaluated 150 times by 1 test | | FALSE | evaluated 1750 times by 1 test |
| TRUE | evaluated 310 times by 1 test | | FALSE | evaluated 1590 times by 1 test |
| TRUE | evaluated 150 times by 1 test | | FALSE | evaluated 160 times by 1 test |
| TRUE | evaluated 310 times by 1 test | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | evaluated 310 times by 1 test |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | evaluated 310 times by 1 test | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | evaluated 310 times by 1 test |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0-72210 |
| 733 | text[i+2] != satisfy && level == 0)| TRUE | evaluated 150 times by 1 test | | FALSE | never evaluated |
| TRUE | evaluated 146 times by 1 test | | FALSE | evaluated 4 times by 1 test |
| 0-150 |
| 734 | commas++;executed 146 times by 1 test: commas++; | 146 |
| 735 | #endif | - |
| 736 | | - |
| 737 | #if defined (SHELL) | - |
| 738 | ADVANCE_CHAR (text, tlen, i);executed 78687 times by 1 test: mblength = 1; executed 3813 times by 1 test: mblength = 1; never executed: end of block never executed: end of block never executed: (i)++; executed 82500 times by 1 test: (i) += mblength; executed 4081 times by 1 test: (i)++; | TRUE | evaluated 82500 times by 1 test | | FALSE | evaluated 4081 times by 1 test |
| TRUE | evaluated 78687 times by 1 test | | FALSE | evaluated 3813 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 82500 times by 1 test |
| TRUE | evaluated 3813 times by 1 test | | FALSE | never evaluated |
| TRUE | evaluated 3813 times by 1 test | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | evaluated 82500 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 82500 times by 1 test |
| 0-82500 |
| 739 | #else | - |
| 740 | i++; | - |
| 741 | #endif | - |
| 742 | }executed 86581 times by 1 test: end of block | 86581 |
| 743 | | - |
| 744 | *indx = i; | - |
| 745 | return (c);executed 39798 times by 1 test: return (c); | 39798 |
| 746 | } | - |
| 747 | | - |
| 748 | | - |
| 749 | | - |
| 750 | | - |
| 751 | | - |
| 752 | | - |
| 753 | static char ** | - |
| 754 | array_concat (arr1, arr2) | - |
| 755 | char **arr1, **arr2; | - |
| 756 | { | - |
| 757 | register int i, j, len, len1, len2; | - |
| 758 | register char **result; | - |
| 759 | | - |
| 760 | if (arr1 == 0)| TRUE | never evaluated | | FALSE | evaluated 129 times by 1 test |
| 0-129 |
| 761 | return (arr2); never executed: return (arr2); | 0 |
| 762 | | - |
| 763 | if (arr2 == 0)| TRUE | never evaluated | | FALSE | evaluated 129 times by 1 test |
| 0-129 |
| 764 | return (arr1); never executed: return (arr1); | 0 |
| 765 | | - |
| 766 | | - |
| 767 | | - |
| 768 | | - |
| 769 | if (arr1[0] && arr1[0][0] == 0 && arr1[1] == 0)| TRUE | evaluated 129 times by 1 test | | FALSE | never evaluated |
| TRUE | evaluated 53 times by 1 test | | FALSE | evaluated 76 times by 1 test |
| TRUE | evaluated 53 times by 1 test | | FALSE | never evaluated |
| 0-129 |
| 770 | { | - |
| 771 | strvec_dispose (arr1); | - |
| 772 | return (arr2); executed 53 times by 1 test: return (arr2); | 53 |
| 773 | } | - |
| 774 | | - |
| 775 | if (arr2[0] && arr2[0][0] == 0 && arr2[1] == 0)| TRUE | evaluated 76 times by 1 test | | FALSE | never evaluated |
| TRUE | evaluated 2 times by 1 test | | FALSE | evaluated 74 times by 1 test |
| TRUE | never evaluated | | FALSE | evaluated 2 times by 1 test |
| 0-76 |
| 776 | return (arr1); never executed: return (arr1); | 0 |
| 777 | | - |
| 778 | len1 = strvec_len (arr1); | - |
| 779 | len2 = strvec_len (arr2); | - |
| 780 | | - |
| 781 | result = (char **)xmalloc ((1 + (len1 * len2)) * sizeof (char *)); | - |
| 782 | | - |
| 783 | len = 0; | - |
| 784 | for (i = 0; i < len1; i++)| TRUE | evaluated 166 times by 1 test | | FALSE | evaluated 76 times by 1 test |
| 76-166 |
| 785 | { | - |
| 786 | int strlen_1 = strlen (arr1[i]); | - |
| 787 | | - |
| 788 | for (j = 0; j < len2; j++)| TRUE | evaluated 293 times by 1 test | | FALSE | evaluated 166 times by 1 test |
| 166-293 |
| 789 | { | - |
| 790 | result[len] = (char *)xmalloc (1 + strlen_1 + strlen (arr2[j])); | - |
| 791 | strcpy (result[len], arr1[i]); | - |
| 792 | strcpy (result[len] + strlen_1, arr2[j]); | - |
| 793 | len++; | - |
| 794 | }executed 293 times by 1 test: end of block | 293 |
| 795 | free (arr1[i]); | - |
| 796 | }executed 166 times by 1 test: end of block | 166 |
| 797 | free (arr1); | - |
| 798 | | - |
| 799 | result[len] = (char *)NULL; | - |
| 800 | return (result);executed 76 times by 1 test: return (result); | 76 |
| 801 | } | - |
| 802 | | - |
| 803 | #if defined (TEST) | - |
| 804 | #include <stdio.h> | - |
| 805 | | - |
| 806 | void * | - |
| 807 | xmalloc(n) | - |
| 808 | size_t n; | - |
| 809 | { | - |
| 810 | return (malloc (n)); | - |
| 811 | } | - |
| 812 | | - |
| 813 | void * | - |
| 814 | xrealloc(p, n) | - |
| 815 | void *p; | - |
| 816 | size_t n; | - |
| 817 | { | - |
| 818 | return (realloc (p, n)); | - |
| 819 | } | - |
| 820 | | - |
| 821 | int | - |
| 822 | internal_error (format, arg1, arg2) | - |
| 823 | char *format, *arg1, *arg2; | - |
| 824 | { | - |
| 825 | fprintf (stderr, format, arg1, arg2); | - |
| 826 | fprintf (stderr, "\n"); | - |
| 827 | } | - |
| 828 | | - |
| 829 | main () | - |
| 830 | { | - |
| 831 | char example[256]; | - |
| 832 | | - |
| 833 | for (;;) | - |
| 834 | { | - |
| 835 | char **result; | - |
| 836 | int i; | - |
| 837 | | - |
| 838 | fprintf (stderr, "brace_expand> "); | - |
| 839 | | - |
| 840 | if ((!fgets (example, 256, stdin)) || | - |
| 841 | (strncmp (example, "quit", 4) == 0)) | - |
| 842 | break; | - |
| 843 | | - |
| 844 | if (strlen (example)) | - |
| 845 | example[strlen (example) - 1] = '\0'; | - |
| 846 | | - |
| 847 | result = brace_expand (example); | - |
| 848 | | - |
| 849 | for (i = 0; result[i]; i++) | - |
| 850 | printf ("%s\n", result[i]); | - |
| 851 | | - |
| 852 | strvec_dispose (result); | - |
| 853 | } | - |
| 854 | } | - |
| 855 | | - |
| 856 | | - |
| 857 | | - |
| 858 | | - |
| 859 | | - |
| 860 | | - |
| 861 | | - |
| 862 | #endif /* TEST */ | - |
| 863 | #endif /* BRACE_EXPANSION */ | - |
| | |