OpenCoverage

subst.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/bash/src/subst.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/* subst.c -- The part of the shell that does parameter, command, arithmetic,-
2 and globbing substitutions. */-
3-
4/* ``Have a little faith, there's magic in the night. You ain't a-
5 beauty, but, hey, you're alright.'' */-
6-
7/* Copyright (C) 1987-2018 Free Software Foundation, Inc.-
8-
9 This file is part of GNU Bash, the Bourne Again SHell.-
10-
11 Bash is free software: you can redistribute it and/or modify-
12 it under the terms of the GNU General Public License as published by-
13 the Free Software Foundation, either version 3 of the License, or-
14 (at your option) any later version.-
15-
16 Bash is distributed in the hope that it will be useful,-
17 but WITHOUT ANY WARRANTY; without even the implied warranty of-
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-
19 GNU General Public License for more details.-
20-
21 You should have received a copy of the GNU General Public License-
22 along with Bash. If not, see <http://www.gnu.org/licenses/>.-
23*/-
24-
25#include "config.h"-
26-
27#include "bashtypes.h"-
28#include <stdio.h>-
29#include "chartypes.h"-
30#if defined (HAVE_PWD_H)-
31# include <pwd.h>-
32#endif-
33#include <signal.h>-
34#include <errno.h>-
35-
36#if defined (HAVE_UNISTD_H)-
37# include <unistd.h>-
38#endif-
39-
40#define NEED_FPURGE_DECL-
41-
42#include "bashansi.h"-
43#include "posixstat.h"-
44#include "bashintl.h"-
45-
46#include "shell.h"-
47#include "parser.h"-
48#include "flags.h"-
49#include "jobs.h"-
50#include "execute_cmd.h"-
51#include "filecntl.h"-
52#include "trap.h"-
53#include "pathexp.h"-
54#include "mailcheck.h"-
55-
56#include "shmbutil.h"-
57#if defined (HAVE_MBSTR_H) && defined (HAVE_MBSCHR)-
58# include <mbstr.h> /* mbschr */-
59#endif-
60#include "typemax.h"-
61-
62#include "builtins/getopt.h"-
63#include "builtins/common.h"-
64-
65#include "builtins/builtext.h"-
66-
67#include <tilde/tilde.h>-
68#include <glob/strmatch.h>-
69-
70#if !defined (errno)-
71extern int errno;-
72#endif /* !errno */-
73-
74/* The size that strings change by. */-
75#define DEFAULT_INITIAL_ARRAY_SIZE 112-
76#define DEFAULT_ARRAY_SIZE 128-
77-
78/* Variable types. */-
79#define VT_VARIABLE 0-
80#define VT_POSPARMS 1-
81#define VT_ARRAYVAR 2-
82#define VT_ARRAYMEMBER 3-
83#define VT_ASSOCVAR 4-
84-
85#define VT_STARSUB 128 /* $* or ${array[*]} -- used to split */-
86-
87/* Flags for quoted_strchr */-
88#define ST_BACKSL 0x01-
89#define ST_CTLESC 0x02-
90#define ST_SQUOTE 0x04 /* unused yet */-
91#define ST_DQUOTE 0x08 /* unused yet */-
92-
93/* These defs make it easier to use the editor. */-
94#define LBRACE '{'-
95#define RBRACE '}'-
96#define LPAREN '('-
97#define RPAREN ')'-
98#define LBRACK '['-
99#define RBRACK ']'-
100-
101#if defined (HANDLE_MULTIBYTE)-
102#define WLPAREN L'('-
103#define WRPAREN L')'-
104#endif-
105-
106#define DOLLAR_AT_STAR(c) ((c) == '@' || (c) == '*')-
107#define STR_DOLLAR_AT_STAR(s) (DOLLAR_AT_STAR ((s)[0]) && (s)[1] == '\0')-
108-
109/* Evaluates to 1 if C is one of the shell's special parameters whose length-
110 can be taken, but is also one of the special expansion characters. */-
111#define VALID_SPECIAL_LENGTH_PARAM(c) \-
112 ((c) == '-' || (c) == '?' || (c) == '#' || (c) == '@')-
113-
114/* Evaluates to 1 if C is one of the shell's special parameters for which an-
115 indirect variable reference may be made. */-
116#define VALID_INDIR_PARAM(c) \-
117 ((posixly_correct == 0 && (c) == '#') || (posixly_correct == 0 && (c) == '?') || (c) == '@' || (c) == '*')-
118-
119/* Evaluates to 1 if C is one of the OP characters that follows the parameter-
120 in ${parameter[:]OPword}. */-
121#define VALID_PARAM_EXPAND_CHAR(c) (sh_syntaxtab[(unsigned char)c] & CSUBSTOP)-
122-
123/* Evaluates to 1 if this is one of the shell's special variables. */-
124#define SPECIAL_VAR(name, wi) \-
125 (*name && ((DIGIT (*name) && all_digits (name)) || \-
126 (name[1] == '\0' && (sh_syntaxtab[(unsigned char)*name] & CSPECVAR)) || \-
127 (wi && name[2] == '\0' && VALID_INDIR_PARAM (name[1]))))-
128-
129/* This can be used by all of the *_extract_* functions that have a similar-
130 structure. It can't just be wrapped in a do...while(0) loop because of-
131 the embedded `break'. The dangling else accommodates a trailing semicolon;-
132 we could also put in a do ; while (0) */-
133-
134 -
135#define CHECK_STRING_OVERRUN(oind, ind, len, ch) \-
136 if (ind >= len) \-
137 { \-
138 oind = len; \-
139 ch = 0; \-
140 break; \-
141 } \-
142 else \-
143-
144/* An expansion function that takes a string and a quoted flag and returns-
145 a WORD_LIST *. Used as the type of the third argument to-
146 expand_string_if_necessary(). */-
147typedef WORD_LIST *EXPFUNC __P((char *, int));-
148-
149/* Process ID of the last command executed within command substitution. */-
150pid_t last_command_subst_pid = NO_PID;-
151pid_t current_command_subst_pid = NO_PID;-
152-
153/* Variables used to keep track of the characters in IFS. */-
154SHELL_VAR *ifs_var;-
155char *ifs_value;-
156unsigned char ifs_cmap[UCHAR_MAX + 1];-
157int ifs_is_set, ifs_is_null;-
158-
159#if defined (HANDLE_MULTIBYTE)-
160unsigned char ifs_firstc[MB_LEN_MAX];-
161size_t ifs_firstc_len;-
162#else-
163unsigned char ifs_firstc;-
164#endif-
165-
166/* If non-zero, command substitution inherits the value of errexit option */-
167int inherit_errexit = 0;-
168-
169/* Sentinel to tell when we are performing variable assignments preceding a-
170 command name and putting them into the environment. Used to make sure-
171 we use the temporary environment when looking up variable values. */-
172int assigning_in_environment;-
173-
174/* Used to hold a list of variable assignments preceding a command. Global-
175 so the SIGCHLD handler in jobs.c can unwind-protect it when it runs a-
176 SIGCHLD trap and so it can be saved and restored by the trap handlers. */-
177WORD_LIST *subst_assign_varlist = (WORD_LIST *)NULL;-
178-
179/* Tell the expansion functions to not longjmp back to top_level on fatal-
180 errors. Enabled when doing completion and prompt string expansion. */-
181int no_longjmp_on_fatal_error = 0;-
182-
183/* Non-zero means to allow unmatched globbed filenames to expand to-
184 a null file. */-
185int allow_null_glob_expansion;-
186-
187/* Non-zero means to throw an error when globbing fails to match anything. */-
188int fail_glob_expansion;-
189-
190/* Extern functions and variables from different files. */-
191extern struct fd_bitmap *current_fds_to_close;-
192extern int wordexp_only;-
193-
194#if defined (JOB_CONTROL) && defined (PROCESS_SUBSTITUTION)-
195extern PROCESS *last_procsub_child;-
196#endif-
197-
198#if !defined (HAVE_WCSDUP) && defined (HANDLE_MULTIBYTE)-
199extern wchar_t *wcsdup __P((const wchar_t *));-
200#endif-
201-
202#if 0-
203/* Variables to keep track of which words in an expanded word list (the-
204 output of expand_word_list_internal) are the result of globbing-
205 expansions. GLOB_ARGV_FLAGS is used by execute_cmd.c.-
206 (CURRENTLY UNUSED). */-
207char *glob_argv_flags;-
208static int glob_argv_flags_size;-
209#endif-
210-
211static WORD_LIST *cached_quoted_dollar_at = 0;-
212-
213/* Distinguished error values to return from expansion functions */-
214static WORD_LIST expand_word_error, expand_word_fatal;-
215static WORD_DESC expand_wdesc_error, expand_wdesc_fatal;-
216static char expand_param_error, expand_param_fatal, expand_param_unset;-
217static char extract_string_error, extract_string_fatal;-
218-
219/* Set by expand_word_unsplit and several of the expand_string_XXX functions;-
220 used to inhibit splitting and re-joining $* on $IFS, primarily when doing-
221 assignment statements. The idea is that if we're in a context where this-
222 is set, we're not going to be performing word splitting, so we use the same-
223 rules to expand $* as we would if it appeared within double quotes. */-
224static int expand_no_split_dollar_star = 0;-
225-
226/* A WORD_LIST of words to be expanded by expand_word_list_internal,-
227 without any leading variable assignments. */-
228static WORD_LIST *garglist = (WORD_LIST *)NULL;-
229-
230static char *quoted_substring __P((char *, int, int));-
231static int quoted_strlen __P((char *));-
232static char *quoted_strchr __P((char *, int, int));-
233-
234static char *expand_string_if_necessary __P((char *, int, EXPFUNC *));-
235static inline char *expand_string_to_string_internal __P((char *, int, EXPFUNC *));-
236static WORD_LIST *call_expand_word_internal __P((WORD_DESC *, int, int, int *, int *));-
237static WORD_LIST *expand_string_internal __P((char *, int));-
238static WORD_LIST *expand_string_leave_quoted __P((char *, int));-
239static WORD_LIST *expand_string_for_rhs __P((char *, int, int, int, int *, int *));-
240static WORD_LIST *expand_string_for_pat __P((char *, int, int *, int *));-
241-
242static WORD_LIST *list_quote_escapes __P((WORD_LIST *));-
243static WORD_LIST *list_dequote_escapes __P((WORD_LIST *));-
244-
245static char *make_quoted_char __P((int));-
246static WORD_LIST *quote_list __P((WORD_LIST *));-
247-
248static int unquoted_substring __P((char *, char *));-
249static int unquoted_member __P((int, char *));-
250-
251#if defined (ARRAY_VARS)-
252static SHELL_VAR *do_compound_assignment __P((char *, char *, int));-
253#endif-
254static int do_assignment_internal __P((const WORD_DESC *, int));-
255-
256static char *string_extract_verbatim __P((char *, size_t, int *, char *, int));-
257static char *string_extract __P((char *, int *, char *, int));-
258static char *string_extract_double_quoted __P((char *, int *, int));-
259static inline char *string_extract_single_quoted __P((char *, int *));-
260static inline int skip_single_quoted __P((const char *, size_t, int, int));-
261static int skip_double_quoted __P((char *, size_t, int, int));-
262static char *extract_delimited_string __P((char *, int *, char *, char *, char *, int));-
263static char *extract_dollar_brace_string __P((char *, int *, int, int));-
264static int skip_matched_pair __P((const char *, int, int, int, int));-
265-
266static char *pos_params __P((char *, int, int, int));-
267-
268static unsigned char *mb_getcharlens __P((char *, int));-
269-
270static char *remove_upattern __P((char *, char *, int));-
271#if defined (HANDLE_MULTIBYTE) -
272static wchar_t *remove_wpattern __P((wchar_t *, size_t, wchar_t *, int));-
273#endif-
274static char *remove_pattern __P((char *, char *, int));-
275-
276static int match_upattern __P((char *, char *, int, char **, char **));-
277#if defined (HANDLE_MULTIBYTE)-
278static int match_wpattern __P((wchar_t *, char **, size_t, wchar_t *, int, char **, char **));-
279#endif-
280static int match_pattern __P((char *, char *, int, char **, char **));-
281static int getpatspec __P((int, char *));-
282static char *getpattern __P((char *, int, int));-
283static char *variable_remove_pattern __P((char *, char *, int, int));-
284static char *list_remove_pattern __P((WORD_LIST *, char *, int, int, int));-
285static char *parameter_list_remove_pattern __P((int, char *, int, int));-
286#ifdef ARRAY_VARS-
287static char *array_remove_pattern __P((SHELL_VAR *, char *, int, char *, int));-
288#endif-
289static char *parameter_brace_remove_pattern __P((char *, char *, int, char *, int, int, int));-
290-
291static char *string_var_assignment __P((SHELL_VAR *, char *));-
292#if defined (ARRAY_VARS)-
293static char *array_var_assignment __P((SHELL_VAR *, int, int));-
294#endif-
295static char *pos_params_assignment __P((WORD_LIST *, int, int));-
296static char *string_transform __P((int, SHELL_VAR *, char *));-
297static char *list_transform __P((int, SHELL_VAR *, WORD_LIST *, int, int));-
298static char *parameter_list_transform __P((int, int, int));-
299#if defined ARRAY_VARS-
300static char *array_transform __P((int, SHELL_VAR *, char *, int));-
301#endif-
302static char *parameter_brace_transform __P((char *, char *, int, char *, int, int, int, int));-
303-
304static char *process_substitute __P((char *, int));-
305-
306static char *read_comsub __P((int, int, int, int *));-
307-
308#ifdef ARRAY_VARS-
309static arrayind_t array_length_reference __P((char *));-
310#endif-
311-
312static int valid_brace_expansion_word __P((char *, int));-
313static int chk_atstar __P((char *, int, int *, int *));-
314static int chk_arithsub __P((const char *, int));-
315-
316static WORD_DESC *parameter_brace_expand_word __P((char *, int, int, int, arrayind_t *));-
317static char *parameter_brace_find_indir __P((char *, int, int, int));-
318static WORD_DESC *parameter_brace_expand_indir __P((char *, int, int, int *, int *));-
319static WORD_DESC *parameter_brace_expand_rhs __P((char *, char *, int, int, int, int *, int *));-
320static void parameter_brace_expand_error __P((char *, char *, int));-
321-
322static int valid_length_expression __P((char *));-
323static intmax_t parameter_brace_expand_length __P((char *));-
324-
325static char *skiparith __P((char *, int));-
326static int verify_substring_values __P((SHELL_VAR *, char *, char *, int, intmax_t *, intmax_t *));-
327static int get_var_and_type __P((char *, char *, arrayind_t, int, int, SHELL_VAR **, char **));-
328static char *mb_substring __P((char *, int, int));-
329static char *parameter_brace_substring __P((char *, char *, int, char *, int, int, int));-
330-
331static int shouldexp_replacement __P((char *));-
332-
333static char *pos_params_pat_subst __P((char *, char *, char *, int));-
334-
335static char *parameter_brace_patsub __P((char *, char *, int, char *, int, int, int));-
336-
337static char *pos_params_casemod __P((char *, char *, int, int));-
338static char *parameter_brace_casemod __P((char *, char *, int, int, char *, int, int, int));-
339-
340static WORD_DESC *parameter_brace_expand __P((char *, int *, int, int, int *, int *));-
341static WORD_DESC *param_expand __P((char *, int *, int, int *, int *, int *, int *, int));-
342-
343static WORD_LIST *expand_word_internal __P((WORD_DESC *, int, int, int *, int *));-
344-
345static WORD_LIST *word_list_split __P((WORD_LIST *));-
346-
347static void exp_jump_to_top_level __P((int));-
348-
349static WORD_LIST *separate_out_assignments __P((WORD_LIST *));-
350static WORD_LIST *glob_expand_word_list __P((WORD_LIST *, int));-
351#ifdef BRACE_EXPANSION-
352static WORD_LIST *brace_expand_word_list __P((WORD_LIST *, int));-
353#endif-
354#if defined (ARRAY_VARS)-
355static int make_internal_declare __P((char *, char *, char *));-
356#endif-
357static WORD_LIST *shell_expand_word_list __P((WORD_LIST *, int));-
358static WORD_LIST *expand_word_list_internal __P((WORD_LIST *, int));-
359-
360/* **************************************************************** */-
361/* */-
362/* Utility Functions */-
363/* */-
364/* **************************************************************** */-
365-
366#if defined (DEBUG)-
367void-
368dump_word_flags (flags)-
369 int flags;-
370{-
371 int f;-
372-
373 f = flags;-
374 fprintf (stderr, "%d -> ", f);-
375 if (f & W_ARRAYIND)
f & 0x1000000Description
TRUEnever evaluated
FALSEnever evaluated
0
376 {-
377 f &= ~W_ARRAYIND;-
378 fprintf (stderr, "W_ARRAYIND%s", f ? "|" : "");-
379 }
never executed: end of block
0
380 if (f & W_ASSIGNASSOC)
f & 0x400000Description
TRUEnever evaluated
FALSEnever evaluated
0
381 {-
382 f &= ~W_ASSIGNASSOC;-
383 fprintf (stderr, "W_ASSIGNASSOC%s", f ? "|" : "");-
384 }
never executed: end of block
0
385 if (f & W_ASSIGNARRAY)
f & 0x800000Description
TRUEnever evaluated
FALSEnever evaluated
0
386 {-
387 f &= ~W_ASSIGNARRAY;-
388 fprintf (stderr, "W_ASSIGNARRAY%s", f ? "|" : "");-
389 }
never executed: end of block
0
390 if (f & W_HASCTLESC)
f & 0x200000Description
TRUEnever evaluated
FALSEnever evaluated
0
391 {-
392 f &= ~W_HASCTLESC;-
393 fprintf (stderr, "W_HASCTLESC%s", f ? "|" : "");-
394 }
never executed: end of block
0
395 if (f & W_NOPROCSUB)
f & 0x100000Description
TRUEnever evaluated
FALSEnever evaluated
0
396 {-
397 f &= ~W_NOPROCSUB;-
398 fprintf (stderr, "W_NOPROCSUB%s", f ? "|" : "");-
399 }
never executed: end of block
0
400 if (f & W_DQUOTE)
f & 0x080000Description
TRUEnever evaluated
FALSEnever evaluated
0
401 {-
402 f &= ~W_DQUOTE;-
403 fprintf (stderr, "W_DQUOTE%s", f ? "|" : "");-
404 }
never executed: end of block
0
405 if (f & W_HASQUOTEDNULL)
f & 0x040000Description
TRUEnever evaluated
FALSEnever evaluated
0
406 {-
407 f &= ~W_HASQUOTEDNULL;-
408 fprintf (stderr, "W_HASQUOTEDNULL%s", f ? "|" : "");-
409 }
never executed: end of block
0
410 if (f & W_ASSIGNARG)
f & 0x020000Description
TRUEnever evaluated
FALSEnever evaluated
0
411 {-
412 f &= ~W_ASSIGNARG;-
413 fprintf (stderr, "W_ASSIGNARG%s", f ? "|" : "");-
414 }
never executed: end of block
0
415 if (f & W_ASSNBLTIN)
f & 0x010000Description
TRUEnever evaluated
FALSEnever evaluated
0
416 {-
417 f &= ~W_ASSNBLTIN;-
418 fprintf (stderr, "W_ASSNBLTIN%s", f ? "|" : "");-
419 }
never executed: end of block
0
420 if (f & W_ASSNGLOBAL)
f & 0x2000000Description
TRUEnever evaluated
FALSEnever evaluated
0
421 {-
422 f &= ~W_ASSNGLOBAL;-
423 fprintf (stderr, "W_ASSNGLOBAL%s", f ? "|" : "");-
424 }
never executed: end of block
0
425 if (f & W_COMPASSIGN)
f & 0x008000Description
TRUEnever evaluated
FALSEnever evaluated
0
426 {-
427 f &= ~W_COMPASSIGN;-
428 fprintf (stderr, "W_COMPASSIGN%s", f ? "|" : "");-
429 }
never executed: end of block
0
430 if (f & W_NOEXPAND)
f & 0x004000Description
TRUEnever evaluated
FALSEnever evaluated
0
431 {-
432 f &= ~W_NOEXPAND;-
433 fprintf (stderr, "W_NOEXPAND%s", f ? "|" : "");-
434 }
never executed: end of block
0
435 if (f & W_ITILDE)
f & 0x002000Description
TRUEnever evaluated
FALSEnever evaluated
0
436 {-
437 f &= ~W_ITILDE;-
438 fprintf (stderr, "W_ITILDE%s", f ? "|" : "");-
439 }
never executed: end of block
0
440 if (f & W_NOTILDE)
f & 0x001000Description
TRUEnever evaluated
FALSEnever evaluated
0
441 {-
442 f &= ~W_NOTILDE;-
443 fprintf (stderr, "W_NOTILDE%s", f ? "|" : "");-
444 }
never executed: end of block
0
445 if (f & W_ASSIGNRHS)
f & 0x000800Description
TRUEnever evaluated
FALSEnever evaluated
0
446 {-
447 f &= ~W_ASSIGNRHS;-
448 fprintf (stderr, "W_ASSIGNRHS%s", f ? "|" : "");-
449 }
never executed: end of block
0
450 if (f & W_NOASSNTILDE)
f & 0x20000000Description
TRUEnever evaluated
FALSEnever evaluated
0
451 {-
452 f &= ~W_NOASSNTILDE;-
453 fprintf (stderr, "W_NOASSNTILDE%s", f ? "|" : "");-
454 }
never executed: end of block
0
455 if (f & W_NOCOMSUB)
f & 0x000400Description
TRUEnever evaluated
FALSEnever evaluated
0
456 {-
457 f &= ~W_NOCOMSUB;-
458 fprintf (stderr, "W_NOCOMSUB%s", f ? "|" : "");-
459 }
never executed: end of block
0
460 if (f & W_DOLLARSTAR)
f & 0x000200Description
TRUEnever evaluated
FALSEnever evaluated
0
461 {-
462 f &= ~W_DOLLARSTAR;-
463 fprintf (stderr, "W_DOLLARSTAR%s", f ? "|" : "");-
464 }
never executed: end of block
0
465 if (f & W_DOLLARAT)
f & 0x000100Description
TRUEnever evaluated
FALSEnever evaluated
0
466 {-
467 f &= ~W_DOLLARAT;-
468 fprintf (stderr, "W_DOLLARAT%s", f ? "|" : "");-
469 }
never executed: end of block
0
470 if (f & W_TILDEEXP)
f & 0x000080Description
TRUEnever evaluated
FALSEnever evaluated
0
471 {-
472 f &= ~W_TILDEEXP;-
473 fprintf (stderr, "W_TILDEEXP%s", f ? "|" : "");-
474 }
never executed: end of block
0
475 if (f & W_NOSPLIT2)
f & 0x000040Description
TRUEnever evaluated
FALSEnever evaluated
0
476 {-
477 f &= ~W_NOSPLIT2;-
478 fprintf (stderr, "W_NOSPLIT2%s", f ? "|" : "");-
479 }
never executed: end of block
0
480 if (f & W_NOSPLIT)
f & 0x000010Description
TRUEnever evaluated
FALSEnever evaluated
0
481 {-
482 f &= ~W_NOSPLIT;-
483 fprintf (stderr, "W_NOSPLIT%s", f ? "|" : "");-
484 }
never executed: end of block
0
485 if (f & W_NOBRACE)
f & 0x4000000Description
TRUEnever evaluated
FALSEnever evaluated
0
486 {-
487 f &= ~W_NOBRACE;-
488 fprintf (stderr, "W_NOBRACE%s", f ? "|" : "");-
489 }
never executed: end of block
0
490 if (f & W_NOGLOB)
f & 0x000020Description
TRUEnever evaluated
FALSEnever evaluated
0
491 {-
492 f &= ~W_NOGLOB;-
493 fprintf (stderr, "W_NOGLOB%s", f ? "|" : "");-
494 }
never executed: end of block
0
495 if (f & W_SPLITSPACE)
f & 0x000008Description
TRUEnever evaluated
FALSEnever evaluated
0
496 {-
497 f &= ~W_SPLITSPACE;-
498 fprintf (stderr, "W_SPLITSPACE%s", f ? "|" : "");-
499 }
never executed: end of block
0
500 if (f & W_ASSIGNMENT)
f & 0x000004Description
TRUEnever evaluated
FALSEnever evaluated
0
501 {-
502 f &= ~W_ASSIGNMENT;-
503 fprintf (stderr, "W_ASSIGNMENT%s", f ? "|" : "");-
504 }
never executed: end of block
0
505 if (f & W_QUOTED)
f & 0x000002Description
TRUEnever evaluated
FALSEnever evaluated
0
506 {-
507 f &= ~W_QUOTED;-
508 fprintf (stderr, "W_QUOTED%s", f ? "|" : "");-
509 }
never executed: end of block
0
510 if (f & W_HASDOLLAR)
f & 0x000001Description
TRUEnever evaluated
FALSEnever evaluated
0
511 {-
512 f &= ~W_HASDOLLAR;-
513 fprintf (stderr, "W_HASDOLLAR%s", f ? "|" : "");-
514 }
never executed: end of block
0
515 if (f & W_COMPLETE)
f & 0x8000000Description
TRUEnever evaluated
FALSEnever evaluated
0
516 {-
517 f &= ~W_COMPLETE;-
518 fprintf (stderr, "W_COMPLETE%s", f ? "|" : "");-
519 }
never executed: end of block
0
520 if (f & W_CHKLOCAL)
f & 0x10000000Description
TRUEnever evaluated
FALSEnever evaluated
0
521 {-
522 f &= ~W_CHKLOCAL;-
523 fprintf (stderr, "W_CHKLOCAL%s", f ? "|" : "");-
524 }
never executed: end of block
0
525 -
526 fprintf (stderr, "\n");-
527 fflush (stderr);-
528}
never executed: end of block
0
529#endif-
530-
531#ifdef INCLUDE_UNUSED-
532static char *-
533quoted_substring (string, start, end)-
534 char *string;-
535 int start, end;-
536{-
537 register int len, l;-
538 register char *result, *s, *r;-
539-
540 len = end - start;-
541-
542 /* Move to string[start], skipping quoted characters. */-
543 for (s = string, l = 0; *s && l < start; )-
544 {-
545 if (*s == CTLESC)-
546 {-
547 s++;-
548 continue;-
549 }-
550 l++;-
551 if (*s == 0)-
552 break;-
553 }-
554-
555 r = result = (char *)xmalloc (2*len + 1); /* save room for quotes */-
556-
557 /* Copy LEN characters, including quote characters. */-
558 s = string + l;-
559 for (l = 0; l < len; s++)-
560 {-
561 if (*s == CTLESC)-
562 *r++ = *s++;-
563 *r++ = *s;-
564 l++;-
565 if (*s == 0)-
566 break;-
567 }-
568 *r = '\0';-
569 return result;-
570}-
571#endif-
572-
573#ifdef INCLUDE_UNUSED-
574/* Return the length of S, skipping over quoted characters */-
575static int-
576quoted_strlen (s)-
577 char *s;-
578{-
579 register char *p;-
580 int i;-
581-
582 i = 0;-
583 for (p = s; *p; p++)-
584 {-
585 if (*p == CTLESC)-
586 {-
587 p++;-
588 if (*p == 0)-
589 return (i + 1);-
590 }-
591 i++;-
592 }-
593-
594 return i;-
595}-
596#endif-
597-
598#ifdef INCLUDE_UNUSED-
599/* Find the first occurrence of character C in string S, obeying shell-
600 quoting rules. If (FLAGS & ST_BACKSL) is non-zero, backslash-escaped-
601 characters are skipped. If (FLAGS & ST_CTLESC) is non-zero, characters-
602 escaped with CTLESC are skipped. */-
603static char *-
604quoted_strchr (s, c, flags)-
605 char *s;-
606 int c, flags;-
607{-
608 register char *p;-
609-
610 for (p = s; *p; p++)-
611 {-
612 if (((flags & ST_BACKSL) && *p == '\\')-
613 || ((flags & ST_CTLESC) && *p == CTLESC))-
614 {-
615 p++;-
616 if (*p == '\0')-
617 return ((char *)NULL);-
618 continue;-
619 }-
620 else if (*p == c)-
621 return p;-
622 }-
623 return ((char *)NULL);-
624}-
625-
626/* Return 1 if CHARACTER appears in an unquoted portion of-
627 STRING. Return 0 otherwise. CHARACTER must be a single-byte character. */-
628static int-
629unquoted_member (character, string)-
630 int character;-
631 char *string;-
632{-
633 size_t slen;-
634 int sindex, c;-
635 DECLARE_MBSTATE;-
636-
637 slen = strlen (string);-
638 sindex = 0;-
639 while (c = string[sindex])-
640 {-
641 if (c == character)-
642 return (1);-
643-
644 switch (c)-
645 {-
646 default:-
647 ADVANCE_CHAR (string, slen, sindex);-
648 break;-
649-
650 case '\\':-
651 sindex++;-
652 if (string[sindex])-
653 ADVANCE_CHAR (string, slen, sindex);-
654 break;-
655-
656 case '\'':-
657 sindex = skip_single_quoted (string, slen, ++sindex, 0);-
658 break;-
659-
660 case '"':-
661 sindex = skip_double_quoted (string, slen, ++sindex, 0);-
662 break;-
663 }-
664 }-
665 return (0);-
666}-
667-
668/* Return 1 if SUBSTR appears in an unquoted portion of STRING. */-
669static int-
670unquoted_substring (substr, string)-
671 char *substr, *string;-
672{-
673 size_t slen;-
674 int sindex, c, sublen;-
675 DECLARE_MBSTATE;-
676-
677 if (substr == 0 || *substr == '\0')-
678 return (0);-
679-
680 slen = strlen (string);-
681 sublen = strlen (substr);-
682 for (sindex = 0; c = string[sindex]; )-
683 {-
684 if (STREQN (string + sindex, substr, sublen))-
685 return (1);-
686-
687 switch (c)-
688 {-
689 case '\\':-
690 sindex++;-
691 if (string[sindex])-
692 ADVANCE_CHAR (string, slen, sindex);-
693 break;-
694-
695 case '\'':-
696 sindex = skip_single_quoted (string, slen, ++sindex, 0);-
697 break;-
698-
699 case '"':-
700 sindex = skip_double_quoted (string, slen, ++sindex, 0);-
701 break;-
702-
703 default:-
704 ADVANCE_CHAR (string, slen, sindex);-
705 break;-
706 }-
707 }-
708 return (0);-
709}-
710#endif-
711-
712/* Most of the substitutions must be done in parallel. In order-
713 to avoid using tons of unclear goto's, I have some functions-
714 for manipulating malloc'ed strings. They all take INDX, a-
715 pointer to an integer which is the offset into the string-
716 where manipulation is taking place. They also take SIZE, a-
717 pointer to an integer which is the current length of the-
718 character array for this string. */-
719-
720/* Append SOURCE to TARGET at INDEX. SIZE is the current amount-
721 of space allocated to TARGET. SOURCE can be NULL, in which-
722 case nothing happens. Gets rid of SOURCE by freeing it.-
723 Returns TARGET in case the location has changed. */-
724INLINE char *-
725sub_append_string (source, target, indx, size)-
726 char *source, *target;-
727 int *indx;-
728 size_t *size;-
729{-
730 if (source)
sourceDescription
TRUEevaluated 390464861 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-390464861
731 {-
732 int n;-
733 size_t srclen;-
734-
735 srclen = STRLEN (source);
(source)[1]Description
TRUEevaluated 147985904 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 225929227 times by 1 test
Evaluated by:
  • Self test
(source)[2]Description
TRUEevaluated 81289883 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 66696021 times by 1 test
Evaluated by:
  • Self test
(source)Description
TRUEevaluated 390464861 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(source)[0]Description
TRUEevaluated 373915131 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16549730 times by 1 test
Evaluated by:
  • Self test
0-390464861
736 if (srclen >= (int)(*size - *indx))
srclen >= (int)(*size - *indx)Description
TRUEevaluated 5186 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 390459675 times by 1 test
Evaluated by:
  • Self test
5186-390459675
737 {-
738 n = srclen + *indx;-
739 n = (n + DEFAULT_ARRAY_SIZE) - (n % DEFAULT_ARRAY_SIZE);-
740 target = (char *)xrealloc (target, (*size = n));-
741 }
executed 5186 times by 1 test: end of block
Executed by:
  • Self test
5186
742-
743 FASTCOPY (source, target + *indx, srclen);-
744 *indx += srclen;-
745 target[*indx] = '\0';-
746-
747 free (source);-
748 }
executed 390464861 times by 1 test: end of block
Executed by:
  • Self test
390464861
749 return (target);
executed 390464861 times by 1 test: return (target);
Executed by:
  • Self test
390464861
750}-
751-
752#if 0-
753/* UNUSED */-
754/* Append the textual representation of NUMBER to TARGET.-
755 INDX and SIZE are as in SUB_APPEND_STRING. */-
756char *-
757sub_append_number (number, target, indx, size)-
758 intmax_t number;-
759 char *target;-
760 int *indx;-
761 size_t *size;-
762{-
763 char *temp;-
764-
765 temp = itos (number);-
766 return (sub_append_string (temp, target, indx, size));-
767}-
768#endif-
769-
770/* Extract a substring from STRING, starting at SINDEX and ending with-
771 one of the characters in CHARLIST. Don't make the ending character-
772 part of the string. Leave SINDEX pointing at the ending character.-
773 Understand about backslashes in the string. If (flags & SX_VARNAME)-
774 is non-zero, and array variables have been compiled into the shell,-
775 everything between a `[' and a corresponding `]' is skipped over.-
776 If (flags & SX_NOALLOC) is non-zero, don't return the substring, just-
777 update SINDEX. If (flags & SX_REQMATCH) is non-zero, the string must-
778 contain a closing character from CHARLIST. */-
779static char *-
780string_extract (string, sindex, charlist, flags)-
781 char *string;-
782 int *sindex;-
783 char *charlist;-
784 int flags;-
785{-
786 register int c, i;-
787 int found;-
788 size_t slen;-
789 char *temp;-
790 DECLARE_MBSTATE;-
791-
792 slen = (MB_CUR_MAX > 1) ? strlen (string + *sindex) + *sindex : 0;
( (__ctype_get...r_max ()) > 1)Description
TRUEevaluated 5600715 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 652 times by 1 test
Evaluated by:
  • Self test
652-5600715
793 i = *sindex;-
794 found = 0;-
795 while (c = string[i])
c = string[i]Description
TRUEevaluated 211573938 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2-211573938
796 {-
797 if (c == '\\')
c == '\\'Description
TRUEevaluated 358 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 211573580 times by 1 test
Evaluated by:
  • Self test
358-211573580
798 {-
799 if (string[i + 1])
string[i + 1]Description
TRUEevaluated 358 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-358
800 i++;
executed 358 times by 1 test: i++;
Executed by:
  • Self test
358
801 else-
802 break;
never executed: break;
0
803 }-
804#if defined (ARRAY_VARS)-
805 else if ((flags & SX_VARNAME) && c == LBRACK)
(flags & 0x0002)Description
TRUEevaluated 4874176 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 206699404 times by 1 test
Evaluated by:
  • Self test
c == '['Description
TRUEevaluated 6225 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4867951 times by 1 test
Evaluated by:
  • Self test
6225-206699404
806 {-
807 int ni;-
808 /* If this is an array subscript, skip over it and continue. */-
809 ni = skipsubscript (string, i, 0);-
810 if (string[ni] == RBRACK)
string[ni] == ']'Description
TRUEevaluated 6225 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-6225
811 i = ni;
executed 6225 times by 1 test: i = ni;
Executed by:
  • Self test
6225
812 }
executed 6225 times by 1 test: end of block
Executed by:
  • Self test
6225
813#endif-
814 else if (MEMBER (c, charlist))
(c)Description
TRUEevaluated 208335641 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(c)Description
TRUEevaluated 211567355 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
c == (charlist)[0]Description
TRUEevaluated 4389750 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 207177605 times by 1 test
Evaluated by:
  • Self test
!(charlist)[1]Description
TRUEevaluated 3231714 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1158036 times by 1 test
Evaluated by:
  • Self test
(((c) ? ((char...d *)0) ) : 0))Description
TRUEevaluated 2369651 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 205965990 times by 1 test
Evaluated by:
  • Self test
0-211567355
815 {-
816 found = 1;-
817 break;
executed 5601365 times by 1 test: break;
Executed by:
  • Self test
5601365
818 }-
819-
820 ADVANCE_CHAR (string, slen, i);
executed 193047879 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 12918103 times by 1 test: mblength = 1;
Executed by:
  • Self test
never executed: end of block
never executed: end of block
never executed: (i)++;
executed 205965982 times by 1 test: (i) += mblength;
Executed by:
  • Self test
executed 6591 times by 1 test: (i)++;
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 205965982 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6591 times by 1 test
Evaluated by:
  • Self test
_fDescription
TRUEevaluated 193047879 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12918103 times by 1 test
Evaluated by:
  • Self test
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 205965982 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 12918103 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEevaluated 12918103 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 205965982 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 205965982 times by 1 test
Evaluated by:
  • Self test
0-205965982
821 }
executed 205972573 times by 1 test: end of block
Executed by:
  • Self test
205972573
822-
823 /* If we had to have a matching delimiter and didn't find one, return an-
824 error and let the caller deal with it. */-
825 if ((flags & SX_REQMATCH) && found == 0)
(flags & 0x0004)Description
TRUEevaluated 3231120 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2370247 times by 1 test
Evaluated by:
  • Self test
found == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3231118 times by 1 test
Evaluated by:
  • Self test
2-3231120
826 {-
827 *sindex = i;-
828 return (&extract_string_error);
executed 2 times by 1 test: return (&extract_string_error);
Executed by:
  • Self test
2
829 }-
830 -
831 temp = (flags & SX_NOALLOC) ? (char *)NULL : substring (string, *sindex, i);
(flags & 0x0001)Description
TRUEevaluated 123 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5601242 times by 1 test
Evaluated by:
  • Self test
123-5601242
832 *sindex = i;-
833 -
834 return (temp);
executed 5601365 times by 1 test: return (temp);
Executed by:
  • Self test
5601365
835}-
836-
837/* Extract the contents of STRING as if it is enclosed in double quotes.-
838 SINDEX, when passed in, is the offset of the character immediately-
839 following the opening double quote; on exit, SINDEX is left pointing after-
840 the closing double quote. If STRIPDQ is non-zero, unquoted double-
841 quotes are stripped and the string is terminated by a null byte.-
842 Backslashes between the embedded double quotes are processed. If STRIPDQ-
843 is zero, an unquoted `"' terminates the string. */-
844static char *-
845string_extract_double_quoted (string, sindex, flags)-
846 char *string;-
847 int *sindex, flags;-
848{-
849 size_t slen;-
850 char *send;-
851 int j, i, t;-
852 unsigned char c;-
853 char *temp, *ret; /* The new string we return. */-
854 int pass_next, backquote, si; /* State variables for the machine. */-
855 int dquote;-
856 int stripdq;-
857 DECLARE_MBSTATE;-
858-
859 slen = strlen (string + *sindex) + *sindex;-
860 send = string + slen;-
861-
862 stripdq = (flags & SX_STRIPDQ);-
863-
864 pass_next = backquote = dquote = 0;-
865 temp = (char *)xmalloc (1 + slen - *sindex);-
866-
867 j = 0;-
868 i = *sindex;-
869 while (c = string[i])
c = string[i]Description
TRUEevaluated 183584657 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2049 times by 1 test
Evaluated by:
  • Self test
2049-183584657
870 {-
871 /* Process a character that was quoted by a backslash. */-
872 if (pass_next)
pass_nextDescription
TRUEevaluated 3018 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 183581639 times by 1 test
Evaluated by:
  • Self test
3018-183581639
873 {-
874 /* XXX - take another look at this in light of Interp 221 */-
875 /* Posix.2 sez:-
876-
877 ``The backslash shall retain its special meaning as an escape-
878 character only when followed by one of the characters:-
879 $ ` " \ <newline>''.-
880-
881 If STRIPDQ is zero, we handle the double quotes here and let-
882 expand_word_internal handle the rest. If STRIPDQ is non-zero,-
883 we have already been through one round of backslash stripping,-
884 and want to strip these backslashes only if DQUOTE is non-zero,-
885 indicating that we are inside an embedded double-quoted string. */-
886-
887 /* If we are in an embedded quoted string, then don't strip-
888 backslashes before characters for which the backslash-
889 retains its special meaning, but remove backslashes in-
890 front of other characters. If we are not in an-
891 embedded quoted string, don't strip backslashes at all.-
892 This mess is necessary because the string was already-
893 surrounded by double quotes (and sh has some really weird-
894 quoting rules).-
895 The returned string will be run through expansion as if-
896 it were double-quoted. */-
897 if ((stripdq == 0 && c != '"') ||
stripdq == 0Description
TRUEevaluated 2942 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 76 times by 1 test
Evaluated by:
  • Self test
c != '"'Description
TRUEevaluated 2361 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 581 times by 1 test
Evaluated by:
  • Self test
76-2942
898 (stripdq && ((dquote && (sh_syntaxtab[c] & CBSDQUOTE)) || dquote == 0)))
stripdqDescription
TRUEevaluated 76 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 581 times by 1 test
Evaluated by:
  • Self test
dquoteDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 69 times by 1 test
Evaluated by:
  • Self test
(sh_syntaxtab[c] & 0x0040)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
dquote == 0Description
TRUEevaluated 69 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
3-581
899 temp[j++] = '\\';
executed 2433 times by 1 test: temp[j++] = '\\';
Executed by:
  • Self test
2433
900 pass_next = 0;-
901-
902add_one_character:
code before this statement executed 3018 times by 1 test: add_one_character:
Executed by:
  • Self test
3018
903 COPY_CHAR_I (temp, j, string, send, i);
executed 108873915 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 48187202 times by 1 test: end of block
Executed by:
  • Self test
never executed: end of block
executed 157061117 times by 1 test: mblength = (mblength < 1) ? 1 : mblength;
Executed by:
  • Self test
executed 157061117 times by 1 test: temp[j++] = string[i++];
Executed by:
  • Self test
executed 157061117 times by 1 test: end of block
Executed by:
  • Self test
executed 7431 times by 1 test: temp[j++] = string[i++];
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 157061117 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7431 times by 1 test
Evaluated by:
  • Self test
_kDescription
TRUEevaluated 108873915 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 48187202 times by 1 test
Evaluated by:
  • Self test
_k < mblengthDescription
TRUEevaluated 157061117 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 157061117 times by 1 test
Evaluated by:
  • Self test
(mblength < 1)Description
TRUEnever evaluated
FALSEevaluated 157061117 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 157061117 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 157061117 times by 1 test
Evaluated by:
  • Self test
0-157061117
904 continue;
executed 157068548 times by 1 test: continue;
Executed by:
  • Self test
157068548
905 }-
906-
907 /* A backslash protects the next character. The code just above-
908 handles preserving the backslash in front of any character but-
909 a double quote. */-
910 if (c == '\\')
c == '\\'Description
TRUEevaluated 3018 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 183578621 times by 1 test
Evaluated by:
  • Self test
3018-183578621
911 {-
912 pass_next++;-
913 i++;-
914 continue;
executed 3018 times by 1 test: continue;
Executed by:
  • Self test
3018
915 }-
916-
917 /* Inside backquotes, ``the portion of the quoted string from the-
918 initial backquote and the characters up to the next backquote-
919 that is not preceded by a backslash, having escape characters-
920 removed, defines that command''. */-
921 if (backquote)
backquoteDescription
TRUEevaluated 2151 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 183576470 times by 1 test
Evaluated by:
  • Self test
2151-183576470
922 {-
923 if (c == '`')
c == '`'Description
TRUEevaluated 175 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1976 times by 1 test
Evaluated by:
  • Self test
175-1976
924 backquote = 0;
executed 175 times by 1 test: backquote = 0;
Executed by:
  • Self test
175
925 temp[j++] = c; /* COPY_CHAR_I? */-
926 i++;-
927 continue;
executed 2151 times by 1 test: continue;
Executed by:
  • Self test
2151
928 }-
929-
930 if (c == '`')
c == '`'Description
TRUEevaluated 175 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 183576295 times by 1 test
Evaluated by:
  • Self test
175-183576295
931 {-
932 temp[j++] = c;-
933 backquote++;-
934 i++;-
935 continue;
executed 175 times by 1 test: continue;
Executed by:
  • Self test
175
936 }-
937-
938 /* Pass everything between `$(' and the matching `)' or a quoted-
939 ${ ... } pair through according to the Posix.2 specification. */-
940 if (c == '$' && ((string[i + 1] == LPAREN) || (string[i + 1] == LBRACE)))
c == '$'Description
TRUEevaluated 48219730 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 135356565 times by 1 test
Evaluated by:
  • Self test
(string[i + 1] == '(')Description
TRUEevaluated 5395 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 48214335 times by 1 test
Evaluated by:
  • Self test
(string[i + 1] == '{')Description
TRUEevaluated 30072 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 48184263 times by 1 test
Evaluated by:
  • Self test
5395-135356565
941 {-
942 int free_ret = 1;-
943-
944 si = i + 2;-
945 if (string[i + 1] == LPAREN)
string[i + 1] == '('Description
TRUEevaluated 5395 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 30072 times by 1 test
Evaluated by:
  • Self test
5395-30072
946 ret = extract_command_subst (string, &si, (flags & SX_COMPLETE));
executed 5395 times by 1 test: ret = extract_command_subst (string, &si, (flags & 0x0400));
Executed by:
  • Self test
5395
947 else-
948 ret = extract_dollar_brace_string (string, &si, Q_DOUBLE_QUOTES, 0);
executed 30072 times by 1 test: ret = extract_dollar_brace_string (string, &si, 0x001, 0);
Executed by:
  • Self test
30072
949-
950 temp[j++] = '$';-
951 temp[j++] = string[i + 1];-
952-
953 /* Just paranoia; ret will not be 0 unless no_longjmp_on_fatal_error-
954 is set. */-
955 if (ret == 0 && no_longjmp_on_fatal_error)
ret == 0Description
TRUEnever evaluated
FALSEevaluated 35467 times by 1 test
Evaluated by:
  • Self test
no_longjmp_on_fatal_errorDescription
TRUEnever evaluated
FALSEnever evaluated
0-35467
956 {-
957 free_ret = 0;-
958 ret = string + i + 2;-
959 }
never executed: end of block
0
960-
961 /* XXX - CHECK_STRING_OVERRUN here? */-
962 for (t = 0; ret[t]; t++, j++)
ret[t]Description
TRUEevaluated 398419 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 35467 times by 1 test
Evaluated by:
  • Self test
35467-398419
963 temp[j] = ret[t];
executed 398419 times by 1 test: temp[j] = ret[t];
Executed by:
  • Self test
398419
964 temp[j] = string[si];-
965-
966 if (string[si])
string[si]Description
TRUEevaluated 35467 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-35467
967 {-
968 j++;-
969 i = si + 1;-
970 }
executed 35467 times by 1 test: end of block
Executed by:
  • Self test
35467
971 else-
972 i = si;
never executed: i = si;
0
973-
974 if (free_ret)
free_retDescription
TRUEevaluated 35467 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-35467
975 free (ret);
executed 35467 times by 1 test: sh_xfree((ret), "subst.c", 975);
Executed by:
  • Self test
35467
976 continue;
executed 35467 times by 1 test: continue;
Executed by:
  • Self test
35467
977 }-
978-
979 /* Add any character but a double quote to the quoted string we're-
980 accumulating. */-
981 if (c != '"')
c != '"'Description
TRUEevaluated 157065530 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 26475298 times by 1 test
Evaluated by:
  • Self test
26475298-157065530
982 goto add_one_character;
executed 157065530 times by 1 test: goto add_one_character;
Executed by:
  • Self test
157065530
983-
984 /* c == '"' */-
985 if (stripdq)
stripdqDescription
TRUEevaluated 242 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 26475056 times by 1 test
Evaluated by:
  • Self test
242-26475056
986 {-
987 dquote ^= 1;-
988 i++;-
989 continue;
executed 242 times by 1 test: continue;
Executed by:
  • Self test
242
990 }-
991-
992 break;
executed 26475056 times by 1 test: break;
Executed by:
  • Self test
26475056
993 }-
994 temp[j] = '\0';-
995-
996 /* Point to after the closing quote. */-
997 if (c)
cDescription
TRUEevaluated 26475056 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2049 times by 1 test
Evaluated by:
  • Self test
2049-26475056
998 i++;
executed 26475056 times by 1 test: i++;
Executed by:
  • Self test
26475056
999 *sindex = i;-
1000-
1001 return (temp);
executed 26477105 times by 1 test: return (temp);
Executed by:
  • Self test
26477105
1002}-
1003-
1004/* This should really be another option to string_extract_double_quoted. */-
1005static int-
1006skip_double_quoted (string, slen, sind, flags)-
1007 char *string;-
1008 size_t slen;-
1009 int sind;-
1010 int flags;-
1011{-
1012 int c, i;-
1013 char *ret;-
1014 int pass_next, backquote, si;-
1015 DECLARE_MBSTATE;-
1016-
1017 pass_next = backquote = 0;-
1018 i = sind;-
1019 while (c = string[i])
c = string[i]Description
TRUEevaluated 41887 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-41887
1020 {-
1021 if (pass_next)
pass_nextDescription
TRUEevaluated 71 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 41816 times by 1 test
Evaluated by:
  • Self test
71-41816
1022 {-
1023 pass_next = 0;-
1024 ADVANCE_CHAR (string, slen, i);
executed 60 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 6 times by 1 test: mblength = 1;
Executed by:
  • Self test
never executed: end of block
never executed: end of block
never executed: (i)++;
executed 66 times by 1 test: (i) += mblength;
Executed by:
  • Self test
executed 5 times by 1 test: (i)++;
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 66 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
_fDescription
TRUEevaluated 60 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 66 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 66 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 66 times by 1 test
Evaluated by:
  • Self test
0-66
1025 continue;
executed 71 times by 1 test: continue;
Executed by:
  • Self test
71
1026 }-
1027 else if (c == '\\')
c == '\\'Description
TRUEevaluated 71 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 41745 times by 1 test
Evaluated by:
  • Self test
71-41745
1028 {-
1029 pass_next++;-
1030 i++;-
1031 continue;
executed 71 times by 1 test: continue;
Executed by:
  • Self test
71
1032 }-
1033 else if (backquote)
backquoteDescription
TRUEevaluated 562 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 41183 times by 1 test
Evaluated by:
  • Self test
562-41183
1034 {-
1035 if (c == '`')
c == '`'Description
TRUEevaluated 63 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 499 times by 1 test
Evaluated by:
  • Self test
63-499
1036 backquote = 0;
executed 63 times by 1 test: backquote = 0;
Executed by:
  • Self test
63
1037 ADVANCE_CHAR (string, slen, i);
executed 441 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 121 times by 1 test: mblength = 1;
Executed by:
  • Self test
never executed: end of block
never executed: end of block
never executed: (i)++;
executed 562 times by 1 test: (i) += mblength;
Executed by:
  • Self test
never executed: (i)++;
locale_mb_cur_max > 1Description
TRUEevaluated 562 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
_fDescription
TRUEevaluated 441 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 121 times by 1 test
Evaluated by:
  • Self test
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 562 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 121 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEevaluated 121 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 562 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 562 times by 1 test
Evaluated by:
  • Self test
0-562
1038 continue;
executed 562 times by 1 test: continue;
Executed by:
  • Self test
562
1039 }-
1040 else if (c == '`')
c == '`'Description
TRUEevaluated 63 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 41120 times by 1 test
Evaluated by:
  • Self test
63-41120
1041 {-
1042 backquote++;-
1043 i++;-
1044 continue;
executed 63 times by 1 test: continue;
Executed by:
  • Self test
63
1045 }-
1046 else if (c == '$' && ((string[i + 1] == LPAREN) || (string[i + 1] == LBRACE)))
c == '$'Description
TRUEevaluated 16265 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 24855 times by 1 test
Evaluated by:
  • Self test
(string[i + 1] == '(')Description
TRUEevaluated 41 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16224 times by 1 test
Evaluated by:
  • Self test
(string[i + 1] == '{')Description
TRUEevaluated 14137 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2087 times by 1 test
Evaluated by:
  • Self test
41-24855
1047 {-
1048 si = i + 2;-
1049 if (string[i + 1] == LPAREN)
string[i + 1] == '('Description
TRUEevaluated 41 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14137 times by 1 test
Evaluated by:
  • Self test
41-14137
1050 ret = extract_command_subst (string, &si, SX_NOALLOC|(flags&SX_COMPLETE));
executed 41 times by 1 test: ret = extract_command_subst (string, &si, 0x0001|(flags&0x0400));
Executed by:
  • Self test
41
1051 else-
1052 ret = extract_dollar_brace_string (string, &si, Q_DOUBLE_QUOTES, SX_NOALLOC);
executed 14137 times by 1 test: ret = extract_dollar_brace_string (string, &si, 0x001, 0x0001);
Executed by:
  • Self test
14137
1053-
1054 /* These can consume the entire string if they are unterminated */-
1055 CHECK_STRING_OVERRUN (i, si, slen, c);
never executed: break;
executed 14178 times by 1 test: ;
Executed by:
  • Self test
si >= slenDescription
TRUEnever evaluated
FALSEevaluated 14178 times by 1 test
Evaluated by:
  • Self test
0-14178
1056-
1057 i = si + 1;-
1058 continue;
executed 14178 times by 1 test: continue;
Executed by:
  • Self test
14178
1059 }-
1060 else if (c != '"')
c != '"'Description
TRUEevaluated 9245 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 17697 times by 1 test
Evaluated by:
  • Self test
9245-17697
1061 {-
1062 ADVANCE_CHAR (string, slen, i);
executed 5972 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 3003 times by 1 test: mblength = 1;
Executed by:
  • Self test
never executed: end of block
never executed: end of block
never executed: (i)++;
executed 8975 times by 1 test: (i) += mblength;
Executed by:
  • Self test
executed 270 times by 1 test: (i)++;
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 8975 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 270 times by 1 test
Evaluated by:
  • Self test
_fDescription
TRUEevaluated 5972 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3003 times by 1 test
Evaluated by:
  • Self test
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 8975 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 3003 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEevaluated 3003 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 8975 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 8975 times by 1 test
Evaluated by:
  • Self test
0-8975
1063 continue;
executed 9245 times by 1 test: continue;
Executed by:
  • Self test
9245
1064 }-
1065 else-
1066 break;
executed 17697 times by 1 test: break;
Executed by:
  • Self test
17697
1067 }-
1068-
1069 if (c)
cDescription
TRUEevaluated 17697 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-17697
1070 i++;
executed 17697 times by 1 test: i++;
Executed by:
  • Self test
17697
1071-
1072 return (i);
executed 17698 times by 1 test: return (i);
Executed by:
  • Self test
17698
1073}-
1074-
1075/* Extract the contents of STRING as if it is enclosed in single quotes.-
1076 SINDEX, when passed in, is the offset of the character immediately-
1077 following the opening single quote; on exit, SINDEX is left pointing after-
1078 the closing single quote. */-
1079static inline char *-
1080string_extract_single_quoted (string, sindex)-
1081 char *string;-
1082 int *sindex;-
1083{-
1084 register int i;-
1085 size_t slen;-
1086 char *t;-
1087 DECLARE_MBSTATE;-
1088-
1089 /* Don't need slen for ADVANCE_CHAR unless multibyte chars possible. */-
1090 slen = (MB_CUR_MAX > 1) ? strlen (string + *sindex) + *sindex : 0;
( (__ctype_get...r_max ()) > 1)Description
TRUEevaluated 24824613 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 542 times by 1 test
Evaluated by:
  • Self test
542-24824613
1091 i = *sindex;-
1092 while (string[i] && string[i] != '\'')
string[i]Description
TRUEevaluated 43137340 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
string[i] != '\''Description
TRUEevaluated 18312185 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 24825155 times by 1 test
Evaluated by:
  • Self test
0-43137340
1093 ADVANCE_CHAR (string, slen, i);
executed 18280662 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 21387 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 1470 times by 1 test: end of block
Executed by:
  • Self test
executed 233 times by 1 test: end of block
Executed by:
  • Self test
never executed: (i)++;
executed 18303286 times by 1 test: (i) += mblength;
Executed by:
  • Self test
executed 8666 times by 1 test: (i)++;
Executed by:
  • Self test
executed 18312185 times by 1 test: end of block
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 18303519 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8666 times by 1 test
Evaluated by:
  • Self test
_fDescription
TRUEevaluated 18280662 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 22857 times by 1 test
Evaluated by:
  • Self test
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 18303286 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 22857 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEevaluated 21387 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1470 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 18303519 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEevaluated 233 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 18303286 times by 1 test
Evaluated by:
  • Self test
0-18312185
1094-
1095 t = substring (string, *sindex, i);-
1096-
1097 if (string[i])
string[i]Description
TRUEevaluated 24825155 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-24825155
1098 i++;
executed 24825155 times by 1 test: i++;
Executed by:
  • Self test
24825155
1099 *sindex = i;-
1100-
1101 return (t);
executed 24825155 times by 1 test: return (t);
Executed by:
  • Self test
24825155
1102}-
1103-
1104/* Skip over a single-quoted string. We overload the SX_COMPLETE flag to mean-
1105 that we are splitting out words for completion and have encountered a $'...'-
1106 string, which allows backslash-escaped single quotes. */-
1107static inline int-
1108skip_single_quoted (string, slen, sind, flags)-
1109 const char *string;-
1110 size_t slen;-
1111 int sind;-
1112 int flags;-
1113{-
1114 register int c;-
1115 DECLARE_MBSTATE;-
1116-
1117 c = sind;-
1118 while (string[c] && string[c] != '\'')
string[c]Description
TRUEevaluated 4633007 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
string[c] != '\''Description
TRUEevaluated 2316883 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2316124 times by 1 test
Evaluated by:
  • Self test
3-4633007
1119 {-
1120 if ((flags & SX_COMPLETE) && string[c] == '\\' && string[c+1] == '\'' && string[c+2])
(flags & 0x0400)Description
TRUEevaluated 37 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2316846 times by 1 test
Evaluated by:
  • Self test
string[c] == '\\'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 35 times by 1 test
Evaluated by:
  • Self test
string[c+1] == '\''Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
string[c+2]Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2316846
1121 ADVANCE_CHAR (string, slen, c);
executed 2 times by 1 test: mblength = 1;
Executed by:
  • Self test
never executed: mblength = 1;
never executed: end of block
never executed: end of block
never executed: (c)++;
executed 2 times by 1 test: (c) += mblength;
Executed by:
  • Self test
never executed: (c)++;
executed 2 times by 1 test: end of block
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
_fDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEnever evaluated
FALSEnever evaluated
(((string)[c] & 0x80) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
0-2
1122 ADVANCE_CHAR (string, slen, c);
executed 2316404 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 227 times by 1 test: mblength = 1;
Executed by:
  • Self test
never executed: end of block
never executed: end of block
never executed: (c)++;
executed 2316631 times by 1 test: (c) += mblength;
Executed by:
  • Self test
executed 252 times by 1 test: (c)++;
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 2316631 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 252 times by 1 test
Evaluated by:
  • Self test
_fDescription
TRUEevaluated 2316404 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 227 times by 1 test
Evaluated by:
  • Self test
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 2316631 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 227 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((string)[c] & 0x80) == 0)Description
TRUEevaluated 227 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 2316631 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 2316631 times by 1 test
Evaluated by:
  • Self test
0-2316631
1123 }
executed 2316883 times by 1 test: end of block
Executed by:
  • Self test
2316883
1124-
1125 if (string[c])
string[c]Description
TRUEevaluated 2316124 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
3-2316124
1126 c++;
executed 2316124 times by 1 test: c++;
Executed by:
  • Self test
2316124
1127 return c;
executed 2316127 times by 1 test: return c;
Executed by:
  • Self test
2316127
1128}-
1129-
1130/* Just like string_extract, but doesn't hack backslashes or any of-
1131 that other stuff. Obeys CTLESC quoting. Used to do splitting on $IFS. */-
1132static char *-
1133string_extract_verbatim (string, slen, sindex, charlist, flags)-
1134 char *string;-
1135 size_t slen;-
1136 int *sindex;-
1137 char *charlist;-
1138 int flags;-
1139{-
1140 register int i;-
1141#if defined (HANDLE_MULTIBYTE)-
1142 wchar_t *wcharlist;-
1143#endif-
1144 int c;-
1145 char *temp;-
1146 DECLARE_MBSTATE;-
1147-
1148 if ((flags & SX_NOCTLESC) && charlist[0] == '\'' && charlist[1] == '\0')
(flags & 0x0010)Description
TRUEevaluated 432 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9374363 times by 1 test
Evaluated by:
  • Self test
charlist[0] == '\''Description
TRUEnever evaluated
FALSEevaluated 432 times by 1 test
Evaluated by:
  • Self test
charlist[1] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0-9374363
1149 {-
1150 temp = string_extract_single_quoted (string, sindex);-
1151 --*sindex; /* leave *sindex at separator character */-
1152 return temp;
never executed: return temp;
0
1153 }-
1154-
1155 i = *sindex;-
1156#if defined (HANDLE_MULTIBYTE)-
1157 wcharlist = 0;-
1158#endif-
1159 while (c = string[i])
c = string[i]Description
TRUEevaluated 14322426 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1006095 times by 1 test
Evaluated by:
  • Self test
1006095-14322426
1160 {-
1161#if defined (HANDLE_MULTIBYTE)-
1162 size_t mblength;-
1163#endif-
1164 if ((flags & SX_NOCTLESC) == 0 && c == CTLESC)
(flags & 0x0010) == 0Description
TRUEevaluated 14321051 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1375 times by 1 test
Evaluated by:
  • Self test
c == '\001'Description
TRUEevaluated 103801 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14217250 times by 1 test
Evaluated by:
  • Self test
1375-14321051
1165 {-
1166 i += 2;-
1167 CHECK_STRING_OVERRUN (i, i, slen, c);
executed 20725 times by 1 test: break;
Executed by:
  • Self test
executed 83076 times by 1 test: ;
Executed by:
  • Self test
i >= slenDescription
TRUEevaluated 20725 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 83076 times by 1 test
Evaluated by:
  • Self test
20725-83076
1168 continue;
executed 83076 times by 1 test: continue;
Executed by:
  • Self test
83076
1169 }-
1170 /* Even if flags contains SX_NOCTLESC, we let CTLESC quoting CTLNUL-
1171 through, to protect the CTLNULs from later calls to-
1172 remove_quoted_nulls. */-
1173 else if ((flags & SX_NOESCCTLNUL) == 0 && c == CTLESC && string[i+1] == CTLNUL)
(flags & 0x0020) == 0Description
TRUEevaluated 14218387 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 238 times by 1 test
Evaluated by:
  • Self test
c == '\001'Description
TRUEevaluated 291 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14218096 times by 1 test
Evaluated by:
  • Self test
string[i+1] == '\177'Description
TRUEevaluated 34 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 257 times by 1 test
Evaluated by:
  • Self test
34-14218387
1174 {-
1175 i += 2;-
1176 CHECK_STRING_OVERRUN (i, i, slen, c);
never executed: break;
executed 34 times by 1 test: ;
Executed by:
  • Self test
i >= slenDescription
TRUEnever evaluated
FALSEevaluated 34 times by 1 test
Evaluated by:
  • Self test
0-34
1177 continue;
executed 34 times by 1 test: continue;
Executed by:
  • Self test
34
1178 }-
1179-
1180#if defined (HANDLE_MULTIBYTE)-
1181 mblength = MBLEN (string + i, slen - i);
( (__ctype_get...r_max ()) > 1)Description
TRUEevaluated 13795024 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 423567 times by 1 test
Evaluated by:
  • Self test
423567-13795024
1182 if (mblength > 1)
mblength > 1Description
TRUEevaluated 110 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14218481 times by 1 test
Evaluated by:
  • Self test
110-14218481
1183 {-
1184 wchar_t wc;-
1185 mblength = mbtowc (&wc, string + i, slen - i);-
1186 if (MB_INVALIDCH (mblength))
(mblength) == (size_t)-1Description
TRUEevaluated 40 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 70 times by 1 test
Evaluated by:
  • Self test
(mblength) == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 70 times by 1 test
Evaluated by:
  • Self test
0-70
1187 {-
1188 if (MEMBER (c, charlist))
(c)Description
TRUEevaluated 40 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(c)Description
TRUEevaluated 40 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
c == (charlist)[0]Description
TRUEnever evaluated
FALSEevaluated 40 times by 1 test
Evaluated by:
  • Self test
!(charlist)[1]Description
TRUEnever evaluated
FALSEnever evaluated
(((c) ? ((char...d *)0) ) : 0))Description
TRUEnever evaluated
FALSEevaluated 40 times by 1 test
Evaluated by:
  • Self test
0-40
1189 break;
never executed: break;
0
1190 }
executed 40 times by 1 test: end of block
Executed by:
  • Self test
40
1191 else-
1192 {-
1193 if (wcharlist == 0)
wcharlist == 0Description
TRUEevaluated 33 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 37 times by 1 test
Evaluated by:
  • Self test
33-37
1194 {-
1195 size_t len;-
1196 len = mbstowcs (wcharlist, charlist, 0);-
1197 if (len == -1)
len == -1Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 30 times by 1 test
Evaluated by:
  • Self test
3-30
1198 len = 0;
executed 3 times by 1 test: len = 0;
Executed by:
  • Self test
3
1199 wcharlist = (wchar_t *)xmalloc (sizeof (wchar_t) * (len + 1));-
1200 mbstowcs (wcharlist, charlist, len + 1);-
1201 }
executed 33 times by 1 test: end of block
Executed by:
  • Self test
33
1202-
1203 if (wcschr (wcharlist, wc))
wcschr (wcharlist, wc)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 64 times by 1 test
Evaluated by:
  • Self test
6-64
1204 break;
executed 6 times by 1 test: break;
Executed by:
  • Self test
6
1205 }
executed 64 times by 1 test: end of block
Executed by:
  • Self test
64
1206 }-
1207 else -
1208#endif-
1209 if (MEMBER (c, charlist))
(c)Description
TRUEevaluated 14195952 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(c)Description
TRUEevaluated 14218481 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
c == (charlist)[0]Description
TRUEevaluated 4189208 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10029273 times by 1 test
Evaluated by:
  • Self test
!(charlist)[1]Description
TRUEevaluated 22529 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4166679 times by 1 test
Evaluated by:
  • Self test
(((c) ? ((char...d *)0) ) : 0))Description
TRUEevaluated 8325440 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5870512 times by 1 test
Evaluated by:
  • Self test
0-14218481
1210 break;
executed 8347969 times by 1 test: break;
Executed by:
  • Self test
8347969
1211-
1212 ADVANCE_CHAR (string, slen, i);
executed 5436266 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 11090 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 104 times by 1 test: end of block
Executed by:
  • Self test
executed 40 times by 1 test: end of block
Executed by:
  • Self test
never executed: (i)++;
executed 5447420 times by 1 test: (i) += mblength;
Executed by:
  • Self test
executed 423156 times by 1 test: (i)++;
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 5447460 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 423156 times by 1 test
Evaluated by:
  • Self test
_fDescription
TRUEevaluated 5436266 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11194 times by 1 test
Evaluated by:
  • Self test
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 5447420 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 11194 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEevaluated 11090 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 104 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 5447460 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEevaluated 40 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5447420 times by 1 test
Evaluated by:
  • Self test
0-5447460
1213 }
executed 5870616 times by 1 test: end of block
Executed by:
  • Self test
5870616
1214-
1215#if defined (HANDLE_MULTIBYTE)-
1216 FREE (wcharlist);
executed 33 times by 1 test: sh_xfree((wcharlist), "subst.c", 1216);
Executed by:
  • Self test
wcharlistDescription
TRUEevaluated 33 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9374762 times by 1 test
Evaluated by:
  • Self test
33-9374762
1217#endif-
1218-
1219 temp = substring (string, *sindex, i);-
1220 *sindex = i;-
1221-
1222 return (temp);
executed 9374795 times by 1 test: return (temp);
Executed by:
  • Self test
9374795
1223}-
1224-
1225/* Extract the $( construct in STRING, and return a new string.-
1226 Start extracting at (SINDEX) as if we had just seen "$(".-
1227 Make (SINDEX) get the position of the matching ")". )-
1228 XFLAGS is additional flags to pass to other extraction functions. */-
1229char *-
1230extract_command_subst (string, sindex, xflags)-
1231 char *string;-
1232 int *sindex;-
1233 int xflags;-
1234{-
1235 char *ret;-
1236-
1237 if (string[*sindex] == LPAREN || (xflags & SX_COMPLETE))
string[*sindex] == '('Description
TRUEevaluated 11460 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 26302 times by 1 test
Evaluated by:
  • Self test
(xflags & 0x0400)Description
TRUEevaluated 41 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 26261 times by 1 test
Evaluated by:
  • Self test
41-26302
1238 return (extract_delimited_string (string, sindex, "$(", "(", ")", xflags|SX_COMMAND)); /*)*/
executed 11501 times by 1 test: return (extract_delimited_string (string, sindex, "$(", "(", ")", xflags|0x0008));
Executed by:
  • Self test
11501
1239 else-
1240 {-
1241 xflags |= (no_longjmp_on_fatal_error ? SX_NOLONGJMP : 0);
no_longjmp_on_fatal_errorDescription
TRUEevaluated 69 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 26192 times by 1 test
Evaluated by:
  • Self test
69-26192
1242 ret = xparse_dolparen (string, string+*sindex, sindex, xflags);-
1243 return ret;
executed 26254 times by 1 test: return ret;
Executed by:
  • Self test
26254
1244 }-
1245}-
1246-
1247/* Extract the $[ construct in STRING, and return a new string. (])-
1248 Start extracting at (SINDEX) as if we had just seen "$[".-
1249 Make (SINDEX) get the position of the matching "]". */-
1250char *-
1251extract_arithmetic_subst (string, sindex)-
1252 char *string;-
1253 int *sindex;-
1254{-
1255 return (extract_delimited_string (string, sindex, "$[", "[", "]", 0)); /*]*/
executed 3 times by 1 test: return (extract_delimited_string (string, sindex, "$[", "[", "]", 0));
Executed by:
  • Self test
3
1256}-
1257-
1258#if defined (PROCESS_SUBSTITUTION)-
1259/* Extract the <( or >( construct in STRING, and return a new string.-
1260 Start extracting at (SINDEX) as if we had just seen "<(".-
1261 Make (SINDEX) get the position of the matching ")". */ /*))*/-
1262char *-
1263extract_process_subst (string, starter, sindex, xflags)-
1264 char *string;-
1265 char *starter;-
1266 int *sindex;-
1267 int xflags;-
1268{-
1269#if 0-
1270 /* XXX - check xflags&SX_COMPLETE here? */-
1271 return (extract_delimited_string (string, sindex, starter, "(", ")", SX_COMMAND));-
1272#else-
1273 xflags |= (no_longjmp_on_fatal_error ? SX_NOLONGJMP : 0);
no_longjmp_on_fatal_errorDescription
TRUEnever evaluated
FALSEevaluated 679046 times by 1 test
Evaluated by:
  • Self test
0-679046
1274 return (xparse_dolparen (string, string+*sindex, sindex, xflags));
executed 679046 times by 1 test: return (xparse_dolparen (string, string+*sindex, sindex, xflags));
Executed by:
  • Self test
679046
1275#endif-
1276}-
1277#endif /* PROCESS_SUBSTITUTION */-
1278-
1279#if defined (ARRAY_VARS)-
1280/* This can be fooled by unquoted right parens in the passed string. If-
1281 each caller verifies that the last character in STRING is a right paren,-
1282 we don't even need to call extract_delimited_string. */-
1283char *-
1284extract_array_assignment_list (string, sindex)-
1285 char *string;-
1286 int *sindex;-
1287{-
1288 int slen;-
1289 char *ret;-
1290-
1291 slen = strlen (string);-
1292 if (string[slen - 1] == RPAREN)
string[slen - 1] == ')'Description
TRUEevaluated 544 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-544
1293 {-
1294 ret = substring (string, *sindex, slen - 1);-
1295 *sindex = slen - 1;-
1296 return ret;
executed 544 times by 1 test: return ret;
Executed by:
  • Self test
544
1297 }-
1298 return 0;
never executed: return 0;
0
1299}-
1300#endif-
1301-
1302/* Extract and create a new string from the contents of STRING, a-
1303 character string delimited with OPENER and CLOSER. SINDEX is-
1304 the address of an int describing the current offset in STRING;-
1305 it should point to just after the first OPENER found. On exit,-
1306 SINDEX gets the position of the last character of the matching CLOSER.-
1307 If OPENER is more than a single character, ALT_OPENER, if non-null,-
1308 contains a character string that can also match CLOSER and thus-
1309 needs to be skipped. */-
1310static char *-
1311extract_delimited_string (string, sindex, opener, alt_opener, closer, flags)-
1312 char *string;-
1313 int *sindex;-
1314 char *opener, *alt_opener, *closer;-
1315 int flags;-
1316{-
1317 int i, c, si;-
1318 size_t slen;-
1319 char *t, *result;-
1320 int pass_character, nesting_level, in_comment;-
1321 int len_closer, len_opener, len_alt_opener;-
1322 DECLARE_MBSTATE;-
1323-
1324 slen = strlen (string + *sindex) + *sindex;-
1325 len_opener = STRLEN (opener);
(opener)[1]Description
TRUEevaluated 12466 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12704 times by 1 test
Evaluated by:
  • Self test
(opener)[2]Description
TRUEnever evaluated
FALSEevaluated 12466 times by 1 test
Evaluated by:
  • Self test
(opener)Description
TRUEevaluated 25170 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(opener)[0]Description
TRUEevaluated 25170 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-25170
1326 len_alt_opener = STRLEN (alt_opener);
(alt_opener)[1]Description
TRUEnever evaluated
FALSEevaluated 25170 times by 1 test
Evaluated by:
  • Self test
(alt_opener)[2]Description
TRUEnever evaluated
FALSEnever evaluated
(alt_opener)Description
TRUEevaluated 25170 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(alt_opener)[0]Description
TRUEevaluated 25170 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-25170
1327 len_closer = STRLEN (closer);
(closer)[1]Description
TRUEnever evaluated
FALSEevaluated 25170 times by 1 test
Evaluated by:
  • Self test
(closer)[2]Description
TRUEnever evaluated
FALSEnever evaluated
(closer)Description
TRUEevaluated 25170 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(closer)[0]Description
TRUEevaluated 25170 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-25170
1328-
1329 pass_character = in_comment = 0;-
1330-
1331 nesting_level = 1;-
1332 i = *sindex;-
1333-
1334 while (nesting_level)
nesting_levelDescription
TRUEevaluated 107912 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-107912
1335 {-
1336 c = string[i];-
1337-
1338 /* If a recursive call or a call to ADVANCE_CHAR leaves the index beyond-
1339 the end of the string, catch it and cut the loop. */-
1340 if (i > slen)
i > slenDescription
TRUEnever evaluated
FALSEevaluated 107912 times by 1 test
Evaluated by:
  • Self test
0-107912
1341 {-
1342 i = slen;-
1343 c = string[i = slen];-
1344 break;
never executed: break;
0
1345 }-
1346-
1347 if (c == 0)
c == 0Description
TRUEnever evaluated
FALSEevaluated 107912 times by 1 test
Evaluated by:
  • Self test
0-107912
1348 break;
never executed: break;
0
1349-
1350 if (in_comment)
in_commentDescription
TRUEnever evaluated
FALSEevaluated 107912 times by 1 test
Evaluated by:
  • Self test
0-107912
1351 {-
1352 if (c == '\n')
c == '\n'Description
TRUEnever evaluated
FALSEnever evaluated
0
1353 in_comment = 0;
never executed: in_comment = 0;
0
1354 ADVANCE_CHAR (string, slen, i);
never executed: mblength = 1;
never executed: mblength = 1;
never executed: end of block
never executed: end of block
never executed: (i)++;
never executed: (i) += mblength;
never executed: (i)++;
locale_mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
_fDescription
TRUEnever evaluated
FALSEnever evaluated
mblength == 0Description
TRUEnever evaluated
FALSEnever evaluated
locale_utf8localeDescription
TRUEnever evaluated
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEnever evaluated
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEnever evaluated
0
1355 continue;
never executed: continue;
0
1356 }-
1357-
1358 if (pass_character) /* previous char was backslash */
pass_characterDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 107902 times by 1 test
Evaluated by:
  • Self test
10-107902
1359 {-
1360 pass_character = 0;-
1361 ADVANCE_CHAR (string, slen, i);
never executed: mblength = 1;
executed 10 times by 1 test: mblength = 1;
Executed by:
  • Self test
never executed: end of block
never executed: end of block
never executed: (i)++;
executed 10 times by 1 test: (i) += mblength;
Executed by:
  • Self test
never executed: (i)++;
locale_mb_cur_max > 1Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
_fDescription
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
0-10
1362 continue;
executed 10 times by 1 test: continue;
Executed by:
  • Self test
10
1363 }-
1364-
1365 /* Not exactly right yet; should handle shell metacharacters and-
1366 multibyte characters, too. See COMMENT_BEGIN define in parse.y */-
1367 if ((flags & SX_COMMAND) && c == '#' && (i == 0 || string[i - 1] == '\n' || shellblank (string[i - 1])))
(flags & 0x0008)Description
TRUEevaluated 107588 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 314 times by 1 test
Evaluated by:
  • Self test
c == '#'Description
TRUEevaluated 209 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 107379 times by 1 test
Evaluated by:
  • Self test
i == 0Description
TRUEnever evaluated
FALSEevaluated 209 times by 1 test
Evaluated by:
  • Self test
string[i - 1] == '\n'Description
TRUEnever evaluated
FALSEevaluated 209 times by 1 test
Evaluated by:
  • Self test
(sh_syntaxtab[...1])] & 0x2000)Description
TRUEnever evaluated
FALSEevaluated 209 times by 1 test
Evaluated by:
  • Self test
0-107588
1368 {-
1369 in_comment = 1;-
1370 ADVANCE_CHAR (string, slen, i);
never executed: mblength = 1;
never executed: mblength = 1;
never executed: end of block
never executed: end of block
never executed: (i)++;
never executed: (i) += mblength;
never executed: (i)++;
locale_mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
_fDescription
TRUEnever evaluated
FALSEnever evaluated
mblength == 0Description
TRUEnever evaluated
FALSEnever evaluated
locale_utf8localeDescription
TRUEnever evaluated
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEnever evaluated
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEnever evaluated
0
1371 continue;
never executed: continue;
0
1372 }-
1373 -
1374 if (c == CTLESC || c == '\\')
c == '\001'Description
TRUEnever evaluated
FALSEevaluated 107902 times by 1 test
Evaluated by:
  • Self test
c == '\\'Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 107892 times by 1 test
Evaluated by:
  • Self test
0-107902
1375 {-
1376 pass_character++;-
1377 i++;-
1378 continue;
executed 10 times by 1 test: continue;
Executed by:
  • Self test
10
1379 }-
1380-
1381 /* Process a nested command substitution, but only if we're parsing an-
1382 arithmetic substitution. */-
1383 if ((flags & SX_COMMAND) && string[i] == '$' && string[i+1] == LPAREN)
(flags & 0x0008)Description
TRUEevaluated 107578 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 314 times by 1 test
Evaluated by:
  • Self test
string[i] == '$'Description
TRUEevaluated 726 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 106852 times by 1 test
Evaluated by:
  • Self test
string[i+1] == '('Description
TRUEevaluated 166 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 560 times by 1 test
Evaluated by:
  • Self test
166-107578
1384 {-
1385 si = i + 2;-
1386 t = extract_command_subst (string, &si, flags|SX_NOALLOC);-
1387 CHECK_STRING_OVERRUN (i, si, slen, c);
never executed: break;
executed 166 times by 1 test: ;
Executed by:
  • Self test
si >= slenDescription
TRUEnever evaluated
FALSEevaluated 166 times by 1 test
Evaluated by:
  • Self test
0-166
1388 i = si + 1;-
1389 continue;
executed 166 times by 1 test: continue;
Executed by:
  • Self test
166
1390 }-
1391-
1392 /* Process a nested OPENER. */-
1393 if (STREQN (string + i, opener, len_opener))
never executed: __result = (((const unsigned char *) (const char *) ( string + i ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( opener ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
((len_opener =...ner ))) == 0))Description
TRUEevaluated 521 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 107205 times by 1 test
Evaluated by:
  • Self test
(len_opener == 0)Description
TRUEnever evaluated
FALSEevaluated 107726 times by 1 test
Evaluated by:
  • Self test
(string + i)[0] == (opener)[0]Description
TRUEevaluated 521 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 107205 times by 1 test
Evaluated by:
  • Self test
(__extension__...pener ))) == 0Description
TRUEevaluated 521 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__builtin_cons...( len_opener )Description
TRUEnever evaluated
FALSEevaluated 521 times by 1 test
Evaluated by:
  • Self test
__builtin_cons...( string + i )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( strin... len_opener ))Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...t_p ( opener )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( opene... len_opener ))Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-107726
1394 {-
1395 si = i + len_opener;-
1396 t = extract_delimited_string (string, &si, opener, alt_opener, closer, flags|SX_NOALLOC);-
1397 CHECK_STRING_OVERRUN (i, si, slen, c);
never executed: break;
executed 521 times by 1 test: ;
Executed by:
  • Self test
si >= slenDescription
TRUEnever evaluated
FALSEevaluated 521 times by 1 test
Evaluated by:
  • Self test
0-521
1398 i = si + 1;-
1399 continue;
executed 521 times by 1 test: continue;
Executed by:
  • Self test
521
1400 }-
1401-
1402 /* Process a nested ALT_OPENER */-
1403 if (len_alt_opener && STREQN (string + i, alt_opener, len_alt_opener))
never executed: __result = (((const unsigned char *) (const char *) ( string + i ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( alt_opener ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
(len_alt_opener == 0)Description
TRUEnever evaluated
FALSEevaluated 107205 times by 1 test
Evaluated by:
  • Self test
len_alt_openerDescription
TRUEevaluated 107205 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((len_alt_open...ner ))) == 0))Description
TRUEevaluated 12150 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 95055 times by 1 test
Evaluated by:
  • Self test
(string + i)[0...alt_opener)[0]Description
TRUEevaluated 12150 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 95055 times by 1 test
Evaluated by:
  • Self test
(__extension__...pener ))) == 0Description
TRUEevaluated 12150 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__builtin_cons...n_alt_opener )Description
TRUEnever evaluated
FALSEevaluated 12150 times by 1 test
Evaluated by:
  • Self test
__builtin_cons...( string + i )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( strin..._alt_opener ))Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...( alt_opener )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( alt_o..._alt_opener ))Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-107205
1404 {-
1405 si = i + len_alt_opener;-
1406 t = extract_delimited_string (string, &si, alt_opener, alt_opener, closer, flags|SX_NOALLOC);-
1407 CHECK_STRING_OVERRUN (i, si, slen, c);
never executed: break;
executed 12150 times by 1 test: ;
Executed by:
  • Self test
si >= slenDescription
TRUEnever evaluated
FALSEevaluated 12150 times by 1 test
Evaluated by:
  • Self test
0-12150
1408 i = si + 1;-
1409 continue;
executed 12150 times by 1 test: continue;
Executed by:
  • Self test
12150
1410 }-
1411-
1412 /* If the current substring terminates the delimited string, decrement-
1413 the nesting level. */-
1414 if (STREQN (string + i, closer, len_closer))
never executed: __result = (((const unsigned char *) (const char *) ( string + i ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( closer ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
((len_closer =...ser ))) == 0))Description
TRUEevaluated 25170 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 69885 times by 1 test
Evaluated by:
  • Self test
(len_closer == 0)Description
TRUEnever evaluated
FALSEevaluated 95055 times by 1 test
Evaluated by:
  • Self test
(string + i)[0] == (closer)[0]Description
TRUEevaluated 25170 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 69885 times by 1 test
Evaluated by:
  • Self test
(__extension__...loser ))) == 0Description
TRUEevaluated 25170 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__builtin_cons...( len_closer )Description
TRUEnever evaluated
FALSEevaluated 25170 times by 1 test
Evaluated by:
  • Self test
__builtin_cons...( string + i )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( strin... len_closer ))Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...t_p ( closer )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( close... len_closer ))Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-95055
1415 {-
1416 i += len_closer - 1; /* move to last byte of the closer */-
1417 nesting_level--;-
1418 if (nesting_level == 0)
nesting_level == 0Description
TRUEevaluated 25170 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-25170
1419 break;
executed 25170 times by 1 test: break;
Executed by:
  • Self test
25170
1420 }
never executed: end of block
0
1421-
1422 /* Pass old-style command substitution through verbatim. */-
1423 if (c == '`')
c == '`'Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 69880 times by 1 test
Evaluated by:
  • Self test
5-69880
1424 {-
1425 si = i + 1;-
1426 t = string_extract (string, &si, "`", flags|SX_NOALLOC);-
1427 CHECK_STRING_OVERRUN (i, si, slen, c);
never executed: break;
executed 5 times by 1 test: ;
Executed by:
  • Self test
si >= slenDescription
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
0-5
1428 i = si + 1;-
1429 continue;
executed 5 times by 1 test: continue;
Executed by:
  • Self test
5
1430 }-
1431-
1432 /* Pass single-quoted and double-quoted strings through verbatim. */-
1433 if (c == '\'' || c == '"')
c == '\''Description
TRUEevaluated 25 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 69855 times by 1 test
Evaluated by:
  • Self test
c == '"'Description
TRUEevaluated 335 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 69520 times by 1 test
Evaluated by:
  • Self test
25-69855
1434 {-
1435 si = i + 1;-
1436 i = (c == '\'') ? skip_single_quoted (string, slen, si, 0)
(c == '\'')Description
TRUEevaluated 25 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 335 times by 1 test
Evaluated by:
  • Self test
25-335
1437 : skip_double_quoted (string, slen, si, 0);-
1438 continue;
executed 360 times by 1 test: continue;
Executed by:
  • Self test
360
1439 }-
1440-
1441 /* move past this character, which was not special. */-
1442 ADVANCE_CHAR (string, slen, i);
executed 68075 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 560 times by 1 test: mblength = 1;
Executed by:
  • Self test
never executed: end of block
never executed: end of block
never executed: (i)++;
executed 68635 times by 1 test: (i) += mblength;
Executed by:
  • Self test
executed 885 times by 1 test: (i)++;
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 68635 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 885 times by 1 test
Evaluated by:
  • Self test
_fDescription
TRUEevaluated 68075 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 560 times by 1 test
Evaluated by:
  • Self test
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 68635 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 560 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEevaluated 560 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 68635 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 68635 times by 1 test
Evaluated by:
  • Self test
0-68635
1443 }
executed 69520 times by 1 test: end of block
Executed by:
  • Self test
69520
1444-
1445 if (c == 0 && nesting_level)
c == 0Description
TRUEnever evaluated
FALSEevaluated 25170 times by 1 test
Evaluated by:
  • Self test
nesting_levelDescription
TRUEnever evaluated
FALSEnever evaluated
0-25170
1446 {-
1447 if (no_longjmp_on_fatal_error == 0)
no_longjmp_on_fatal_error == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1448 {-
1449 last_command_exit_value = EXECUTION_FAILURE;-
1450 report_error (_("bad substitution: no closing `%s' in %s"), closer, string);-
1451 exp_jump_to_top_level (DISCARD);-
1452 }
never executed: end of block
0
1453 else-
1454 {-
1455 *sindex = i;-
1456 return (char *)NULL;
never executed: return (char *) ((void *)0) ;
0
1457 }-
1458 }-
1459-
1460 si = i - *sindex - len_closer + 1;-
1461 if (flags & SX_NOALLOC)
flags & 0x0001Description
TRUEevaluated 13733 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11437 times by 1 test
Evaluated by:
  • Self test
11437-13733
1462 result = (char *)NULL;
executed 13733 times by 1 test: result = (char *) ((void *)0) ;
Executed by:
  • Self test
13733
1463 else -
1464 {-
1465 result = (char *)xmalloc (1 + si);-
1466 strncpy (result, string + *sindex, si);-
1467 result[si] = '\0';-
1468 }
executed 11437 times by 1 test: end of block
Executed by:
  • Self test
11437
1469 *sindex = i;-
1470-
1471 return (result);
executed 25170 times by 1 test: return (result);
Executed by:
  • Self test
25170
1472}-
1473-
1474/* Extract a parameter expansion expression within ${ and } from STRING.-
1475 Obey the Posix.2 rules for finding the ending `}': count braces while-
1476 skipping over enclosed quoted strings and command substitutions.-
1477 SINDEX is the address of an int describing the current offset in STRING;-
1478 it should point to just after the first `{' found. On exit, SINDEX-
1479 gets the position of the matching `}'. QUOTED is non-zero if this-
1480 occurs inside double quotes. */-
1481/* XXX -- this is very similar to extract_delimited_string -- XXX */-
1482static char *-
1483extract_dollar_brace_string (string, sindex, quoted, flags)-
1484 char *string;-
1485 int *sindex, quoted, flags;-
1486{-
1487 register int i, c;-
1488 size_t slen;-
1489 int pass_character, nesting_level, si, dolbrace_state;-
1490 char *result, *t;-
1491 DECLARE_MBSTATE;-
1492-
1493 pass_character = 0;-
1494 nesting_level = 1;-
1495 slen = strlen (string + *sindex) + *sindex;-
1496-
1497 /* The handling of dolbrace_state needs to agree with the code in parse.y:-
1498 parse_matched_pair(). The different initial value is to handle the-
1499 case where this function is called to parse the word in-
1500 ${param op word} (SX_WORD). */-
1501 dolbrace_state = (flags & SX_WORD) ? DOLBRACE_WORD : DOLBRACE_PARAM;
(flags & 0x0200)Description
TRUEevaluated 2343676 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 45576 times by 1 test
Evaluated by:
  • Self test
45576-2343676
1502 if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && (flags & SX_POSIXEXP))
(quoted & (0x002|0x001))Description
TRUEevaluated 56089 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2333163 times by 1 test
Evaluated by:
  • Self test
(flags & 0x0100)Description
TRUEevaluated 749 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 55340 times by 1 test
Evaluated by:
  • Self test
749-2333163
1503 dolbrace_state = DOLBRACE_QUOTE;
executed 749 times by 1 test: dolbrace_state = 0x40;
Executed by:
  • Self test
749
1504-
1505 i = *sindex;-
1506 while (c = string[i])
c = string[i]Description
TRUEevaluated 5532568 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-5532568
1507 {-
1508 if (pass_character)
pass_characterDescription
TRUEevaluated 436 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5532132 times by 1 test
Evaluated by:
  • Self test
436-5532132
1509 {-
1510 pass_character = 0;-
1511 ADVANCE_CHAR (string, slen, i);
executed 375 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 61 times by 1 test: mblength = 1;
Executed by:
  • Self test
never executed: end of block
never executed: end of block
never executed: (i)++;
executed 436 times by 1 test: (i) += mblength;
Executed by:
  • Self test
never executed: (i)++;
locale_mb_cur_max > 1Description
TRUEevaluated 436 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
_fDescription
TRUEevaluated 375 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 61 times by 1 test
Evaluated by:
  • Self test
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 436 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 436 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 436 times by 1 test
Evaluated by:
  • Self test
0-436
1512 continue;
executed 436 times by 1 test: continue;
Executed by:
  • Self test
436
1513 }-
1514-
1515 /* CTLESCs and backslashes quote the next character. */-
1516 if (c == CTLESC || c == '\\')
c == '\001'Description
TRUEevaluated 34 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5532098 times by 1 test
Evaluated by:
  • Self test
c == '\\'Description
TRUEevaluated 402 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5531696 times by 1 test
Evaluated by:
  • Self test
34-5532098
1517 {-
1518 pass_character++;-
1519 i++;-
1520 continue;
executed 436 times by 1 test: continue;
Executed by:
  • Self test
436
1521 }-
1522-
1523 if (string[i] == '$' && string[i+1] == LBRACE)
string[i] == '$'Description
TRUEevaluated 5777 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5525919 times by 1 test
Evaluated by:
  • Self test
string[i+1] == '{'Description
TRUEevaluated 98 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5679 times by 1 test
Evaluated by:
  • Self test
98-5525919
1524 {-
1525 nesting_level++;-
1526 i += 2;-
1527 continue;
executed 98 times by 1 test: continue;
Executed by:
  • Self test
98
1528 }-
1529-
1530 if (c == RBRACE)
c == '}'Description
TRUEevaluated 2389350 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3142248 times by 1 test
Evaluated by:
  • Self test
2389350-3142248
1531 {-
1532 nesting_level--;-
1533 if (nesting_level == 0)
nesting_level == 0Description
TRUEevaluated 2389252 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 98 times by 1 test
Evaluated by:
  • Self test
98-2389252
1534 break;
executed 2389252 times by 1 test: break;
Executed by:
  • Self test
2389252
1535 i++;-
1536 continue;
executed 98 times by 1 test: continue;
Executed by:
  • Self test
98
1537 }-
1538-
1539 /* Pass the contents of old-style command substitutions through-
1540 verbatim. */-
1541 if (c == '`')
c == '`'Description
TRUEevaluated 118 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3142130 times by 1 test
Evaluated by:
  • Self test
118-3142130
1542 {-
1543 si = i + 1;-
1544 t = string_extract (string, &si, "`", flags|SX_NOALLOC);-
1545-
1546 CHECK_STRING_OVERRUN (i, si, slen, c);
never executed: break;
executed 118 times by 1 test: ;
Executed by:
  • Self test
si >= slenDescription
TRUEnever evaluated
FALSEevaluated 118 times by 1 test
Evaluated by:
  • Self test
0-118
1547-
1548 i = si + 1;-
1549 continue;
executed 118 times by 1 test: continue;
Executed by:
  • Self test
118
1550 }-
1551-
1552 /* Pass the contents of new-style command substitutions and-
1553 arithmetic substitutions through verbatim. */-
1554 if (string[i] == '$' && string[i+1] == LPAREN)
string[i] == '$'Description
TRUEevaluated 5679 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3136451 times by 1 test
Evaluated by:
  • Self test
string[i+1] == '('Description
TRUEevaluated 70 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5609 times by 1 test
Evaluated by:
  • Self test
70-3136451
1555 {-
1556 si = i + 2;-
1557 t = extract_command_subst (string, &si, flags|SX_NOALLOC);-
1558-
1559 CHECK_STRING_OVERRUN (i, si, slen, c);
never executed: break;
executed 70 times by 1 test: ;
Executed by:
  • Self test
si >= slenDescription
TRUEnever evaluated
FALSEevaluated 70 times by 1 test
Evaluated by:
  • Self test
0-70
1560-
1561 i = si + 1;-
1562 continue;
executed 70 times by 1 test: continue;
Executed by:
  • Self test
70
1563 }-
1564-
1565#if defined (PROCESS_SUBSTITUTION)-
1566 /* Technically this should only work at the start of a word */-
1567 if ((string[i] == '<' || string[i] == '>') && string[i+1] == LPAREN)
string[i] == '<'Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3142057 times by 1 test
Evaluated by:
  • Self test
string[i] == '>'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3142056 times by 1 test
Evaluated by:
  • Self test
string[i+1] == '('Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
1-3142057
1568 {-
1569 si = i + 2;-
1570 t = extract_process_subst (string, (string[i] == '<' ? "<(" : ">)"), &si, flags|SX_NOALLOC);-
1571-
1572 CHECK_STRING_OVERRUN (i, si, slen, c);
never executed: break;
executed 2 times by 1 test: ;
Executed by:
  • Self test
si >= slenDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
0-2
1573-
1574 i = si + 1;-
1575 continue;
executed 2 times by 1 test: continue;
Executed by:
  • Self test
2
1576 }-
1577#endif-
1578-
1579 /* Pass the contents of double-quoted strings through verbatim. */-
1580 if (c == '"')
c == '"'Description
TRUEevaluated 2428 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3139630 times by 1 test
Evaluated by:
  • Self test
2428-3139630
1581 {-
1582 si = i + 1;-
1583 i = skip_double_quoted (string, slen, si, 0);-
1584 /* skip_XXX_quoted leaves index one past close quote */-
1585 continue;
executed 2428 times by 1 test: continue;
Executed by:
  • Self test
2428
1586 }-
1587-
1588 if (c == '\'')
c == '\''Description
TRUEevaluated 2315940 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 823690 times by 1 test
Evaluated by:
  • Self test
823690-2315940
1589 {-
1590/*itrace("extract_dollar_brace_string: c == single quote flags = %d quoted = %d dolbrace_state = %d", flags, quoted, dolbrace_state);*/-
1591 if (posixly_correct && shell_compatibility_level > 42 && dolbrace_state != DOLBRACE_QUOTE && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))
posixly_correctDescription
TRUEevaluated 38 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2315902 times by 1 test
Evaluated by:
  • Self test
shell_compatibility_level > 42Description
TRUEevaluated 38 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
dolbrace_state != 0x40Description
TRUEevaluated 36 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
(quoted & (0x002|0x001))Description
TRUEevaluated 28 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
0-2315902
1592 ADVANCE_CHAR (string, slen, i);
executed 28 times by 1 test: mblength = 1;
Executed by:
  • Self test
never executed: mblength = 1;
never executed: end of block
never executed: end of block
never executed: (i)++;
executed 28 times by 1 test: (i) += mblength;
Executed by:
  • Self test
never executed: (i)++;
executed 28 times by 1 test: end of block
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 28 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
_fDescription
TRUEevaluated 28 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 28 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEnever evaluated
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 28 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 28 times by 1 test
Evaluated by:
  • Self test
0-28
1593 else-
1594 {-
1595 si = i + 1;-
1596 i = skip_single_quoted (string, slen, si, 0);-
1597 }
executed 2315912 times by 1 test: end of block
Executed by:
  • Self test
2315912
1598-
1599 continue;
executed 2315940 times by 1 test: continue;
Executed by:
  • Self test
2315940
1600 }-
1601-
1602#if defined (ARRAY_VARS)-
1603 /* XXX - bash-5.0 */-
1604 if (c == LBRACK && dolbrace_state == DOLBRACE_PARAM)
c == '['Description
TRUEevaluated 4895 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 818795 times by 1 test
Evaluated by:
  • Self test
dolbrace_state == 0x01Description
TRUEevaluated 4737 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 158 times by 1 test
Evaluated by:
  • Self test
158-818795
1605 {-
1606 si = skipsubscript (string, i, 0);-
1607 CHECK_STRING_OVERRUN (i, si, slen, c);
never executed: break;
executed 4737 times by 1 test: ;
Executed by:
  • Self test
si >= slenDescription
TRUEnever evaluated
FALSEevaluated 4737 times by 1 test
Evaluated by:
  • Self test
0-4737
1608 if (string[si] == RBRACK)
string[si] == ']'Description
TRUEevaluated 4737 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-4737
1609 c = string[i = si];
executed 4737 times by 1 test: c = string[i = si];
Executed by:
  • Self test
4737
1610 }
executed 4737 times by 1 test: end of block
Executed by:
  • Self test
4737
1611#endif-
1612-
1613 /* move past this character, which was not special. */-
1614 ADVANCE_CHAR (string, slen, i);
executed 814730 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 8189 times by 1 test: mblength = 1;
Executed by:
  • Self test
never executed: end of block
never executed: end of block
never executed: (i)++;
executed 822919 times by 1 test: (i) += mblength;
Executed by:
  • Self test
executed 771 times by 1 test: (i)++;
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 822919 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 771 times by 1 test
Evaluated by:
  • Self test
_fDescription
TRUEevaluated 814730 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8189 times by 1 test
Evaluated by:
  • Self test
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 822919 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 8189 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEevaluated 8189 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 822919 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 822919 times by 1 test
Evaluated by:
  • Self test
0-822919
1615-
1616 /* This logic must agree with parse.y:parse_matched_pair, since they-
1617 share the same defines. */-
1618 if (dolbrace_state == DOLBRACE_PARAM && c == '%' && (i - *sindex) > 1)
dolbrace_state == 0x01Description
TRUEevaluated 140413 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 683277 times by 1 test
Evaluated by:
  • Self test
c == '%'Description
TRUEevaluated 60 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 140353 times by 1 test
Evaluated by:
  • Self test
(i - *sindex) > 1Description
TRUEevaluated 60 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-683277
1619 dolbrace_state = DOLBRACE_QUOTE;
executed 60 times by 1 test: dolbrace_state = 0x40;
Executed by:
  • Self test
60
1620 else if (dolbrace_state == DOLBRACE_PARAM && c == '#' && (i - *sindex) > 1)
dolbrace_state == 0x01Description
TRUEevaluated 140353 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 683277 times by 1 test
Evaluated by:
  • Self test
c == '#'Description
TRUEevaluated 138 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 140215 times by 1 test
Evaluated by:
  • Self test
(i - *sindex) > 1Description
TRUEevaluated 88 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 50 times by 1 test
Evaluated by:
  • Self test
50-683277
1621 dolbrace_state = DOLBRACE_QUOTE;
executed 88 times by 1 test: dolbrace_state = 0x40;
Executed by:
  • Self test
88
1622 else if (dolbrace_state == DOLBRACE_PARAM && c == '/' && (i - *sindex) > 1)
dolbrace_state == 0x01Description
TRUEevaluated 140265 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 683277 times by 1 test
Evaluated by:
  • Self test
c == '/'Description
TRUEevaluated 232 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 140033 times by 1 test
Evaluated by:
  • Self test
(i - *sindex) > 1Description
TRUEevaluated 232 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-683277
1623 dolbrace_state = DOLBRACE_QUOTE2; /* XXX */
executed 232 times by 1 test: dolbrace_state = 0x80;
Executed by:
  • Self test
232
1624 else if (dolbrace_state == DOLBRACE_PARAM && c == '^' && (i - *sindex) > 1)
dolbrace_state == 0x01Description
TRUEevaluated 140033 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 683277 times by 1 test
Evaluated by:
  • Self test
c == '^'Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 140024 times by 1 test
Evaluated by:
  • Self test
(i - *sindex) > 1Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-683277
1625 dolbrace_state = DOLBRACE_QUOTE;
executed 9 times by 1 test: dolbrace_state = 0x40;
Executed by:
  • Self test
9
1626 else if (dolbrace_state == DOLBRACE_PARAM && c == ',' && (i - *sindex) > 1)
dolbrace_state == 0x01Description
TRUEevaluated 140024 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 683277 times by 1 test
Evaluated by:
  • Self test
c == ','Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 140012 times by 1 test
Evaluated by:
  • Self test
(i - *sindex) > 1Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-683277
1627 dolbrace_state = DOLBRACE_QUOTE;
executed 12 times by 1 test: dolbrace_state = 0x40;
Executed by:
  • Self test
12
1628 /* This is intended to handle all of the [:]op expansions and the substring/-
1629 length/pattern removal/pattern substitution expansions. */-
1630 else if (dolbrace_state == DOLBRACE_PARAM && strchr ("#%^,~:-=?+/", c) != 0)
dolbrace_state == 0x01Description
TRUEevaluated 140012 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 683277 times by 1 test
Evaluated by:
  • Self test
(__extension__..." , c ))) != 0Description
TRUEevaluated 25839 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 114173 times by 1 test
Evaluated by:
  • Self test
__builtin_constant_p ( c )Description
TRUEnever evaluated
FALSEevaluated 140012 times by 1 test
Evaluated by:
  • Self test
!__builtin_con...#%^,~:-=?+/" )Description
TRUEnever evaluated
FALSEnever evaluated
( c ) == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0-683277
1631 dolbrace_state = DOLBRACE_OP;
executed 25839 times by 1 test: dolbrace_state = 0x02;
Executed by:
  • Self test
25839
1632 else if (dolbrace_state == DOLBRACE_OP && strchr ("#%^,~:-=?+/", c) == 0)
dolbrace_state == 0x02Description
TRUEevaluated 50051 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 747399 times by 1 test
Evaluated by:
  • Self test
(__extension__..." , c ))) == 0Description
TRUEevaluated 25518 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 24533 times by 1 test
Evaluated by:
  • Self test
__builtin_constant_p ( c )Description
TRUEnever evaluated
FALSEevaluated 50051 times by 1 test
Evaluated by:
  • Self test
!__builtin_con...#%^,~:-=?+/" )Description
TRUEnever evaluated
FALSEnever evaluated
( c ) == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0-747399
1633 dolbrace_state = DOLBRACE_WORD;
executed 25518 times by 1 test: dolbrace_state = 0x04;
Executed by:
  • Self test
25518
1634 }
executed 823690 times by 1 test: end of block
Executed by:
  • Self test
823690
1635-
1636 if (c == 0 && nesting_level)
c == 0Description
TRUEnever evaluated
FALSEevaluated 2389252 times by 1 test
Evaluated by:
  • Self test
nesting_levelDescription
TRUEnever evaluated
FALSEnever evaluated
0-2389252
1637 {-
1638 if (no_longjmp_on_fatal_error == 0)
no_longjmp_on_fatal_error == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1639 { /* { */-
1640 last_command_exit_value = EXECUTION_FAILURE;-
1641 report_error (_("bad substitution: no closing `%s' in %s"), "}", string);-
1642 exp_jump_to_top_level (DISCARD);-
1643 }
never executed: end of block
0
1644 else-
1645 {-
1646 *sindex = i;-
1647 return ((char *)NULL);
never executed: return ((char *) ((void *)0) );
0
1648 }-
1649 }-
1650-
1651 result = (flags & SX_NOALLOC) ? (char *)NULL : substring (string, *sindex, i);
(flags & 0x0001)Description
TRUEevaluated 15504 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2373748 times by 1 test
Evaluated by:
  • Self test
15504-2373748
1652 *sindex = i;-
1653-
1654 return (result);
executed 2389252 times by 1 test: return (result);
Executed by:
  • Self test
2389252
1655}-
1656-
1657/* Remove backslashes which are quoting backquotes from STRING. Modifies-
1658 STRING, and returns a pointer to it. */-
1659char *-
1660de_backslash (string)-
1661 char *string;-
1662{-
1663 register size_t slen;-
1664 register int i, j, prev_i;-
1665 DECLARE_MBSTATE;-
1666-
1667 slen = strlen (string);-
1668 i = j = 0;-
1669-
1670 /* Loop copying string[i] to string[j], i >= j. */-
1671 while (i < slen)
i < slenDescription
TRUEevaluated 203467366 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3231118 times by 1 test
Evaluated by:
  • Self test
3231118-203467366
1672 {-
1673 if (string[i] == '\\' && (string[i + 1] == '`' || string[i + 1] == '\\' ||
string[i] == '\\'Description
TRUEevaluated 350 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 203467016 times by 1 test
Evaluated by:
  • Self test
string[i + 1] == '`'Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 328 times by 1 test
Evaluated by:
  • Self test
string[i + 1] == '\\'Description
TRUEevaluated 174 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 154 times by 1 test
Evaluated by:
  • Self test
22-203467016
1674 string[i + 1] == '$'))
string[i + 1] == '$'Description
TRUEevaluated 39 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 115 times by 1 test
Evaluated by:
  • Self test
39-115
1675 i++;
executed 235 times by 1 test: i++;
Executed by:
  • Self test
235
1676 prev_i = i;-
1677 ADVANCE_CHAR (string, slen, i);
executed 190545729 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 12918068 times by 1 test: mblength = 1;
Executed by:
  • Self test
never executed: end of block
never executed: end of block
never executed: (i)++;
executed 203463797 times by 1 test: (i) += mblength;
Executed by:
  • Self test
executed 3569 times by 1 test: (i)++;
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 203463797 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3569 times by 1 test
Evaluated by:
  • Self test
_fDescription
TRUEevaluated 190545729 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12918068 times by 1 test
Evaluated by:
  • Self test
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 203463797 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 12918068 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEevaluated 12918068 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 203463797 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 203463797 times by 1 test
Evaluated by:
  • Self test
0-203463797
1678 if (j < prev_i)
j < prev_iDescription
TRUEevaluated 1608 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 203465758 times by 1 test
Evaluated by:
  • Self test
1608-203465758
1679 do string[j++] = string[prev_i++]; while (prev_i < i);
executed 1608 times by 1 test: string[j++] = string[prev_i++];
Executed by:
  • Self test
prev_i < iDescription
TRUEnever evaluated
FALSEevaluated 1608 times by 1 test
Evaluated by:
  • Self test
0-1608
1680 else-
1681 j = i;
executed 203465758 times by 1 test: j = i;
Executed by:
  • Self test
203465758
1682 }
executed 203467366 times by 1 test: end of block
Executed by:
  • Self test
203467366
1683 string[j] = '\0';-
1684-
1685 return (string);
executed 3231118 times by 1 test: return (string);
Executed by:
  • Self test
3231118
1686}-
1687-
1688#if 0-
1689/*UNUSED*/-
1690/* Replace instances of \! in a string with !. */-
1691void-
1692unquote_bang (string)-
1693 char *string;-
1694{-
1695 register int i, j;-
1696 register char *temp;-
1697-
1698 temp = (char *)xmalloc (1 + strlen (string));-
1699-
1700 for (i = 0, j = 0; (temp[j] = string[i]); i++, j++)-
1701 {-
1702 if (string[i] == '\\' && string[i + 1] == '!')-
1703 {-
1704 temp[j] = '!';-
1705 i++;-
1706 }-
1707 }-
1708 strcpy (string, temp);-
1709 free (temp);-
1710}-
1711#endif-
1712-
1713#define CQ_RETURN(x) do { no_longjmp_on_fatal_error = oldjmp; return (x); } while (0)-
1714-
1715/* This function assumes s[i] == open; returns with s[ret] == close; used to-
1716 parse array subscripts. FLAGS & 1 means to not attempt to skip over-
1717 matched pairs of quotes or backquotes, or skip word expansions; it is-
1718 intended to be used after expansion has been performed and during final-
1719 assignment parsing (see arrayfunc.c:assign_compound_array_list()) or-
1720 during execution by a builtin which has already undergone word expansion. */-
1721static int-
1722skip_matched_pair (string, start, open, close, flags)-
1723 const char *string;-
1724 int start, open, close, flags;-
1725{-
1726 int i, pass_next, backq, si, c, count, oldjmp;-
1727 size_t slen;-
1728 char *temp, *ss;-
1729 DECLARE_MBSTATE;-
1730-
1731 slen = strlen (string + start) + start;-
1732 oldjmp = no_longjmp_on_fatal_error;-
1733 no_longjmp_on_fatal_error = 1;-
1734-
1735 i = start + 1; /* skip over leading bracket */-
1736 count = 1;-
1737 pass_next = backq = 0;-
1738 ss = (char *)string;-
1739 while (c = string[i])
c = string[i]Description
TRUEevaluated 1147136 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test
12-1147136
1740 {-
1741 if (pass_next)
pass_nextDescription
TRUEevaluated 64 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1147072 times by 1 test
Evaluated by:
  • Self test
64-1147072
1742 {-
1743 pass_next = 0;-
1744 if (c == 0)
c == 0Description
TRUEnever evaluated
FALSEevaluated 64 times by 1 test
Evaluated by:
  • Self test
0-64
1745 CQ_RETURN(i);
never executed: return (i);
never executed: end of block
0
1746 ADVANCE_CHAR (string, slen, i);
executed 54 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 10 times by 1 test: mblength = 1;
Executed by:
  • Self test
never executed: end of block
never executed: end of block
never executed: (i)++;
executed 64 times by 1 test: (i) += mblength;
Executed by:
  • Self test
never executed: (i)++;
locale_mb_cur_max > 1Description
TRUEevaluated 64 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
_fDescription
TRUEevaluated 54 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 64 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 64 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 64 times by 1 test
Evaluated by:
  • Self test
0-64
1747 continue;
executed 64 times by 1 test: continue;
Executed by:
  • Self test
64
1748 }-
1749 else if ((flags & 1) == 0 && c == '\\')
(flags & 1) == 0Description
TRUEevaluated 919475 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 227597 times by 1 test
Evaluated by:
  • Self test
c == '\\'Description
TRUEevaluated 64 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 919411 times by 1 test
Evaluated by:
  • Self test
64-919475
1750 {-
1751 pass_next = 1;-
1752 i++;-
1753 continue;
executed 64 times by 1 test: continue;
Executed by:
  • Self test
64
1754 }-
1755 else if (backq)
backqDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1147007 times by 1 test
Evaluated by:
  • Self test
1-1147007
1756 {-
1757 if (c == '`')
c == '`'Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-1
1758 backq = 0;
never executed: backq = 0;
0
1759 ADVANCE_CHAR (string, slen, i);
executed 1 time by 1 test: mblength = 1;
Executed by:
  • Self test
never executed: mblength = 1;
never executed: end of block
never executed: end of block
never executed: (i)++;
executed 1 time by 1 test: (i) += mblength;
Executed by:
  • Self test
never executed: (i)++;
locale_mb_cur_max > 1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
_fDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEnever evaluated
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-1
1760 continue;
executed 1 time by 1 test: continue;
Executed by:
  • Self test
1
1761 }-
1762 else if ((flags & 1) == 0 && c == '`')
(flags & 1) == 0Description
TRUEevaluated 919410 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 227597 times by 1 test
Evaluated by:
  • Self test
c == '`'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 919409 times by 1 test
Evaluated by:
  • Self test
1-919410
1763 {-
1764 backq = 1;-
1765 i++;-
1766 continue;
executed 1 time by 1 test: continue;
Executed by:
  • Self test
1
1767 }-
1768 else if ((flags & 1) == 0 && c == open)
(flags & 1) == 0Description
TRUEevaluated 919409 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 227597 times by 1 test
Evaluated by:
  • Self test
c == openDescription
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 919394 times by 1 test
Evaluated by:
  • Self test
15-919409
1769 {-
1770 count++;-
1771 i++;-
1772 continue;
executed 15 times by 1 test: continue;
Executed by:
  • Self test
15
1773 }-
1774 else if (c == close)
c == closeDescription
TRUEevaluated 130759 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1016232 times by 1 test
Evaluated by:
  • Self test
130759-1016232
1775 {-
1776 count--;-
1777 if (count == 0)
count == 0Description
TRUEevaluated 130744 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 15 times by 1 test
Evaluated by:
  • Self test
15-130744
1778 break;
executed 130744 times by 1 test: break;
Executed by:
  • Self test
130744
1779 i++;-
1780 continue;
executed 15 times by 1 test: continue;
Executed by:
  • Self test
15
1781 }-
1782 else if ((flags & 1) == 0 && (c == '\'' || c == '"'))
(flags & 1) == 0Description
TRUEevaluated 798854 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 217378 times by 1 test
Evaluated by:
  • Self test
c == '\''Description
TRUEevaluated 87 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 798767 times by 1 test
Evaluated by:
  • Self test
c == '"'Description
TRUEevaluated 14405 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 784362 times by 1 test
Evaluated by:
  • Self test
87-798854
1783 {-
1784 i = (c == '\'') ? skip_single_quoted (ss, slen, ++i, 0)
(c == '\'')Description
TRUEevaluated 87 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14405 times by 1 test
Evaluated by:
  • Self test
87-14405
1785 : skip_double_quoted (ss, slen, ++i, 0);-
1786 /* no increment, the skip functions increment past the closing quote. */-
1787 }
executed 14492 times by 1 test: end of block
Executed by:
  • Self test
14492
1788 else if ((flags&1) == 0 && c == '$' && (string[i+1] == LPAREN || string[i+1] == LBRACE))
(flags&1) == 0Description
TRUEevaluated 784362 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 217378 times by 1 test
Evaluated by:
  • Self test
c == '$'Description
TRUEevaluated 6898 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 777464 times by 1 test
Evaluated by:
  • Self test
string[i+1] == '('Description
TRUEevaluated 589 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6309 times by 1 test
Evaluated by:
  • Self test
string[i+1] == '{'Description
TRUEevaluated 1289 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5020 times by 1 test
Evaluated by:
  • Self test
589-784362
1789 {-
1790 si = i + 2;-
1791 if (string[si] == '\0')
string[si] == '\0'Description
TRUEnever evaluated
FALSEevaluated 1878 times by 1 test
Evaluated by:
  • Self test
0-1878
1792 CQ_RETURN(si);
never executed: return (si);
never executed: end of block
0
1793-
1794 /* XXX - extract_command_subst here? */-
1795 if (string[i+1] == LPAREN)
string[i+1] == '('Description
TRUEevaluated 589 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1289 times by 1 test
Evaluated by:
  • Self test
589-1289
1796 temp = extract_delimited_string (ss, &si, "$(", "(", ")", SX_NOALLOC|SX_COMMAND); /* ) */
executed 589 times by 1 test: temp = extract_delimited_string (ss, &si, "$(", "(", ")", 0x0001|0x0008);
Executed by:
  • Self test
589
1797 else-
1798 temp = extract_dollar_brace_string (ss, &si, 0, SX_NOALLOC);
executed 1289 times by 1 test: temp = extract_dollar_brace_string (ss, &si, 0, 0x0001);
Executed by:
  • Self test
1289
1799-
1800 CHECK_STRING_OVERRUN (i, si, slen, c);
never executed: break;
executed 1878 times by 1 test: ;
Executed by:
  • Self test
si >= slenDescription
TRUEnever evaluated
FALSEevaluated 1878 times by 1 test
Evaluated by:
  • Self test
0-1878
1801-
1802 i = si;-
1803 if (string[i] == '\0') /* don't increment i past EOS in loop */
string[i] == '\0'Description
TRUEnever evaluated
FALSEevaluated 1878 times by 1 test
Evaluated by:
  • Self test
0-1878
1804 break;
never executed: break;
0
1805 i++;-
1806 continue;
executed 1878 times by 1 test: continue;
Executed by:
  • Self test
1878
1807 }-
1808 else-
1809 ADVANCE_CHAR (string, slen, i);
executed 986540 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 10878 times by 1 test: mblength = 1;
Executed by:
  • Self test
never executed: end of block
never executed: end of block
never executed: (i)++;
executed 997418 times by 1 test: (i) += mblength;
Executed by:
  • Self test
executed 2444 times by 1 test: (i)++;
Executed by:
  • Self test
executed 999862 times by 1 test: end of block
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 997418 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2444 times by 1 test
Evaluated by:
  • Self test
_fDescription
TRUEevaluated 986540 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10878 times by 1 test
Evaluated by:
  • Self test
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 997418 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 10878 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEevaluated 10878 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 997418 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 997418 times by 1 test
Evaluated by:
  • Self test
0-999862
1810 }-
1811-
1812 CQ_RETURN(i);
executed 130756 times by 1 test: return (i);
Executed by:
  • Self test
130756
1813}-
1814-
1815#if defined (ARRAY_VARS)-
1816int-
1817skipsubscript (string, start, flags)-
1818 const char *string;-
1819 int start, flags;-
1820{-
1821 return (skip_matched_pair (string, start, '[', ']', flags));
executed 130756 times by 1 test: return (skip_matched_pair (string, start, '[', ']', flags));
Executed by:
  • Self test
130756
1822}-
1823#endif-
1824-
1825/* Skip characters in STRING until we find a character in DELIMS, and return-
1826 the index of that character. START is the index into string at which we-
1827 begin. This is similar in spirit to strpbrk, but it returns an index into-
1828 STRING and takes a starting index. This little piece of code knows quite-
1829 a lot of shell syntax. It's very similar to skip_double_quoted and other-
1830 functions of that ilk. */-
1831int-
1832skip_to_delim (string, start, delims, flags)-
1833 char *string;-
1834 int start;-
1835 char *delims;-
1836 int flags;-
1837{-
1838 int i, pass_next, backq, dquote, si, c, oldjmp;-
1839 int invert, skipquote, skipcmd, noprocsub, completeflag;-
1840 int arithexp, skipcol;-
1841 size_t slen;-
1842 char *temp, open[3];-
1843 DECLARE_MBSTATE;-
1844-
1845 slen = strlen (string + start) + start;-
1846 oldjmp = no_longjmp_on_fatal_error;-
1847 if (flags & SD_NOJMP)
flags & 0x001Description
TRUEevaluated 8424 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1653 times by 1 test
Evaluated by:
  • Self test
1653-8424
1848 no_longjmp_on_fatal_error = 1;
executed 8424 times by 1 test: no_longjmp_on_fatal_error = 1;
Executed by:
  • Self test
8424
1849 invert = (flags & SD_INVERT);-
1850 skipcmd = (flags & SD_NOSKIPCMD) == 0;-
1851 noprocsub = (flags & SD_NOPROCSUB);-
1852 completeflag = (flags & SD_COMPLETE) ? SX_COMPLETE : 0;
(flags & 0x100)Description
TRUEevaluated 481 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9596 times by 1 test
Evaluated by:
  • Self test
481-9596
1853-
1854 arithexp = (flags & SD_ARITHEXP);-
1855 skipcol = 0;-
1856-
1857 i = start;-
1858 pass_next = backq = dquote = 0;-
1859 while (c = string[i])
c = string[i]Description
TRUEevaluated 47736 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3510 times by 1 test
Evaluated by:
  • Self test
3510-47736
1860 {-
1861 /* If this is non-zero, we should not let quote characters be delimiters-
1862 and the current character is a single or double quote. We should not-
1863 test whether or not it's a delimiter until after we skip single- or-
1864 double-quoted strings. */-
1865 skipquote = ((flags & SD_NOQUOTEDELIM) && (c == '\'' || c =='"'));
(flags & 0x004)Description
TRUEnever evaluated
FALSEevaluated 47736 times by 1 test
Evaluated by:
  • Self test
c == '\''Description
TRUEnever evaluated
FALSEnever evaluated
c =='"'Description
TRUEnever evaluated
FALSEnever evaluated
0-47736
1866 if (pass_next)
pass_nextDescription
TRUEevaluated 88 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 47648 times by 1 test
Evaluated by:
  • Self test
88-47648
1867 {-
1868 pass_next = 0;-
1869 if (c == 0)
c == 0Description
TRUEnever evaluated
FALSEevaluated 88 times by 1 test
Evaluated by:
  • Self test
0-88
1870 CQ_RETURN(i);
never executed: return (i);
never executed: end of block
0
1871 ADVANCE_CHAR (string, slen, i);
executed 75 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 1 time by 1 test: mblength = 1;
Executed by:
  • Self test
never executed: end of block
never executed: end of block
never executed: (i)++;
executed 76 times by 1 test: (i) += mblength;
Executed by:
  • Self test
executed 12 times by 1 test: (i)++;
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 76 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test
_fDescription
TRUEevaluated 75 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 76 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 76 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 76 times by 1 test
Evaluated by:
  • Self test
0-76
1872 continue;
executed 88 times by 1 test: continue;
Executed by:
  • Self test
88
1873 }-
1874 else if (c == '\\')
c == '\\'Description
TRUEevaluated 88 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 47560 times by 1 test
Evaluated by:
  • Self test
88-47560
1875 {-
1876 pass_next = 1;-
1877 i++;-
1878 continue;
executed 88 times by 1 test: continue;
Executed by:
  • Self test
88
1879 }-
1880 else if (backq)
backqDescription
TRUEevaluated 302 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 47258 times by 1 test
Evaluated by:
  • Self test
302-47258
1881 {-
1882 if (c == '`')
c == '`'Description
TRUEevaluated 33 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 269 times by 1 test
Evaluated by:
  • Self test
33-269
1883 backq = 0;
executed 33 times by 1 test: backq = 0;
Executed by:
  • Self test
33
1884 ADVANCE_CHAR (string, slen, i);
executed 136 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 20 times by 1 test: mblength = 1;
Executed by:
  • Self test
never executed: end of block
never executed: end of block
never executed: (i)++;
executed 156 times by 1 test: (i) += mblength;
Executed by:
  • Self test
executed 146 times by 1 test: (i)++;
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 156 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 146 times by 1 test
Evaluated by:
  • Self test
_fDescription
TRUEevaluated 136 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20 times by 1 test
Evaluated by:
  • Self test
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 156 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 156 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 156 times by 1 test
Evaluated by:
  • Self test
0-156
1885 continue;
executed 302 times by 1 test: continue;
Executed by:
  • Self test
302
1886 }-
1887 else if (c == '`')
c == '`'Description
TRUEevaluated 33 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 47225 times by 1 test
Evaluated by:
  • Self test
33-47225
1888 {-
1889 backq = 1;-
1890 i++;-
1891 continue;
executed 33 times by 1 test: continue;
Executed by:
  • Self test
33
1892 }-
1893 else if (arithexp && skipcol && c == ':')
arithexpDescription
TRUEevaluated 1579 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 45646 times by 1 test
Evaluated by:
  • Self test
skipcolDescription
TRUEevaluated 56 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1523 times by 1 test
Evaluated by:
  • Self test
c == ':'Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 32 times by 1 test
Evaluated by:
  • Self test
24-45646
1894 {-
1895 skipcol--;-
1896 i++;-
1897 continue;
executed 24 times by 1 test: continue;
Executed by:
  • Self test
24
1898 }-
1899 else if (arithexp && c == '?')
arithexpDescription
TRUEevaluated 1555 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 45646 times by 1 test
Evaluated by:
  • Self test
c == '?'Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1531 times by 1 test
Evaluated by:
  • Self test
24-45646
1900 {-
1901 skipcol++;-
1902 i++;-
1903 continue;
executed 24 times by 1 test: continue;
Executed by:
  • Self test
24
1904 }-
1905 else if (skipquote == 0 && invert == 0 && member (c, delims))
(c)Description
TRUEevaluated 47177 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
skipquote == 0Description
TRUEevaluated 47177 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
invert == 0Description
TRUEevaluated 47177 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((c) ? ((char ...id *)0) ) : 0)Description
TRUEevaluated 6567 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 40610 times by 1 test
Evaluated by:
  • Self test
0-47177
1906 break;
executed 6567 times by 1 test: break;
Executed by:
  • Self test
6567
1907 /* the usual case is to use skip_xxx_quoted, but we don't skip over double-
1908 quoted strings when looking for the history expansion character as a-
1909 delimiter. */-
1910 /* special case for programmable completion which takes place before-
1911 parser converts backslash-escaped single quotes between $'...' to-
1912 `regular' single-quoted strings. */-
1913 else if (completeflag && i > 0 && string[i-1] == '$' && c == '\'')
completeflagDescription
TRUEevaluated 4538 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 36072 times by 1 test
Evaluated by:
  • Self test
i > 0Description
TRUEevaluated 4059 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 479 times by 1 test
Evaluated by:
  • Self test
string[i-1] == '$'Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4047 times by 1 test
Evaluated by:
  • Self test
c == '\''Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
3-36072
1914 i = skip_single_quoted (string, slen, ++i, SX_COMPLETE);
executed 3 times by 1 test: i = skip_single_quoted (string, slen, ++i, 0x0400);
Executed by:
  • Self test
3
1915 else if (c == '\'')
c == '\''Description
TRUEevaluated 86 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 40521 times by 1 test
Evaluated by:
  • Self test
86-40521
1916 i = skip_single_quoted (string, slen, ++i, 0);
executed 86 times by 1 test: i = skip_single_quoted (string, slen, ++i, 0);
Executed by:
  • Self test
86
1917 else if (c == '"')
c == '"'Description
TRUEevaluated 507 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 40014 times by 1 test
Evaluated by:
  • Self test
507-40014
1918 i = skip_double_quoted (string, slen, ++i, completeflag);
executed 507 times by 1 test: i = skip_double_quoted (string, slen, ++i, completeflag);
Executed by:
  • Self test
507
1919 else if (c == LPAREN && arithexp)
c == '('Description
TRUEevaluated 445 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 39569 times by 1 test
Evaluated by:
  • Self test
arithexpDescription
TRUEevaluated 30 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 415 times by 1 test
Evaluated by:
  • Self test
30-39569
1920 {-
1921 si = i + 1;-
1922 if (string[si] == '\0')
string[si] == '\0'Description
TRUEnever evaluated
FALSEevaluated 30 times by 1 test
Evaluated by:
  • Self test
0-30
1923 CQ_RETURN(si);
never executed: return (si);
never executed: end of block
0
1924-
1925 temp = extract_delimited_string (string, &si, "(", "(", ")", SX_NOALLOC); /* ) */-
1926 i = si;-
1927 if (string[i] == '\0') /* don't increment i past EOS in loop */
string[i] == '\0'Description
TRUEnever evaluated
FALSEevaluated 30 times by 1 test
Evaluated by:
  • Self test
0-30
1928 break;
never executed: break;
0
1929 i++;-
1930 continue;
executed 30 times by 1 test: continue;
Executed by:
  • Self test
30
1931 }-
1932 else if (c == '$' && ((skipcmd && string[i+1] == LPAREN) || string[i+1] == LBRACE))
c == '$'Description
TRUEevaluated 583 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 39401 times by 1 test
Evaluated by:
  • Self test
skipcmdDescription
TRUEevaluated 583 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
string[i+1] == '('Description
TRUEevaluated 366 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 217 times by 1 test
Evaluated by:
  • Self test
string[i+1] == '{'Description
TRUEevaluated 78 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 139 times by 1 test
Evaluated by:
  • Self test
0-39401
1933 {-
1934 si = i + 2;-
1935 if (string[si] == '\0')
string[si] == '\0'Description
TRUEnever evaluated
FALSEevaluated 444 times by 1 test
Evaluated by:
  • Self test
0-444
1936 CQ_RETURN(si);
never executed: return (si);
never executed: end of block
0
1937-
1938 if (string[i+1] == LPAREN)
string[i+1] == '('Description
TRUEevaluated 366 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 78 times by 1 test
Evaluated by:
  • Self test
78-366
1939 temp = extract_delimited_string (string, &si, "$(", "(", ")", SX_NOALLOC|SX_COMMAND); /* ) */
executed 366 times by 1 test: temp = extract_delimited_string (string, &si, "$(", "(", ")", 0x0001|0x0008);
Executed by:
  • Self test
366
1940 else-
1941 temp = extract_dollar_brace_string (string, &si, 0, SX_NOALLOC);
executed 78 times by 1 test: temp = extract_dollar_brace_string (string, &si, 0, 0x0001);
Executed by:
  • Self test
78
1942 CHECK_STRING_OVERRUN (i, si, slen, c);
never executed: break;
executed 444 times by 1 test: ;
Executed by:
  • Self test
si >= slenDescription
TRUEnever evaluated
FALSEevaluated 444 times by 1 test
Evaluated by:
  • Self test
0-444
1943 i = si;-
1944 if (string[i] == '\0') /* don't increment i past EOS in loop */
string[i] == '\0'Description
TRUEnever evaluated
FALSEevaluated 444 times by 1 test
Evaluated by:
  • Self test
0-444
1945 break;
never executed: break;
0
1946 i++;-
1947 continue;
executed 444 times by 1 test: continue;
Executed by:
  • Self test
444
1948 }-
1949#if defined (PROCESS_SUBSTITUTION)-
1950 else if (skipcmd && noprocsub == 0 && (c == '<' || c == '>') && string[i+1] == LPAREN)
skipcmdDescription
TRUEevaluated 39540 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
noprocsub == 0Description
TRUEevaluated 7021 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 32519 times by 1 test
Evaluated by:
  • Self test
c == '<'Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7006 times by 1 test
Evaluated by:
  • Self test
c == '>'Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7003 times by 1 test
Evaluated by:
  • Self test
string[i+1] == '('Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
0-39540
1951 {-
1952 si = i + 2;-
1953 if (string[si] == '\0')
string[si] == '\0'Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
0-5
1954 CQ_RETURN(si);
never executed: return (si);
never executed: end of block
0
1955-
1956 temp = extract_delimited_string (string, &si, (c == '<') ? "<(" : ">(", "(", ")", SX_COMMAND|SX_NOALLOC); /* )) */-
1957 CHECK_STRING_OVERRUN (i, si, slen, c);
never executed: break;
executed 5 times by 1 test: ;
Executed by:
  • Self test
si >= slenDescription
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
0-5
1958 i = si;-
1959 if (string[i] == '\0')
string[i] == '\0'Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
0-5
1960 break;
never executed: break;
0
1961 i++;-
1962 continue;
executed 5 times by 1 test: continue;
Executed by:
  • Self test
5
1963 }-
1964#endif /* PROCESS_SUBSTITUTION */-
1965#if defined (EXTENDED_GLOB)-
1966 else if ((flags & SD_EXTGLOB) && extended_glob && string[i+1] == LPAREN && member (c, "?*+!@"))
(c)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(flags & 0x010)Description
TRUEevaluated 4373 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 35162 times by 1 test
Evaluated by:
  • Self test
extended_globDescription
TRUEevaluated 23 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4350 times by 1 test
Evaluated by:
  • Self test
string[i+1] == '('Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 21 times by 1 test
Evaluated by:
  • Self test
((c) ? ((char ...id *)0) ) : 0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-35162
1967 {-
1968 si = i + 2;-
1969 if (string[si] == '\0')
string[si] == '\0'Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
0-2
1970 CQ_RETURN(si);
never executed: return (si);
never executed: end of block
0
1971-
1972 open[0] = c;-
1973 open[1] = LPAREN;-
1974 open[2] = '\0';-
1975 temp = extract_delimited_string (string, &si, open, "(", ")", SX_NOALLOC); /* ) */-
1976-
1977 CHECK_STRING_OVERRUN (i, si, slen, c);
never executed: break;
executed 2 times by 1 test: ;
Executed by:
  • Self test
si >= slenDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
0-2
1978 i = si;-
1979 if (string[i] == '\0') /* don't increment i past EOS in loop */
string[i] == '\0'Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
0-2
1980 break;
never executed: break;
0
1981 i++;-
1982 continue;
executed 2 times by 1 test: continue;
Executed by:
  • Self test
2
1983 }-
1984#endif-
1985 else if ((flags & SD_GLOB) && c == LBRACK)
(flags & 0x040)Description
TRUEevaluated 4371 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 35162 times by 1 test
Evaluated by:
  • Self test
c == '['Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4368 times by 1 test
Evaluated by:
  • Self test
3-35162
1986 {-
1987 si = i + 1;-
1988 if (string[si] == '\0')
string[si] == '\0'Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
0-3
1989 CQ_RETURN(si);
never executed: return (si);
never executed: end of block
0
1990-
1991 temp = extract_delimited_string (string, &si, "[", "[", "]", SX_NOALLOC); /* ] */-
1992-
1993 i = si;-
1994 if (string[i] == '\0') /* don't increment i past EOS in loop */
string[i] == '\0'Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
0-3
1995 break;
never executed: break;
0
1996 i++;-
1997 continue;
executed 3 times by 1 test: continue;
Executed by:
  • Self test
3
1998 }-
1999 else if ((skipquote || invert) && (member (c, delims) == 0))
(c)Description
TRUEnever evaluated
FALSEnever evaluated
skipquoteDescription
TRUEnever evaluated
FALSEevaluated 39530 times by 1 test
Evaluated by:
  • Self test
invertDescription
TRUEnever evaluated
FALSEevaluated 39530 times by 1 test
Evaluated by:
  • Self test
(((c) ? ((char...) ) : 0) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
0-39530
2000 break;
never executed: break;
0
2001 else-
2002 ADVANCE_CHAR (string, slen, i);
executed 35759 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 144 times by 1 test: mblength = 1;
Executed by:
  • Self test
never executed: end of block
never executed: end of block
never executed: (i)++;
executed 35903 times by 1 test: (i) += mblength;
Executed by:
  • Self test
executed 3627 times by 1 test: (i)++;
Executed by:
  • Self test
executed 39530 times by 1 test: end of block
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 35903 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3627 times by 1 test
Evaluated by:
  • Self test
_fDescription
TRUEevaluated 35759 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 144 times by 1 test
Evaluated by:
  • Self test
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 35903 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 144 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEevaluated 144 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 35903 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 35903 times by 1 test
Evaluated by:
  • Self test
0-39530
2003 }-
2004-
2005 CQ_RETURN(i);
executed 10077 times by 1 test: return (i);
Executed by:
  • Self test
10077
2006}-
2007-
2008#if defined (BANG_HISTORY)-
2009/* Skip to the history expansion character (delims[0]), paying attention to-
2010 quoted strings and command and process substitution. This is a stripped--
2011 down version of skip_to_delims. The essential difference is that this-
2012 resets the quoting state when starting a command substitution */-
2013int-
2014skip_to_histexp (string, start, delims, flags)-
2015 char *string;-
2016 int start;-
2017 char *delims;-
2018 int flags;-
2019{-
2020 int i, pass_next, backq, dquote, c, oldjmp;-
2021 int histexp_comsub, histexp_backq, old_dquote;-
2022 size_t slen;-
2023 DECLARE_MBSTATE;-
2024-
2025 slen = strlen (string + start) + start;-
2026 oldjmp = no_longjmp_on_fatal_error;-
2027 if (flags & SD_NOJMP)
flags & 0x001Description
TRUEevaluated 321 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-321
2028 no_longjmp_on_fatal_error = 1;
executed 321 times by 1 test: no_longjmp_on_fatal_error = 1;
Executed by:
  • Self test
321
2029-
2030 histexp_comsub = histexp_backq = old_dquote = 0;-
2031-
2032 i = start;-
2033 pass_next = backq = dquote = 0;-
2034 while (c = string[i])
c = string[i]Description
TRUEevaluated 2311 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 23 times by 1 test
Evaluated by:
  • Self test
23-2311
2035 {-
2036 if (pass_next)
pass_nextDescription
TRUEevaluated 16 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2295 times by 1 test
Evaluated by:
  • Self test
16-2295
2037 {-
2038 pass_next = 0;-
2039 if (c == 0)
c == 0Description
TRUEnever evaluated
FALSEevaluated 16 times by 1 test
Evaluated by:
  • Self test
0-16
2040 CQ_RETURN(i);
never executed: return (i);
never executed: end of block
0
2041 ADVANCE_CHAR (string, slen, i);
never executed: mblength = 1;
never executed: mblength = 1;
never executed: end of block
never executed: end of block
never executed: (i)++;
never executed: (i) += mblength;
executed 16 times by 1 test: (i)++;
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEnever evaluated
FALSEevaluated 16 times by 1 test
Evaluated by:
  • Self test
_fDescription
TRUEnever evaluated
FALSEnever evaluated
mblength == 0Description
TRUEnever evaluated
FALSEnever evaluated
locale_utf8localeDescription
TRUEnever evaluated
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEnever evaluated
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEnever evaluated
0-16
2042 continue;
executed 16 times by 1 test: continue;
Executed by:
  • Self test
16
2043 }-
2044 else if (c == '\\')
c == '\\'Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2279 times by 1 test
Evaluated by:
  • Self test
16-2279
2045 {-
2046 pass_next = 1;-
2047 i++;-
2048 continue;
executed 16 times by 1 test: continue;
Executed by:
  • Self test
16
2049 }-
2050 else if (backq && c == '`')
backqDescription
TRUEevaluated 118 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2161 times by 1 test
Evaluated by:
  • Self test
c == '`'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 114 times by 1 test
Evaluated by:
  • Self test
4-2161
2051 {-
2052 backq = 0;-
2053 histexp_backq--;-
2054 dquote = old_dquote;-
2055 i++;-
2056 continue;
executed 4 times by 1 test: continue;
Executed by:
  • Self test
4
2057 }-
2058 else if (c == '`')
c == '`'Description
TRUEevaluated 19 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2256 times by 1 test
Evaluated by:
  • Self test
19-2256
2059 {-
2060 backq = 1;-
2061 histexp_backq++;-
2062 old_dquote = dquote; /* simple - one level for now */-
2063 dquote = 0;-
2064 i++;-
2065 continue;
executed 19 times by 1 test: continue;
Executed by:
  • Self test
19
2066 }-
2067 /* When in double quotes, act as if the double quote is a member of-
2068 history_no_expand_chars, like the history library does */-
2069 else if (dquote && c == delims[0] && string[i+1] == '"')
dquoteDescription
TRUEevaluated 157 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2099 times by 1 test
Evaluated by:
  • Self test
c == delims[0]Description
TRUEevaluated 74 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 83 times by 1 test
Evaluated by:
  • Self test
string[i+1] == '"'Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 63 times by 1 test
Evaluated by:
  • Self test
11-2099
2070 {-
2071 i++;-
2072 continue;
executed 11 times by 1 test: continue;
Executed by:
  • Self test
11
2073 }-
2074 else if (c == delims[0])
c == delims[0]Description
TRUEevaluated 298 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1947 times by 1 test
Evaluated by:
  • Self test
298-1947
2075 break;
executed 298 times by 1 test: break;
Executed by:
  • Self test
298
2076 /* the usual case is to use skip_xxx_quoted, but we don't skip over double-
2077 quoted strings when looking for the history expansion character as a-
2078 delimiter. */-
2079 else if (dquote && c == '\'')
dquoteDescription
TRUEevaluated 83 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1864 times by 1 test
Evaluated by:
  • Self test
c == '\''Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 81 times by 1 test
Evaluated by:
  • Self test
2-1864
2080 {-
2081 i++;-
2082 continue;
executed 2 times by 1 test: continue;
Executed by:
  • Self test
2
2083 }-
2084 else if (c == '\'')
c == '\''Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1932 times by 1 test
Evaluated by:
  • Self test
13-1932
2085 i = skip_single_quoted (string, slen, ++i, 0);
executed 13 times by 1 test: i = skip_single_quoted (string, slen, ++i, 0);
Executed by:
  • Self test
13
2086 /* The posixly_correct test makes posix-mode shells allow double quotes-
2087 to quote the history expansion character */-
2088 else if (posixly_correct == 0 && c == '"')
posixly_correct == 0Description
TRUEevaluated 1898 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 34 times by 1 test
Evaluated by:
  • Self test
c == '"'Description
TRUEevaluated 149 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1749 times by 1 test
Evaluated by:
  • Self test
34-1898
2089 {-
2090 dquote = 1 - dquote;-
2091 i++;-
2092 continue;
executed 149 times by 1 test: continue;
Executed by:
  • Self test
149
2093 } -
2094 else if (c == '"')
c == '"'Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1778 times by 1 test
Evaluated by:
  • Self test
5-1778
2095 i = skip_double_quoted (string, slen, ++i, 0);
executed 5 times by 1 test: i = skip_double_quoted (string, slen, ++i, 0);
Executed by:
  • Self test
5
2096#if defined (PROCESS_SUBSTITUTION)-
2097 else if ((c == '$' || c == '<' || c == '>') && string[i+1] == LPAREN && string[i+2] != LPAREN)
c == '$'Description
TRUEevaluated 62 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1716 times by 1 test
Evaluated by:
  • Self test
c == '<'Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1696 times by 1 test
Evaluated by:
  • Self test
c == '>'Description
TRUEnever evaluated
FALSEevaluated 1696 times by 1 test
Evaluated by:
  • Self test
string[i+1] == '('Description
TRUEevaluated 71 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11 times by 1 test
Evaluated by:
  • Self test
string[i+2] != '('Description
TRUEevaluated 71 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1716
2098#else-
2099 else if (c == '$' && string[i+1] == LPAREN && string[i+2] != LPAREN)-
2100#endif-
2101 {-
2102 if (string[i+2] == '\0')
string[i+2] == '\0'Description
TRUEnever evaluated
FALSEevaluated 71 times by 1 test
Evaluated by:
  • Self test
0-71
2103 CQ_RETURN(i+2);
never executed: return (i+2);
never executed: end of block
0
2104 i += 2;-
2105 histexp_comsub++;-
2106 old_dquote = dquote;-
2107 dquote = 0;-
2108 }
executed 71 times by 1 test: end of block
Executed by:
  • Self test
71
2109 else if (histexp_comsub && c == RPAREN)
histexp_comsubDescription
TRUEevaluated 416 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1291 times by 1 test
Evaluated by:
  • Self test
c == ')'Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 394 times by 1 test
Evaluated by:
  • Self test
22-1291
2110 {-
2111 histexp_comsub--;-
2112 dquote = old_dquote;-
2113 i++;-
2114 continue;
executed 22 times by 1 test: continue;
Executed by:
  • Self test
22
2115 }-
2116 else if (backq) /* placeholder */
backqDescription
TRUEevaluated 99 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1586 times by 1 test
Evaluated by:
  • Self test
99-1586
2117 {-
2118 ADVANCE_CHAR (string, slen, i);
never executed: mblength = 1;
never executed: mblength = 1;
never executed: end of block
never executed: end of block
never executed: (i)++;
never executed: (i) += mblength;
executed 99 times by 1 test: (i)++;
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEnever evaluated
FALSEevaluated 99 times by 1 test
Evaluated by:
  • Self test
_fDescription
TRUEnever evaluated
FALSEnever evaluated
mblength == 0Description
TRUEnever evaluated
FALSEnever evaluated
locale_utf8localeDescription
TRUEnever evaluated
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEnever evaluated
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEnever evaluated
0-99
2119 continue;
executed 99 times by 1 test: continue;
Executed by:
  • Self test
99
2120 }-
2121 else-
2122 ADVANCE_CHAR (string, slen, i);
never executed: mblength = 1;
never executed: mblength = 1;
never executed: end of block
never executed: end of block
never executed: (i)++;
never executed: (i) += mblength;
executed 1586 times by 1 test: (i)++;
Executed by:
  • Self test
executed 1586 times by 1 test: end of block
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEnever evaluated
FALSEevaluated 1586 times by 1 test
Evaluated by:
  • Self test
_fDescription
TRUEnever evaluated
FALSEnever evaluated
mblength == 0Description
TRUEnever evaluated
FALSEnever evaluated
locale_utf8localeDescription
TRUEnever evaluated
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEnever evaluated
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEnever evaluated
0-1586
2123 }-
2124-
2125 CQ_RETURN(i);
executed 321 times by 1 test: return (i);
Executed by:
  • Self test
321
2126}-
2127#endif /* BANG_HISTORY */-
2128-
2129#if defined (READLINE)-
2130/* Return 1 if the portion of STRING ending at EINDEX is quoted (there is-
2131 an unclosed quoted string), or if the character at EINDEX is quoted-
2132 by a backslash. NO_LONGJMP_ON_FATAL_ERROR is used to flag that the various-
2133 single and double-quoted string parsing functions should not return an-
2134 error if there are unclosed quotes or braces. The characters that this-
2135 recognizes need to be the same as the contents of-
2136 rl_completer_quote_characters. */-
2137-
2138int-
2139char_is_quoted (string, eindex)-
2140 char *string;-
2141 int eindex;-
2142{-
2143 int i, pass_next, c, oldjmp;-
2144 size_t slen;-
2145 DECLARE_MBSTATE;-
2146-
2147 slen = strlen (string);-
2148 oldjmp = no_longjmp_on_fatal_error;-
2149 no_longjmp_on_fatal_error = 1;-
2150 i = pass_next = 0;-
2151 while (i <= eindex)
i <= eindexDescription
TRUEnever evaluated
FALSEnever evaluated
0
2152 {-
2153 c = string[i];-
2154-
2155 if (pass_next)
pass_nextDescription
TRUEnever evaluated
FALSEnever evaluated
0
2156 {-
2157 pass_next = 0;-
2158 if (i >= eindex) /* XXX was if (i >= eindex - 1) */
i >= eindexDescription
TRUEnever evaluated
FALSEnever evaluated
0
2159 CQ_RETURN(1);
never executed: return (1);
never executed: end of block
0
2160 ADVANCE_CHAR (string, slen, i);
never executed: mblength = 1;
never executed: mblength = 1;
never executed: end of block
never executed: end of block
never executed: (i)++;
never executed: (i) += mblength;
never executed: (i)++;
locale_mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
_fDescription
TRUEnever evaluated
FALSEnever evaluated
mblength == 0Description
TRUEnever evaluated
FALSEnever evaluated
locale_utf8localeDescription
TRUEnever evaluated
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEnever evaluated
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEnever evaluated
0
2161 continue;
never executed: continue;
0
2162 }-
2163 else if (c == '\\')
c == '\\'Description
TRUEnever evaluated
FALSEnever evaluated
0
2164 {-
2165 pass_next = 1;-
2166 i++;-
2167 continue;
never executed: continue;
0
2168 }-
2169 else if (c == '$' && string[i+1] == '\'' && string[i+2])
c == '$'Description
TRUEnever evaluated
FALSEnever evaluated
string[i+1] == '\''Description
TRUEnever evaluated
FALSEnever evaluated
string[i+2]Description
TRUEnever evaluated
FALSEnever evaluated
0
2170 {-
2171 i += 2;-
2172 i = skip_single_quoted (string, slen, i, SX_COMPLETE);-
2173 if (i > eindex)
i > eindexDescription
TRUEnever evaluated
FALSEnever evaluated
0
2174 CQ_RETURN (i);
never executed: return (i);
never executed: end of block
0
2175 }
never executed: end of block
0
2176 else if (c == '\'' || c == '"')
c == '\''Description
TRUEnever evaluated
FALSEnever evaluated
c == '"'Description
TRUEnever evaluated
FALSEnever evaluated
0
2177 {-
2178 i = (c == '\'') ? skip_single_quoted (string, slen, ++i, 0)
(c == '\'')Description
TRUEnever evaluated
FALSEnever evaluated
0
2179 : skip_double_quoted (string, slen, ++i, SX_COMPLETE);-
2180 if (i > eindex)
i > eindexDescription
TRUEnever evaluated
FALSEnever evaluated
0
2181 CQ_RETURN(1);
never executed: return (1);
never executed: end of block
0
2182 /* no increment, the skip_xxx functions go one past end */-
2183 }
never executed: end of block
0
2184 else-
2185 ADVANCE_CHAR (string, slen, i);
never executed: mblength = 1;
never executed: mblength = 1;
never executed: end of block
never executed: end of block
never executed: (i)++;
never executed: (i) += mblength;
never executed: (i)++;
never executed: end of block
locale_mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
_fDescription
TRUEnever evaluated
FALSEnever evaluated
mblength == 0Description
TRUEnever evaluated
FALSEnever evaluated
locale_utf8localeDescription
TRUEnever evaluated
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEnever evaluated
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEnever evaluated
0
2186 }-
2187-
2188 CQ_RETURN(0);
never executed: return (0);
0
2189}-
2190-
2191int-
2192unclosed_pair (string, eindex, openstr)-
2193 char *string;-
2194 int eindex;-
2195 char *openstr;-
2196{-
2197 int i, pass_next, openc, olen;-
2198 size_t slen;-
2199 DECLARE_MBSTATE;-
2200-
2201 slen = strlen (string);-
2202 olen = strlen (openstr);-
2203 i = pass_next = openc = 0;-
2204 while (i <= eindex)
i <= eindexDescription
TRUEnever evaluated
FALSEnever evaluated
0
2205 {-
2206 if (pass_next)
pass_nextDescription
TRUEnever evaluated
FALSEnever evaluated
0
2207 {-
2208 pass_next = 0;-
2209 if (i >= eindex) /* XXX was if (i >= eindex - 1) */
i >= eindexDescription
TRUEnever evaluated
FALSEnever evaluated
0
2210 return 0;
never executed: return 0;
0
2211 ADVANCE_CHAR (string, slen, i);
never executed: mblength = 1;
never executed: mblength = 1;
never executed: end of block
never executed: end of block
never executed: (i)++;
never executed: (i) += mblength;
never executed: (i)++;
locale_mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
_fDescription
TRUEnever evaluated
FALSEnever evaluated
mblength == 0Description
TRUEnever evaluated
FALSEnever evaluated
locale_utf8localeDescription
TRUEnever evaluated
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEnever evaluated
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEnever evaluated
0
2212 continue;
never executed: continue;
0
2213 }-
2214 else if (string[i] == '\\')
string[i] == '\\'Description
TRUEnever evaluated
FALSEnever evaluated
0
2215 {-
2216 pass_next = 1;-
2217 i++;-
2218 continue;
never executed: continue;
0
2219 }-
2220 else if (STREQN (string + i, openstr, olen))
never executed: __result = (((const unsigned char *) (const char *) ( string + i ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( openstr ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
((olen == 0) ?...len ))) == 0))Description
TRUEnever evaluated
FALSEnever evaluated
(olen == 0)Description
TRUEnever evaluated
FALSEnever evaluated
(string + i)[0...= (openstr)[0]Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__... olen ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_constant_p ( olen )Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons...( string + i )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( strin...e_t) ( olen ))Description
TRUEnever evaluated
FALSEnever evaluated
__builtin_cons..._p ( openstr )Description
TRUEnever evaluated
FALSEnever evaluated
strlen ( opens...e_t) ( olen ))Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2221 {-
2222 openc = 1 - openc;-
2223 i += olen;-
2224 }
never executed: end of block
0
2225 /* XXX - may want to handle $'...' specially here */-
2226 else if (string[i] == '\'' || string[i] == '"')
string[i] == '\''Description
TRUEnever evaluated
FALSEnever evaluated
string[i] == '"'Description
TRUEnever evaluated
FALSEnever evaluated
0
2227 {-
2228 i = (string[i] == '\'') ? skip_single_quoted (string, slen, i, 0)
(string[i] == '\'')Description
TRUEnever evaluated
FALSEnever evaluated
0
2229 : skip_double_quoted (string, slen, i, SX_COMPLETE);-
2230 if (i > eindex)
i > eindexDescription
TRUEnever evaluated
FALSEnever evaluated
0
2231 return 0;
never executed: return 0;
0
2232 }
never executed: end of block
0
2233 else-
2234 ADVANCE_CHAR (string, slen, i);
never executed: mblength = 1;
never executed: mblength = 1;
never executed: end of block
never executed: end of block
never executed: (i)++;
never executed: (i) += mblength;
never executed: (i)++;
never executed: end of block
locale_mb_cur_max > 1Description
TRUEnever evaluated
FALSEnever evaluated
_fDescription
TRUEnever evaluated
FALSEnever evaluated
mblength == 0Description
TRUEnever evaluated
FALSEnever evaluated
locale_utf8localeDescription
TRUEnever evaluated
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEnever evaluated
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEnever evaluated
0
2235 }-
2236 return (openc);
never executed: return (openc);
0
2237}-
2238-
2239/* Split STRING (length SLEN) at DELIMS, and return a WORD_LIST with the-
2240 individual words. If DELIMS is NULL, the current value of $IFS is used-
2241 to split the string, and the function follows the shell field splitting-
2242 rules. SENTINEL is an index to look for. NWP, if non-NULL,-
2243 gets the number of words in the returned list. CWP, if non-NULL, gets-
2244 the index of the word containing SENTINEL. Non-whitespace chars in-
2245 DELIMS delimit separate fields. This is used by programmable completion. */-
2246WORD_LIST *-
2247split_at_delims (string, slen, delims, sentinel, flags, nwp, cwp)-
2248 char *string;-
2249 int slen;-
2250 char *delims;-
2251 int sentinel, flags;-
2252 int *nwp, *cwp;-
2253{-
2254 int ts, te, i, nw, cw, ifs_split, dflags;-
2255 char *token, *d, *d2;-
2256 WORD_LIST *ret, *tl;-
2257-
2258 if (string == 0 || *string == '\0')
string == 0Description
TRUEnever evaluated
FALSEnever evaluated
*string == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0
2259 {-
2260 if (nwp)
nwpDescription
TRUEnever evaluated
FALSEnever evaluated
0
2261 *nwp = 0;
never executed: *nwp = 0;
0
2262 if (cwp)
cwpDescription
TRUEnever evaluated
FALSEnever evaluated
0
2263 *cwp = 0;
never executed: *cwp = 0;
0
2264 return ((WORD_LIST *)NULL);
never executed: return ((WORD_LIST *) ((void *)0) );
0
2265 }-
2266-
2267 d = (delims == 0) ? ifs_value : delims;
(delims == 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
2268 ifs_split = delims == 0;-
2269-
2270 /* Make d2 the non-whitespace characters in delims */-
2271 d2 = 0;-
2272 if (delims)
delimsDescription
TRUEnever evaluated
FALSEnever evaluated
0
2273 {-
2274 size_t slength;-
2275#if defined (HANDLE_MULTIBYTE)-
2276 size_t mblength = 1;-
2277#endif-
2278 DECLARE_MBSTATE;-
2279-
2280 slength = strlen (delims);-
2281 d2 = (char *)xmalloc (slength + 1);-
2282 i = ts = 0;-
2283 while (delims[i])
delims[i]Description
TRUEnever evaluated
FALSEnever evaluated
0
2284 {-
2285#if defined (HANDLE_MULTIBYTE)-
2286 mbstate_t state_bak;-
2287 state_bak = state;-
2288 mblength = MBRLEN (delims + i, slength, &state);
( (__ctype_get...r_max ()) > 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
2289 if (MB_INVALIDCH (mblength))
(mblength) == (size_t)-1Description
TRUEnever evaluated
FALSEnever evaluated
(mblength) == (size_t)-2Description
TRUEnever evaluated
FALSEnever evaluated
0
2290 state = state_bak;
never executed: state = state_bak;
0
2291 else if (mblength > 1)
mblength > 1Description
TRUEnever evaluated
FALSEnever evaluated
0
2292 {-
2293 memcpy (d2 + ts, delims + i, mblength);-
2294 ts += mblength;-
2295 i += mblength;-
2296 slength -= mblength;-
2297 continue;
never executed: continue;
0
2298 }-
2299#endif-
2300 if (whitespace (delims[i]) == 0)
(((delims[i]) ...== '\t')) == 0Description
TRUEnever evaluated
FALSEnever evaluated
((delims[i]) == ' ')Description
TRUEnever evaluated
FALSEnever evaluated
((delims[i]) == '\t')Description
TRUEnever evaluated
FALSEnever evaluated
0
2301 d2[ts++] = delims[i];
never executed: d2[ts++] = delims[i];
0
2302-
2303 i++;-
2304 slength--;-
2305 }
never executed: end of block
0
2306 d2[ts] = '\0';-
2307 }
never executed: end of block
0
2308-
2309 ret = (WORD_LIST *)NULL;-
2310-
2311 /* Remove sequences of whitespace characters at the start of the string, as-
2312 long as those characters are delimiters. */-
2313 for (i = 0; member (string[i], d) && spctabnl (string[i]); i++)
(string[i])Description
TRUEnever evaluated
FALSEnever evaluated
((string[i]) ?...id *)0) ) : 0)Description
TRUEnever evaluated
FALSEnever evaluated
(string[i]) == ' 'Description
TRUEnever evaluated
FALSEnever evaluated
(string[i]) == '\t'Description
TRUEnever evaluated
FALSEnever evaluated
(string[i]) == '\n'Description
TRUEnever evaluated
FALSEnever evaluated
0
2314 ;
never executed: ;
0
2315 if (string[i] == '\0')
string[i] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0
2316 {-
2317 FREE (d2);
never executed: sh_xfree((d2), "subst.c", 2317);
d2Description
TRUEnever evaluated
FALSEnever evaluated
0
2318 return (ret);
never executed: return (ret);
0
2319 }-
2320-
2321 ts = i;-
2322 nw = 0;-
2323 cw = -1;-
2324 dflags = flags|SD_NOJMP;-
2325 while (1)-
2326 {-
2327 te = skip_to_delim (string, ts, d, dflags);-
2328-
2329 /* If we have a non-whitespace delimiter character, use it to make a-
2330 separate field. This is just about what $IFS splitting does and-
2331 is closer to the behavior of the shell parser. */-
2332 if (ts == te && d2 && member (string[ts], d2))
(string[ts])Description
TRUEnever evaluated
FALSEnever evaluated
ts == teDescription
TRUEnever evaluated
FALSEnever evaluated
d2Description
TRUEnever evaluated
FALSEnever evaluated
((string[ts]) ...id *)0) ) : 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
2333 {-
2334 te = ts + 1;-
2335 /* If we're using IFS splitting, the non-whitespace delimiter char-
2336 and any additional IFS whitespace delimits a field. */-
2337 if (ifs_split)
ifs_splitDescription
TRUEnever evaluated
FALSEnever evaluated
0
2338 while (member (string[te], d) && spctabnl (string[te]) && ((flags&SD_NOQUOTEDELIM) == 0 || (string[te] != '\'' && string[te] != '"')))
(string[te])Description
TRUEnever evaluated
FALSEnever evaluated
((string[te]) ...id *)0) ) : 0)Description
TRUEnever evaluated
FALSEnever evaluated
(string[te]) == ' 'Description
TRUEnever evaluated
FALSEnever evaluated
(string[te]) == '\t'Description
TRUEnever evaluated
FALSEnever evaluated
(string[te]) == '\n'Description
TRUEnever evaluated
FALSEnever evaluated
(flags&0x004) == 0Description
TRUEnever evaluated
FALSEnever evaluated
string[te] != '\''Description
TRUEnever evaluated
FALSEnever evaluated
string[te] != '"'Description
TRUEnever evaluated
FALSEnever evaluated
0
2339 te++;
never executed: te++;
0
2340 else-
2341 while (member (string[te], d2) && ((flags&SD_NOQUOTEDELIM) == 0 || (string[te] != '\'' && string[te] != '"')))
(string[te])Description
TRUEnever evaluated
FALSEnever evaluated
((string[te]) ...id *)0) ) : 0)Description
TRUEnever evaluated
FALSEnever evaluated
(flags&0x004) == 0Description
TRUEnever evaluated
FALSEnever evaluated
string[te] != '\''Description
TRUEnever evaluated
FALSEnever evaluated
string[te] != '"'Description
TRUEnever evaluated
FALSEnever evaluated
0
2342 te++;
never executed: te++;
0
2343 }
never executed: end of block
0
2344-
2345 token = substring (string, ts, te);-
2346-
2347 ret = add_string_to_list (token, ret);-
2348 free (token);-
2349 nw++;-
2350-
2351 if (sentinel >= ts && sentinel <= te)
sentinel >= tsDescription
TRUEnever evaluated
FALSEnever evaluated
sentinel <= teDescription
TRUEnever evaluated
FALSEnever evaluated
0
2352 cw = nw;
never executed: cw = nw;
0
2353-
2354 /* If the cursor is at whitespace just before word start, set the-
2355 sentinel word to the current word. */-
2356 if (cwp && cw == -1 && sentinel == ts-1)
cwpDescription
TRUEnever evaluated
FALSEnever evaluated
cw == -1Description
TRUEnever evaluated
FALSEnever evaluated
sentinel == ts-1Description
TRUEnever evaluated
FALSEnever evaluated
0
2357 cw = nw;
never executed: cw = nw;
0
2358-
2359 /* If the cursor is at whitespace between two words, make a new, empty-
2360 word, add it before (well, after, since the list is in reverse order)-
2361 the word we just added, and set the current word to that one. */-
2362 if (cwp && cw == -1 && sentinel < ts)
cwpDescription
TRUEnever evaluated
FALSEnever evaluated
cw == -1Description
TRUEnever evaluated
FALSEnever evaluated
sentinel < tsDescription
TRUEnever evaluated
FALSEnever evaluated
0
2363 {-
2364 tl = make_word_list (make_word (""), ret->next);-
2365 ret->next = tl;-
2366 cw = nw;-
2367 nw++;-
2368 }
never executed: end of block
0
2369-
2370 if (string[te] == 0)
string[te] == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
2371 break;
never executed: break;
0
2372-
2373 i = te;-
2374 /* XXX - honor SD_NOQUOTEDELIM here */-
2375 while (member (string[i], d) && (ifs_split || spctabnl(string[i])) && ((flags&SD_NOQUOTEDELIM) == 0 || (string[te] != '\'' && string[te] != '"')))
(string[i])Description
TRUEnever evaluated
FALSEnever evaluated
((string[i]) ?...id *)0) ) : 0)Description
TRUEnever evaluated
FALSEnever evaluated
ifs_splitDescription
TRUEnever evaluated
FALSEnever evaluated
(string[i]) == ' 'Description
TRUEnever evaluated
FALSEnever evaluated
(string[i]) == '\t'Description
TRUEnever evaluated
FALSEnever evaluated
(string[i]) == '\n'Description
TRUEnever evaluated
FALSEnever evaluated
(flags&0x004) == 0Description
TRUEnever evaluated
FALSEnever evaluated
string[te] != '\''Description
TRUEnever evaluated
FALSEnever evaluated
string[te] != '"'Description
TRUEnever evaluated
FALSEnever evaluated
0
2376 i++;
never executed: i++;
0
2377-
2378 if (string[i])
string[i]Description
TRUEnever evaluated
FALSEnever evaluated
0
2379 ts = i;
never executed: ts = i;
0
2380 else-
2381 break;
never executed: break;
0
2382 }-
2383-
2384 /* Special case for SENTINEL at the end of STRING. If we haven't found-
2385 the word containing SENTINEL yet, and the index we're looking for is at-
2386 the end of STRING (or past the end of the previously-found token,-
2387 possible if the end of the line is composed solely of IFS whitespace)-
2388 add an additional null argument and set the current word pointer to that. */-
2389 if (cwp && cw == -1 && (sentinel >= slen || sentinel >= te))
cwpDescription
TRUEnever evaluated
FALSEnever evaluated
cw == -1Description
TRUEnever evaluated
FALSEnever evaluated
sentinel >= slenDescription
TRUEnever evaluated
FALSEnever evaluated
sentinel >= teDescription
TRUEnever evaluated
FALSEnever evaluated
0
2390 {-
2391 if (whitespace (string[sentinel - 1]))
((string[senti... - 1]) == ' ')Description
TRUEnever evaluated
FALSEnever evaluated
((string[senti...- 1]) == '\t')Description
TRUEnever evaluated
FALSEnever evaluated
0
2392 {-
2393 token = "";-
2394 ret = add_string_to_list (token, ret);-
2395 nw++;-
2396 }
never executed: end of block
0
2397 cw = nw;-
2398 }
never executed: end of block
0
2399-
2400 if (nwp)
nwpDescription
TRUEnever evaluated
FALSEnever evaluated
0
2401 *nwp = nw;
never executed: *nwp = nw;
0
2402 if (cwp)
cwpDescription
TRUEnever evaluated
FALSEnever evaluated
0
2403 *cwp = cw;
never executed: *cwp = cw;
0
2404-
2405 FREE (d2);
never executed: sh_xfree((d2), "subst.c", 2405);
d2Description
TRUEnever evaluated
FALSEnever evaluated
0
2406-
2407 return (REVERSE_LIST (ret, WORD_LIST *));
never executed: return (((ret && ret->next) ? (WORD_LIST *)list_reverse ((GENERIC_LIST *)ret) : (WORD_LIST *)(ret)));
0
2408}-
2409#endif /* READLINE */-
2410-
2411#if 0-
2412/* UNUSED */-
2413/* Extract the name of the variable to bind to from the assignment string. */-
2414char *-
2415assignment_name (string)-
2416 char *string;-
2417{-
2418 int offset;-
2419 char *temp;-
2420-
2421 offset = assignment (string, 0);-
2422 if (offset == 0)-
2423 return (char *)NULL;-
2424 temp = substring (string, 0, offset);-
2425 return (temp);-
2426}-
2427#endif-
2428-
2429/* **************************************************************** */-
2430/* */-
2431/* Functions to convert strings to WORD_LISTs and vice versa */-
2432/* */-
2433/* **************************************************************** */-
2434-
2435/* Return a single string of all the words in LIST. SEP is the separator-
2436 to put between individual elements of LIST in the output string. */-
2437char *-
2438string_list_internal (list, sep)-
2439 WORD_LIST *list;-
2440 char *sep;-
2441{-
2442 register WORD_LIST *t;-
2443 char *result, *r;-
2444 size_t word_len, sep_len, result_size;-
2445-
2446 if (list == 0)
list == 0Description
TRUEevaluated 330 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 66488618 times by 1 test
Evaluated by:
  • Self test
330-66488618
2447 return ((char *)NULL);
executed 330 times by 1 test: return ((char *) ((void *)0) );
Executed by:
  • Self test
330
2448-
2449 /* Short-circuit quickly if we don't need to separate anything. */-
2450 if (list->next == 0)
list->next == 0Description
TRUEevaluated 66481802 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6816 times by 1 test
Evaluated by:
  • Self test
6816-66481802
2451 return (savestring (list->word->word));
executed 66481802 times by 1 test: return ((char *)strcpy (sh_xmalloc((1 + strlen (list->word->word)), "subst.c", 2451), (list->word->word)));
Executed by:
  • Self test
66481802
2452-
2453 /* This is nearly always called with either sep[0] == 0 or sep[1] == 0. */-
2454 sep_len = STRLEN (sep);
(sep)[1]Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6734 times by 1 test
Evaluated by:
  • Self test
(sep)[2]Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
(sep)Description
TRUEevaluated 6816 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(sep)[0]Description
TRUEevaluated 6738 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 78 times by 1 test
Evaluated by:
  • Self test
0-6816
2455 result_size = 0;-
2456-
2457 for (t = list; t; t = t->next)
tDescription
TRUEevaluated 22017 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6816 times by 1 test
Evaluated by:
  • Self test
6816-22017
2458 {-
2459 if (t != list)
t != listDescription
TRUEevaluated 15201 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6816 times by 1 test
Evaluated by:
  • Self test
6816-15201
2460 result_size += sep_len;
executed 15201 times by 1 test: result_size += sep_len;
Executed by:
  • Self test
15201
2461 result_size += strlen (t->word->word);-
2462 }
executed 22017 times by 1 test: end of block
Executed by:
  • Self test
22017
2463-
2464 r = result = (char *)xmalloc (result_size + 1);-
2465-
2466 for (t = list; t; t = t->next)
tDescription
TRUEevaluated 22017 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6816 times by 1 test
Evaluated by:
  • Self test
6816-22017
2467 {-
2468 if (t != list && sep_len)
t != listDescription
TRUEevaluated 15201 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6816 times by 1 test
Evaluated by:
  • Self test
sep_lenDescription
TRUEevaluated 15091 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 110 times by 1 test
Evaluated by:
  • Self test
110-15201
2469 {-
2470 if (sep_len > 1)
sep_len > 1Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 15087 times by 1 test
Evaluated by:
  • Self test
4-15087
2471 {-
2472 FASTCOPY (sep, r, sep_len);-
2473 r += sep_len;-
2474 }
executed 4 times by 1 test: end of block
Executed by:
  • Self test
4
2475 else-
2476 *r++ = sep[0];
executed 15087 times by 1 test: *r++ = sep[0];
Executed by:
  • Self test
15087
2477 }-
2478-
2479 word_len = strlen (t->word->word);-
2480 FASTCOPY (t->word->word, r, word_len);-
2481 r += word_len;-
2482 }
executed 22017 times by 1 test: end of block
Executed by:
  • Self test
22017
2483-
2484 *r = '\0';-
2485 return (result);
executed 6816 times by 1 test: return (result);
Executed by:
  • Self test
6816
2486}-
2487-
2488/* Return a single string of all the words present in LIST, separating-
2489 each word with a space. */-
2490char *-
2491string_list (list)-
2492 WORD_LIST *list;-
2493{-
2494 return (string_list_internal (list, " "));
executed 66477465 times by 1 test: return (string_list_internal (list, " "));
Executed by:
  • Self test
66477465
2495}-
2496-
2497/* An external interface that can be used by the rest of the shell to-
2498 obtain a string containing the first character in $IFS. Handles all-
2499 the multibyte complications. If LENP is non-null, it is set to the-
2500 length of the returned string. */-
2501char *-
2502ifs_firstchar (lenp)-
2503 int *lenp;-
2504{-
2505 char *ret;-
2506 int len;-
2507-
2508 ret = xmalloc (MB_LEN_MAX + 1);-
2509#if defined (HANDLE_MULTIBYTE)-
2510 if (ifs_firstc_len == 1)
ifs_firstc_len == 1Description
TRUEevaluated 109 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-109
2511 {-
2512 ret[0] = ifs_firstc[0];-
2513 ret[1] = '\0';-
2514 len = ret[0] ? 1 : 0;
ret[0]Description
TRUEevaluated 105 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
4-105
2515 }
executed 109 times by 1 test: end of block
Executed by:
  • Self test
109
2516 else-
2517 {-
2518 memcpy (ret, ifs_firstc, ifs_firstc_len);-
2519 ret[len = ifs_firstc_len] = '\0';-
2520 }
never executed: end of block
0
2521#else-
2522 ret[0] = ifs_firstc;-
2523 ret[1] = '\0';-
2524 len = ret[0] ? 0 : 1;-
2525#endif-
2526-
2527 if (lenp)
lenpDescription
TRUEevaluated 77 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 32 times by 1 test
Evaluated by:
  • Self test
32-77
2528 *lenp = len;
executed 77 times by 1 test: *lenp = len;
Executed by:
  • Self test
77
2529-
2530 return ret;
executed 109 times by 1 test: return ret;
Executed by:
  • Self test
109
2531}-
2532-
2533/* Return a single string of all the words present in LIST, obeying the-
2534 quoting rules for "$*", to wit: (P1003.2, draft 11, 3.5.2) "If the-
2535 expansion [of $*] appears within a double quoted string, it expands-
2536 to a single field with the value of each parameter separated by the-
2537 first character of the IFS variable, or by a <space> if IFS is unset." */-
2538/* Posix interpretation 888 changes this when IFS is null by specifying-
2539 that when unquoted, this expands to separate arguments */-
2540char *-
2541string_list_dollar_star (list, quoted, flags)-
2542 WORD_LIST *list;-
2543 int quoted, flags;-
2544{-
2545 char *ret;-
2546#if defined (HANDLE_MULTIBYTE)-
2547# if defined (__GNUC__)-
2548 char sep[MB_CUR_MAX + 1];-
2549# else-
2550 char *sep = 0;-
2551# endif-
2552#else-
2553 char sep[2];-
2554#endif-
2555-
2556#if defined (HANDLE_MULTIBYTE)-
2557# if !defined (__GNUC__)-
2558 sep = (char *)xmalloc (MB_CUR_MAX + 1);-
2559# endif /* !__GNUC__ */-
2560 if (ifs_firstc_len == 1)
ifs_firstc_len == 1Description
TRUEevaluated 6117 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
4-6117
2561 {-
2562 sep[0] = ifs_firstc[0];-
2563 sep[1] = '\0';-
2564 }
executed 6117 times by 1 test: end of block
Executed by:
  • Self test
6117
2565 else-
2566 {-
2567 memcpy (sep, ifs_firstc, ifs_firstc_len);-
2568 sep[ifs_firstc_len] = '\0';-
2569 }
executed 4 times by 1 test: end of block
Executed by:
  • Self test
4
2570#else-
2571 sep[0] = ifs_firstc;-
2572 sep[1] = '\0';-
2573#endif-
2574-
2575 ret = string_list_internal (list, sep);-
2576#if defined (HANDLE_MULTIBYTE) && !defined (__GNUC__)-
2577 free (sep);-
2578#endif-
2579 return ret;
executed 6121 times by 1 test: return ret;
Executed by:
  • Self test
6121
2580}-
2581-
2582/* Turn $@ into a string. If (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))-
2583 is non-zero, the $@ appears within double quotes, and we should quote-
2584 the list before converting it into a string. If IFS is unset, and the-
2585 word is not quoted, we just need to quote CTLESC and CTLNUL characters-
2586 in the words in the list, because the default value of $IFS is-
2587 <space><tab><newline>, IFS characters in the words in the list should-
2588 also be split. If IFS is null, and the word is not quoted, we need-
2589 to quote the words in the list to preserve the positional parameters-
2590 exactly.-
2591 Valid values for the FLAGS argument are the PF_ flags in command.h,-
2592 the only one we care about is PF_ASSIGNRHS. $@ is supposed to expand-
2593 to the positional parameters separated by spaces no matter what IFS is-
2594 set to if in a context where word splitting is not performed. The only-
2595 one that we didn't handle before is assignment statement arguments to-
2596 declaration builtins like `declare'. */-
2597char *-
2598string_list_dollar_at (list, quoted, flags)-
2599 WORD_LIST *list;-
2600 int quoted;-
2601 int flags;-
2602{-
2603 char *ifs, *ret;-
2604#if defined (HANDLE_MULTIBYTE)-
2605# if defined (__GNUC__)-
2606 char sep[MB_CUR_MAX + 1];-
2607# else-
2608 char *sep = 0;-
2609# endif /* !__GNUC__ */-
2610#else-
2611 char sep[2];-
2612#endif-
2613 WORD_LIST *tlist;-
2614-
2615 /* XXX this could just be ifs = ifs_value; */-
2616 ifs = ifs_var ? value_cell (ifs_var) : (char *)0;
ifs_varDescription
TRUEevaluated 4031 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1290 times by 1 test
Evaluated by:
  • Self test
1290-4031
2617-
2618#if defined (HANDLE_MULTIBYTE)-
2619# if !defined (__GNUC__)-
2620 sep = (char *)xmalloc (MB_CUR_MAX + 1);-
2621# endif /* !__GNUC__ */-
2622 /* XXX - bash-4.4/bash-5.0 testing PF_ASSIGNRHS */-
2623 if (flags & PF_ASSIGNRHS)
flags & 0x08Description
TRUEevaluated 1899 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3422 times by 1 test
Evaluated by:
  • Self test
1899-3422
2624 {-
2625 sep[0] = ' ';-
2626 sep[1] = '\0';-
2627 }
executed 1899 times by 1 test: end of block
Executed by:
  • Self test
1899
2628 else if (ifs && *ifs)
ifsDescription
TRUEevaluated 3084 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 338 times by 1 test
Evaluated by:
  • Self test
*ifsDescription
TRUEevaluated 2684 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 400 times by 1 test
Evaluated by:
  • Self test
338-3084
2629 {-
2630 if (ifs_firstc_len == 1)
ifs_firstc_len == 1Description
TRUEevaluated 2684 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2684
2631 {-
2632 sep[0] = ifs_firstc[0];-
2633 sep[1] = '\0';-
2634 }
executed 2684 times by 1 test: end of block
Executed by:
  • Self test
2684
2635 else-
2636 {-
2637 memcpy (sep, ifs_firstc, ifs_firstc_len);-
2638 sep[ifs_firstc_len] = '\0';-
2639 }
never executed: end of block
0
2640 }-
2641 else-
2642 {-
2643 sep[0] = ' ';-
2644 sep[1] = '\0';-
2645 }
executed 738 times by 1 test: end of block
Executed by:
  • Self test
738
2646#else /* !HANDLE_MULTIBYTE */-
2647 /* XXX - bash-4.4/bash-5.0 test PF_ASSIGNRHS */-
2648 sep[0] = ((flags & PF_ASSIGNRHS) || ifs == 0 || *ifs == 0) ? ' ' : *ifs;-
2649 sep[1] = '\0';-
2650#endif /* !HANDLE_MULTIBYTE */-
2651-
2652 /* XXX -- why call quote_list if ifs == 0? we can get away without doing-
2653 it now that quote_escapes quotes spaces */-
2654 tlist = (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES|Q_PATQUOTE))
(quoted & (0x002|0x001|0x008))Description
TRUEevaluated 4051 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1270 times by 1 test
Evaluated by:
  • Self test
1270-4051
2655 ? quote_list (list)-
2656 : list_quote_escapes (list);-
2657-
2658 ret = string_list_internal (tlist, sep);-
2659#if defined (HANDLE_MULTIBYTE) && !defined (__GNUC__)-
2660 free (sep);-
2661#endif-
2662 return ret;
executed 5321 times by 1 test: return ret;
Executed by:
  • Self test
5321
2663}-
2664-
2665/* Turn the positional parameters into a string, understanding quoting and-
2666 the various subtleties of using the first character of $IFS as the-
2667 separator. Calls string_list_dollar_at, string_list_dollar_star, and-
2668 string_list as appropriate. */-
2669char *-
2670string_list_pos_params (pchar, list, quoted)-
2671 int pchar;-
2672 WORD_LIST *list;-
2673 int quoted;-
2674{-
2675 char *ret;-
2676 WORD_LIST *tlist;-
2677-
2678 if (pchar == '*' && (quoted & Q_DOUBLE_QUOTES))
pchar == '*'Description
TRUEevaluated 219 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 300 times by 1 test
Evaluated by:
  • Self test
(quoted & 0x001)Description
TRUEevaluated 90 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 129 times by 1 test
Evaluated by:
  • Self test
90-300
2679 {-
2680 tlist = quote_list (list);-
2681 word_list_remove_quoted_nulls (tlist);-
2682 ret = string_list_dollar_star (tlist, 0, 0);-
2683 }
executed 90 times by 1 test: end of block
Executed by:
  • Self test
90
2684 else if (pchar == '*' && (quoted & Q_HERE_DOCUMENT))
pchar == '*'Description
TRUEevaluated 129 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 300 times by 1 test
Evaluated by:
  • Self test
(quoted & 0x002)Description
TRUEnever evaluated
FALSEevaluated 129 times by 1 test
Evaluated by:
  • Self test
0-300
2685 {-
2686 tlist = quote_list (list);-
2687 word_list_remove_quoted_nulls (tlist);-
2688 ret = string_list (tlist);-
2689 }
never executed: end of block
0
2690 else if (pchar == '*' && quoted == 0 && ifs_is_null) /* XXX */
pchar == '*'Description
TRUEevaluated 129 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 300 times by 1 test
Evaluated by:
  • Self test
quoted == 0Description
TRUEevaluated 129 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
ifs_is_nullDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 118 times by 1 test
Evaluated by:
  • Self test
0-300
2691 ret = expand_no_split_dollar_star ? string_list_dollar_star (list, quoted, 0) : string_list_dollar_at (list, quoted, 0); /* Posix interp 888 */
executed 11 times by 1 test: ret = expand_no_split_dollar_star ? string_list_dollar_star (list, quoted, 0) : string_list_dollar_at (list, quoted, 0);
Executed by:
  • Self test
expand_no_split_dollar_starDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
2-11
2692 else if (pchar == '*')
pchar == '*'Description
TRUEevaluated 118 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 300 times by 1 test
Evaluated by:
  • Self test
118-300
2693 {-
2694 /* Even when unquoted, string_list_dollar_star does the right thing-
2695 making sure that the first character of $IFS is used as the-
2696 separator. */-
2697 ret = string_list_dollar_star (list, quoted, 0);-
2698 }
executed 118 times by 1 test: end of block
Executed by:
  • Self test
118
2699 else if (pchar == '@' && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))
pchar == '@'Description
TRUEevaluated 300 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(quoted & (0x002|0x001))Description
TRUEevaluated 112 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 188 times by 1 test
Evaluated by:
  • Self test
0-300
2700 /* We use string_list_dollar_at, but only if the string is quoted, since-
2701 that quotes the escapes if it's not, which we don't want. We could-
2702 use string_list (the old code did), but that doesn't do the right-
2703 thing if the first character of $IFS is not a space. We use-
2704 string_list_dollar_star if the string is unquoted so we make sure that-
2705 the elements of $@ are separated by the first character of $IFS for-
2706 later splitting. */-
2707 ret = string_list_dollar_at (list, quoted, 0);
executed 112 times by 1 test: ret = string_list_dollar_at (list, quoted, 0);
Executed by:
  • Self test
112
2708 else if (pchar == '@' && quoted == 0 && ifs_is_null) /* XXX */
pchar == '@'Description
TRUEevaluated 188 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
quoted == 0Description
TRUEevaluated 188 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
ifs_is_nullDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 181 times by 1 test
Evaluated by:
  • Self test
0-188
2709 ret = string_list_dollar_at (list, quoted, 0); /* Posix interp 888 */
executed 7 times by 1 test: ret = string_list_dollar_at (list, quoted, 0);
Executed by:
  • Self test
7
2710 else if (pchar == '@')
pchar == '@'Description
TRUEevaluated 181 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-181
2711 ret = string_list_dollar_star (list, quoted, 0);
executed 181 times by 1 test: ret = string_list_dollar_star (list, quoted, 0);
Executed by:
  • Self test
181
2712 else-
2713 ret = string_list ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) ? quote_list (list) : list);
never executed: ret = string_list ((quoted & (0x002|0x001)) ? quote_list (list) : list);
0
2714-
2715 return ret;
executed 519 times by 1 test: return ret;
Executed by:
  • Self test
519
2716}-
2717-
2718/* Return the list of words present in STRING. Separate the string into-
2719 words at any of the characters found in SEPARATORS. If QUOTED is-
2720 non-zero then word in the list will have its quoted flag set, otherwise-
2721 the quoted flag is left as make_word () deemed fit.-
2722-
2723 This obeys the P1003.2 word splitting semantics. If `separators' is-
2724 exactly <space><tab><newline>, then the splitting algorithm is that of-
2725 the Bourne shell, which treats any sequence of characters from `separators'-
2726 as a delimiter. If IFS is unset, which results in `separators' being set-
2727 to "", no splitting occurs. If separators has some other value, the-
2728 following rules are applied (`IFS white space' means zero or more-
2729 occurrences of <space>, <tab>, or <newline>, as long as those characters-
2730 are in `separators'):-
2731-
2732 1) IFS white space is ignored at the start and the end of the-
2733 string.-
2734 2) Each occurrence of a character in `separators' that is not-
2735 IFS white space, along with any adjacent occurrences of-
2736 IFS white space delimits a field.-
2737 3) Any nonzero-length sequence of IFS white space delimits a field.-
2738 */-
2739-
2740/* BEWARE! list_string strips null arguments. Don't call it twice and-
2741 expect to have "" preserved! */-
2742-
2743/* This performs word splitting and quoted null character removal on-
2744 STRING. */-
2745#define issep(c) \-
2746 (((separators)[0]) ? ((separators)[1] ? isifs(c) \-
2747 : (c) == (separators)[0]) \-
2748 : 0)-
2749-
2750WORD_LIST *-
2751list_string (string, separators, quoted)-
2752 register char *string, *separators;-
2753 int quoted;-
2754{-
2755 WORD_LIST *result;-
2756 WORD_DESC *t;-
2757 char *current_word, *s;-
2758 int sindex, sh_style_split, whitesep, xflags;-
2759 size_t slen;-
2760-
2761 if (!string || !*string)
!stringDescription
TRUEnever evaluated
FALSEevaluated 3294725 times by 1 test
Evaluated by:
  • Self test
!*stringDescription
TRUEnever evaluated
FALSEevaluated 3294725 times by 1 test
Evaluated by:
  • Self test
0-3294725
2762 return ((WORD_LIST *)NULL);
never executed: return ((WORD_LIST *) ((void *)0) );
0
2763-
2764 sh_style_split = separators && separators[0] == ' ' &&
separatorsDescription
TRUEevaluated 3294725 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
separators[0] == ' 'Description
TRUEevaluated 1663239 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1631486 times by 1 test
Evaluated by:
  • Self test
0-3294725
2765 separators[1] == '\t' &&
separators[1] == '\t'Description
TRUEevaluated 30812 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1632427 times by 1 test
Evaluated by:
  • Self test
30812-1632427
2766 separators[2] == '\n' &&
separators[2] == '\n'Description
TRUEevaluated 30812 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-30812
2767 separators[3] == '\0';
separators[3] == '\0'Description
TRUEevaluated 30812 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-30812
2768 for (xflags = 0, s = ifs_value; s && *s; s++)
sDescription
TRUEevaluated 9900006 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*sDescription
TRUEevaluated 6605281 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3294725 times by 1 test
Evaluated by:
  • Self test
0-9900006
2769 {-
2770 if (*s == CTLESC) xflags |= SX_NOCTLESC;
executed 181 times by 1 test: xflags |= 0x0010;
Executed by:
  • Self test
*s == '\001'Description
TRUEevaluated 181 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6605100 times by 1 test
Evaluated by:
  • Self test
181-6605100
2771 else if (*s == CTLNUL) xflags |= SX_NOESCCTLNUL;
executed 20 times by 1 test: xflags |= 0x0020;
Executed by:
  • Self test
*s == '\177'Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6605080 times by 1 test
Evaluated by:
  • Self test
20-6605080
2772 }
executed 6605281 times by 1 test: end of block
Executed by:
  • Self test
6605281
2773-
2774 slen = 0;-
2775 /* Remove sequences of whitespace at the beginning of STRING, as-
2776 long as those characters appear in IFS. Do not do this if-
2777 STRING is quoted or if there are no separator characters. */-
2778 if (!quoted || !separators || !*separators)
!quotedDescription
TRUEevaluated 3270660 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 24065 times by 1 test
Evaluated by:
  • Self test
!separatorsDescription
TRUEnever evaluated
FALSEevaluated 24065 times by 1 test
Evaluated by:
  • Self test
!*separatorsDescription
TRUEevaluated 15844 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8221 times by 1 test
Evaluated by:
  • Self test
0-3270660
2779 {-
2780 for (s = string; *s && spctabnl (*s) && issep (*s); s++);
executed 2387281 times by 1 test: ;
Executed by:
  • Self test
((separators)[0])Description
TRUEevaluated 2387283 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
(separators)[1]Description
TRUEevaluated 2387281 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
*sDescription
TRUEevaluated 5669320 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4465 times by 1 test
Evaluated by:
  • Self test
(*s) == ' 'Description
TRUEevaluated 2387261 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3282059 times by 1 test
Evaluated by:
  • Self test
(*s) == '\t'Description
TRUEevaluated 23 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3282036 times by 1 test
Evaluated by:
  • Self test
(*s) == '\n'Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3282033 times by 1 test
Evaluated by:
  • Self test
(((separators)...tors)[0]) : 0)Description
TRUEevaluated 2387281 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
2-5669320
2781-
2782 if (!*s)
!*sDescription
TRUEevaluated 4465 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3282039 times by 1 test
Evaluated by:
  • Self test
4465-3282039
2783 return ((WORD_LIST *)NULL);
executed 4465 times by 1 test: return ((WORD_LIST *) ((void *)0) );
Executed by:
  • Self test
4465
2784-
2785 string = s;-
2786 }
executed 3282039 times by 1 test: end of block
Executed by:
  • Self test
3282039
2787-
2788 /* OK, now STRING points to a word that does not begin with white space.-
2789 The splitting algorithm is:-
2790 extract a word, stopping at a separator-
2791 skip sequences of spc, tab, or nl as long as they are separators-
2792 This obeys the field splitting rules in Posix.2. */-
2793 slen = STRLEN (string);
(string)[1]Description
TRUEevaluated 3231574 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 58686 times by 1 test
Evaluated by:
  • Self test
(string)[2]Description
TRUEevaluated 3130833 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 100741 times by 1 test
Evaluated by:
  • Self test
(string)Description
TRUEevaluated 3290260 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(string)[0]Description
TRUEevaluated 3290260 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3290260
2794 for (result = (WORD_LIST *)NULL, sindex = 0; string[sindex]; )
string[sindex]Description
TRUEevaluated 8711954 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3290260 times by 1 test
Evaluated by:
  • Self test
3290260-8711954
2795 {-
2796 /* Don't need string length in ADVANCE_CHAR unless multibyte chars are-
2797 possible, but need it in string_extract_verbatim for bounds checking */-
2798 current_word = string_extract_verbatim (string, slen, &sindex, separators, xflags);-
2799 if (current_word == 0)
current_word == 0Description
TRUEnever evaluated
FALSEevaluated 8711954 times by 1 test
Evaluated by:
  • Self test
0-8711954
2800 break;
never executed: break;
0
2801-
2802 /* If we have a quoted empty string, add a quoted null argument. We-
2803 want to preserve the quoted null character iff this is a quoted-
2804 empty string; otherwise the quoted null characters are removed-
2805 below. */-
2806 if (QUOTED_NULL (current_word))
(current_word)[0] == '\177'Description
TRUEevaluated 835 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8711119 times by 1 test
Evaluated by:
  • Self test
(current_word)[1] == '\0'Description
TRUEevaluated 792 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 43 times by 1 test
Evaluated by:
  • Self test
43-8711119
2807 {-
2808 t = alloc_word_desc ();-
2809 t->word = make_quoted_char ('\0');-
2810 t->flags |= W_QUOTED|W_HASQUOTEDNULL;-
2811 result = make_word_list (t, result);-
2812 }
executed 792 times by 1 test: end of block
Executed by:
  • Self test
792
2813 else if (current_word[0] != '\0')
current_word[0] != '\0'Description
TRUEevaluated 4621690 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4089472 times by 1 test
Evaluated by:
  • Self test
4089472-4621690
2814 {-
2815 /* If we have something, then add it regardless. However,-
2816 perform quoted null character removal on the current word. */-
2817 remove_quoted_nulls (current_word);-
2818 result = add_string_to_list (current_word, result);-
2819 result->word->flags &= ~W_HASQUOTEDNULL; /* just to be sure */-
2820 if (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))
quoted & (0x001|0x002)Description
TRUEevaluated 28995 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4592695 times by 1 test
Evaluated by:
  • Self test
28995-4592695
2821 result->word->flags |= W_QUOTED;
executed 28995 times by 1 test: result->word->flags |= 0x000002;
Executed by:
  • Self test
28995
2822 }
executed 4621690 times by 1 test: end of block
Executed by:
  • Self test
4621690
2823-
2824 /* If we're not doing sequences of separators in the traditional-
2825 Bourne shell style, then add a quoted null argument. */-
2826 else if (!sh_style_split && !spctabnl (string[sindex]))
!sh_style_splitDescription
TRUEevaluated 4089423 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 49 times by 1 test
Evaluated by:
  • Self test
(string[sindex]) == ' 'Description
TRUEnever evaluated
FALSEevaluated 4089423 times by 1 test
Evaluated by:
  • Self test
(string[sindex]) == '\t'Description
TRUEnever evaluated
FALSEevaluated 4089423 times by 1 test
Evaluated by:
  • Self test
(string[sindex]) == '\n'Description
TRUEnever evaluated
FALSEevaluated 4089423 times by 1 test
Evaluated by:
  • Self test
0-4089423
2827 {-
2828 t = alloc_word_desc ();-
2829 t->word = make_quoted_char ('\0');-
2830 t->flags |= W_QUOTED|W_HASQUOTEDNULL;-
2831 result = make_word_list (t, result);-
2832 }
executed 4089423 times by 1 test: end of block
Executed by:
  • Self test
4089423
2833-
2834 free (current_word);-
2835-
2836 /* Note whether or not the separator is IFS whitespace, used later. */-
2837 whitesep = string[sindex] && spctabnl (string[sindex]);
string[sindex]Description
TRUEevaluated 8346290 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 365664 times by 1 test
Evaluated by:
  • Self test
(string[sindex]) == ' 'Description
TRUEevaluated 2362413 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5983877 times by 1 test
Evaluated by:
  • Self test
(string[sindex]) == '\t'Description
TRUEnever evaluated
FALSEevaluated 5983877 times by 1 test
Evaluated by:
  • Self test
(string[sindex]) == '\n'Description
TRUEevaluated 509 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5983368 times by 1 test
Evaluated by:
  • Self test
0-8346290
2838-
2839 /* Move past the current separator character. */-
2840 if (string[sindex])
string[sindex]Description
TRUEevaluated 8346290 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 365664 times by 1 test
Evaluated by:
  • Self test
365664-8346290
2841 {-
2842 DECLARE_MBSTATE;-
2843 ADVANCE_CHAR (string, slen, sindex);
executed 8345105 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 788 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 3 times by 1 test: end of block
Executed by:
  • Self test
never executed: end of block
never executed: (sindex)++;
executed 8345896 times by 1 test: (sindex) += mblength;
Executed by:
  • Self test
executed 394 times by 1 test: (sindex)++;
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 8345896 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 394 times by 1 test
Evaluated by:
  • Self test
_fDescription
TRUEevaluated 8345105 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 791 times by 1 test
Evaluated by:
  • Self test
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 8345896 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 791 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((string)[sin... & 0x80) == 0)Description
TRUEevaluated 788 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 8345896 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 8345896 times by 1 test
Evaluated by:
  • Self test
0-8345896
2844 }
executed 8346290 times by 1 test: end of block
Executed by:
  • Self test
8346290
2845-
2846 /* Now skip sequences of space, tab, or newline characters if they are-
2847 in the list of separators. */-
2848 while (string[sindex] && spctabnl (string[sindex]) && issep (string[sindex]))
((separators)[0])Description
TRUEevaluated 3871062 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(separators)[1]Description
TRUEevaluated 3871062 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
string[sindex]Description
TRUEevaluated 9948438 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2634578 times by 1 test
Evaluated by:
  • Self test
(string[sindex]) == ' 'Description
TRUEevaluated 3871025 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6077413 times by 1 test
Evaluated by:
  • Self test
(string[sindex]) == '\t'Description
TRUEnever evaluated
FALSEevaluated 6077413 times by 1 test
Evaluated by:
  • Self test
(string[sindex]) == '\n'Description
TRUEevaluated 37 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6077376 times by 1 test
Evaluated by:
  • Self test
(((separators)...tors)[0]) : 0)Description
TRUEevaluated 3871062 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-9948438
2849 sindex++;
executed 3871062 times by 1 test: sindex++;
Executed by:
  • Self test
3871062
2850-
2851 /* If the first separator was IFS whitespace and the current character-
2852 is a non-whitespace IFS character, it should be part of the current-
2853 field delimiter, not a separate delimiter that would result in an-
2854 empty field. Look at POSIX.2, 3.6.5, (3)(b). */-
2855 if (string[sindex] && whitesep && issep (string[sindex]) && !spctabnl (string[sindex]))
((separators)[0])Description
TRUEevaluated 2067783 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(separators)[1]Description
TRUEevaluated 2045931 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 21852 times by 1 test
Evaluated by:
  • Self test
string[sindex]Description
TRUEevaluated 6077376 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2634578 times by 1 test
Evaluated by:
  • Self test
whitesepDescription
TRUEevaluated 2067783 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4009593 times by 1 test
Evaluated by:
  • Self test
(((separators)...tors)[0]) : 0)Description
TRUEevaluated 1858829 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 208954 times by 1 test
Evaluated by:
  • Self test
(string[sindex]) == ' 'Description
TRUEnever evaluated
FALSEevaluated 1858829 times by 1 test
Evaluated by:
  • Self test
(string[sindex]) == '\t'Description
TRUEnever evaluated
FALSEevaluated 1858829 times by 1 test
Evaluated by:
  • Self test
(string[sindex]) == '\n'Description
TRUEnever evaluated
FALSEevaluated 1858829 times by 1 test
Evaluated by:
  • Self test
0-6077376
2856 {-
2857 sindex++;-
2858 /* An IFS character that is not IFS white space, along with any-
2859 adjacent IFS white space, shall delimit a field. (SUSv3) */-
2860 while (string[sindex] && spctabnl (string[sindex]) && isifs (string[sindex]))
string[sindex]Description
TRUEevaluated 2408683 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 655682 times by 1 test
Evaluated by:
  • Self test
(string[sindex]) == ' 'Description
TRUEevaluated 1205536 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1203147 times by 1 test
Evaluated by:
  • Self test
(string[sindex]) == '\t'Description
TRUEnever evaluated
FALSEevaluated 1203147 times by 1 test
Evaluated by:
  • Self test
(string[sindex]) == '\n'Description
TRUEnever evaluated
FALSEevaluated 1203147 times by 1 test
Evaluated by:
  • Self test
(ifs_cmap[(uns...index])] != 0)Description
TRUEevaluated 1205536 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2408683
2861 sindex++;
executed 1205536 times by 1 test: sindex++;
Executed by:
  • Self test
1205536
2862 }
executed 1858829 times by 1 test: end of block
Executed by:
  • Self test
1858829
2863 }
executed 8711954 times by 1 test: end of block
Executed by:
  • Self test
8711954
2864 return (REVERSE_LIST (result, WORD_LIST *));
executed 3290260 times by 1 test: return (((result && result->next) ? (WORD_LIST *)list_reverse ((GENERIC_LIST *)result) : (WORD_LIST *)(result)));
Executed by:
  • Self test
3290260
2865}-
2866-
2867/* Parse a single word from STRING, using SEPARATORS to separate fields.-
2868 ENDPTR is set to the first character after the word. This is used by-
2869 the `read' builtin.-
2870 -
2871 This is never called with SEPARATORS != $IFS, and takes advantage of that.-
2872-
2873 XXX - this function is very similar to list_string; they should be-
2874 combined - XXX */-
2875-
2876#define islocalsep(c) (local_cmap[(unsigned char)(c)] != 0)-
2877-
2878char *-
2879get_word_from_string (stringp, separators, endptr)-
2880 char **stringp, *separators, **endptr;-
2881{-
2882 register char *s;-
2883 char *current_word;-
2884 int sindex, sh_style_split, whitesep, xflags;-
2885 unsigned char local_cmap[UCHAR_MAX+1]; /* really only need single-byte chars here */-
2886 size_t slen;-
2887-
2888 if (!stringp || !*stringp || !**stringp)
!stringpDescription
TRUEnever evaluated
FALSEevaluated 662841 times by 1 test
Evaluated by:
  • Self test
!*stringpDescription
TRUEnever evaluated
FALSEevaluated 662841 times by 1 test
Evaluated by:
  • Self test
!**stringpDescription
TRUEnever evaluated
FALSEevaluated 662841 times by 1 test
Evaluated by:
  • Self test
0-662841
2889 return ((char *)NULL);
never executed: return ((char *) ((void *)0) );
0
2890-
2891 sh_style_split = separators && separators[0] == ' ' &&
separatorsDescription
TRUEevaluated 662841 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
separators[0] == ' 'Description
TRUEevaluated 662052 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 789 times by 1 test
Evaluated by:
  • Self test
0-662841
2892 separators[1] == '\t' &&
separators[1] == '\t'Description
TRUEevaluated 661337 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 715 times by 1 test
Evaluated by:
  • Self test
715-661337
2893 separators[2] == '\n' &&
separators[2] == '\n'Description
TRUEevaluated 661337 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-661337
2894 separators[3] == '\0';
separators[3] == '\0'Description
TRUEevaluated 661337 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-661337
2895 memset (local_cmap, '\0', sizeof (local_cmap));-
2896 for (xflags = 0, s = separators; s && *s; s++)
sDescription
TRUEevaluated 2649780 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*sDescription
TRUEevaluated 1986939 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 662841 times by 1 test
Evaluated by:
  • Self test
0-2649780
2897 {-
2898 if (*s == CTLESC) xflags |= SX_NOCTLESC;
executed 9 times by 1 test: xflags |= 0x0010;
Executed by:
  • Self test
*s == '\001'Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1986930 times by 1 test
Evaluated by:
  • Self test
9-1986930
2899 if (*s == CTLNUL) xflags |= SX_NOESCCTLNUL;
executed 3 times by 1 test: xflags |= 0x0020;
Executed by:
  • Self test
*s == '\177'Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1986936 times by 1 test
Evaluated by:
  • Self test
3-1986936
2900 local_cmap[(unsigned char)*s] = 1; /* local charmap of separators */-
2901 }
executed 1986939 times by 1 test: end of block
Executed by:
  • Self test
1986939
2902-
2903 s = *stringp;-
2904 slen = 0;-
2905-
2906 /* Remove sequences of whitespace at the beginning of STRING, as-
2907 long as those characters appear in SEPARATORS. This happens if-
2908 SEPARATORS == $' \t\n' or if IFS is unset. */-
2909 if (sh_style_split || separators == 0)
sh_style_splitDescription
TRUEevaluated 661337 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1504 times by 1 test
Evaluated by:
  • Self test
separators == 0Description
TRUEnever evaluated
FALSEevaluated 1504 times by 1 test
Evaluated by:
  • Self test
0-661337
2910 {-
2911 for (; *s && spctabnl (*s) && islocalsep (*s); s++);
never executed: ;
*sDescription
TRUEevaluated 661337 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(*s) == ' 'Description
TRUEnever evaluated
FALSEevaluated 661337 times by 1 test
Evaluated by:
  • Self test
(*s) == '\t'Description
TRUEnever evaluated
FALSEevaluated 661337 times by 1 test
Evaluated by:
  • Self test
(*s) == '\n'Description
TRUEnever evaluated
FALSEevaluated 661337 times by 1 test
Evaluated by:
  • Self test
(local_cmap[(u...ar)(*s)] != 0)Description
TRUEnever evaluated
FALSEnever evaluated
0-661337
2912-
2913 /* If the string is nothing but whitespace, update it and return. */-
2914 if (!*s)
!*sDescription
TRUEnever evaluated
FALSEevaluated 661337 times by 1 test
Evaluated by:
  • Self test
0-661337
2915 {-
2916 *stringp = s;-
2917 if (endptr)
endptrDescription
TRUEnever evaluated
FALSEnever evaluated
0
2918 *endptr = s;
never executed: *endptr = s;
0
2919 return ((char *)NULL);
never executed: return ((char *) ((void *)0) );
0
2920 }-
2921 }
executed 661337 times by 1 test: end of block
Executed by:
  • Self test
661337
2922-
2923 /* OK, S points to a word that does not begin with white space.-
2924 Now extract a word, stopping at a separator, save a pointer to-
2925 the first character after the word, then skip sequences of spc,-
2926 tab, or nl as long as they are separators.-
2927-
2928 This obeys the field splitting rules in Posix.2. */-
2929 sindex = 0;-
2930 /* Don't need string length in ADVANCE_CHAR unless multibyte chars are-
2931 possible, but need it in string_extract_verbatim for bounds checking */-
2932 slen = STRLEN (s);
(s)[1]Description
TRUEevaluated 1927 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 660914 times by 1 test
Evaluated by:
  • Self test
(s)[2]Description
TRUEevaluated 1561 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 366 times by 1 test
Evaluated by:
  • Self test
(s)Description
TRUEevaluated 662841 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(s)[0]Description
TRUEevaluated 662841 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-662841
2933 current_word = string_extract_verbatim (s, slen, &sindex, separators, xflags);-
2934-
2935 /* Set ENDPTR to the first character after the end of the word. */-
2936 if (endptr)
endptrDescription
TRUEevaluated 662841 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-662841
2937 *endptr = s + sindex;
executed 662841 times by 1 test: *endptr = s + sindex;
Executed by:
  • Self test
662841
2938-
2939 /* Note whether or not the separator is IFS whitespace, used later. */-
2940 whitesep = s[sindex] && spctabnl (s[sindex]);
s[sindex]Description
TRUEevaluated 1685 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 661156 times by 1 test
Evaluated by:
  • Self test
(s[sindex]) == ' 'Description
TRUEevaluated 835 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 850 times by 1 test
Evaluated by:
  • Self test
(s[sindex]) == '\t'Description
TRUEnever evaluated
FALSEevaluated 850 times by 1 test
Evaluated by:
  • Self test
(s[sindex]) == '\n'Description
TRUEnever evaluated
FALSEevaluated 850 times by 1 test
Evaluated by:
  • Self test
0-661156
2941-
2942 /* Move past the current separator character. */-
2943 if (s[sindex])
s[sindex]Description
TRUEevaluated 1685 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 661156 times by 1 test
Evaluated by:
  • Self test
1685-661156
2944 {-
2945 DECLARE_MBSTATE;-
2946 ADVANCE_CHAR (s, slen, sindex);
executed 1657 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 8 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 3 times by 1 test: end of block
Executed by:
  • Self test
never executed: end of block
never executed: (sindex)++;
executed 1668 times by 1 test: (sindex) += mblength;
Executed by:
  • Self test
executed 17 times by 1 test: (sindex)++;
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 1668 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 17 times by 1 test
Evaluated by:
  • Self test
_fDescription
TRUEevaluated 1657 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11 times by 1 test
Evaluated by:
  • Self test
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 1668 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((s)[sindex] & 0x80) == 0)Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 1668 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 1668 times by 1 test
Evaluated by:
  • Self test
0-1668
2947 }
executed 1685 times by 1 test: end of block
Executed by:
  • Self test
1685
2948-
2949 /* Now skip sequences of space, tab, or newline characters if they are-
2950 in the list of separators. */-
2951 while (s[sindex] && spctabnl (s[sindex]) && islocalsep (s[sindex]))
s[sindex]Description
TRUEevaluated 2326 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 661475 times by 1 test
Evaluated by:
  • Self test
(s[sindex]) == ' 'Description
TRUEevaluated 960 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1366 times by 1 test
Evaluated by:
  • Self test
(s[sindex]) == '\t'Description
TRUEnever evaluated
FALSEevaluated 1366 times by 1 test
Evaluated by:
  • Self test
(s[sindex]) == '\n'Description
TRUEnever evaluated
FALSEevaluated 1366 times by 1 test
Evaluated by:
  • Self test
(local_cmap[(u...index])] != 0)Description
TRUEevaluated 960 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-661475
2952 sindex++;
executed 960 times by 1 test: sindex++;
Executed by:
  • Self test
960
2953-
2954 /* If the first separator was IFS whitespace and the current character is-
2955 a non-whitespace IFS character, it should be part of the current field-
2956 delimiter, not a separate delimiter that would result in an empty field.-
2957 Look at POSIX.2, 3.6.5, (3)(b). */-
2958 if (s[sindex] && whitesep && islocalsep (s[sindex]) && !spctabnl (s[sindex]))
s[sindex]Description
TRUEevaluated 1366 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 661475 times by 1 test
Evaluated by:
  • Self test
whitesepDescription
TRUEevaluated 776 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 590 times by 1 test
Evaluated by:
  • Self test
(local_cmap[(u...index])] != 0)Description
TRUEevaluated 464 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 312 times by 1 test
Evaluated by:
  • Self test
(s[sindex]) == ' 'Description
TRUEnever evaluated
FALSEevaluated 464 times by 1 test
Evaluated by:
  • Self test
(s[sindex]) == '\t'Description
TRUEnever evaluated
FALSEevaluated 464 times by 1 test
Evaluated by:
  • Self test
(s[sindex]) == '\n'Description
TRUEnever evaluated
FALSEevaluated 464 times by 1 test
Evaluated by:
  • Self test
0-661475
2959 {-
2960 sindex++;-
2961 /* An IFS character that is not IFS white space, along with any adjacent-
2962 IFS white space, shall delimit a field. */-
2963 while (s[sindex] && spctabnl (s[sindex]) && islocalsep(s[sindex]))
s[sindex]Description
TRUEevaluated 652 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 88 times by 1 test
Evaluated by:
  • Self test
(s[sindex]) == ' 'Description
TRUEevaluated 276 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 376 times by 1 test
Evaluated by:
  • Self test
(s[sindex]) == '\t'Description
TRUEnever evaluated
FALSEevaluated 376 times by 1 test
Evaluated by:
  • Self test
(s[sindex]) == '\n'Description
TRUEnever evaluated
FALSEevaluated 376 times by 1 test
Evaluated by:
  • Self test
(local_cmap[(u...index])] != 0)Description
TRUEevaluated 276 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-652
2964 sindex++;
executed 276 times by 1 test: sindex++;
Executed by:
  • Self test
276
2965 }
executed 464 times by 1 test: end of block
Executed by:
  • Self test
464
2966-
2967 /* Update STRING to point to the next field. */-
2968 *stringp = s + sindex;-
2969 return (current_word);
executed 662841 times by 1 test: return (current_word);
Executed by:
  • Self test
662841
2970}-
2971-
2972/* Remove IFS white space at the end of STRING. Start at the end-
2973 of the string and walk backwards until the beginning of the string-
2974 or we find a character that's not IFS white space and not CTLESC.-
2975 Only let CTLESC escape a white space character if SAW_ESCAPE is-
2976 non-zero. */-
2977char *-
2978strip_trailing_ifs_whitespace (string, separators, saw_escape)-
2979 char *string, *separators;-
2980 int saw_escape;-
2981{-
2982 char *s;-
2983-
2984 s = string + STRLEN (string) - 1;
(string)[1]Description
TRUEevaluated 389 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(string)[2]Description
TRUEevaluated 385 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
(string)Description
TRUEevaluated 389 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(string)[0]Description
TRUEevaluated 389 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-389
2985 while (s > string && ((spctabnl (*s) && isifs (*s)) ||
s > stringDescription
TRUEevaluated 575 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(*s) == ' 'Description
TRUEevaluated 185 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 390 times by 1 test
Evaluated by:
  • Self test
(*s) == '\t'Description
TRUEnever evaluated
FALSEevaluated 390 times by 1 test
Evaluated by:
  • Self test
(*s) == '\n'Description
TRUEnever evaluated
FALSEevaluated 390 times by 1 test
Evaluated by:
  • Self test
(ifs_cmap[(uns...ar)(*s)] != 0)Description
TRUEevaluated 185 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-575
2986 (saw_escape && *s == CTLESC && spctabnl (s[1]))))
saw_escapeDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 388 times by 1 test
Evaluated by:
  • Self test
*s == '\001'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
(s[1]) == ' 'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(s[1]) == '\t'Description
TRUEnever evaluated
FALSEnever evaluated
(s[1]) == '\n'Description
TRUEnever evaluated
FALSEnever evaluated
0-388
2987 s--;
executed 186 times by 1 test: s--;
Executed by:
  • Self test
186
2988 *++s = '\0';-
2989 return string;
executed 389 times by 1 test: return string;
Executed by:
  • Self test
389
2990}-
2991-
2992#if 0-
2993/* UNUSED */-
2994/* Split STRING into words at whitespace. Obeys shell-style quoting with-
2995 backslashes, single and double quotes. */-
2996WORD_LIST *-
2997list_string_with_quotes (string)-
2998 char *string;-
2999{-
3000 WORD_LIST *list;-
3001 char *token, *s;-
3002 size_t s_len;-
3003 int c, i, tokstart, len;-
3004-
3005 for (s = string; s && *s && spctabnl (*s); s++)-
3006 ;-
3007 if (s == 0 || *s == 0)-
3008 return ((WORD_LIST *)NULL);-
3009-
3010 s_len = strlen (s);-
3011 tokstart = i = 0;-
3012 list = (WORD_LIST *)NULL;-
3013 while (1)-
3014 {-
3015 c = s[i];-
3016 if (c == '\\')-
3017 {-
3018 i++;-
3019 if (s[i])-
3020 i++;-
3021 }-
3022 else if (c == '\'')-
3023 i = skip_single_quoted (s, s_len, ++i, 0);-
3024 else if (c == '"')-
3025 i = skip_double_quoted (s, s_len, ++i, 0);-
3026 else if (c == 0 || spctabnl (c))-
3027 {-
3028 /* We have found the end of a token. Make a word out of it and-
3029 add it to the word list. */-
3030 token = substring (s, tokstart, i);-
3031 list = add_string_to_list (token, list);-
3032 free (token);-
3033 while (spctabnl (s[i]))-
3034 i++;-
3035 if (s[i])-
3036 tokstart = i;-
3037 else-
3038 break;-
3039 }-
3040 else-
3041 i++; /* normal character */-
3042 }-
3043 return (REVERSE_LIST (list, WORD_LIST *));-
3044}-
3045#endif-
3046-
3047/********************************************************/-
3048/* */-
3049/* Functions to perform assignment statements */-
3050/* */-
3051/********************************************************/-
3052-
3053#if defined (ARRAY_VARS)-
3054static SHELL_VAR *-
3055do_compound_assignment (name, value, flags)-
3056 char *name, *value;-
3057 int flags;-
3058{-
3059 SHELL_VAR *v;-
3060 int mklocal, mkassoc, mkglobal, chklocal;-
3061 WORD_LIST *list;-
3062-
3063 mklocal = flags & ASS_MKLOCAL;-
3064 mkassoc = flags & ASS_MKASSOC;-
3065 mkglobal = flags & ASS_MKGLOBAL;-
3066 chklocal = flags & ASS_CHKLOCAL;-
3067-
3068 if (mklocal && variable_context)
mklocalDescription
TRUEevaluated 50 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 404 times by 1 test
Evaluated by:
  • Self test
variable_contextDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 40 times by 1 test
Evaluated by:
  • Self test
10-404
3069 {-
3070 v = find_variable (name);-
3071 if (v && ((readonly_p (v) && (flags & ASS_FORCE) == 0) || noassign_p (v)))
vDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((((v)->attrib... (0x0000002)))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
(flags & 0x0020) == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((((v)->attrib... (0x0004000)))Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
0-10
3072 {-
3073 if (readonly_p (v))
((((v)->attrib... (0x0000002)))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1
3074 err_readonly (name);
executed 1 time by 1 test: err_readonly (name);
Executed by:
  • Self test
1
3075 return (v); /* XXX */
executed 1 time by 1 test: return (v);
Executed by:
  • Self test
1
3076 }-
3077 list = expand_compound_array_assignment (v, value, flags);-
3078 if (mkassoc)
mkassocDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
1-8
3079 v = make_local_assoc_variable (name);
executed 1 time by 1 test: v = make_local_assoc_variable (name);
Executed by:
  • Self test
1
3080 else if (v == 0 || (array_p (v) == 0 && assoc_p (v) == 0) || v->context != variable_context)
v == 0Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
((((v)->attrib...000004))) == 0Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
((((v)->attrib...000040))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
v->context != variable_contextDescription
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
0-8
3081 v = make_local_array_variable (name, 0);
never executed: v = make_local_array_variable (name, 0);
0
3082 if (v)
vDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-9
3083 assign_compound_array_list (v, list, flags);
executed 9 times by 1 test: assign_compound_array_list (v, list, flags);
Executed by:
  • Self test
9
3084 if (list)
listDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-8
3085 dispose_words (list);
executed 8 times by 1 test: dispose_words (list);
Executed by:
  • Self test
8
3086 }
executed 9 times by 1 test: end of block
Executed by:
  • Self test
9
3087 /* In a function but forcing assignment in global context. CHKLOCAL means to-
3088 check for an existing local variable first. */-
3089 else if (mkglobal && variable_context)
mkglobalDescription
TRUEevaluated 29 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 415 times by 1 test
Evaluated by:
  • Self test
variable_contextDescription
TRUEevaluated 25 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
4-415
3090 {-
3091 v = chklocal ? find_variable (name) : 0;
chklocalDescription
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
10-15
3092 if (v && (local_p (v) == 0 || v->context != variable_context))
vDescription
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
((((v)->attrib...000020))) == 0Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
v->context != variable_contextDescription
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
0-15
3093 v = 0;
executed 13 times by 1 test: v = 0;
Executed by:
  • Self test
13
3094 if (v == 0)
v == 0Description
TRUEevaluated 23 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2-23
3095 v = find_global_variable (name);
executed 23 times by 1 test: v = find_global_variable (name);
Executed by:
  • Self test
23
3096 if (v && ((readonly_p (v) && (flags & ASS_FORCE) == 0) || noassign_p (v)))
vDescription
TRUEevaluated 25 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((((v)->attrib... (0x0000002)))Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 22 times by 1 test
Evaluated by:
  • Self test
(flags & 0x0020) == 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((((v)->attrib... (0x0004000)))Description
TRUEnever evaluated
FALSEevaluated 22 times by 1 test
Evaluated by:
  • Self test
0-25
3097 {-
3098 if (readonly_p (v))
((((v)->attrib... (0x0000002)))Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3
3099 err_readonly (name);
executed 3 times by 1 test: err_readonly (name);
Executed by:
  • Self test
3
3100 return (v); /* XXX */
executed 3 times by 1 test: return (v);
Executed by:
  • Self test
3
3101 }-
3102 list = expand_compound_array_assignment (v, value, flags);-
3103 if (v == 0 && mkassoc)
v == 0Description
TRUEnever evaluated
FALSEevaluated 22 times by 1 test
Evaluated by:
  • Self test
mkassocDescription
TRUEnever evaluated
FALSEnever evaluated
0-22
3104 v = make_new_assoc_variable (name);
never executed: v = make_new_assoc_variable (name);
0
3105 else if (v && mkassoc && assoc_p (v) == 0)
vDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
mkassocDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 19 times by 1 test
Evaluated by:
  • Self test
((((v)->attrib...000040))) == 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
0-22
3106 v = convert_var_to_assoc (v);
never executed: v = convert_var_to_assoc (v);
0
3107 else if (v == 0)
v == 0Description
TRUEnever evaluated
FALSEevaluated 22 times by 1 test
Evaluated by:
  • Self test
0-22
3108 v = make_new_array_variable (name);
never executed: v = make_new_array_variable (name);
0
3109 else if (v && mkassoc == 0 && array_p (v) == 0)
vDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
mkassoc == 0Description
TRUEevaluated 19 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
((((v)->attrib...000004))) == 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test
0-22
3110 v = convert_var_to_array (v);
executed 5 times by 1 test: v = convert_var_to_array (v);
Executed by:
  • Self test
5
3111 if (v)
vDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-22
3112 assign_compound_array_list (v, list, flags);
executed 22 times by 1 test: assign_compound_array_list (v, list, flags);
Executed by:
  • Self test
22
3113 if (list)
listDescription
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-21
3114 dispose_words (list);
executed 21 times by 1 test: dispose_words (list);
Executed by:
  • Self test
21
3115 }
executed 22 times by 1 test: end of block
Executed by:
  • Self test
22
3116 else-
3117 {-
3118 v = assign_array_from_string (name, value, flags);-
3119 if (v && ((readonly_p (v) && (flags & ASS_FORCE) == 0) || noassign_p (v)))
vDescription
TRUEevaluated 402 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 15 times by 1 test
Evaluated by:
  • Self test
((((v)->attrib... (0x0000002)))Description
TRUEnever evaluated
FALSEevaluated 402 times by 1 test
Evaluated by:
  • Self test
(flags & 0x0020) == 0Description
TRUEnever evaluated
FALSEnever evaluated
((((v)->attrib... (0x0004000)))Description
TRUEnever evaluated
FALSEevaluated 402 times by 1 test
Evaluated by:
  • Self test
0-402
3120 {-
3121 if (readonly_p (v))
((((v)->attrib... (0x0000002)))Description
TRUEnever evaluated
FALSEnever evaluated
0
3122 err_readonly (name);
never executed: err_readonly (name);
0
3123 return (v); /* XXX */
never executed: return (v);
0
3124 }-
3125 }
executed 417 times by 1 test: end of block
Executed by:
  • Self test
417
3126-
3127 return (v);
executed 448 times by 1 test: return (v);
Executed by:
  • Self test
448
3128}-
3129#endif-
3130-
3131/* Given STRING, an assignment string, get the value of the right side-
3132 of the `=', and bind it to the left side. If EXPAND is true, then-
3133 perform parameter expansion, command substitution, and arithmetic-
3134 expansion on the right-hand side. Perform tilde expansion in any-
3135 case. Do not perform word splitting on the result of expansion. */-
3136static int-
3137do_assignment_internal (word, expand)-
3138 const WORD_DESC *word;-
3139 int expand;-
3140{-
3141 int offset, appendop, assign_list, aflags, retval;-
3142 char *name, *value, *temp;-
3143 SHELL_VAR *entry;-
3144#if defined (ARRAY_VARS)-
3145 char *t;-
3146 int ni;-
3147#endif-
3148 const char *string;-
3149-
3150 if (word == 0 || word->word == 0)
word == 0Description
TRUEnever evaluated
FALSEevaluated 36424573 times by 1 test
Evaluated by:
  • Self test
word->word == 0Description
TRUEnever evaluated
FALSEevaluated 36424573 times by 1 test
Evaluated by:
  • Self test
0-36424573
3151 return 0;
never executed: return 0;
0
3152-
3153 appendop = assign_list = aflags = 0;-
3154 string = word->word;-
3155 offset = assignment (string, 0);-
3156 name = savestring (string);-
3157 value = (char *)NULL;-
3158-
3159 if (name[offset] == '=')
name[offset] == '='Description
TRUEevaluated 36424573 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-36424573
3160 {-
3161 if (name[offset - 1] == '+')
name[offset - 1] == '+'Description
TRUEevaluated 88 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 36424485 times by 1 test
Evaluated by:
  • Self test
88-36424485
3162 {-
3163 appendop = 1;-
3164 name[offset - 1] = '\0';-
3165 }
executed 88 times by 1 test: end of block
Executed by:
  • Self test
88
3166-
3167 name[offset] = 0; /* might need this set later */-
3168 temp = name + offset + 1;-
3169-
3170#if defined (ARRAY_VARS)-
3171 if (expand && (word->flags & W_COMPASSIGN))
expandDescription
TRUEevaluated 36424369 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 204 times by 1 test
Evaluated by:
  • Self test
(word->flags & 0x008000)Description
TRUEevaluated 464 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 36423905 times by 1 test
Evaluated by:
  • Self test
204-36424369
3172 {-
3173 assign_list = ni = 1;-
3174 value = extract_array_assignment_list (temp, &ni);-
3175 }
executed 464 times by 1 test: end of block
Executed by:
  • Self test
464
3176 else-
3177#endif-
3178 if (expand && temp[0])
expandDescription
TRUEevaluated 36423905 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 204 times by 1 test
Evaluated by:
  • Self test
temp[0]Description
TRUEevaluated 36421320 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2585 times by 1 test
Evaluated by:
  • Self test
204-36423905
3179 value = expand_string_if_necessary (temp, 0, expand_string_assignment);
executed 36421320 times by 1 test: value = expand_string_if_necessary (temp, 0, expand_string_assignment);
Executed by:
  • Self test
36421320
3180 else-
3181 value = savestring (temp);
executed 2789 times by 1 test: value = (char *)strcpy (sh_xmalloc((1 + strlen (temp)), "subst.c", 3181), (temp));
Executed by:
  • Self test
2789
3182 }-
3183-
3184 if (value == 0)
value == 0Description
TRUEevaluated 2404 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 36419714 times by 1 test
Evaluated by:
  • Self test
2404-36419714
3185 {-
3186 value = (char *)xmalloc (1);-
3187 value[0] = '\0';-
3188 }
executed 2404 times by 1 test: end of block
Executed by:
  • Self test
2404
3189-
3190 if (echo_command_at_execute)
echo_command_at_executeDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 36422106 times by 1 test
Evaluated by:
  • Self test
12-36422106
3191 {-
3192 if (appendop)
appendopDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11 times by 1 test
Evaluated by:
  • Self test
1-11
3193 name[offset - 1] = '+';
executed 1 time by 1 test: name[offset - 1] = '+';
Executed by:
  • Self test
1
3194 xtrace_print_assignment (name, value, assign_list, 1);-
3195 if (appendop)
appendopDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11 times by 1 test
Evaluated by:
  • Self test
1-11
3196 name[offset - 1] = '\0';
executed 1 time by 1 test: name[offset - 1] = '\0';
Executed by:
  • Self test
1
3197 }
executed 12 times by 1 test: end of block
Executed by:
  • Self test
12
3198-
3199#define ASSIGN_RETURN(r) do { FREE (value); free (name); return (r); } while (0)-
3200-
3201 if (appendop)
appendopDescription
TRUEevaluated 88 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 36422030 times by 1 test
Evaluated by:
  • Self test
88-36422030
3202 aflags |= ASS_APPEND;
executed 88 times by 1 test: aflags |= 0x0001;
Executed by:
  • Self test
88
3203-
3204#if defined (ARRAY_VARS)-
3205 if (t = mbschr (name, LBRACK))
t = mbschr (name, '[')Description
TRUEevaluated 704 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 36421414 times by 1 test
Evaluated by:
  • Self test
704-36421414
3206 {-
3207 if (assign_list)
assign_listDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 694 times by 1 test
Evaluated by:
  • Self test
10-694
3208 {-
3209 report_error (_("%s: cannot assign list to array member"), name);-
3210 ASSIGN_RETURN (0);
executed 10 times by 1 test: sh_xfree((value), "subst.c", 3210);
Executed by:
  • Self test
executed 10 times by 1 test: return (0);
Executed by:
  • Self test
valueDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-10
3211 }-
3212 entry = assign_array_element (name, value, aflags);-
3213 if (entry == 0)
entry == 0Description
TRUEevaluated 37 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 649 times by 1 test
Evaluated by:
  • Self test
37-649
3214 ASSIGN_RETURN (0);
executed 37 times by 1 test: sh_xfree((value), "subst.c", 3214);
Executed by:
  • Self test
executed 37 times by 1 test: return (0);
Executed by:
  • Self test
never executed: end of block
valueDescription
TRUEevaluated 37 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-37
3215 }
executed 649 times by 1 test: end of block
Executed by:
  • Self test
649
3216 else if (assign_list)
assign_listDescription
TRUEevaluated 454 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 36420960 times by 1 test
Evaluated by:
  • Self test
454-36420960
3217 {-
3218 if ((word->flags & W_ASSIGNARG) && (word->flags & W_CHKLOCAL))
(word->flags & 0x020000)Description
TRUEevaluated 79 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 375 times by 1 test
Evaluated by:
  • Self test
(word->flags & 0x10000000)Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 63 times by 1 test
Evaluated by:
  • Self test
16-375
3219 aflags |= ASS_CHKLOCAL;
executed 16 times by 1 test: aflags |= 0x0040;
Executed by:
  • Self test
16
3220 if ((word->flags & W_ASSIGNARG) && (word->flags & W_ASSNGLOBAL) == 0)
(word->flags & 0x020000)Description
TRUEevaluated 79 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 375 times by 1 test
Evaluated by:
  • Self test
(word->flags & 0x2000000) == 0Description
TRUEevaluated 50 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 29 times by 1 test
Evaluated by:
  • Self test
29-375
3221 aflags |= ASS_MKLOCAL;
executed 50 times by 1 test: aflags |= 0x0002;
Executed by:
  • Self test
50
3222 if ((word->flags & W_ASSIGNARG) && (word->flags & W_ASSNGLOBAL))
(word->flags & 0x020000)Description
TRUEevaluated 79 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 375 times by 1 test
Evaluated by:
  • Self test
(word->flags & 0x2000000)Description
TRUEevaluated 29 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 50 times by 1 test
Evaluated by:
  • Self test
29-375
3223 aflags |= ASS_MKGLOBAL;
executed 29 times by 1 test: aflags |= 0x0008;
Executed by:
  • Self test
29
3224 if (word->flags & W_ASSIGNASSOC)
word->flags & 0x400000Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 438 times by 1 test
Evaluated by:
  • Self test
16-438
3225 aflags |= ASS_MKASSOC;
executed 16 times by 1 test: aflags |= 0x0004;
Executed by:
  • Self test
16
3226 entry = do_compound_assignment (name, value, aflags);-
3227 }
executed 452 times by 1 test: end of block
Executed by:
  • Self test
452
3228 else-
3229#endif /* ARRAY_VARS */-
3230 entry = bind_variable (name, value, aflags);
executed 36420960 times by 1 test: entry = bind_variable (name, value, aflags);
Executed by:
  • Self test
36420960
3231-
3232 stupidly_hack_special_variables (name);-
3233-
3234 /* Return 1 if the assignment seems to have been performed correctly. */-
3235 if (entry == 0 || readonly_p (entry))
entry == 0Description
TRUEevaluated 33 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 36422012 times by 1 test
Evaluated by:
  • Self test
((((entry)->at... (0x0000002)))Description
TRUEevaluated 37 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 36421975 times by 1 test
Evaluated by:
  • Self test
33-36422012
3236 retval = 0; /* assignment failure */
executed 70 times by 1 test: retval = 0;
Executed by:
  • Self test
70
3237 else if (noassign_p (entry))
((((entry)->at... (0x0004000)))Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 36421971 times by 1 test
Evaluated by:
  • Self test
4-36421971
3238 {-
3239 last_command_exit_value = EXECUTION_FAILURE;-
3240 retval = 1; /* error status, but not assignment failure */-
3241 }
executed 4 times by 1 test: end of block
Executed by:
  • Self test
4
3242 else-
3243 retval = 1;
executed 36421971 times by 1 test: retval = 1;
Executed by:
  • Self test
36421971
3244-
3245 if (entry && retval != 0 && noassign_p (entry) == 0)
entryDescription
TRUEevaluated 36422012 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 33 times by 1 test
Evaluated by:
  • Self test
retval != 0Description
TRUEevaluated 36421975 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 37 times by 1 test
Evaluated by:
  • Self test
((((entry)->at...004000))) == 0Description
TRUEevaluated 36421971 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
4-36422012
3246 VUNSETATTR (entry, att_invisible);
executed 36421971 times by 1 test: ((entry)->attributes &= ~(0x0001000));
Executed by:
  • Self test
36421971
3247-
3248 ASSIGN_RETURN (retval);
executed 36422045 times by 1 test: sh_xfree((value), "subst.c", 3248);
Executed by:
  • Self test
executed 36422045 times by 1 test: return (retval);
Executed by:
  • Self test
valueDescription
TRUEevaluated 36422045 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-36422045
3249}-
3250-
3251/* Perform the assignment statement in STRING, and expand the-
3252 right side by doing tilde, command and parameter expansion. */-
3253int-
3254do_assignment (string)-
3255 char *string;-
3256{-
3257 WORD_DESC td;-
3258-
3259 td.flags = W_ASSIGNMENT;-
3260 td.word = string;-
3261-
3262 return do_assignment_internal (&td, 1);
never executed: return do_assignment_internal (&td, 1);
0
3263}-
3264-
3265int-
3266do_word_assignment (word, flags)-
3267 WORD_DESC *word;-
3268 int flags;-
3269{-
3270 return do_assignment_internal (word, 1);
executed 36424369 times by 1 test: return do_assignment_internal (word, 1);
Executed by:
  • Self test
36424369
3271}-
3272-
3273/* Given STRING, an assignment string, get the value of the right side-
3274 of the `=', and bind it to the left side. Do not perform any word-
3275 expansions on the right hand side. */-
3276int-
3277do_assignment_no_expand (string)-
3278 char *string;-
3279{-
3280 WORD_DESC td;-
3281-
3282 td.flags = W_ASSIGNMENT;-
3283 td.word = string;-
3284-
3285 return (do_assignment_internal (&td, 0));
executed 204 times by 1 test: return (do_assignment_internal (&td, 0));
Executed by:
  • Self test
204
3286}-
3287-
3288/***************************************************-
3289 * *-
3290 * Functions to manage the positional parameters *-
3291 * *-
3292 ***************************************************/-
3293-
3294/* Return the word list that corresponds to `$*'. */-
3295WORD_LIST *-
3296list_rest_of_args ()-
3297{-
3298 register WORD_LIST *list, *args;-
3299 int i;-
3300-
3301 /* Break out of the loop as soon as one of the dollar variables is null. */-
3302 for (i = 1, list = (WORD_LIST *)NULL; i < 10 && dollar_vars[i]; i++)
i < 10Description
TRUEevaluated 1687610 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 198 times by 1 test
Evaluated by:
  • Self test
dollar_vars[i]Description
TRUEevaluated 35538 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1652072 times by 1 test
Evaluated by:
  • Self test
198-1687610
3303 list = make_word_list (make_bare_word (dollar_vars[i]), list);
executed 35538 times by 1 test: list = make_word_list (make_bare_word (dollar_vars[i]), list);
Executed by:
  • Self test
35538
3304-
3305 for (args = rest_of_args; args; args = args->next)
argsDescription
TRUEevaluated 353 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1652270 times by 1 test
Evaluated by:
  • Self test
353-1652270
3306 list = make_word_list (make_bare_word (args->word->word), list);
executed 353 times by 1 test: list = make_word_list (make_bare_word (args->word->word), list);
Executed by:
  • Self test
353
3307-
3308 return (REVERSE_LIST (list, WORD_LIST *));
executed 1652270 times by 1 test: return (((list && list->next) ? (WORD_LIST *)list_reverse ((GENERIC_LIST *)list) : (WORD_LIST *)(list)));
Executed by:
  • Self test
1652270
3309}-
3310-
3311int-
3312number_of_args ()-
3313{-
3314 register WORD_LIST *list;-
3315 int n;-
3316-
3317 for (n = 0; n < 9 && dollar_vars[n+1]; n++)
n < 9Description
TRUEevaluated 80311693 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 29 times by 1 test
Evaluated by:
  • Self test
dollar_vars[n+1]Description
TRUEevaluated 53283592 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 27028101 times by 1 test
Evaluated by:
  • Self test
29-80311693
3318 ;
executed 53283592 times by 1 test: ;
Executed by:
  • Self test
53283592
3319 for (list = rest_of_args; list; list = list->next)
listDescription
TRUEevaluated 38 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 27028130 times by 1 test
Evaluated by:
  • Self test
38-27028130
3320 n++;
executed 38 times by 1 test: n++;
Executed by:
  • Self test
38
3321 return n;
executed 27028130 times by 1 test: return n;
Executed by:
  • Self test
27028130
3322}-
3323-
3324/* Return the value of a positional parameter. This handles values > 10. */-
3325char *-
3326get_dollar_var_value (ind)-
3327 intmax_t ind;-
3328{-
3329 char *temp;-
3330 WORD_LIST *p;-
3331-
3332 if (ind < 10)
ind < 10Description
TRUEevaluated 14893 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-14893
3333 temp = dollar_vars[ind] ? savestring (dollar_vars[ind]) : (char *)NULL;
executed 14893 times by 1 test: temp = dollar_vars[ind] ? (char *)strcpy (sh_xmalloc((1 + strlen (dollar_vars[ind])), "subst.c", 3333), (dollar_vars[ind])) : (char *) ((void *)0) ;
Executed by:
  • Self test
dollar_vars[ind]Description
TRUEevaluated 14652 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 241 times by 1 test
Evaluated by:
  • Self test
241-14893
3334 else /* We want something like ${11} */-
3335 {-
3336 ind -= 10;-
3337 for (p = rest_of_args; p && ind--; p = p->next)
pDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
ind--Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-1
3338 ;
never executed: ;
0
3339 temp = p ? savestring (p->word->word) : (char *)NULL;
pDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1
3340 }
executed 1 time by 1 test: end of block
Executed by:
  • Self test
1
3341 return (temp);
executed 14894 times by 1 test: return (temp);
Executed by:
  • Self test
14894
3342}-
3343-
3344/* Make a single large string out of the dollar digit variables,-
3345 and the rest_of_args. If DOLLAR_STAR is 1, then obey the special-
3346 case of "$*" with respect to IFS. */-
3347char *-
3348string_rest_of_args (dollar_star)-
3349 int dollar_star;-
3350{-
3351 register WORD_LIST *list;-
3352 char *string;-
3353-
3354 list = list_rest_of_args ();-
3355 string = dollar_star ? string_list_dollar_star (list, 0, 0) : string_list (list);
dollar_starDescription
TRUEnever evaluated
FALSEnever evaluated
0
3356 dispose_words (list);-
3357 return (string);
never executed: return (string);
0
3358}-
3359-
3360/* Return a string containing the positional parameters from START to-
3361 END, inclusive. If STRING[0] == '*', we obey the rules for $*,-
3362 which only makes a difference if QUOTED is non-zero. If QUOTED includes-
3363 Q_HERE_DOCUMENT or Q_DOUBLE_QUOTES, this returns a quoted list, otherwise-
3364 no quoting chars are added. */-
3365static char *-
3366pos_params (string, start, end, quoted)-
3367 char *string;-
3368 int start, end, quoted;-
3369{-
3370 WORD_LIST *save, *params, *h, *t;-
3371 char *ret;-
3372 int i;-
3373-
3374 /* see if we can short-circuit. if start == end, we want 0 parameters. */-
3375 if (start == end)
start == endDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 215 times by 1 test
Evaluated by:
  • Self test
6-215
3376 return ((char *)NULL);
executed 6 times by 1 test: return ((char *) ((void *)0) );
Executed by:
  • Self test
6
3377-
3378 save = params = list_rest_of_args ();-
3379 if (save == 0 && start > 0)
save == 0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 207 times by 1 test
Evaluated by:
  • Self test
start > 0Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
0-207
3380 return ((char *)NULL);
never executed: return ((char *) ((void *)0) );
0
3381-
3382 if (start == 0) /* handle ${@:0[:x]} specially */
start == 0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 207 times by 1 test
Evaluated by:
  • Self test
8-207
3383 {-
3384 t = make_word_list (make_word (dollar_vars[0]), params);-
3385 save = params = t;-
3386 }
executed 8 times by 1 test: end of block
Executed by:
  • Self test
8
3387-
3388 for (i = start ? 1 : 0; params && i < start; i++)
paramsDescription
TRUEevaluated 296 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
i < startDescription
TRUEevaluated 81 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 215 times by 1 test
Evaluated by:
  • Self test
0-296
3389 params = params->next;
executed 81 times by 1 test: params = params->next;
Executed by:
  • Self test
81
3390 if (params == 0)
params == 0Description
TRUEnever evaluated
FALSEevaluated 215 times by 1 test
Evaluated by:
  • Self test
0-215
3391 {-
3392 dispose_words (save);-
3393 return ((char *)NULL);
never executed: return ((char *) ((void *)0) );
0
3394 }-
3395 for (h = t = params; params && i < end; i++)
paramsDescription
TRUEevaluated 423 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 170 times by 1 test
Evaluated by:
  • Self test
i < endDescription
TRUEevaluated 378 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 45 times by 1 test
Evaluated by:
  • Self test
45-423
3396 {-
3397 t = params;-
3398 params = params->next;-
3399 }
executed 378 times by 1 test: end of block
Executed by:
  • Self test
378
3400 t->next = (WORD_LIST *)NULL;-
3401-
3402 ret = string_list_pos_params (string[0], h, quoted);-
3403-
3404 if (t != params)
t != paramsDescription
TRUEevaluated 215 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-215
3405 t->next = params;
executed 215 times by 1 test: t->next = params;
Executed by:
  • Self test
215
3406-
3407 dispose_words (save);-
3408 return (ret);
executed 215 times by 1 test: return (ret);
Executed by:
  • Self test
215
3409}-
3410-
3411/******************************************************************/-
3412/* */-
3413/* Functions to expand strings to strings or WORD_LISTs */-
3414/* */-
3415/******************************************************************/-
3416-
3417#if defined (PROCESS_SUBSTITUTION)-
3418#define EXP_CHAR(s) (s == '$' || s == '`' || s == '<' || s == '>' || s == CTLESC || s == '~')-
3419#else-
3420#define EXP_CHAR(s) (s == '$' || s == '`' || s == CTLESC || s == '~')-
3421#endif-
3422-
3423/* If there are any characters in STRING that require full expansion,-
3424 then call FUNC to expand STRING; otherwise just perform quote-
3425 removal if necessary. This returns a new string. */-
3426static char *-
3427expand_string_if_necessary (string, quoted, func)-
3428 char *string;-
3429 int quoted;-
3430 EXPFUNC *func;-
3431{-
3432 WORD_LIST *list;-
3433 size_t slen;-
3434 int i, saw_quote;-
3435 char *ret;-
3436 DECLARE_MBSTATE;-
3437-
3438 /* Don't need string length for ADVANCE_CHAR unless multibyte chars possible. */-
3439 slen = (MB_CUR_MAX > 1) ? strlen (string) : 0;
( (__ctype_get...r_max ()) > 1)Description
TRUEevaluated 36421009 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 900 times by 1 test
Evaluated by:
  • Self test
900-36421009
3440 i = saw_quote = 0;-
3441 while (string[i])
string[i]Description
TRUEevaluated 61299003 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6522001 times by 1 test
Evaluated by:
  • Self test
6522001-61299003
3442 {-
3443 if (EXP_CHAR (string[i]))
string[i] == '$'Description
TRUEevaluated 26668544 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 34630459 times by 1 test
Evaluated by:
  • Self test
string[i] == '`'Description
TRUEevaluated 3230002 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31400457 times by 1 test
Evaluated by:
  • Self test
string[i] == '<'Description
TRUEevaluated 1144 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31399313 times by 1 test
Evaluated by:
  • Self test
string[i] == '>'Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31399304 times by 1 test
Evaluated by:
  • Self test
string[i] == '\001'Description
TRUEevaluated 190 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31399114 times by 1 test
Evaluated by:
  • Self test
string[i] == '~'Description
TRUEevaluated 19 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31399095 times by 1 test
Evaluated by:
  • Self test
9-34630459
3444 break;
executed 29899908 times by 1 test: break;
Executed by:
  • Self test
29899908
3445 else if (string[i] == '\'' || string[i] == '\\' || string[i] == '"')
string[i] == '\''Description
TRUEevaluated 13006906 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 18392189 times by 1 test
Evaluated by:
  • Self test
string[i] == '\\'Description
TRUEevaluated 141 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 18392048 times by 1 test
Evaluated by:
  • Self test
string[i] == '"'Description
TRUEevaluated 11845252 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6546796 times by 1 test
Evaluated by:
  • Self test
141-18392189
3446 saw_quote = 1;
executed 24852299 times by 1 test: saw_quote = 1;
Executed by:
  • Self test
24852299
3447 ADVANCE_CHAR (string, slen, i);
executed 31397685 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 130 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 61 times by 1 test: end of block
Executed by:
  • Self test
executed 26 times by 1 test: end of block
Executed by:
  • Self test
never executed: (i)++;
executed 31397850 times by 1 test: (i) += mblength;
Executed by:
  • Self test
executed 1219 times by 1 test: (i)++;
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 31397876 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1219 times by 1 test
Evaluated by:
  • Self test
_fDescription
TRUEevaluated 31397685 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 191 times by 1 test
Evaluated by:
  • Self test
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 31397850 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 191 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEevaluated 130 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 61 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 31397876 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31397850 times by 1 test
Evaluated by:
  • Self test
0-31397876
3448 }
executed 31399095 times by 1 test: end of block
Executed by:
  • Self test
31399095
3449-
3450 if (string[i])
string[i]Description
TRUEevaluated 29899908 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6522001 times by 1 test
Evaluated by:
  • Self test
6522001-29899908
3451 {-
3452 list = (*func) (string, quoted);-
3453 if (list)
listDescription
TRUEevaluated 29895048 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2405 times by 1 test
Evaluated by:
  • Self test
2405-29895048
3454 {-
3455 ret = string_list (list);-
3456 dispose_words (list);-
3457 }
executed 29895048 times by 1 test: end of block
Executed by:
  • Self test
29895048
3458 else-
3459 ret = (char *)NULL;
executed 2405 times by 1 test: ret = (char *) ((void *)0) ;
Executed by:
  • Self test
2405
3460 }-
3461 else if (saw_quote && ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) == 0))
saw_quoteDescription
TRUEevaluated 6503628 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 18373 times by 1 test
Evaluated by:
  • Self test
((quoted & (0x...|0x001)) == 0)Description
TRUEevaluated 6503628 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-6503628
3462 ret = string_quote_removal (string, quoted);
executed 6503628 times by 1 test: ret = string_quote_removal (string, quoted);
Executed by:
  • Self test
6503628
3463 else-
3464 ret = savestring (string);
executed 18373 times by 1 test: ret = (char *)strcpy (sh_xmalloc((1 + strlen (string)), "subst.c", 3464), (string));
Executed by:
  • Self test
18373
3465-
3466 return ret;
executed 36419454 times by 1 test: return ret;
Executed by:
  • Self test
36419454
3467}-
3468-
3469static inline char *-
3470expand_string_to_string_internal (string, quoted, func)-
3471 char *string;-
3472 int quoted;-
3473 EXPFUNC *func;-
3474{-
3475 WORD_LIST *list;-
3476 char *ret;-
3477-
3478 if (string == 0 || *string == '\0')
string == 0Description
TRUEnever evaluated
FALSEevaluated 2630 times by 1 test
Evaluated by:
  • Self test
*string == '\0'Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2609 times by 1 test
Evaluated by:
  • Self test
0-2630
3479 return ((char *)NULL);
executed 21 times by 1 test: return ((char *) ((void *)0) );
Executed by:
  • Self test
21
3480-
3481 list = (*func) (string, quoted);-
3482 if (list)
listDescription
TRUEevaluated 2604 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
3-2604
3483 {-
3484 ret = string_list (list);-
3485 dispose_words (list);-
3486 }
executed 2604 times by 1 test: end of block
Executed by:
  • Self test
2604
3487 else-
3488 ret = (char *)NULL;
executed 3 times by 1 test: ret = (char *) ((void *)0) ;
Executed by:
  • Self test
3
3489-
3490 return (ret);
executed 2607 times by 1 test: return (ret);
Executed by:
  • Self test
2607
3491}-
3492-
3493char *-
3494expand_string_to_string (string, quoted)-
3495 char *string;-
3496 int quoted;-
3497{-
3498 return (expand_string_to_string_internal (string, quoted, expand_string));
never executed: return (expand_string_to_string_internal (string, quoted, expand_string));
0
3499}-
3500-
3501char *-
3502expand_string_unsplit_to_string (string, quoted)-
3503 char *string;-
3504 int quoted;-
3505{-
3506 return (expand_string_to_string_internal (string, quoted, expand_string_unsplit));
executed 67 times by 1 test: return (expand_string_to_string_internal (string, quoted, expand_string_unsplit));
Executed by:
  • Self test
67
3507}-
3508-
3509char *-
3510expand_assignment_string_to_string (string, quoted)-
3511 char *string;-
3512 int quoted;-
3513{-
3514 return (expand_string_to_string_internal (string, quoted, expand_string_assignment));
executed 2563 times by 1 test: return (expand_string_to_string_internal (string, quoted, expand_string_assignment));
Executed by:
  • Self test
2563
3515}-
3516-
3517char *-
3518expand_arith_string (string, quoted)-
3519 char *string;-
3520 int quoted;-
3521{-
3522 WORD_DESC td;-
3523 WORD_LIST *list, *tlist;-
3524 size_t slen;-
3525 int i, saw_quote;-
3526 char *ret;-
3527 DECLARE_MBSTATE;-
3528-
3529 /* Don't need string length for ADVANCE_CHAR unless multibyte chars possible. */-
3530 slen = (MB_CUR_MAX > 1) ? strlen (string) : 0;
( (__ctype_get...r_max ()) > 1)Description
TRUEevaluated 35264 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 21 times by 1 test
Evaluated by:
  • Self test
21-35264
3531 i = saw_quote = 0;-
3532 while (string[i])
string[i]Description
TRUEevaluated 277455 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31924 times by 1 test
Evaluated by:
  • Self test
31924-277455
3533 {-
3534 if (EXP_CHAR (string[i]))
string[i] == '$'Description
TRUEevaluated 3180 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 274275 times by 1 test
Evaluated by:
  • Self test
string[i] == '`'Description
TRUEevaluated 29 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 274246 times by 1 test
Evaluated by:
  • Self test
string[i] == '<'Description
TRUEevaluated 91 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 274155 times by 1 test
Evaluated by:
  • Self test
string[i] == '>'Description
TRUEevaluated 41 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 274114 times by 1 test
Evaluated by:
  • Self test
string[i] == '\001'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 274113 times by 1 test
Evaluated by:
  • Self test
string[i] == '~'Description
TRUEevaluated 19 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 274094 times by 1 test
Evaluated by:
  • Self test
1-274275
3535 break;
executed 3361 times by 1 test: break;
Executed by:
  • Self test
3361
3536 else if (string[i] == '\'' || string[i] == '\\' || string[i] == '"')
string[i] == '\''Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 274090 times by 1 test
Evaluated by:
  • Self test
string[i] == '\\'Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 274080 times by 1 test
Evaluated by:
  • Self test
string[i] == '"'Description
TRUEevaluated 1794 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 272286 times by 1 test
Evaluated by:
  • Self test
4-274090
3537 saw_quote = 1;
executed 1808 times by 1 test: saw_quote = 1;
Executed by:
  • Self test
1808
3538 ADVANCE_CHAR (string, slen, i);
executed 274037 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 8 times by 1 test: mblength = 1;
Executed by:
  • Self test
never executed: end of block
never executed: end of block
never executed: (i)++;
executed 274045 times by 1 test: (i) += mblength;
Executed by:
  • Self test
executed 49 times by 1 test: (i)++;
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 274045 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 49 times by 1 test
Evaluated by:
  • Self test
_fDescription
TRUEevaluated 274037 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 274045 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 274045 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 274045 times by 1 test
Evaluated by:
  • Self test
0-274045
3539 }
executed 274094 times by 1 test: end of block
Executed by:
  • Self test
274094
3540-
3541 if (string[i])
string[i]Description
TRUEevaluated 3361 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31924 times by 1 test
Evaluated by:
  • Self test
3361-31924
3542 {-
3543 /* This is expanded version of expand_string_internal as it's called by-
3544 expand_string_leave_quoted */-
3545 td.flags = W_NOPROCSUB; /* don't want process substitution */-
3546 td.word = savestring (string);-
3547 list = call_expand_word_internal (&td, quoted, 0, (int *)NULL, (int *)NULL);-
3548 /* This takes care of the calls from expand_string_leave_quoted and-
3549 expand_string */-
3550 if (list)
listDescription
TRUEevaluated 3323 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
3-3323
3551 {-
3552 tlist = word_list_split (list);-
3553 dispose_words (list);-
3554 list = tlist;-
3555 if (list)
listDescription
TRUEevaluated 3323 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3323
3556 dequote_list (list);
executed 3323 times by 1 test: dequote_list (list);
Executed by:
  • Self test
3323
3557 }
executed 3323 times by 1 test: end of block
Executed by:
  • Self test
3323
3558 /* This comes from expand_string_if_necessary */-
3559 if (list)
listDescription
TRUEevaluated 3323 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
3-3323
3560 {-
3561 ret = string_list (list);-
3562 dispose_words (list);-
3563 }
executed 3323 times by 1 test: end of block
Executed by:
  • Self test
3323
3564 else-
3565 ret = (char *)NULL;
executed 3 times by 1 test: ret = (char *) ((void *)0) ;
Executed by:
  • Self test
3
3566 FREE (td.word);
executed 3326 times by 1 test: sh_xfree((td.word), "subst.c", 3566);
Executed by:
  • Self test
td.wordDescription
TRUEevaluated 3326 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3326
3567 }
executed 3326 times by 1 test: end of block
Executed by:
  • Self test
3326
3568 else if (saw_quote && (quoted & Q_ARITH))
saw_quoteDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31915 times by 1 test
Evaluated by:
  • Self test
(quoted & 0x100)Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-31915
3569 ret = string_quote_removal (string, quoted);
executed 9 times by 1 test: ret = string_quote_removal (string, quoted);
Executed by:
  • Self test
9
3570 else if (saw_quote && ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) == 0))
saw_quoteDescription
TRUEnever evaluated
FALSEevaluated 31915 times by 1 test
Evaluated by:
  • Self test
((quoted & (0x...|0x001)) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
0-31915
3571 ret = string_quote_removal (string, quoted);
never executed: ret = string_quote_removal (string, quoted);
0
3572 else-
3573 ret = savestring (string);
executed 31915 times by 1 test: ret = (char *)strcpy (sh_xmalloc((1 + strlen (string)), "subst.c", 3573), (string));
Executed by:
  • Self test
31915
3574-
3575 return ret;
executed 35250 times by 1 test: return ret;
Executed by:
  • Self test
35250
3576}-
3577-
3578#if defined (COND_COMMAND)-
3579/* Just remove backslashes in STRING. Returns a new string. */-
3580char *-
3581remove_backslashes (string)-
3582 char *string;-
3583{-
3584 char *r, *ret, *s;-
3585-
3586 r = ret = (char *)xmalloc (strlen (string) + 1);-
3587 for (s = string; s && *s; )
sDescription
TRUEnever evaluated
FALSEnever evaluated
*sDescription
TRUEnever evaluated
FALSEnever evaluated
0
3588 {-
3589 if (*s == '\\')
*s == '\\'Description
TRUEnever evaluated
FALSEnever evaluated
0
3590 s++;
never executed: s++;
0
3591 if (*s == 0)
*s == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3592 break;
never executed: break;
0
3593 *r++ = *s++;-
3594 }
never executed: end of block
0
3595 *r = '\0';-
3596 return ret;
never executed: return ret;
0
3597}-
3598-
3599/* This needs better error handling. */-
3600/* Expand W for use as an argument to a unary or binary operator in a-
3601 [[...]] expression. If SPECIAL is 1, this is the rhs argument-
3602 to the != or == operator, and should be treated as a pattern. In-
3603 this case, we quote the string specially for the globbing code. If-
3604 SPECIAL is 2, this is an rhs argument for the =~ operator, and should-
3605 be quoted appropriately for regcomp/regexec. The caller is responsible-
3606 for removing the backslashes if the unquoted word is needed later. */ -
3607char *-
3608cond_expand_word (w, special)-
3609 WORD_DESC *w;-
3610 int special;-
3611{-
3612 char *r, *p;-
3613 WORD_LIST *l;-
3614 int qflags;-
3615-
3616 if (w->word == 0 || w->word[0] == '\0')
w->word == 0Description
TRUEnever evaluated
FALSEevaluated 1460 times by 1 test
Evaluated by:
  • Self test
w->word[0] == '\0'Description
TRUEnever evaluated
FALSEevaluated 1460 times by 1 test
Evaluated by:
  • Self test
0-1460
3617 return ((char *)NULL);
never executed: return ((char *) ((void *)0) );
0
3618-
3619 expand_no_split_dollar_star = 1;-
3620 w->flags |= W_NOSPLIT2;-
3621 l = call_expand_word_internal (w, 0, 0, (int *)0, (int *)0);-
3622 expand_no_split_dollar_star = 0;-
3623 if (l)
lDescription
TRUEevaluated 1367 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 92 times by 1 test
Evaluated by:
  • Self test
92-1367
3624 {-
3625 if (special == 0) /* LHS */
special == 0Description
TRUEevaluated 858 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 509 times by 1 test
Evaluated by:
  • Self test
509-858
3626 {-
3627 dequote_list (l);-
3628 r = string_list (l);-
3629 }
executed 858 times by 1 test: end of block
Executed by:
  • Self test
858
3630 else-
3631 {-
3632 /* Need to figure out whether or not we should call dequote_escapes-
3633 or a new dequote_ctlnul function here, and under what-
3634 circumstances. */-
3635 qflags = QGLOB_CVTNULL;-
3636 if (special == 2)
special == 2Description
TRUEevaluated 89 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 420 times by 1 test
Evaluated by:
  • Self test
89-420
3637 qflags |= QGLOB_REGEXP;
executed 89 times by 1 test: qflags |= 0x04;
Executed by:
  • Self test
89
3638 word_list_remove_quoted_nulls (l);-
3639 p = string_list (l);-
3640 r = quote_string_for_globbing (p, qflags);-
3641 free (p);-
3642 }
executed 509 times by 1 test: end of block
Executed by:
  • Self test
509
3643 dispose_words (l);-
3644 }
executed 1367 times by 1 test: end of block
Executed by:
  • Self test
1367
3645 else-
3646 r = (char *)NULL;
executed 92 times by 1 test: r = (char *) ((void *)0) ;
Executed by:
  • Self test
92
3647-
3648 return r;
executed 1459 times by 1 test: return r;
Executed by:
  • Self test
1459
3649}-
3650#endif-
3651-
3652/* Call expand_word_internal to expand W and handle error returns.-
3653 A convenience function for functions that don't want to handle-
3654 any errors or free any memory before aborting. */-
3655static WORD_LIST *-
3656call_expand_word_internal (w, q, i, c, e)-
3657 WORD_DESC *w;-
3658 int q, i, *c, *e;-
3659{-
3660 WORD_LIST *result;-
3661-
3662 result = expand_word_internal (w, q, i, c, e);-
3663 if (result == &expand_word_error || result == &expand_word_fatal)
result == &expand_word_errorDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 116033927 times by 1 test
Evaluated by:
  • Self test
result == &expand_word_fatalDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 116033924 times by 1 test
Evaluated by:
  • Self test
3-116033927
3664 {-
3665 /* By convention, each time this error is returned, w->word has-
3666 already been freed (it sometimes may not be in the fatal case,-
3667 but that doesn't result in a memory leak because we're going-
3668 to exit in most cases). */-
3669 w->word = (char *)NULL;-
3670 last_command_exit_value = EXECUTION_FAILURE;-
3671 exp_jump_to_top_level ((result == &expand_word_error) ? DISCARD : FORCE_EOF);-
3672 /* NOTREACHED */-
3673 return (NULL);
never executed: return ( ((void *)0) );
0
3674 }-
3675 else-
3676 return (result);
executed 116033924 times by 1 test: return (result);
Executed by:
  • Self test
116033924
3677}-
3678-
3679/* Perform parameter expansion, command substitution, and arithmetic-
3680 expansion on STRING, as if it were a word. Leave the result quoted.-
3681 Since this does not perform word splitting, it leaves quoted nulls-
3682 in the result. */-
3683static WORD_LIST *-
3684expand_string_internal (string, quoted)-
3685 char *string;-
3686 int quoted;-
3687{-
3688 WORD_DESC td;-
3689 WORD_LIST *tresult;-
3690-
3691 if (string == 0 || *string == 0)
string == 0Description
TRUEnever evaluated
FALSEevaluated 343 times by 1 test
Evaluated by:
  • Self test
*string == 0Description
TRUEnever evaluated
FALSEevaluated 343 times by 1 test
Evaluated by:
  • Self test
0-343
3692 return ((WORD_LIST *)NULL);
never executed: return ((WORD_LIST *) ((void *)0) );
0
3693-
3694 td.flags = 0;-
3695 td.word = savestring (string);-
3696-
3697 tresult = call_expand_word_internal (&td, quoted, 0, (int *)NULL, (int *)NULL);-
3698-
3699 FREE (td.word);
executed 339 times by 1 test: sh_xfree((td.word), "subst.c", 3699);
Executed by:
  • Self test
td.wordDescription
TRUEevaluated 339 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-339
3700 return (tresult);
executed 339 times by 1 test: return (tresult);
Executed by:
  • Self test
339
3701}-
3702-
3703/* Expand STRING by performing parameter expansion, command substitution,-
3704 and arithmetic expansion. Dequote the resulting WORD_LIST before-
3705 returning it, but do not perform word splitting. The call to-
3706 remove_quoted_nulls () is in here because word splitting normally-
3707 takes care of quote removal. */-
3708WORD_LIST *-
3709expand_string_unsplit (string, quoted)-
3710 char *string;-
3711 int quoted;-
3712{-
3713 WORD_LIST *value;-
3714-
3715 if (string == 0 || *string == '\0')
string == 0Description
TRUEnever evaluated
FALSEevaluated 70 times by 1 test
Evaluated by:
  • Self test
*string == '\0'Description
TRUEnever evaluated
FALSEevaluated 70 times by 1 test
Evaluated by:
  • Self test
0-70
3716 return ((WORD_LIST *)NULL);
never executed: return ((WORD_LIST *) ((void *)0) );
0
3717-
3718 expand_no_split_dollar_star = 1;-
3719 value = expand_string_internal (string, quoted);-
3720 expand_no_split_dollar_star = 0;-
3721-
3722 if (value)
valueDescription
TRUEevaluated 68 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-68
3723 {-
3724 if (value->word)
value->wordDescription
TRUEevaluated 68 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-68
3725 {-
3726 remove_quoted_nulls (value->word->word);-
3727 value->word->flags &= ~W_HASQUOTEDNULL;-
3728 }
executed 68 times by 1 test: end of block
Executed by:
  • Self test
68
3729 dequote_list (value);-
3730 }
executed 68 times by 1 test: end of block
Executed by:
  • Self test
68
3731 return (value);
executed 69 times by 1 test: return (value);
Executed by:
  • Self test
69
3732}-
3733-
3734/* Expand the rhs of an assignment statement */-
3735WORD_LIST *-
3736expand_string_assignment (string, quoted)-
3737 char *string;-
3738 int quoted;-
3739{-
3740 WORD_DESC td;-
3741 WORD_LIST *value;-
3742-
3743 if (string == 0 || *string == '\0')
string == 0Description
TRUEnever evaluated
FALSEevaluated 29902447 times by 1 test
Evaluated by:
  • Self test
*string == '\0'Description
TRUEnever evaluated
FALSEevaluated 29902447 times by 1 test
Evaluated by:
  • Self test
0-29902447
3744 return ((WORD_LIST *)NULL);
never executed: return ((WORD_LIST *) ((void *)0) );
0
3745-
3746 expand_no_split_dollar_star = 1;-
3747-
3748#if 0-
3749 /* Other shells (ksh93) do it this way, which affects how $@ is expanded-
3750 in constructs like bar=${@#0} (preserves the spaces resulting from the-
3751 expansion of $@ in a context where you don't do word splitting); Posix-
3752 interp 888 makes the expansion of $@ in contexts where word splitting-
3753 is not performed unspecified. */-
3754 td.flags = W_ASSIGNRHS|W_NOSPLIT2; /* Posix interp 888 */-
3755#else-
3756 td.flags = W_ASSIGNRHS;-
3757#endif-
3758 td.word = savestring (string);-
3759 value = call_expand_word_internal (&td, quoted, 0, (int *)NULL, (int *)NULL);-
3760 FREE (td.word);
executed 29899991 times by 1 test: sh_xfree((td.word), "subst.c", 3760);
Executed by:
  • Self test
td.wordDescription
TRUEevaluated 29899991 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-29899991
3761-
3762 expand_no_split_dollar_star = 0;-
3763-
3764 if (value)
valueDescription
TRUEevaluated 29897584 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2407 times by 1 test
Evaluated by:
  • Self test
2407-29897584
3765 {-
3766 if (value->word)
value->wordDescription
TRUEevaluated 29897584 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-29897584
3767 {-
3768 remove_quoted_nulls (value->word->word);-
3769 value->word->flags &= ~W_HASQUOTEDNULL;-
3770 }
executed 29897584 times by 1 test: end of block
Executed by:
  • Self test
29897584
3771 dequote_list (value);-
3772 }
executed 29897584 times by 1 test: end of block
Executed by:
  • Self test
29897584
3773 return (value);
executed 29899991 times by 1 test: return (value);
Executed by:
  • Self test
29899991
3774}-
3775-
3776-
3777/* Expand one of the PS? prompt strings. This is a sort of combination of-
3778 expand_string_unsplit and expand_string_internal, but returns the-
3779 passed string when an error occurs. Might want to trap other calls-
3780 to jump_to_top_level here so we don't endlessly loop. */-
3781WORD_LIST *-
3782expand_prompt_string (string, quoted, wflags)-
3783 char *string;-
3784 int quoted;-
3785 int wflags;-
3786{-
3787 WORD_LIST *value;-
3788 WORD_DESC td;-
3789-
3790 if (string == 0 || *string == 0)
string == 0Description
TRUEnever evaluated
FALSEevaluated 61 times by 1 test
Evaluated by:
  • Self test
*string == 0Description
TRUEnever evaluated
FALSEevaluated 61 times by 1 test
Evaluated by:
  • Self test
0-61
3791 return ((WORD_LIST *)NULL);
never executed: return ((WORD_LIST *) ((void *)0) );
0
3792-
3793 td.flags = wflags;-
3794 td.word = savestring (string);-
3795-
3796 no_longjmp_on_fatal_error = 1;-
3797 value = expand_word_internal (&td, quoted, 0, (int *)NULL, (int *)NULL);-
3798 no_longjmp_on_fatal_error = 0;-
3799-
3800 if (value == &expand_word_error || value == &expand_word_fatal)
value == &expand_word_errorDescription
TRUEnever evaluated
FALSEevaluated 61 times by 1 test
Evaluated by:
  • Self test
value == &expand_word_fatalDescription
TRUEnever evaluated
FALSEevaluated 61 times by 1 test
Evaluated by:
  • Self test
0-61
3801 {-
3802 value = make_word_list (make_bare_word (string), (WORD_LIST *)NULL);-
3803 return value;
never executed: return value;
0
3804 }-
3805 FREE (td.word);
executed 61 times by 1 test: sh_xfree((td.word), "subst.c", 3805);
Executed by:
  • Self test
td.wordDescription
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-61
3806 if (value)
valueDescription
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-61
3807 {-
3808 if (value->word)
value->wordDescription
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-61
3809 {-
3810 remove_quoted_nulls (value->word->word);-
3811 value->word->flags &= ~W_HASQUOTEDNULL;-
3812 }
executed 61 times by 1 test: end of block
Executed by:
  • Self test
61
3813 dequote_list (value);-
3814 }
executed 61 times by 1 test: end of block
Executed by:
  • Self test
61
3815 return (value);
executed 61 times by 1 test: return (value);
Executed by:
  • Self test
61
3816}-
3817-
3818/* Expand STRING just as if you were expanding a word, but do not dequote-
3819 the resultant WORD_LIST. This is called only from within this file,-
3820 and is used to correctly preserve quoted characters when expanding-
3821 things like ${1+"$@"}. This does parameter expansion, command-
3822 substitution, arithmetic expansion, and word splitting. */-
3823static WORD_LIST *-
3824expand_string_leave_quoted (string, quoted)-
3825 char *string;-
3826 int quoted;-
3827{-
3828 WORD_LIST *tlist;-
3829 WORD_LIST *tresult;-
3830-
3831 if (string == 0 || *string == '\0')
string == 0Description
TRUEnever evaluated
FALSEevaluated 273 times by 1 test
Evaluated by:
  • Self test
*string == '\0'Description
TRUEnever evaluated
FALSEevaluated 273 times by 1 test
Evaluated by:
  • Self test
0-273
3832 return ((WORD_LIST *)NULL);
never executed: return ((WORD_LIST *) ((void *)0) );
0
3833-
3834 tlist = expand_string_internal (string, quoted);-
3835-
3836 if (tlist)
tlistDescription
TRUEevaluated 264 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
6-264
3837 {-
3838 tresult = word_list_split (tlist);-
3839 dispose_words (tlist);-
3840 return (tresult);
executed 264 times by 1 test: return (tresult);
Executed by:
  • Self test
264
3841 }-
3842 return ((WORD_LIST *)NULL);
executed 6 times by 1 test: return ((WORD_LIST *) ((void *)0) );
Executed by:
  • Self test
6
3843}-
3844-
3845/* This does not perform word splitting or dequote the WORD_LIST-
3846 it returns. */-
3847static WORD_LIST *-
3848expand_string_for_rhs (string, quoted, op, pflags, dollar_at_p, expanded_p)-
3849 char *string;-
3850 int quoted, op, pflags;-
3851 int *dollar_at_p, *expanded_p;-
3852{-
3853 WORD_DESC td;-
3854 WORD_LIST *tresult;-
3855 int old_nosplit;-
3856-
3857 if (string == 0 || *string == '\0')
string == 0Description
TRUEnever evaluated
FALSEevaluated 10971 times by 1 test
Evaluated by:
  • Self test
*string == '\0'Description
TRUEnever evaluated
FALSEevaluated 10971 times by 1 test
Evaluated by:
  • Self test
0-10971
3858 return (WORD_LIST *)NULL;
never executed: return (WORD_LIST *) ((void *)0) ;
0
3859-
3860 /* We want field splitting to be determined by what is going to be done with-
3861 the entire ${parameterOPword} expansion, so we don't want to split the RHS-
3862 we expand here. However, the expansion of $* is determined by whether we-
3863 are going to eventually perform word splitting, so we want to set this-
3864 depending on whether or not are are going to be splitting: if the expansion-
3865 is quoted, if the OP is `=', or if IFS is set to the empty string, we-
3866 are not going to be splitting, so we set expand_no_split_dollar_star to-
3867 We pass through PF_ASSIGNRHS as W_ASSIGNRHS if this is on the RHS of an-
3868 assignment statement. */-
3869 /* The updated treatment of $* is the result of Posix interp 888 */-
3870 /* This was further clarified on the austin-group list in March, 2017 and-
3871 in Posix bug 1129 */-
3872 old_nosplit = expand_no_split_dollar_star;-
3873 expand_no_split_dollar_star = (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) || op == '=' || ifs_is_null == 0; /* XXX - was 1 */
(quoted & (0x001|0x002))Description
TRUEevaluated 2049 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8922 times by 1 test
Evaluated by:
  • Self test
op == '='Description
TRUEevaluated 3480 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5442 times by 1 test
Evaluated by:
  • Self test
ifs_is_null == 0Description
TRUEevaluated 3809 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1633 times by 1 test
Evaluated by:
  • Self test
1633-8922
3874 td.flags = W_NOSPLIT2; /* no splitting, remove "" and '' */-
3875 if (pflags & PF_ASSIGNRHS) /* pass through */
pflags & 0x08Description
TRUEevaluated 231 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10740 times by 1 test
Evaluated by:
  • Self test
231-10740
3876 td.flags |= W_ASSIGNRHS;
executed 231 times by 1 test: td.flags |= 0x000800;
Executed by:
  • Self test
231
3877 if (op == '=')
op == '='Description
TRUEevaluated 5136 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5835 times by 1 test
Evaluated by:
  • Self test
5136-5835
3878#if 0-
3879 td.flags |= W_ASSIGNRHS; /* expand b in ${a=b} like assignment */-
3880#else-
3881 td.flags |= W_ASSIGNRHS|W_NOASSNTILDE; /* expand b in ${a=b} like assignment */
executed 5136 times by 1 test: td.flags |= 0x000800|0x20000000;
Executed by:
  • Self test
5136
3882#endif-
3883 td.word = string;-
3884 tresult = call_expand_word_internal (&td, quoted, 1, dollar_at_p, expanded_p);-
3885 expand_no_split_dollar_star = old_nosplit;-
3886-
3887 return (tresult);
executed 10956 times by 1 test: return (tresult);
Executed by:
  • Self test
10956
3888}-
3889-
3890/* This does not perform word splitting or dequote the WORD_LIST-
3891 it returns and it treats $* as if it were quoted. */-
3892static WORD_LIST *-
3893expand_string_for_pat (string, quoted, dollar_at_p, expanded_p)-
3894 char *string;-
3895 int quoted, *dollar_at_p, *expanded_p;-
3896{-
3897 WORD_DESC td;-
3898 WORD_LIST *tresult;-
3899-
3900 if (string == 0 || *string == '\0')
string == 0Description
TRUEnever evaluated
FALSEevaluated 2316712 times by 1 test
Evaluated by:
  • Self test
*string == '\0'Description
TRUEnever evaluated
FALSEevaluated 2316712 times by 1 test
Evaluated by:
  • Self test
0-2316712
3901 return (WORD_LIST *)NULL;
never executed: return (WORD_LIST *) ((void *)0) ;
0
3902-
3903 expand_no_split_dollar_star = 1;-
3904 td.flags = W_NOSPLIT2; /* no splitting, remove "" and '' */-
3905 td.word = string;-
3906 tresult = call_expand_word_internal (&td, quoted, 1, dollar_at_p, expanded_p);-
3907 expand_no_split_dollar_star = 0;-
3908-
3909 return (tresult);
executed 2316708 times by 1 test: return (tresult);
Executed by:
  • Self test
2316708
3910}-
3911-
3912/* Expand STRING just as if you were expanding a word. This also returns-
3913 a list of words. Note that filename globbing is *NOT* done for word-
3914 or string expansion, just when the shell is expanding a command. This-
3915 does parameter expansion, command substitution, arithmetic expansion,-
3916 and word splitting. Dequote the resultant WORD_LIST before returning. */-
3917WORD_LIST *-
3918expand_string (string, quoted)-
3919 char *string;-
3920 int quoted;-
3921{-
3922 WORD_LIST *result;-
3923-
3924 if (string == 0 || *string == '\0')
string == 0Description
TRUEnever evaluated
FALSEevaluated 273 times by 1 test
Evaluated by:
  • Self test
*string == '\0'Description
TRUEnever evaluated
FALSEevaluated 273 times by 1 test
Evaluated by:
  • Self test
0-273
3925 return ((WORD_LIST *)NULL);
never executed: return ((WORD_LIST *) ((void *)0) );
0
3926-
3927 result = expand_string_leave_quoted (string, quoted);-
3928 return (result ? dequote_list (result) : result);
executed 270 times by 1 test: return (result ? dequote_list (result) : result);
Executed by:
  • Self test
270
3929}-
3930-
3931/*******************************************-
3932 * *-
3933 * Functions to expand WORD_DESCs *-
3934 * *-
3935 *******************************************/-
3936-
3937/* Expand WORD, performing word splitting on the result. This does-
3938 parameter expansion, command substitution, arithmetic expansion,-
3939 word splitting, and quote removal. */-
3940-
3941WORD_LIST *-
3942expand_word (word, quoted)-
3943 WORD_DESC *word;-
3944 int quoted;-
3945{-
3946 WORD_LIST *result, *tresult;-
3947-
3948 tresult = call_expand_word_internal (word, quoted, 0, (int *)NULL, (int *)NULL);-
3949 result = word_list_split (tresult);-
3950 dispose_words (tresult);-
3951 return (result ? dequote_list (result) : result);
never executed: return (result ? dequote_list (result) : result);
0
3952}-
3953-
3954/* Expand WORD, but do not perform word splitting on the result. This-
3955 does parameter expansion, command substitution, arithmetic expansion,-
3956 and quote removal. */-
3957WORD_LIST *-
3958expand_word_unsplit (word, quoted)-
3959 WORD_DESC *word;-
3960 int quoted;-
3961{-
3962 WORD_LIST *result;-
3963-
3964 expand_no_split_dollar_star = 1;-
3965 if (ifs_is_null)
ifs_is_nullDescription
TRUEevaluated 1614 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 36945557 times by 1 test
Evaluated by:
  • Self test
1614-36945557
3966 word->flags |= W_NOSPLIT;
executed 1614 times by 1 test: word->flags |= 0x000010;
Executed by:
  • Self test
1614
3967 word->flags |= W_NOSPLIT2;-
3968 result = call_expand_word_internal (word, quoted, 0, (int *)NULL, (int *)NULL);-
3969 expand_no_split_dollar_star = 0;-
3970-
3971 return (result ? dequote_list (result) : result);
executed 36947163 times by 1 test: return (result ? dequote_list (result) : result);
Executed by:
  • Self test
36947163
3972}-
3973-
3974/* Perform shell expansions on WORD, but do not perform word splitting or-
3975 quote removal on the result. Virtually identical to expand_word_unsplit;-
3976 could be combined if implementations don't diverge. */-
3977WORD_LIST *-
3978expand_word_leave_quoted (word, quoted)-
3979 WORD_DESC *word;-
3980 int quoted;-
3981{-
3982 WORD_LIST *result;-
3983-
3984 expand_no_split_dollar_star = 1;-
3985 if (ifs_is_null)
ifs_is_nullDescription
TRUEevaluated 3224 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 46850759 times by 1 test
Evaluated by:
  • Self test
3224-46850759
3986 word->flags |= W_NOSPLIT;
executed 3224 times by 1 test: word->flags |= 0x000010;
Executed by:
  • Self test
3224
3987 word->flags |= W_NOSPLIT2;-
3988 result = call_expand_word_internal (word, quoted, 0, (int *)NULL, (int *)NULL);-
3989 expand_no_split_dollar_star = 0;-
3990-
3991 return result;
executed 46853982 times by 1 test: return result;
Executed by:
  • Self test
46853982
3992}-
3993-
3994/***************************************************-
3995 * *-
3996 * Functions to handle quoting chars *-
3997 * *-
3998 ***************************************************/-
3999-
4000/* Conventions:-
4001-
4002 A string with s[0] == CTLNUL && s[1] == 0 is a quoted null string.-
4003 The parser passes CTLNUL as CTLESC CTLNUL. */-
4004-
4005/* Quote escape characters in string s, but no other characters. This is-
4006 used to protect CTLESC and CTLNUL in variable values from the rest of-
4007 the word expansion process after the variable is expanded (word splitting-
4008 and filename generation). If IFS is null, we quote spaces as well, just-
4009 in case we split on spaces later (in the case of unquoted $@, we will-
4010 eventually attempt to split the entire word on spaces). Corresponding-
4011 code exists in dequote_escapes. Even if we don't end up splitting on-
4012 spaces, quoting spaces is not a problem. This should never be called on-
4013 a string that is quoted with single or double quotes or part of a here-
4014 document (effectively double-quoted). */-
4015char *-
4016quote_escapes (string)-
4017 const char *string;-
4018{-
4019 const char *s, *send;-
4020 char *t, *result;-
4021 size_t slen;-
4022 int quote_spaces, skip_ctlesc, skip_ctlnul;-
4023 DECLARE_MBSTATE; -
4024-
4025 slen = strlen (string);-
4026 send = string + slen;-
4027-
4028 quote_spaces = (ifs_value && *ifs_value == 0);
ifs_valueDescription
TRUEevaluated 62557889 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*ifs_value == 0Description
TRUEevaluated 5724 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 62552165 times by 1 test
Evaluated by:
  • Self test
0-62557889
4029-
4030 for (skip_ctlesc = skip_ctlnul = 0, s = ifs_value; s && *s; s++)
sDescription
TRUEevaluated 128440759 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*sDescription
TRUEevaluated 65882870 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 62557889 times by 1 test
Evaluated by:
  • Self test
0-128440759
4031 skip_ctlesc |= *s == CTLESC, skip_ctlnul |= *s == CTLNUL;
executed 65882870 times by 1 test: skip_ctlesc |= *s == '\001', skip_ctlnul |= *s == '\177';
Executed by:
  • Self test
65882870
4032-
4033 t = result = (char *)xmalloc ((slen * 2) + 1);-
4034 s = string;-
4035-
4036 while (*s)
*sDescription
TRUEevaluated 221002151 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 62557889 times by 1 test
Evaluated by:
  • Self test
62557889-221002151
4037 {-
4038 if ((skip_ctlesc == 0 && *s == CTLESC) || (skip_ctlnul == 0 && *s == CTLNUL) || (quote_spaces && *s == ' '))
skip_ctlesc == 0Description
TRUEevaluated 221000859 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1292 times by 1 test
Evaluated by:
  • Self test
*s == '\001'Description
TRUEevaluated 4414 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 220996445 times by 1 test
Evaluated by:
  • Self test
skip_ctlnul == 0Description
TRUEevaluated 220997557 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 180 times by 1 test
Evaluated by:
  • Self test
*s == '\177'Description
TRUEevaluated 3908 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 220993649 times by 1 test
Evaluated by:
  • Self test
quote_spacesDescription
TRUEevaluated 4250 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 220989579 times by 1 test
Evaluated by:
  • Self test
*s == ' 'Description
TRUEevaluated 286 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3964 times by 1 test
Evaluated by:
  • Self test
180-221000859
4039 *t++ = CTLESC;
executed 8608 times by 1 test: *t++ = '\001';
Executed by:
  • Self test
8608
4040 COPY_CHAR_P (t, s, send);
executed 220571463 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 17557 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 156 times by 1 test: end of block
Executed by:
  • Self test
executed 8 times by 1 test: end of block
Executed by:
  • Self test
executed 220589168 times by 1 test: mblength = (mblength < 1) ? 1 : mblength;
Executed by:
  • Self test
executed 220589363 times by 1 test: *(t)++ = *(s)++;
Executed by:
  • Self test
executed 220589176 times by 1 test: end of block
Executed by:
  • Self test
executed 412975 times by 1 test: *(t)++ = *(s)++;
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 220589176 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 412975 times by 1 test
Evaluated by:
  • Self test
_kDescription
TRUEevaluated 220571463 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 17713 times by 1 test
Evaluated by:
  • Self test
_k < mblengthDescription
TRUEevaluated 220589363 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 220589176 times by 1 test
Evaluated by:
  • Self test
(mblength < 1)Description
TRUEnever evaluated
FALSEevaluated 220589168 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 17713 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((*(s) & 0x80) == 0)Description
TRUEevaluated 17557 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 156 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 220589176 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 220589168 times by 1 test
Evaluated by:
  • Self test
0-220589363
4041 }
executed 221002151 times by 1 test: end of block
Executed by:
  • Self test
221002151
4042 *t = '\0';-
4043-
4044 return (result);
executed 62557889 times by 1 test: return (result);
Executed by:
  • Self test
62557889
4045}-
4046-
4047static WORD_LIST *-
4048list_quote_escapes (list)-
4049 WORD_LIST *list;-
4050{-
4051 register WORD_LIST *w;-
4052 char *t;-
4053-
4054 for (w = list; w; w = w->next)
wDescription
TRUEevaluated 4753 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1270 times by 1 test
Evaluated by:
  • Self test
1270-4753
4055 {-
4056 t = w->word->word;-
4057 w->word->word = quote_escapes (t);-
4058 free (t);-
4059 }
executed 4753 times by 1 test: end of block
Executed by:
  • Self test
4753
4060 return list;
executed 1270 times by 1 test: return list;
Executed by:
  • Self test
1270
4061}-
4062-
4063/* Inverse of quote_escapes; remove CTLESC protecting CTLESC or CTLNUL.-
4064-
4065 The parser passes us CTLESC as CTLESC CTLESC and CTLNUL as CTLESC CTLNUL.-
4066 This is necessary to make unquoted CTLESC and CTLNUL characters in the-
4067 data stream pass through properly.-
4068-
4069 We need to remove doubled CTLESC characters inside quoted strings before-
4070 quoting the entire string, so we do not double the number of CTLESC-
4071 characters.-
4072-
4073 Also used by parts of the pattern substitution code. */-
4074char *-
4075dequote_escapes (string)-
4076 const char *string;-
4077{-
4078 const char *s, *send;-
4079 char *t, *result;-
4080 size_t slen;-
4081 int quote_spaces;-
4082 DECLARE_MBSTATE;-
4083-
4084 if (string == 0)
string == 0Description
TRUEnever evaluated
FALSEevaluated 12109353 times by 1 test
Evaluated by:
  • Self test
0-12109353
4085 return (char *)0;
never executed: return (char *)0;
0
4086-
4087 slen = strlen (string);-
4088 send = string + slen;-
4089-
4090 t = result = (char *)xmalloc (slen + 1);-
4091-
4092 if (strchr (string, CTLESC) == 0)
(__extension__...\001' ))) == 0Description
TRUEevaluated 12108850 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 503 times by 1 test
Evaluated by:
  • Self test
__builtin_cons...t_p ( '\001' )Description
TRUEevaluated 12109353 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
!__builtin_con...t_p ( string )Description
TRUEevaluated 12109353 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
( '\001' ) == '\0'Description
TRUEnever evaluated
FALSEevaluated 12109353 times by 1 test
Evaluated by:
  • Self test
0-12109353
4093 return (strcpy (result, string));
executed 12108850 times by 1 test: return (strcpy (result, string));
Executed by:
  • Self test
12108850
4094-
4095 quote_spaces = (ifs_value && *ifs_value == 0);
ifs_valueDescription
TRUEevaluated 503 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*ifs_value == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 502 times by 1 test
Evaluated by:
  • Self test
0-503
4096-
4097 s = string;-
4098 while (*s)
*sDescription
TRUEevaluated 1596 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 503 times by 1 test
Evaluated by:
  • Self test
503-1596
4099 {-
4100 if (*s == CTLESC && (s[1] == CTLESC || s[1] == CTLNUL || (quote_spaces && s[1] == ' ')))
*s == '\001'Description
TRUEevaluated 674 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 922 times by 1 test
Evaluated by:
  • Self test
s[1] == '\001'Description
TRUEevaluated 331 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 343 times by 1 test
Evaluated by:
  • Self test
s[1] == '\177'Description
TRUEevaluated 288 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 55 times by 1 test
Evaluated by:
  • Self test
quote_spacesDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 54 times by 1 test
Evaluated by:
  • Self test
s[1] == ' 'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-922
4101 {-
4102 s++;-
4103 if (*s == '\0')
*s == '\0'Description
TRUEnever evaluated
FALSEevaluated 620 times by 1 test
Evaluated by:
  • Self test
0-620
4104 break;
never executed: break;
0
4105 }
executed 620 times by 1 test: end of block
Executed by:
  • Self test
620
4106 COPY_CHAR_P (t, s, send);
executed 913 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 683 times by 1 test: mblength = 1;
Executed by:
  • Self test
never executed: end of block
never executed: end of block
executed 1596 times by 1 test: mblength = (mblength < 1) ? 1 : mblength;
Executed by:
  • Self test
executed 1596 times by 1 test: *(t)++ = *(s)++;
Executed by:
  • Self test
executed 1596 times by 1 test: end of block
Executed by:
  • Self test
never executed: *(t)++ = *(s)++;
locale_mb_cur_max > 1Description
TRUEevaluated 1596 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
_kDescription
TRUEevaluated 913 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 683 times by 1 test
Evaluated by:
  • Self test
_k < mblengthDescription
TRUEevaluated 1596 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1596 times by 1 test
Evaluated by:
  • Self test
(mblength < 1)Description
TRUEnever evaluated
FALSEevaluated 1596 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 683 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((*(s) & 0x80) == 0)Description
TRUEevaluated 683 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 1596 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 1596 times by 1 test
Evaluated by:
  • Self test
0-1596
4107 }
executed 1596 times by 1 test: end of block
Executed by:
  • Self test
1596
4108 *t = '\0';-
4109-
4110 return result;
executed 503 times by 1 test: return result;
Executed by:
  • Self test
503
4111}-
4112-
4113#if defined (INCLUDE_UNUSED)-
4114static WORD_LIST *-
4115list_dequote_escapes (list)-
4116 WORD_LIST *list;-
4117{-
4118 register WORD_LIST *w;-
4119 char *t;-
4120-
4121 for (w = list; w; w = w->next)-
4122 {-
4123 t = w->word->word;-
4124 w->word->word = dequote_escapes (t);-
4125 free (t);-
4126 }-
4127 return list;-
4128}-
4129#endif-
4130-
4131/* Return a new string with the quoted representation of character C.-
4132 This turns "" into QUOTED_NULL, so the W_HASQUOTEDNULL flag needs to be-
4133 set in any resultant WORD_DESC where this value is the word. */-
4134static char *-
4135make_quoted_char (c)-
4136 int c;-
4137{-
4138 char *temp;-
4139-
4140 temp = (char *)xmalloc (3);-
4141 if (c == 0)
c == 0Description
TRUEevaluated 4090250 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-4090250
4142 {-
4143 temp[0] = CTLNUL;-
4144 temp[1] = '\0';-
4145 }
executed 4090250 times by 1 test: end of block
Executed by:
  • Self test
4090250
4146 else-
4147 {-
4148 temp[0] = CTLESC;-
4149 temp[1] = c;-
4150 temp[2] = '\0';-
4151 }
never executed: end of block
0
4152 return (temp);
executed 4090250 times by 1 test: return (temp);
Executed by:
  • Self test
4090250
4153}-
4154-
4155/* Quote STRING, returning a new string. This turns "" into QUOTED_NULL, so-
4156 the W_HASQUOTEDNULL flag needs to be set in any resultant WORD_DESC where-
4157 this value is the word. */-
4158char *-
4159quote_string (string)-
4160 char *string;-
4161{-
4162 register char *t;-
4163 size_t slen;-
4164 char *result, *send;-
4165-
4166 if (*string == 0)
*string == 0Description
TRUEevaluated 714 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 70765794 times by 1 test
Evaluated by:
  • Self test
714-70765794
4167 {-
4168 result = (char *)xmalloc (2);-
4169 result[0] = CTLNUL;-
4170 result[1] = '\0';-
4171 }
executed 714 times by 1 test: end of block
Executed by:
  • Self test
714
4172 else-
4173 {-
4174 DECLARE_MBSTATE;-
4175-
4176 slen = strlen (string);-
4177 send = string + slen;-
4178-
4179 result = (char *)xmalloc ((slen * 2) + 1);-
4180-
4181 for (t = result; string < send; )
string < sendDescription
TRUEevaluated 387339420 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 70765794 times by 1 test
Evaluated by:
  • Self test
70765794-387339420
4182 {-
4183 *t++ = CTLESC;-
4184 COPY_CHAR_P (t, string, send);
executed 386874408 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 182047 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 10217 times by 1 test: end of block
Executed by:
  • Self test
executed 1297 times by 1 test: end of block
Executed by:
  • Self test
executed 387065375 times by 1 test: mblength = (mblength < 1) ? 1 : mblength;
Executed by:
  • Self test
executed 387076390 times by 1 test: *(t)++ = *(string)++;
Executed by:
  • Self test
executed 387066672 times by 1 test: end of block
Executed by:
  • Self test
executed 272748 times by 1 test: *(t)++ = *(string)++;
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 387066672 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 272748 times by 1 test
Evaluated by:
  • Self test
_kDescription
TRUEevaluated 386874408 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 192264 times by 1 test
Evaluated by:
  • Self test
_k < mblengthDescription
TRUEevaluated 387076390 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 387066672 times by 1 test
Evaluated by:
  • Self test
(mblength < 1)Description
TRUEnever evaluated
FALSEevaluated 387065375 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 192264 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((*(string) & 0x80) == 0)Description
TRUEevaluated 182047 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10217 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-2Description
TRUEevaluated 591 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 387066081 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEevaluated 706 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 387065375 times by 1 test
Evaluated by:
  • Self test
0-387076390
4185 }
executed 387339420 times by 1 test: end of block
Executed by:
  • Self test
387339420
4186 *t = '\0';-
4187 }
executed 70765794 times by 1 test: end of block
Executed by:
  • Self test
70765794
4188 return (result);
executed 70766508 times by 1 test: return (result);
Executed by:
  • Self test
70766508
4189}-
4190-
4191/* De-quote quoted characters in STRING. */-
4192char *-
4193dequote_string (string)-
4194 char *string;-
4195{-
4196 register char *s, *t;-
4197 size_t slen;-
4198 char *result, *send;-
4199 DECLARE_MBSTATE;-
4200-
4201#if defined (DEBUG)-
4202 if (string[0] == CTLESC && string[1] == 0)
string[0] == '\001'Description
TRUEevaluated 48806861 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 110194750 times by 1 test
Evaluated by:
  • Self test
string[1] == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 48806859 times by 1 test
Evaluated by:
  • Self test
2-110194750
4203 internal_inform ("dequote_string: string with bare CTLESC");
executed 2 times by 1 test: internal_inform ("dequote_string: string with bare CTLESC");
Executed by:
  • Self test
2
4204#endif-
4205-
4206 slen = STRLEN (string);
(string)[1]Description
TRUEevaluated 110736598 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 47947940 times by 1 test
Evaluated by:
  • Self test
(string)[2]Description
TRUEevaluated 104663761 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6072837 times by 1 test
Evaluated by:
  • Self test
(string)Description
TRUEevaluated 159001611 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(string)[0]Description
TRUEevaluated 158684538 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 317073 times by 1 test
Evaluated by:
  • Self test
0-159001611
4207-
4208 t = result = (char *)xmalloc (slen + 1);-
4209-
4210 if (QUOTED_NULL (string))
(string)[0] == '\177'Description
TRUEevaluated 4089997 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 154911614 times by 1 test
Evaluated by:
  • Self test
(string)[1] == '\0'Description
TRUEevaluated 4089997 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-154911614
4211 {-
4212 result[0] = '\0';-
4213 return (result);
executed 4089997 times by 1 test: return (result);
Executed by:
  • Self test
4089997
4214 }-
4215-
4216 /* A string consisting of only a single CTLESC should pass through unchanged */-
4217 if (string[0] == CTLESC && string[1] == 0)
string[0] == '\001'Description
TRUEevaluated 48806861 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 106104753 times by 1 test
Evaluated by:
  • Self test
string[1] == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 48806859 times by 1 test
Evaluated by:
  • Self test
2-106104753
4218 {-
4219 result[0] = CTLESC;-
4220 result[1] = '\0';-
4221 return (result);
executed 2 times by 1 test: return (result);
Executed by:
  • Self test
2
4222 }-
4223-
4224 /* If no character in the string can be quoted, don't bother examining-
4225 each character. Just return a copy of the string passed to us. */-
4226 if (strchr (string, CTLESC) == NULL)
(__extension__...== ((void *)0)Description
TRUEevaluated 106102661 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 48808951 times by 1 test
Evaluated by:
  • Self test
__builtin_cons...t_p ( '\001' )Description
TRUEevaluated 154911612 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
!__builtin_con...t_p ( string )Description
TRUEevaluated 154911612 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
( '\001' ) == '\0'Description
TRUEnever evaluated
FALSEevaluated 154911612 times by 1 test
Evaluated by:
  • Self test
0-154911612
4227 return (strcpy (result, string));
executed 106102661 times by 1 test: return (strcpy (result, string));
Executed by:
  • Self test
106102661
4228-
4229 send = string + slen;-
4230 s = string;-
4231 while (*s)
*sDescription
TRUEevaluated 347228404 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 48808951 times by 1 test
Evaluated by:
  • Self test
48808951-347228404
4232 {-
4233 if (*s == CTLESC)
*s == '\001'Description
TRUEevaluated 343656626 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3571778 times by 1 test
Evaluated by:
  • Self test
3571778-343656626
4234 {-
4235 s++;-
4236 if (*s == '\0')
*s == '\0'Description
TRUEnever evaluated
FALSEevaluated 343656626 times by 1 test
Evaluated by:
  • Self test
0-343656626
4237 break;
never executed: break;
0
4238 }
executed 343656626 times by 1 test: end of block
Executed by:
  • Self test
343656626
4239 COPY_CHAR_P (t, s, send);
executed 346436594 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 200505 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 10217 times by 1 test: end of block
Executed by:
  • Self test
executed 1299 times by 1 test: end of block
Executed by:
  • Self test
executed 346646017 times by 1 test: mblength = (mblength < 1) ? 1 : mblength;
Executed by:
  • Self test
executed 346657032 times by 1 test: *(t)++ = *(s)++;
Executed by:
  • Self test
executed 346647316 times by 1 test: end of block
Executed by:
  • Self test
executed 581088 times by 1 test: *(t)++ = *(s)++;
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 346647316 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 581088 times by 1 test
Evaluated by:
  • Self test
_kDescription
TRUEevaluated 346436594 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 210722 times by 1 test
Evaluated by:
  • Self test
_k < mblengthDescription
TRUEevaluated 346657032 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 346647316 times by 1 test
Evaluated by:
  • Self test
(mblength < 1)Description
TRUEnever evaluated
FALSEevaluated 346646017 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 210722 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((*(s) & 0x80) == 0)Description
TRUEevaluated 200505 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10217 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-2Description
TRUEevaluated 581 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 346646735 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEevaluated 718 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 346646017 times by 1 test
Evaluated by:
  • Self test
0-346657032
4240 }
executed 347228404 times by 1 test: end of block
Executed by:
  • Self test
347228404
4241-
4242 *t = '\0';-
4243 return (result);
executed 48808951 times by 1 test: return (result);
Executed by:
  • Self test
48808951
4244}-
4245-
4246/* Quote the entire WORD_LIST list. */-
4247static WORD_LIST *-
4248quote_list (list)-
4249 WORD_LIST *list;-
4250{-
4251 register WORD_LIST *w;-
4252 char *t;-
4253-
4254 for (w = list; w; w = w->next)
wDescription
TRUEevaluated 10768 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7128 times by 1 test
Evaluated by:
  • Self test
7128-10768
4255 {-
4256 t = w->word->word;-
4257 w->word->word = quote_string (t);-
4258 if (*t == 0)
*t == 0Description
TRUEevaluated 372 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10396 times by 1 test
Evaluated by:
  • Self test
372-10396
4259 w->word->flags |= W_HASQUOTEDNULL; /* XXX - turn on W_HASQUOTEDNULL here? */
executed 372 times by 1 test: w->word->flags |= 0x040000;
Executed by:
  • Self test
372
4260 w->word->flags |= W_QUOTED;-
4261 free (t);-
4262 }
executed 10768 times by 1 test: end of block
Executed by:
  • Self test
10768
4263 return list;
executed 7128 times by 1 test: return list;
Executed by:
  • Self test
7128
4264}-
4265-
4266/* De-quote quoted characters in each word in LIST. */-
4267WORD_LIST *-
4268dequote_list (list)-
4269 WORD_LIST *list;-
4270{-
4271 register char *s;-
4272 register WORD_LIST *tlist;-
4273-
4274 for (tlist = list; tlist; tlist = tlist->next)
tlistDescription
TRUEevaluated 90034639 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 89971816 times by 1 test
Evaluated by:
  • Self test
89971816-90034639
4275 {-
4276 s = dequote_string (tlist->word->word);-
4277 if (QUOTED_NULL (tlist->word->word))
(tlist->word->...)[0] == '\177'Description
TRUEevaluated 258 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 90034381 times by 1 test
Evaluated by:
  • Self test
(tlist->word->word)[1] == '\0'Description
TRUEevaluated 258 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-90034381
4278 tlist->word->flags &= ~W_HASQUOTEDNULL;
executed 258 times by 1 test: tlist->word->flags &= ~0x040000;
Executed by:
  • Self test
258
4279 free (tlist->word->word);-
4280 tlist->word->word = s;-
4281 }
executed 90034639 times by 1 test: end of block
Executed by:
  • Self test
90034639
4282 return list;
executed 89971816 times by 1 test: return list;
Executed by:
  • Self test
89971816
4283}-
4284-
4285/* Remove CTLESC protecting a CTLESC or CTLNUL in place. Return the passed-
4286 string. */-
4287char *-
4288remove_quoted_escapes (string)-
4289 char *string;-
4290{-
4291 char *t;-
4292-
4293 if (string)
stringDescription
TRUEevaluated 9793033 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-9793033
4294 {-
4295 t = dequote_escapes (string);-
4296 strcpy (string, t);-
4297 free (t);-
4298 }
executed 9793033 times by 1 test: end of block
Executed by:
  • Self test
9793033
4299-
4300 return (string);
executed 9793033 times by 1 test: return (string);
Executed by:
  • Self test
9793033
4301}-
4302-
4303/* Remove quoted $IFS characters from STRING. Quoted IFS characters are-
4304 added to protect them from word splitting, but we need to remove them-
4305 if no word splitting takes place. This returns newly-allocated memory,-
4306 so callers can use it to replace savestring(). */-
4307char *-
4308remove_quoted_ifs (string)-
4309 char *string;-
4310{-
4311 register size_t slen;-
4312 register int i, j;-
4313 char *ret, *send;-
4314 DECLARE_MBSTATE;-
4315-
4316 slen = strlen (string);-
4317 send = string + slen;-
4318-
4319 i = j = 0;-
4320 ret = (char *)xmalloc (slen + 1);-
4321-
4322 while (i < slen)
i < slenDescription
TRUEevaluated 68 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 15 times by 1 test
Evaluated by:
  • Self test
15-68
4323 {-
4324 if (string[i] == CTLESC)
string[i] == '\001'Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 46 times by 1 test
Evaluated by:
  • Self test
22-46
4325 {-
4326 i++;-
4327 if (string[i] == 0 || isifs (string[i]) == 0)
string[i] == 0Description
TRUEnever evaluated
FALSEevaluated 22 times by 1 test
Evaluated by:
  • Self test
(ifs_cmap[(uns...])] != 0) == 0Description
TRUEnever evaluated
FALSEevaluated 22 times by 1 test
Evaluated by:
  • Self test
0-22
4328 ret[j++] = CTLESC;
never executed: ret[j++] = '\001';
0
4329 if (i == slen)
i == slenDescription
TRUEnever evaluated
FALSEevaluated 22 times by 1 test
Evaluated by:
  • Self test
0-22
4330 break;
never executed: break;
0
4331 }
executed 22 times by 1 test: end of block
Executed by:
  • Self test
22
4332-
4333 COPY_CHAR_I (ret, j, string, send, i);
executed 67 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 1 time by 1 test: end of block
Executed by:
  • Self test
never executed: end of block
executed 68 times by 1 test: mblength = (mblength < 1) ? 1 : mblength;
Executed by:
  • Self test
executed 68 times by 1 test: ret[j++] = string[i++];
Executed by:
  • Self test
executed 68 times by 1 test: end of block
Executed by:
  • Self test
never executed: ret[j++] = string[i++];
locale_mb_cur_max > 1Description
TRUEevaluated 68 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
_kDescription
TRUEevaluated 67 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
_k < mblengthDescription
TRUEevaluated 68 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 68 times by 1 test
Evaluated by:
  • Self test
(mblength < 1)Description
TRUEnever evaluated
FALSEevaluated 68 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 68 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 68 times by 1 test
Evaluated by:
  • Self test
0-68
4334 }
executed 68 times by 1 test: end of block
Executed by:
  • Self test
68
4335 ret[j] = '\0';-
4336-
4337 return (ret);
executed 15 times by 1 test: return (ret);
Executed by:
  • Self test
15
4338}-
4339-
4340char *-
4341remove_quoted_nulls (string)-
4342 char *string;-
4343{-
4344 register size_t slen;-
4345 register int i, j, prev_i;-
4346 DECLARE_MBSTATE;-
4347-
4348 if (strchr (string, CTLNUL) == 0) /* XXX */
(__extension__...\177' ))) == 0Description
TRUEevaluated 94544531 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 334449 times by 1 test
Evaluated by:
  • Self test
__builtin_cons...t_p ( '\177' )Description
TRUEevaluated 94878980 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
!__builtin_con...t_p ( string )Description
TRUEevaluated 94878980 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
( '\177' ) == '\0'Description
TRUEnever evaluated
FALSEevaluated 94878980 times by 1 test
Evaluated by:
  • Self test
0-94878980
4349 return string; /* XXX */
executed 94544531 times by 1 test: return string;
Executed by:
  • Self test
94544531
4350-
4351 slen = strlen (string);-
4352 i = j = 0;-
4353-
4354 while (i < slen)
i < slenDescription
TRUEevaluated 385693 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 334449 times by 1 test
Evaluated by:
  • Self test
334449-385693
4355 {-
4356 if (string[i] == CTLESC)
string[i] == '\001'Description
TRUEevaluated 56296 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 329397 times by 1 test
Evaluated by:
  • Self test
56296-329397
4357 {-
4358 /* Old code had j++, but we cannot assume that i == j at this-
4359 point -- what if a CTLNUL has already been removed from the-
4360 string? We don't want to drop the CTLESC or recopy characters-
4361 that we've already copied down. */-
4362 i++;-
4363 string[j++] = CTLESC;-
4364 if (i == slen)
i == slenDescription
TRUEnever evaluated
FALSEevaluated 56296 times by 1 test
Evaluated by:
  • Self test
0-56296
4365 break;
never executed: break;
0
4366 }
executed 56296 times by 1 test: end of block
Executed by:
  • Self test
56296
4367 else if (string[i] == CTLNUL)
string[i] == '\177'Description
TRUEevaluated 317417 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11980 times by 1 test
Evaluated by:
  • Self test
11980-317417
4368 {-
4369 i++;-
4370 continue;
executed 317417 times by 1 test: continue;
Executed by:
  • Self test
317417
4371 }-
4372-
4373 prev_i = i;-
4374 ADVANCE_CHAR (string, slen, i); /* COPY_CHAR_I? */
executed 2733 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 65543 times by 1 test: mblength = 1;
Executed by:
  • Self test
never executed: end of block
never executed: end of block
never executed: (i)++;
executed 68276 times by 1 test: (i) += mblength;
Executed by:
  • Self test
never executed: (i)++;
locale_mb_cur_max > 1Description
TRUEevaluated 68276 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
_fDescription
TRUEevaluated 2733 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 65543 times by 1 test
Evaluated by:
  • Self test
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 68276 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 65543 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((string)[i] & 0x80) == 0)Description
TRUEevaluated 65543 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 68276 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 68276 times by 1 test
Evaluated by:
  • Self test
0-68276
4375 if (j < prev_i)
j < prev_iDescription
TRUEevaluated 644 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 67632 times by 1 test
Evaluated by:
  • Self test
644-67632
4376 {-
4377 do string[j++] = string[prev_i++]; while (prev_i < i);
executed 644 times by 1 test: string[j++] = string[prev_i++];
Executed by:
  • Self test
prev_i < iDescription
TRUEnever evaluated
FALSEevaluated 644 times by 1 test
Evaluated by:
  • Self test
0-644
4378 }
executed 644 times by 1 test: end of block
Executed by:
  • Self test
644
4379 else-
4380 j = i;
executed 67632 times by 1 test: j = i;
Executed by:
  • Self test
67632
4381 }-
4382 string[j] = '\0';-
4383-
4384 return (string);
executed 334449 times by 1 test: return (string);
Executed by:
  • Self test
334449
4385}-
4386-
4387/* Perform quoted null character removal on each element of LIST.-
4388 This modifies LIST. */-
4389void-
4390word_list_remove_quoted_nulls (list)-
4391 WORD_LIST *list;-
4392{-
4393 register WORD_LIST *t;-
4394-
4395 for (t = list; t; t = t->next)
tDescription
TRUEevaluated 60359365 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 60359261 times by 1 test
Evaluated by:
  • Self test
60359261-60359365
4396 {-
4397 remove_quoted_nulls (t->word->word);-
4398 t->word->flags &= ~W_HASQUOTEDNULL;-
4399 }
executed 60359365 times by 1 test: end of block
Executed by:
  • Self test
60359365
4400}
executed 60359261 times by 1 test: end of block
Executed by:
  • Self test
60359261
4401-
4402/* **************************************************************** */-
4403/* */-
4404/* Functions for Matching and Removing Patterns */-
4405/* */-
4406/* **************************************************************** */-
4407-
4408#if defined (HANDLE_MULTIBYTE)-
4409# ifdef INCLUDE_UNUSED-
4410static unsigned char *-
4411mb_getcharlens (string, len)-
4412 char *string;-
4413 int len;-
4414{-
4415 int i, offset, last;-
4416 unsigned char *ret;-
4417 char *p;-
4418 DECLARE_MBSTATE;-
4419-
4420 i = offset = 0;-
4421 last = 0;-
4422 ret = (unsigned char *)xmalloc (len);-
4423 memset (ret, 0, len);-
4424 while (string[last])-
4425 {-
4426 ADVANCE_CHAR (string, len, offset);-
4427 ret[last] = offset - last;-
4428 last = offset;-
4429 }-
4430 return ret;-
4431}-
4432# endif-
4433#endif-
4434-
4435/* Remove the portion of PARAM matched by PATTERN according to OP, where OP-
4436 can have one of 4 values:-
4437 RP_LONG_LEFT remove longest matching portion at start of PARAM-
4438 RP_SHORT_LEFT remove shortest matching portion at start of PARAM-
4439 RP_LONG_RIGHT remove longest matching portion at end of PARAM-
4440 RP_SHORT_RIGHT remove shortest matching portion at end of PARAM-
4441*/-
4442-
4443#define RP_LONG_LEFT 1-
4444#define RP_SHORT_LEFT 2-
4445#define RP_LONG_RIGHT 3-
4446#define RP_SHORT_RIGHT 4-
4447-
4448/* Returns its first argument if nothing matched; new memory otherwise */-
4449static char *-
4450remove_upattern (param, pattern, op)-
4451 char *param, *pattern;-
4452 int op;-
4453{-
4454 register size_t len;-
4455 register char *end;-
4456 register char *p, *ret, c;-
4457-
4458 len = STRLEN (param);
(param)[1]Description
TRUEevaluated 28 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(param)[2]Description
TRUEevaluated 28 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(param)Description
TRUEevaluated 28 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(param)[0]Description
TRUEevaluated 28 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-28
4459 end = param + len;-
4460-
4461 switch (op)-
4462 {-
4463 case RP_LONG_LEFT: /* remove longest match at start */
executed 14 times by 1 test: case 1:
Executed by:
  • Self test
14
4464 for (p = end; p >= param; p--)
p >= paramDescription
TRUEevaluated 82 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-82
4465 {-
4466 c = *p; *p = '\0';-
4467 if (strmatch (pattern, param, FNMATCH_EXTFLAG) != FNM_NOMATCH)
strmatch (patt... 5) : 0)) != 1Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 68 times by 1 test
Evaluated by:
  • Self test
14-68
4468 {-
4469 *p = c;-
4470 return (savestring (p));
executed 14 times by 1 test: return ((char *)strcpy (sh_xmalloc((1 + strlen (p)), "subst.c", 4470), (p)));
Executed by:
  • Self test
14
4471 }-
4472 *p = c;-
4473-
4474 }
executed 68 times by 1 test: end of block
Executed by:
  • Self test
68
4475 break;
never executed: break;
0
4476-
4477 case RP_SHORT_LEFT: /* remove shortest match at start */
executed 6 times by 1 test: case 2:
Executed by:
  • Self test
6
4478 for (p = param; p <= end; p++)
p <= endDescription
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
4-61
4479 {-
4480 c = *p; *p = '\0';-
4481 if (strmatch (pattern, param, FNMATCH_EXTFLAG) != FNM_NOMATCH)
strmatch (patt... 5) : 0)) != 1Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 59 times by 1 test
Evaluated by:
  • Self test
2-59
4482 {-
4483 *p = c;-
4484 return (savestring (p));
executed 2 times by 1 test: return ((char *)strcpy (sh_xmalloc((1 + strlen (p)), "subst.c", 4484), (p)));
Executed by:
  • Self test
2
4485 }-
4486 *p = c;-
4487 }
executed 59 times by 1 test: end of block
Executed by:
  • Self test
59
4488 break;
executed 4 times by 1 test: break;
Executed by:
  • Self test
4
4489-
4490 case RP_LONG_RIGHT: /* remove longest match at end */
executed 3 times by 1 test: case 3:
Executed by:
  • Self test
3
4491 for (p = param; p <= end; p++)
p <= endDescription
TRUEevaluated 28 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-28
4492 {-
4493 if (strmatch (pattern, p, FNMATCH_EXTFLAG) != FNM_NOMATCH)
strmatch (patt... 5) : 0)) != 1Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 25 times by 1 test
Evaluated by:
  • Self test
3-25
4494 {-
4495 c = *p; *p = '\0';-
4496 ret = savestring (param);-
4497 *p = c;-
4498 return (ret);
executed 3 times by 1 test: return (ret);
Executed by:
  • Self test
3
4499 }-
4500 }
executed 25 times by 1 test: end of block
Executed by:
  • Self test
25
4501 break;
never executed: break;
0
4502-
4503 case RP_SHORT_RIGHT: /* remove shortest match at end */
executed 5 times by 1 test: case 4:
Executed by:
  • Self test
5
4504 for (p = end; p >= param; p--)
p >= paramDescription
TRUEevaluated 30 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
3-30
4505 {-
4506 if (strmatch (pattern, p, FNMATCH_EXTFLAG) != FNM_NOMATCH)
strmatch (patt... 5) : 0)) != 1Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 28 times by 1 test
Evaluated by:
  • Self test
2-28
4507 {-
4508 c = *p; *p = '\0';-
4509 ret = savestring (param);-
4510 *p = c;-
4511 return (ret);
executed 2 times by 1 test: return (ret);
Executed by:
  • Self test
2
4512 }-
4513 }
executed 28 times by 1 test: end of block
Executed by:
  • Self test
28
4514 break;
executed 3 times by 1 test: break;
Executed by:
  • Self test
3
4515 }-
4516-
4517 return (param); /* no match, return original string */
executed 7 times by 1 test: return (param);
Executed by:
  • Self test
7
4518}-
4519-
4520#if defined (HANDLE_MULTIBYTE)-
4521/* Returns its first argument if nothing matched; new memory otherwise */-
4522static wchar_t *-
4523remove_wpattern (wparam, wstrlen, wpattern, op)-
4524 wchar_t *wparam;-
4525 size_t wstrlen;-
4526 wchar_t *wpattern;-
4527 int op;-
4528{-
4529 wchar_t wc, *ret;-
4530 int n;-
4531-
4532 switch (op)-
4533 {-
4534 case RP_LONG_LEFT: /* remove longest match at start */
executed 150 times by 1 test: case 1:
Executed by:
  • Self test
150
4535 for (n = wstrlen; n >= 0; n--)
n >= 0Description
TRUEevaluated 858 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 24 times by 1 test
Evaluated by:
  • Self test
24-858
4536 {-
4537 wc = wparam[n]; wparam[n] = L'\0';-
4538 if (wcsmatch (wpattern, wparam, FNMATCH_EXTFLAG) != FNM_NOMATCH)
wcsmatch (wpat... 5) : 0)) != 1Description
TRUEevaluated 126 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 732 times by 1 test
Evaluated by:
  • Self test
126-732
4539 {-
4540 wparam[n] = wc;-
4541 return (wcsdup (wparam + n));
executed 126 times by 1 test: return (wcsdup (wparam + n));
Executed by:
  • Self test
126
4542 }-
4543 wparam[n] = wc;-
4544 }
executed 732 times by 1 test: end of block
Executed by:
  • Self test
732
4545 break;
executed 24 times by 1 test: break;
Executed by:
  • Self test
24
4546-
4547 case RP_SHORT_LEFT: /* remove shortest match at start */
executed 1158112 times by 1 test: case 2:
Executed by:
  • Self test
1158112
4548 for (n = 0; n <= wstrlen; n++)
n <= wstrlenDescription
TRUEevaluated 5568628 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 873181 times by 1 test
Evaluated by:
  • Self test
873181-5568628
4549 {-
4550 wc = wparam[n]; wparam[n] = L'\0';-
4551 if (wcsmatch (wpattern, wparam, FNMATCH_EXTFLAG) != FNM_NOMATCH)
wcsmatch (wpat... 5) : 0)) != 1Description
TRUEevaluated 284931 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5283697 times by 1 test
Evaluated by:
  • Self test
284931-5283697
4552 {-
4553 wparam[n] = wc;-
4554 return (wcsdup (wparam + n));
executed 284931 times by 1 test: return (wcsdup (wparam + n));
Executed by:
  • Self test
284931
4555 }-
4556 wparam[n] = wc;-
4557 }
executed 5283697 times by 1 test: end of block
Executed by:
  • Self test
5283697
4558 break;
executed 873181 times by 1 test: break;
Executed by:
  • Self test
873181
4559-
4560 case RP_LONG_RIGHT: /* remove longest match at end */
executed 157 times by 1 test: case 3:
Executed by:
  • Self test
157
4561 for (n = 0; n <= wstrlen; n++)
n <= wstrlenDescription
TRUEevaluated 510 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 37 times by 1 test
Evaluated by:
  • Self test
37-510
4562 {-
4563 if (wcsmatch (wpattern, wparam + n, FNMATCH_EXTFLAG) != FNM_NOMATCH)
wcsmatch (wpat... 5) : 0)) != 1Description
TRUEevaluated 120 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 390 times by 1 test
Evaluated by:
  • Self test
120-390
4564 {-
4565 wc = wparam[n]; wparam[n] = L'\0';-
4566 ret = wcsdup (wparam);-
4567 wparam[n] = wc;-
4568 return (ret);
executed 120 times by 1 test: return (ret);
Executed by:
  • Self test
120
4569 }-
4570 }
executed 390 times by 1 test: end of block
Executed by:
  • Self test
390
4571 break;
executed 37 times by 1 test: break;
Executed by:
  • Self test
37
4572-
4573 case RP_SHORT_RIGHT: /* remove shortest match at end */
executed 1158080 times by 1 test: case 4:
Executed by:
  • Self test
1158080
4574 for (n = wstrlen; n >= 0; n--)
n >= 0Description
TRUEevaluated 4052978 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 579257 times by 1 test
Evaluated by:
  • Self test
579257-4052978
4575 {-
4576 if (wcsmatch (wpattern, wparam + n, FNMATCH_EXTFLAG) != FNM_NOMATCH)
wcsmatch (wpat... 5) : 0)) != 1Description
TRUEevaluated 578823 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3474155 times by 1 test
Evaluated by:
  • Self test
578823-3474155
4577 {-
4578 wc = wparam[n]; wparam[n] = L'\0';-
4579 ret = wcsdup (wparam);-
4580 wparam[n] = wc;-
4581 return (ret);
executed 578823 times by 1 test: return (ret);
Executed by:
  • Self test
578823
4582 }-
4583 }
executed 3474155 times by 1 test: end of block
Executed by:
  • Self test
3474155
4584 break;
executed 579257 times by 1 test: break;
Executed by:
  • Self test
579257
4585 }-
4586-
4587 return (wparam); /* no match, return original string */
executed 1452499 times by 1 test: return (wparam);
Executed by:
  • Self test
1452499
4588}-
4589#endif /* HANDLE_MULTIBYTE */-
4590-
4591static char *-
4592remove_pattern (param, pattern, op)-
4593 char *param, *pattern;-
4594 int op;-
4595{-
4596 char *xret;-
4597-
4598 if (param == NULL)
param == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 2316560 times by 1 test
Evaluated by:
  • Self test
0-2316560
4599 return (param);
never executed: return (param);
0
4600 if (*param == '\0' || pattern == NULL || *pattern == '\0') /* minor optimization */
*param == '\0'Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2316548 times by 1 test
Evaluated by:
  • Self test
pattern == ((void *)0)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2316543 times by 1 test
Evaluated by:
  • Self test
*pattern == '\0'Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2316527 times by 1 test
Evaluated by:
  • Self test
5-2316548
4601 return (savestring (param));
executed 33 times by 1 test: return ((char *)strcpy (sh_xmalloc((1 + strlen (param)), "subst.c", 4601), (param)));
Executed by:
  • Self test
33
4602-
4603#if defined (HANDLE_MULTIBYTE)-
4604 if (MB_CUR_MAX > 1)
(__ctype_get_m...ur_max ()) > 1Description
TRUEevaluated 2316500 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 27 times by 1 test
Evaluated by:
  • Self test
27-2316500
4605 {-
4606 wchar_t *ret, *oret;-
4607 size_t n;-
4608 wchar_t *wparam, *wpattern;-
4609 mbstate_t ps;-
4610-
4611 /* XXX - could optimize here by checking param and pattern for multibyte-
4612 chars with mbsmbchar and calling remove_upattern. */-
4613-
4614 n = xdupmbstowcs (&wpattern, NULL, pattern);-
4615 if (n == (size_t)-1)
n == (size_t)-1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2316499 times by 1 test
Evaluated by:
  • Self test
1-2316499
4616 {-
4617 xret = remove_upattern (param, pattern, op);-
4618 return ((xret == param) ? savestring (param) : xret);
executed 1 time by 1 test: return ((xret == param) ? (char *)strcpy (sh_xmalloc((1 + strlen (param)), "subst.c", 4618), (param)) : xret);
Executed by:
  • Self test
1
4619 }-
4620 n = xdupmbstowcs (&wparam, NULL, param);-
4621-
4622 if (n == (size_t)-1)
n == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 2316499 times by 1 test
Evaluated by:
  • Self test
0-2316499
4623 {-
4624 free (wpattern);-
4625 xret = remove_upattern (param, pattern, op);-
4626 return ((xret == param) ? savestring (param) : xret);
never executed: return ((xret == param) ? (char *)strcpy (sh_xmalloc((1 + strlen (param)), "subst.c", 4626), (param)) : xret);
0
4627 }-
4628 oret = ret = remove_wpattern (wparam, n, wpattern, op);-
4629 /* Don't bother to convert wparam back to multibyte string if nothing-
4630 matched; just return copy of original string */-
4631 if (ret == wparam)
ret == wparamDescription
TRUEevaluated 1452499 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 864000 times by 1 test
Evaluated by:
  • Self test
864000-1452499
4632 {-
4633 free (wparam);-
4634 free (wpattern);-
4635 return (savestring (param));
executed 1452499 times by 1 test: return ((char *)strcpy (sh_xmalloc((1 + strlen (param)), "subst.c", 4635), (param)));
Executed by:
  • Self test
1452499
4636 }-
4637-
4638 free (wparam);-
4639 free (wpattern);-
4640-
4641 n = strlen (param);-
4642 xret = (char *)xmalloc (n + 1);-
4643 memset (&ps, '\0', sizeof (mbstate_t));-
4644 n = wcsrtombs (xret, (const wchar_t **)&ret, n, &ps);-
4645 xret[n] = '\0'; /* just to make sure */-
4646 free (oret);-
4647 return xret;
executed 864000 times by 1 test: return xret;
Executed by:
  • Self test
864000
4648 }-
4649 else-
4650#endif-
4651 {-
4652 xret = remove_upattern (param, pattern, op);-
4653 return ((xret == param) ? savestring (param) : xret);
executed 27 times by 1 test: return ((xret == param) ? (char *)strcpy (sh_xmalloc((1 + strlen (param)), "subst.c", 4653), (param)) : xret);
Executed by:
  • Self test
27
4654 }-
4655}-
4656-
4657/* Match PAT anywhere in STRING and return the match boundaries.-
4658 This returns 1 in case of a successful match, 0 otherwise. SP-
4659 and EP are pointers into the string where the match begins and-
4660 ends, respectively. MTYPE controls what kind of match is attempted.-
4661 MATCH_BEG and MATCH_END anchor the match at the beginning and end-
4662 of the string, respectively. The longest match is returned. */-
4663static int-
4664match_upattern (string, pat, mtype, sp, ep)-
4665 char *string, *pat;-
4666 int mtype;-
4667 char **sp, **ep;-
4668{-
4669 int c, mlen;-
4670 size_t len;-
4671 register char *p, *p1, *npat;-
4672 char *end;-
4673-
4674 /* If the pattern doesn't match anywhere in the string, go ahead and-
4675 short-circuit right away. A minor optimization, saves a bunch of-
4676 unnecessary calls to strmatch (up to N calls for a string of N-
4677 characters) if the match is unsuccessful. To preserve the semantics-
4678 of the substring matches below, we make sure that the pattern has-
4679 `*' as first and last character, making a new pattern if necessary. */-
4680 /* XXX - check this later if I ever implement `**' with special meaning,-
4681 since this will potentially result in `**' at the beginning or end */-
4682 len = STRLEN (pat);
(pat)[1]Description
TRUEevaluated 58547 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1624 times by 1 test
Evaluated by:
  • Self test
(pat)[2]Description
TRUEevaluated 57653 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 894 times by 1 test
Evaluated by:
  • Self test
(pat)Description
TRUEevaluated 60171 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(pat)[0]Description
TRUEevaluated 60171 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-60171
4683 if (pat[0] != '*' || (pat[0] == '*' && pat[1] == LPAREN && extended_glob) || pat[len - 1] != '*')
pat[0] != '*'Description
TRUEevaluated 59904 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 267 times by 1 test
Evaluated by:
  • Self test
pat[0] == '*'Description
TRUEevaluated 267 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
pat[1] == '('Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 265 times by 1 test
Evaluated by:
  • Self test
extended_globDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
pat[len - 1] != '*'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 261 times by 1 test
Evaluated by:
  • Self test
0-59904
4684 {-
4685 int unescaped_backslash;-
4686 char *pp;-
4687-
4688 p = npat = (char *)xmalloc (len + 3);-
4689 p1 = pat;-
4690 if ((mtype != MATCH_BEG) && (*p1 != '*' || (*p1 == '*' && p1[1] == LPAREN && extended_glob)))
(mtype != 0x001)Description
TRUEevaluated 59815 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 95 times by 1 test
Evaluated by:
  • Self test
*p1 != '*'Description
TRUEevaluated 59809 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
*p1 == '*'Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
p1[1] == '('Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
extended_globDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-59815
4691 *p++ = '*';
executed 59811 times by 1 test: *p++ = '*';
Executed by:
  • Self test
59811
4692 while (*p1)
*p1Description
TRUEevaluated 372193 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 59910 times by 1 test
Evaluated by:
  • Self test
59910-372193
4693 *p++ = *p1++;
executed 372193 times by 1 test: *p++ = *p1++;
Executed by:
  • Self test
372193
4694#if 1-
4695 /* Need to also handle a pattern that ends with an unescaped backslash.-
4696 For right now, we ignore it because the pattern matching code will-
4697 fail the match anyway */-
4698 /* If the pattern ends with a `*' we leave it alone if it's preceded by-
4699 an even number of backslashes, but if it's escaped by a backslash-
4700 we need to add another `*'. */-
4701 if ((mtype != MATCH_END) && (p1[-1] == '*' && (unescaped_backslash = p1[-2] == '\\')))
(mtype != 0x002)Description
TRUEevaluated 59692 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 218 times by 1 test
Evaluated by:
  • Self test
p1[-1] == '*'Description
TRUEevaluated 115 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 59577 times by 1 test
Evaluated by:
  • Self test
(unescaped_bac...1[-2] == '\\')Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 112 times by 1 test
Evaluated by:
  • Self test
3-59692
4702 {-
4703 pp = p1 - 3;-
4704 while (pp >= pat && *pp-- == '\\')
pp >= patDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
*pp-- == '\\'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3
4705 unescaped_backslash = 1 - unescaped_backslash;
executed 1 time by 1 test: unescaped_backslash = 1 - unescaped_backslash;
Executed by:
  • Self test
1
4706 if (unescaped_backslash)
unescaped_backslashDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-2
4707 *p++ = '*';
executed 2 times by 1 test: *p++ = '*';
Executed by:
  • Self test
2
4708 }
executed 3 times by 1 test: end of block
Executed by:
  • Self test
3
4709 else if (mtype != MATCH_END && p1[-1] != '*')
mtype != 0x002Description
TRUEevaluated 59689 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 218 times by 1 test
Evaluated by:
  • Self test
p1[-1] != '*'Description
TRUEevaluated 59577 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 112 times by 1 test
Evaluated by:
  • Self test
112-59689
4710 *p++ = '*';
executed 59577 times by 1 test: *p++ = '*';
Executed by:
  • Self test
59577
4711#else -
4712 if (p1[-1] != '*' || p1[-2] == '\\')-
4713 *p++ = '*';-
4714#endif-
4715 *p = '\0';-
4716 }
executed 59910 times by 1 test: end of block
Executed by:
  • Self test
59910
4717 else-
4718 npat = pat;
executed 261 times by 1 test: npat = pat;
Executed by:
  • Self test
261
4719 c = strmatch (npat, string, FNMATCH_EXTFLAG | FNMATCH_IGNCASE);-
4720 if (npat != pat)
npat != patDescription
TRUEevaluated 59910 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 261 times by 1 test
Evaluated by:
  • Self test
261-59910
4721 free (npat);
executed 59910 times by 1 test: sh_xfree((npat), "subst.c", 4721);
Executed by:
  • Self test
59910
4722 if (c == FNM_NOMATCH)
c == 1Description
TRUEevaluated 812 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 59359 times by 1 test
Evaluated by:
  • Self test
812-59359
4723 return (0);
executed 812 times by 1 test: return (0);
Executed by:
  • Self test
812
4724-
4725 len = STRLEN (string);
(string)[1]Description
TRUEevaluated 59310 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31 times by 1 test
Evaluated by:
  • Self test
(string)[2]Description
TRUEevaluated 58572 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 738 times by 1 test
Evaluated by:
  • Self test
(string)Description
TRUEevaluated 59359 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(string)[0]Description
TRUEevaluated 59341 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 18 times by 1 test
Evaluated by:
  • Self test
0-59359
4726 end = string + len;-
4727-
4728 mlen = umatchlen (pat, len);-
4729-
4730 switch (mtype)-
4731 {-
4732 case MATCH_ANY:
executed 59010 times by 1 test: case 0x000:
Executed by:
  • Self test
59010
4733 for (p = string; p <= end; p++)
p <= endDescription
TRUEevaluated 94052 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-94052
4734 {-
4735 if (match_pattern_char (pat, p, FNMATCH_IGNCASE))
match_pattern_...(1 << 4) : 0))Description
TRUEevaluated 78870 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 15182 times by 1 test
Evaluated by:
  • Self test
15182-78870
4736 {-
4737 p1 = (mlen == -1) ? end : p + mlen;
(mlen == -1)Description
TRUEevaluated 179 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 78691 times by 1 test
Evaluated by:
  • Self test
179-78691
4738 /* p1 - p = length of portion of string to be considered-
4739 p = current position in string-
4740 mlen = number of characters consumed by match (-1 for entire string)-
4741 end = end of string-
4742 we want to break immediately if the potential match len-
4743 is greater than the number of characters remaining in the-
4744 string-
4745 */-
4746 if (p1 > end)
p1 > endDescription
TRUEnever evaluated
FALSEevaluated 78870 times by 1 test
Evaluated by:
  • Self test
0-78870
4747 break;
never executed: break;
0
4748 for ( ; p1 >= p; p1--)
p1 >= pDescription
TRUEevaluated 78888 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-78888
4749 {-
4750 c = *p1; *p1 = '\0';-
4751 if (strmatch (pat, p, FNMATCH_EXTFLAG | FNMATCH_IGNCASE) == 0)
strmatch (pat,... 4) : 0)) == 0Description
TRUEevaluated 59010 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 19878 times by 1 test
Evaluated by:
  • Self test
19878-59010
4752 {-
4753 *p1 = c;-
4754 *sp = p;-
4755 *ep = p1;-
4756 return 1;
executed 59010 times by 1 test: return 1;
Executed by:
  • Self test
59010
4757 }-
4758 *p1 = c;-
4759#if 1-
4760 /* If MLEN != -1, we have a fixed length pattern. */-
4761 if (mlen != -1)
mlen != -1Description
TRUEevaluated 19859 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 19 times by 1 test
Evaluated by:
  • Self test
19-19859
4762 break;
executed 19859 times by 1 test: break;
Executed by:
  • Self test
19859
4763#endif-
4764 }
executed 19 times by 1 test: end of block
Executed by:
  • Self test
19
4765 }
executed 19860 times by 1 test: end of block
Executed by:
  • Self test
19860
4766 }
executed 35042 times by 1 test: end of block
Executed by:
  • Self test
35042
4767-
4768 return (0);
never executed: return (0);
0
4769-
4770 case MATCH_BEG:
executed 140 times by 1 test: case 0x001:
Executed by:
  • Self test
140
4771 if (match_pattern_char (pat, string, FNMATCH_IGNCASE) == 0)
match_pattern_... 4) : 0)) == 0Description
TRUEnever evaluated
FALSEevaluated 140 times by 1 test
Evaluated by:
  • Self test
0-140
4772 return (0);
never executed: return (0);
0
4773-
4774 for (p = (mlen == -1) ? end : string + mlen; p >= string; p--)
p >= stringDescription
TRUEevaluated 140 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-140
4775 {-
4776 c = *p; *p = '\0';-
4777 if (strmatch (pat, string, FNMATCH_EXTFLAG | FNMATCH_IGNCASE) == 0)
strmatch (pat,... 4) : 0)) == 0Description
TRUEevaluated 140 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-140
4778 {-
4779 *p = c;-
4780 *sp = string;-
4781 *ep = p;-
4782 return 1;
executed 140 times by 1 test: return 1;
Executed by:
  • Self test
140
4783 }-
4784 *p = c;-
4785 /* If MLEN != -1, we have a fixed length pattern. */-
4786 if (mlen != -1)
mlen != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
4787 break;
never executed: break;
0
4788 }
never executed: end of block
0
4789-
4790 return (0);
never executed: return (0);
0
4791-
4792 case MATCH_END:
executed 209 times by 1 test: case 0x002:
Executed by:
  • Self test
209
4793 for (p = end - ((mlen == -1) ? len : mlen); p <= end; p++)
p <= endDescription
TRUEevaluated 236 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-236
4794 {-
4795 if (strmatch (pat, p, FNMATCH_EXTFLAG | FNMATCH_IGNCASE) == 0)
strmatch (pat,... 4) : 0)) == 0Description
TRUEevaluated 209 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 27 times by 1 test
Evaluated by:
  • Self test
27-209
4796 {-
4797 *sp = p;-
4798 *ep = end;-
4799 return 1;
executed 209 times by 1 test: return 1;
Executed by:
  • Self test
209
4800 }-
4801 /* If MLEN != -1, we have a fixed length pattern. */-
4802 if (mlen != -1)
mlen != -1Description
TRUEnever evaluated
FALSEevaluated 27 times by 1 test
Evaluated by:
  • Self test
0-27
4803 break;
never executed: break;
0
4804 }
executed 27 times by 1 test: end of block
Executed by:
  • Self test
27
4805-
4806 return (0);
never executed: return (0);
0
4807 }-
4808-
4809 return (0);
never executed: return (0);
0
4810}-
4811-
4812#if defined (HANDLE_MULTIBYTE)-
4813-
4814#define WFOLD(c) (match_ignore_case && iswupper (c) ? towlower (c) : (c))-
4815-
4816/* Match WPAT anywhere in WSTRING and return the match boundaries.-
4817 This returns 1 in case of a successful match, 0 otherwise. Wide-
4818 character version. */-
4819static int-
4820match_wpattern (wstring, indices, wstrlen, wpat, mtype, sp, ep)-
4821 wchar_t *wstring;-
4822 char **indices;-
4823 size_t wstrlen;-
4824 wchar_t *wpat;-
4825 int mtype;-
4826 char **sp, **ep;-
4827{-
4828 wchar_t wc, *wp, *nwpat, *wp1;-
4829 size_t len;-
4830 int mlen;-
4831 int n, n1, n2, simple;-
4832-
4833 simple = (wpat[0] != L'\\' && wpat[0] != L'*' && wpat[0] != L'?' && wpat[0] != L'[');
wpat[0] != L'\\'Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
wpat[0] != L'*'Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
wpat[0] != L'?'Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
wpat[0] != L'['Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-10
4834#if defined (EXTENDED_GLOB)-
4835 if (extended_glob)
extended_globDescription
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
0-10
4836 simple &= (wpat[1] != L'(' || (wpat[0] != L'*' && wpat[0] != L'?' && wpat[0] != L'+' && wpat[0] != L'!' && wpat[0] != L'@')); /*)*/
never executed: simple &= (wpat[1] != L'(' || (wpat[0] != L'*' && wpat[0] != L'?' && wpat[0] != L'+' && wpat[0] != L'!' && wpat[0] != L'@'));
wpat[1] != L'('Description
TRUEnever evaluated
FALSEnever evaluated
wpat[0] != L'*'Description
TRUEnever evaluated
FALSEnever evaluated
wpat[0] != L'?'Description
TRUEnever evaluated
FALSEnever evaluated
wpat[0] != L'+'Description
TRUEnever evaluated
FALSEnever evaluated
wpat[0] != L'!'Description
TRUEnever evaluated
FALSEnever evaluated
wpat[0] != L'@'Description
TRUEnever evaluated
FALSEnever evaluated
0
4837#endif-
4838-
4839 /* If the pattern doesn't match anywhere in the string, go ahead and-
4840 short-circuit right away. A minor optimization, saves a bunch of-
4841 unnecessary calls to strmatch (up to N calls for a string of N-
4842 characters) if the match is unsuccessful. To preserve the semantics-
4843 of the substring matches below, we make sure that the pattern has-
4844 `*' as first and last character, making a new pattern if necessary. */-
4845 len = wcslen (wpat);-
4846 if (wpat[0] != L'*' || (wpat[0] == L'*' && wpat[1] == WLPAREN && extended_glob) || wpat[len - 1] != L'*')
wpat[0] != L'*'Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
wpat[0] == L'*'Description
TRUEnever evaluated
FALSEnever evaluated
wpat[1] == L'('Description
TRUEnever evaluated
FALSEnever evaluated
extended_globDescription
TRUEnever evaluated
FALSEnever evaluated
wpat[len - 1] != L'*'Description
TRUEnever evaluated
FALSEnever evaluated
0-10
4847 {-
4848 int unescaped_backslash;-
4849 wchar_t *wpp;-
4850-
4851 wp = nwpat = (wchar_t *)xmalloc ((len + 3) * sizeof (wchar_t));-
4852 wp1 = wpat;-
4853 if (*wp1 != L'*' || (*wp1 == '*' && wp1[1] == WLPAREN && extended_glob))
*wp1 != L'*'Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*wp1 == '*'Description
TRUEnever evaluated
FALSEnever evaluated
wp1[1] == L'('Description
TRUEnever evaluated
FALSEnever evaluated
extended_globDescription
TRUEnever evaluated
FALSEnever evaluated
0-10
4854 *wp++ = L'*';
executed 10 times by 1 test: *wp++ = L'*';
Executed by:
  • Self test
10
4855 while (*wp1 != L'\0')
*wp1 != L'\0'Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
10-20
4856 *wp++ = *wp1++;
executed 20 times by 1 test: *wp++ = *wp1++;
Executed by:
  • Self test
20
4857#if 1-
4858 /* See comments above in match_upattern. */-
4859 if (wp1[-1] == L'*' && (unescaped_backslash = wp1[-2] == L'\\'))
wp1[-1] == L'*'Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
(unescaped_bac...[-2] == L'\\')Description
TRUEnever evaluated
FALSEnever evaluated
0-10
4860 {-
4861 wpp = wp1 - 3;-
4862 while (wpp >= wpat && *wpp-- == L'\\')
wpp >= wpatDescription
TRUEnever evaluated
FALSEnever evaluated
*wpp-- == L'\\'Description
TRUEnever evaluated
FALSEnever evaluated
0
4863 unescaped_backslash = 1 - unescaped_backslash;
never executed: unescaped_backslash = 1 - unescaped_backslash;
0
4864 if (unescaped_backslash)
unescaped_backslashDescription
TRUEnever evaluated
FALSEnever evaluated
0
4865 *wp++ = L'*';
never executed: *wp++ = L'*';
0
4866 }
never executed: end of block
0
4867 else if (wp1[-1] != L'*')
wp1[-1] != L'*'Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-10
4868 *wp++ = L'*';
executed 10 times by 1 test: *wp++ = L'*';
Executed by:
  • Self test
10
4869#else -
4870 if (wp1[-1] != L'*' || wp1[-2] == L'\\')-
4871 *wp++ = L'*';-
4872#endif-
4873 *wp = '\0';-
4874 }
executed 10 times by 1 test: end of block
Executed by:
  • Self test
10
4875 else-
4876 nwpat = wpat;
never executed: nwpat = wpat;
0
4877 len = wcsmatch (nwpat, wstring, FNMATCH_EXTFLAG | FNMATCH_IGNCASE);-
4878 if (nwpat != wpat)
nwpat != wpatDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-10
4879 free (nwpat);
executed 10 times by 1 test: sh_xfree((nwpat), "subst.c", 4879);
Executed by:
  • Self test
10
4880 if (len == FNM_NOMATCH)
len == 1Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
3-7
4881 return (0);
executed 3 times by 1 test: return (0);
Executed by:
  • Self test
3
4882-
4883 mlen = wmatchlen (wpat, wstrlen);-
4884-
4885/* itrace("wmatchlen (%ls) -> %d", wpat, mlen); */-
4886 switch (mtype)-
4887 {-
4888 case MATCH_ANY:
executed 3 times by 1 test: case 0x000:
Executed by:
  • Self test
3
4889 for (n = 0; n <= wstrlen; n++)
n <= wstrlenDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-6
4890 {-
4891 n2 = simple ? (WFOLD(*wpat) == WFOLD(wstring[n])) : match_pattern_wchar (wpat, wstring + n, FNMATCH_IGNCASE);
simpleDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
match_ignore_caseDescription
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
iswupper (*wpat)Description
TRUEnever evaluated
FALSEnever evaluated
match_ignore_caseDescription
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
iswupper (wstring[n])Description
TRUEnever evaluated
FALSEnever evaluated
0-6
4892 if (n2)
n2Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
3
4893 {-
4894 n1 = (mlen == -1) ? wstrlen : n + mlen;
(mlen == -1)Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
0-3
4895 if (n1 > wstrlen)
n1 > wstrlenDescription
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
0-3
4896 break;
never executed: break;
0
4897-
4898 for ( ; n1 >= n; n1--)
n1 >= nDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3
4899 {-
4900 wc = wstring[n1]; wstring[n1] = L'\0';-
4901 if (wcsmatch (wpat, wstring + n, FNMATCH_EXTFLAG | FNMATCH_IGNCASE) == 0)
wcsmatch (wpat... 4) : 0)) == 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3
4902 {-
4903 wstring[n1] = wc;-
4904 *sp = indices[n];-
4905 *ep = indices[n1];-
4906 return 1;
executed 3 times by 1 test: return 1;
Executed by:
  • Self test
3
4907 }-
4908 wstring[n1] = wc;-
4909 /* If MLEN != -1, we have a fixed length pattern. */-
4910 if (mlen != -1)
mlen != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
4911 break;
never executed: break;
0
4912 }
never executed: end of block
0
4913 }
never executed: end of block
0
4914 }
executed 3 times by 1 test: end of block
Executed by:
  • Self test
3
4915-
4916 return (0);
never executed: return (0);
0
4917-
4918 case MATCH_BEG:
executed 2 times by 1 test: case 0x001:
Executed by:
  • Self test
2
4919 if (match_pattern_wchar (wpat, wstring, FNMATCH_IGNCASE) == 0)
match_pattern_... 4) : 0)) == 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
0-2
4920 return (0);
never executed: return (0);
0
4921-
4922 for (n = (mlen == -1) ? wstrlen : mlen; n >= 0; n--)
n >= 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
4923 {-
4924 wc = wstring[n]; wstring[n] = L'\0';-
4925 if (wcsmatch (wpat, wstring, FNMATCH_EXTFLAG | FNMATCH_IGNCASE) == 0)
wcsmatch (wpat... 4) : 0)) == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
4926 {-
4927 wstring[n] = wc;-
4928 *sp = indices[0];-
4929 *ep = indices[n];-
4930 return 1;
executed 2 times by 1 test: return 1;
Executed by:
  • Self test
2
4931 }-
4932 wstring[n] = wc;-
4933 /* If MLEN != -1, we have a fixed length pattern. */-
4934 if (mlen != -1)
mlen != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
4935 break;
never executed: break;
0
4936 }
never executed: end of block
0
4937-
4938 return (0);
never executed: return (0);
0
4939-
4940 case MATCH_END:
executed 2 times by 1 test: case 0x002:
Executed by:
  • Self test
2
4941 for (n = wstrlen - ((mlen == -1) ? wstrlen : mlen); n <= wstrlen; n++)
n <= wstrlenDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
4942 {-
4943 if (wcsmatch (wpat, wstring + n, FNMATCH_EXTFLAG | FNMATCH_IGNCASE) == 0)
wcsmatch (wpat... 4) : 0)) == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
4944 {-
4945 *sp = indices[n];-
4946 *ep = indices[wstrlen];-
4947 return 1;
executed 2 times by 1 test: return 1;
Executed by:
  • Self test
2
4948 }-
4949 /* If MLEN != -1, we have a fixed length pattern. */-
4950 if (mlen != -1)
mlen != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
4951 break;
never executed: break;
0
4952 }
never executed: end of block
0
4953-
4954 return (0);
never executed: return (0);
0
4955 }-
4956-
4957 return (0);
never executed: return (0);
0
4958}-
4959#undef WFOLD-
4960#endif /* HANDLE_MULTIBYTE */-
4961-
4962static int-
4963match_pattern (string, pat, mtype, sp, ep)-
4964 char *string, *pat;-
4965 int mtype;-
4966 char **sp, **ep;-
4967{-
4968#if defined (HANDLE_MULTIBYTE)-
4969 int ret;-
4970 size_t n;-
4971 wchar_t *wstring, *wpat;-
4972 char **indices;-
4973#endif-
4974-
4975 if (string == 0 || pat == 0 || *pat == 0)
string == 0Description
TRUEnever evaluated
FALSEevaluated 60212 times by 1 test
Evaluated by:
  • Self test
pat == 0Description
TRUEevaluated 31 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 60181 times by 1 test
Evaluated by:
  • Self test
*pat == 0Description
TRUEnever evaluated
FALSEevaluated 60181 times by 1 test
Evaluated by:
  • Self test
0-60212
4976 return (0);
executed 31 times by 1 test: return (0);
Executed by:
  • Self test
31
4977-
4978#if defined (HANDLE_MULTIBYTE)-
4979 if (MB_CUR_MAX > 1)
(__ctype_get_m...ur_max ()) > 1Description
TRUEevaluated 31459 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 28722 times by 1 test
Evaluated by:
  • Self test
28722-31459
4980 {-
4981 if (mbsmbchar (string) == 0 && mbsmbchar (pat) == 0)
mbsmbchar (string) == 0Description
TRUEevaluated 31449 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
mbsmbchar (pat) == 0Description
TRUEevaluated 31449 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-31449
4982 return (match_upattern (string, pat, mtype, sp, ep));
executed 31449 times by 1 test: return (match_upattern (string, pat, mtype, sp, ep));
Executed by:
  • Self test
31449
4983-
4984 n = xdupmbstowcs (&wpat, NULL, pat);-
4985 if (n == (size_t)-1)
n == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
0-10
4986 return (match_upattern (string, pat, mtype, sp, ep));
never executed: return (match_upattern (string, pat, mtype, sp, ep));
0
4987 n = xdupmbstowcs (&wstring, &indices, string);-
4988 if (n == (size_t)-1)
n == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
0-10
4989 {-
4990 free (wpat);-
4991 return (match_upattern (string, pat, mtype, sp, ep));
never executed: return (match_upattern (string, pat, mtype, sp, ep));
0
4992 }-
4993 ret = match_wpattern (wstring, indices, n, wpat, mtype, sp, ep);-
4994-
4995 free (wpat);-
4996 free (wstring);-
4997 free (indices);-
4998-
4999 return (ret);
executed 10 times by 1 test: return (ret);
Executed by:
  • Self test
10
5000 }-
5001 else-
5002#endif-
5003 return (match_upattern (string, pat, mtype, sp, ep));
executed 28722 times by 1 test: return (match_upattern (string, pat, mtype, sp, ep));
Executed by:
  • Self test
28722
5004}-
5005-
5006static int-
5007getpatspec (c, value)-
5008 int c;-
5009 char *value;-
5010{-
5011 if (c == '#')
c == '#'Description
TRUEevaluated 1157915 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1157903 times by 1 test
Evaluated by:
  • Self test
1157903-1157915
5012 return ((*value == '#') ? RP_LONG_LEFT : RP_SHORT_LEFT);
executed 1157915 times by 1 test: return ((*value == '#') ? 1 : 2);
Executed by:
  • Self test
1157915
5013 else /* c == '%' */-
5014 return ((*value == '%') ? RP_LONG_RIGHT : RP_SHORT_RIGHT);
executed 1157903 times by 1 test: return ((*value == '%') ? 3 : 4);
Executed by:
  • Self test
1157903
5015}-
5016-
5017/* Posix.2 says that the WORD should be run through tilde expansion,-
5018 parameter expansion, command substitution and arithmetic expansion.-
5019 This leaves the result quoted, so quote_string_for_globbing () has-
5020 to be called to fix it up for strmatch (). If QUOTED is non-zero,-
5021 it means that the entire expression was enclosed in double quotes.-
5022 This means that quoting characters in the pattern do not make any-
5023 special pattern characters quoted. For example, the `*' in the-
5024 following retains its special meaning: "${foo#'*'}". */-
5025static char *-
5026getpattern (value, quoted, expandpat)-
5027 char *value;-
5028 int quoted, expandpat;-
5029{-
5030 char *pat, *tword;-
5031 WORD_LIST *l;-
5032#if 0-
5033 int i;-
5034#endif-
5035 /* There is a problem here: how to handle single or double quotes in the-
5036 pattern string when the whole expression is between double quotes?-
5037 POSIX.2 says that enclosing double quotes do not cause the pattern to-
5038 be quoted, but does that leave us a problem with @ and array[@] and their-
5039 expansions inside a pattern? */-
5040#if 0-
5041 if (expandpat && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && *tword)-
5042 {-
5043 i = 0;-
5044 pat = string_extract_double_quoted (tword, &i, SX_STRIPDQ);-
5045 free (tword);-
5046 tword = pat;-
5047 }-
5048#endif-
5049-
5050 /* expand_string_for_pat () leaves WORD quoted and does not perform-
5051 word splitting. */-
5052 l = *value ? expand_string_for_pat (value,
*valueDescription
TRUEevaluated 2316712 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 47 times by 1 test
Evaluated by:
  • Self test
47-2316712
5053 (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) ? Q_PATQUOTE : quoted,-
5054 (int *)NULL, (int *)NULL)-
5055 : (WORD_LIST *)0;-
5056 pat = string_list (l);-
5057 dispose_words (l);-
5058 if (pat)
patDescription
TRUEevaluated 2316689 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 66 times by 1 test
Evaluated by:
  • Self test
66-2316689
5059 {-
5060 tword = quote_string_for_globbing (pat, QGLOB_CVTNULL);-
5061 free (pat);-
5062 pat = tword;-
5063 }
executed 2316689 times by 1 test: end of block
Executed by:
  • Self test
2316689
5064 return (pat);
executed 2316755 times by 1 test: return (pat);
Executed by:
  • Self test
2316755
5065}-
5066-
5067#if 0-
5068/* Handle removing a pattern from a string as a result of ${name%[%]value}-
5069 or ${name#[#]value}. */-
5070static char *-
5071variable_remove_pattern (value, pattern, patspec, quoted)-
5072 char *value, *pattern;-
5073 int patspec, quoted;-
5074{-
5075 char *tword;-
5076-
5077 tword = remove_pattern (value, pattern, patspec);-
5078-
5079 return (tword);-
5080}-
5081#endif-
5082-
5083static char *-
5084list_remove_pattern (list, pattern, patspec, itype, quoted)-
5085 WORD_LIST *list;-
5086 char *pattern;-
5087 int patspec, itype, quoted;-
5088{-
5089 WORD_LIST *new, *l;-
5090 WORD_DESC *w;-
5091 char *tword;-
5092-
5093 for (new = (WORD_LIST *)NULL, l = list; l; l = l->next)
lDescription
TRUEevaluated 870 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 128 times by 1 test
Evaluated by:
  • Self test
128-870
5094 {-
5095 tword = remove_pattern (l->word->word, pattern, patspec);-
5096 w = alloc_word_desc ();-
5097 w->word = tword ? tword : savestring ("");
twordDescription
TRUEevaluated 870 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-870
5098 new = make_word_list (w, new);-
5099 }
executed 870 times by 1 test: end of block
Executed by:
  • Self test
870
5100-
5101 l = REVERSE_LIST (new, WORD_LIST *);
newDescription
TRUEevaluated 128 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
new->nextDescription
TRUEevaluated 119 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
0-128
5102 tword = string_list_pos_params (itype, l, quoted);-
5103 dispose_words (l);-
5104-
5105 return (tword);
executed 128 times by 1 test: return (tword);
Executed by:
  • Self test
128
5106}-
5107-
5108static char *-
5109parameter_list_remove_pattern (itype, pattern, patspec, quoted)-
5110 int itype;-
5111 char *pattern;-
5112 int patspec, quoted;-
5113{-
5114 char *ret;-
5115 WORD_LIST *list;-
5116-
5117 list = list_rest_of_args ();-
5118 if (list == 0)
list == 0Description
TRUEnever evaluated
FALSEevaluated 61 times by 1 test
Evaluated by:
  • Self test
0-61
5119 return ((char *)NULL);
never executed: return ((char *) ((void *)0) );
0
5120 ret = list_remove_pattern (list, pattern, patspec, itype, quoted);-
5121 dispose_words (list);-
5122 return (ret);
executed 61 times by 1 test: return (ret);
Executed by:
  • Self test
61
5123}-
5124-
5125#if defined (ARRAY_VARS)-
5126static char *-
5127array_remove_pattern (var, pattern, patspec, varname, quoted)-
5128 SHELL_VAR *var;-
5129 char *pattern;-
5130 int patspec;-
5131 char *varname; /* so we can figure out how it's indexed */-
5132 int quoted;-
5133{-
5134 ARRAY *a;-
5135 HASH_TABLE *h;-
5136 int itype;-
5137 char *ret;-
5138 WORD_LIST *list;-
5139 SHELL_VAR *v;-
5140-
5141 /* compute itype from varname here */-
5142 v = array_variable_part (varname, 0, &ret, 0);-
5143-
5144 /* XXX */-
5145 if (v && invisible_p (v))
vDescription
TRUEevaluated 67 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((((v)->attrib... (0x0001000)))Description
TRUEnever evaluated
FALSEevaluated 67 times by 1 test
Evaluated by:
  • Self test
0-67
5146 return ((char *)NULL);
never executed: return ((char *) ((void *)0) );
0
5147-
5148 itype = ret[0];-
5149-
5150 a = (v && array_p (v)) ? array_cell (v) : 0;
vDescription
TRUEevaluated 67 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((((v)->attrib... (0x0000004)))Description
TRUEevaluated 57 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
0-67
5151 h = (v && assoc_p (v)) ? assoc_cell (v) : 0;
vDescription
TRUEevaluated 67 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((((v)->attrib... (0x0000040)))Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 57 times by 1 test
Evaluated by:
  • Self test
0-67
5152 -
5153 list = a ? array_to_word_list (a) : (h ? assoc_to_word_list (h) : 0);
aDescription
TRUEevaluated 57 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
hDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-57
5154 if (list == 0)
list == 0Description
TRUEnever evaluated
FALSEevaluated 67 times by 1 test
Evaluated by:
  • Self test
0-67
5155 return ((char *)NULL);
never executed: return ((char *) ((void *)0) );
0
5156 ret = list_remove_pattern (list, pattern, patspec, itype, quoted);-
5157 dispose_words (list);-
5158-
5159 return ret;
executed 67 times by 1 test: return ret;
Executed by:
  • Self test
67
5160}-
5161#endif /* ARRAY_VARS */-
5162-
5163static char *-
5164parameter_brace_remove_pattern (varname, value, ind, patstr, rtype, quoted, flags)-
5165 char *varname, *value;-
5166 int ind;-
5167 char *patstr;-
5168 int rtype, quoted, flags;-
5169{-
5170 int vtype, patspec, starsub;-
5171 char *temp1, *val, *pattern, *oname;-
5172 SHELL_VAR *v;-
5173-
5174 if (value == 0)
value == 0Description
TRUEnever evaluated
FALSEevaluated 2315818 times by 1 test
Evaluated by:
  • Self test
0-2315818
5175 return ((char *)NULL);
never executed: return ((char *) ((void *)0) );
0
5176-
5177 oname = this_command_name;-
5178 this_command_name = varname;-
5179-
5180 vtype = get_var_and_type (varname, value, ind, quoted, flags, &v, &val);-
5181 if (vtype == -1)
vtype == -1Description
TRUEnever evaluated
FALSEevaluated 2315818 times by 1 test
Evaluated by:
  • Self test
0-2315818
5182 {-
5183 this_command_name = oname;-
5184 return ((char *)NULL);
never executed: return ((char *) ((void *)0) );
0
5185 }-
5186-
5187 starsub = vtype & VT_STARSUB;-
5188 vtype &= ~VT_STARSUB;-
5189-
5190 patspec = getpatspec (rtype, patstr);-
5191 if (patspec == RP_LONG_LEFT || patspec == RP_LONG_RIGHT)
patspec == 1Description
TRUEevaluated 111 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2315707 times by 1 test
Evaluated by:
  • Self test
patspec == 3Description
TRUEevaluated 108 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2315599 times by 1 test
Evaluated by:
  • Self test
108-2315707
5192 patstr++;
executed 219 times by 1 test: patstr++;
Executed by:
  • Self test
219
5193-
5194 /* Need to pass getpattern newly-allocated memory in case of expansion ---
5195 the expansion code will free the passed string on an error. */-
5196 temp1 = savestring (patstr);-
5197 pattern = getpattern (temp1, quoted, 1);-
5198 free (temp1);-
5199-
5200 temp1 = (char *)NULL; /* shut up gcc */-
5201 switch (vtype)-
5202 {-
5203 case VT_VARIABLE:
executed 2315641 times by 1 test: case 0:
Executed by:
  • Self test
2315641
5204 case VT_ARRAYMEMBER:
executed 49 times by 1 test: case 3:
Executed by:
  • Self test
49
5205 temp1 = remove_pattern (val, pattern, patspec);-
5206 if (vtype == VT_VARIABLE)
vtype == 0Description
TRUEevaluated 2315641 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 49 times by 1 test
Evaluated by:
  • Self test
49-2315641
5207 FREE (val);
executed 2315641 times by 1 test: sh_xfree((val), "subst.c", 5207);
Executed by:
  • Self test
executed 2315641 times by 1 test: end of block
Executed by:
  • Self test
valDescription
TRUEevaluated 2315641 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2315641
5208 if (temp1)
temp1Description
TRUEevaluated 2315690 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2315690
5209 {-
5210 val = (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
(quoted & (0x002|0x001))Description
TRUEevaluated 140 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2315550 times by 1 test
Evaluated by:
  • Self test
140-2315550
5211 ? quote_string (temp1)-
5212 : quote_escapes (temp1);-
5213 free (temp1);-
5214 temp1 = val;-
5215 }
executed 2315690 times by 1 test: end of block
Executed by:
  • Self test
2315690
5216 break;
executed 2315690 times by 1 test: break;
Executed by:
  • Self test
2315690
5217#if defined (ARRAY_VARS)-
5218 case VT_ARRAYVAR:
executed 67 times by 1 test: case 2:
Executed by:
  • Self test
67
5219 temp1 = array_remove_pattern (v, pattern, patspec, varname, quoted);-
5220 if (temp1 && ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) == 0))
temp1Description
TRUEevaluated 67 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((quoted & (0x...|0x001)) == 0)Description
TRUEevaluated 55 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test
0-67
5221 {-
5222 val = quote_escapes (temp1);-
5223 free (temp1);-
5224 temp1 = val;-
5225 }
executed 55 times by 1 test: end of block
Executed by:
  • Self test
55
5226 break;
executed 67 times by 1 test: break;
Executed by:
  • Self test
67
5227#endif-
5228 case VT_POSPARMS:
executed 61 times by 1 test: case 1:
Executed by:
  • Self test
61
5229 temp1 = parameter_list_remove_pattern (varname[0], pattern, patspec, quoted);-
5230 if (temp1 && quoted == 0 && ifs_is_null)
temp1Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
quoted == 0Description
TRUEevaluated 46 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 15 times by 1 test
Evaluated by:
  • Self test
ifs_is_nullDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 44 times by 1 test
Evaluated by:
  • Self test
0-61
5231 {-
5232 /* Posix interp 888 */-
5233 }
executed 2 times by 1 test: end of block
Executed by:
  • Self test
2
5234 else if (temp1 && ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) == 0))
temp1Description
TRUEevaluated 59 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((quoted & (0x...|0x001)) == 0)Description
TRUEevaluated 44 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 15 times by 1 test
Evaluated by:
  • Self test
0-59
5235 {-
5236 val = quote_escapes (temp1);-
5237 free (temp1);-
5238 temp1 = val;-
5239 }
executed 44 times by 1 test: end of block
Executed by:
  • Self test
44
5240 break;
executed 61 times by 1 test: break;
Executed by:
  • Self test
61
5241 }-
5242-
5243 this_command_name = oname;-
5244-
5245 FREE (pattern);
executed 2315815 times by 1 test: sh_xfree((pattern), "subst.c", 5245);
Executed by:
  • Self test
patternDescription
TRUEevaluated 2315815 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
3-2315815
5246 return temp1;
executed 2315818 times by 1 test: return temp1;
Executed by:
  • Self test
2315818
5247} -
5248-
5249#if defined (PROCESS_SUBSTITUTION)-
5250-
5251/*****************************************************************/-
5252/* */-
5253/* Hacking Process Substitution */-
5254/* */-
5255/*****************************************************************/-
5256-
5257#if !defined (HAVE_DEV_FD)-
5258/* Named pipes must be removed explicitly with `unlink'. This keeps a list-
5259 of FIFOs the shell has open. unlink_fifo_list will walk the list and-
5260 unlink all of them. add_fifo_list adds the name of an open FIFO to the-
5261 list. NFIFO is a count of the number of FIFOs in the list. */-
5262#define FIFO_INCR 20-
5263-
5264/* PROC value of -1 means the process has been reaped and the FIFO needs to-
5265 be removed. PROC value of 0 means the slot is unused. */-
5266struct temp_fifo {-
5267 char *file;-
5268 pid_t proc;-
5269};-
5270-
5271static struct temp_fifo *fifo_list = (struct temp_fifo *)NULL;-
5272static int nfifo;-
5273static int fifo_list_size;-
5274-
5275void-
5276clear_fifo_list ()-
5277{-
5278}-
5279-
5280char *-
5281copy_fifo_list (sizep)-
5282 int *sizep;-
5283{-
5284 if (sizep)-
5285 *sizep = 0;-
5286 return (char *)NULL;-
5287}-
5288-
5289static void-
5290add_fifo_list (pathname)-
5291 char *pathname;-
5292{-
5293 int osize, i;-
5294-
5295 if (nfifo >= fifo_list_size - 1)-
5296 {-
5297 osize = fifo_list_size;-
5298 fifo_list_size += FIFO_INCR;-
5299 fifo_list = (struct temp_fifo *)xrealloc (fifo_list,-
5300 fifo_list_size * sizeof (struct temp_fifo));-
5301 for (i = osize; i < fifo_list_size; i++)-
5302 {-
5303 fifo_list[i].file = (char *)NULL;-
5304 fifo_list[i].proc = 0; /* unused */-
5305 }-
5306 }-
5307-
5308 fifo_list[nfifo].file = savestring (pathname);-
5309 nfifo++;-
5310}-
5311-
5312void-
5313unlink_fifo (i)-
5314 int i;-
5315{-
5316 if ((fifo_list[i].proc == (pid_t)-1) || (fifo_list[i].proc > 0 && (kill(fifo_list[i].proc, 0) == -1)))-
5317 {-
5318 unlink (fifo_list[i].file);-
5319 free (fifo_list[i].file);-
5320 fifo_list[i].file = (char *)NULL;-
5321 fifo_list[i].proc = 0;-
5322 }-
5323}-
5324-
5325void-
5326unlink_fifo_list ()-
5327{-
5328 int saved, i, j;-
5329-
5330 if (nfifo == 0)-
5331 return;-
5332-
5333 for (i = saved = 0; i < nfifo; i++)-
5334 {-
5335 if ((fifo_list[i].proc == (pid_t)-1) || (fifo_list[i].proc > 0 && (kill(fifo_list[i].proc, 0) == -1)))-
5336 {-
5337 unlink (fifo_list[i].file);-
5338 free (fifo_list[i].file);-
5339 fifo_list[i].file = (char *)NULL;-
5340 fifo_list[i].proc = 0;-
5341 }-
5342 else-
5343 saved++;-
5344 }-
5345-
5346 /* If we didn't remove some of the FIFOs, compact the list. */-
5347 if (saved)-
5348 {-
5349 for (i = j = 0; i < nfifo; i++)-
5350 if (fifo_list[i].file)-
5351 {-
5352 fifo_list[j].file = fifo_list[i].file;-
5353 fifo_list[j].proc = fifo_list[i].proc;-
5354 j++;-
5355 }-
5356 nfifo = j;-
5357 }-
5358 else-
5359 nfifo = 0;-
5360}-
5361-
5362/* Take LIST, which is a bitmap denoting active FIFOs in fifo_list-
5363 from some point in the past, and close all open FIFOs in fifo_list-
5364 that are not marked as active in LIST. If LIST is NULL, close-
5365 everything in fifo_list. LSIZE is the number of elements in LIST, in-
5366 case it's larger than fifo_list_size (size of fifo_list). */-
5367void-
5368close_new_fifos (list, lsize)-
5369 char *list;-
5370 int lsize;-
5371{-
5372 int i;-
5373-
5374 if (list == 0)-
5375 {-
5376 unlink_fifo_list ();-
5377 return;-
5378 }-
5379-
5380 for (i = 0; i < lsize; i++)-
5381 if (list[i] == 0 && i < fifo_list_size && fifo_list[i].proc != -1)-
5382 unlink_fifo (i);-
5383-
5384 for (i = lsize; i < fifo_list_size; i++)-
5385 unlink_fifo (i); -
5386}-
5387-
5388int-
5389find_procsub_child (pid)-
5390 pid_t pid;-
5391{-
5392 int i;-
5393-
5394 for (i = 0; i < nfifo; i++)-
5395 if ((fifo_list[i].proc == pid)-
5396 return i;-
5397 return -1;-
5398}-
5399-
5400void-
5401set_procsub_status (ind, pid, status)-
5402 int ind;-
5403 pid_t pid;-
5404 int status;-
5405{-
5406 if (ind >= 0 && ind < nfifo)-
5407 fifo_list[ind].proc = (pid_t)-1; /* sentinel */-
5408}-
5409-
5410/* If we've marked the process for this procsub as dead, close the-
5411 associated file descriptor and delete the FIFO. */-
5412void-
5413reap_procsubs ()-
5414{-
5415 int i;-
5416-
5417 for (i = 0; i < nfifo; i++)-
5418 if (fifo_list[i].proc == (pid_t)-1) /* reaped */-
5419 unlink_fifo (i);-
5420}-
5421-
5422void-
5423wait_procsubs ()-
5424{-
5425 int i;-
5426-
5427 for (i = 0; i < nfifo; i++)-
5428 {-
5429 if (fifo_list[i].proc != (pid_t)-1 && fifo_list[i].proc > 0)-
5430 {-
5431 r = wait_for (fifo_list[i].proc);-
5432 fifo_list[i].proc = (pid_t)-1;-
5433 }-
5434 }-
5435}-
5436-
5437int-
5438fifos_pending ()-
5439{-
5440 return nfifo;-
5441}-
5442-
5443int-
5444num_fifos ()-
5445{-
5446 return nfifo;-
5447}-
5448-
5449static char *-
5450make_named_pipe ()-
5451{-
5452 char *tname;-
5453-
5454 tname = sh_mktmpname ("sh-np", MT_USERANDOM|MT_USETMPDIR);-
5455 if (mkfifo (tname, 0600) < 0)-
5456 {-
5457 free (tname);-
5458 return ((char *)NULL);-
5459 }-
5460-
5461 add_fifo_list (tname);-
5462 return (tname);-
5463}-
5464-
5465#else /* HAVE_DEV_FD */-
5466-
5467/* DEV_FD_LIST is a bitmap of file descriptors attached to pipes the shell-
5468 has open to children. NFDS is a count of the number of bits currently-
5469 set in DEV_FD_LIST. TOTFDS is a count of the highest possible number-
5470 of open files. */-
5471/* dev_fd_list[I] value of -1 means the process has been reaped and file-
5472 descriptor I needs to be closed. Value of 0 means the slot is unused. */-
5473-
5474static pid_t *dev_fd_list = (pid_t *)NULL;-
5475static int nfds;-
5476static int totfds; /* The highest possible number of open files. */-
5477-
5478void-
5479clear_fifo (i)-
5480 int i;-
5481{-
5482 if (dev_fd_list[i])
dev_fd_list[i]Description
TRUEnever evaluated
FALSEnever evaluated
0
5483 {-
5484 dev_fd_list[i] = 0;-
5485 nfds--;-
5486 }
never executed: end of block
0
5487}
never executed: end of block
0
5488-
5489void-
5490clear_fifo_list ()-
5491{-
5492 register int i;-
5493-
5494 if (nfds == 0)
nfds == 0Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-15
5495 return;
executed 15 times by 1 test: return;
Executed by:
  • Self test
15
5496-
5497 for (i = 0; nfds && i < totfds; i++)
nfdsDescription
TRUEnever evaluated
FALSEnever evaluated
i < totfdsDescription
TRUEnever evaluated
FALSEnever evaluated
0
5498 clear_fifo (i);
never executed: clear_fifo (i);
0
5499-
5500 nfds = 0;-
5501}
never executed: end of block
0
5502-
5503char *-
5504copy_fifo_list (sizep)-
5505 int *sizep;-
5506{-
5507 char *ret;-
5508-
5509 if (nfds == 0 || totfds == 0)
nfds == 0Description
TRUEevaluated 195669801 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4001512 times by 1 test
Evaluated by:
  • Self test
totfds == 0Description
TRUEnever evaluated
FALSEevaluated 4001512 times by 1 test
Evaluated by:
  • Self test
0-195669801
5510 {-
5511 if (sizep)
sizepDescription
TRUEevaluated 195669801 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-195669801
5512 *sizep = 0;
executed 195669801 times by 1 test: *sizep = 0;
Executed by:
  • Self test
195669801
5513 return (char *)NULL;
executed 195669801 times by 1 test: return (char *) ((void *)0) ;
Executed by:
  • Self test
195669801
5514 }-
5515-
5516 if (sizep)
sizepDescription
TRUEevaluated 4001512 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-4001512
5517 *sizep = totfds;
executed 4001512 times by 1 test: *sizep = totfds;
Executed by:
  • Self test
4001512
5518 ret = (char *)xmalloc (totfds * sizeof (pid_t));-
5519 return (memcpy (ret, dev_fd_list, totfds * sizeof (pid_t)));
executed 4001512 times by 1 test: return (memcpy (ret, dev_fd_list, totfds * sizeof (pid_t)));
Executed by:
  • Self test
4001512
5520}-
5521-
5522static void-
5523add_fifo_list (fd)-
5524 int fd;-
5525{-
5526 if (dev_fd_list == 0 || fd >= totfds)
dev_fd_list == 0Description
TRUEevaluated 1399 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 677645 times by 1 test
Evaluated by:
  • Self test
fd >= totfdsDescription
TRUEnever evaluated
FALSEevaluated 677645 times by 1 test
Evaluated by:
  • Self test
0-677645
5527 {-
5528 int ofds;-
5529-
5530 ofds = totfds;-
5531 totfds = getdtablesize ();-
5532 if (totfds < 0 || totfds > 256)
totfds < 0Description
TRUEnever evaluated
FALSEevaluated 1399 times by 1 test
Evaluated by:
  • Self test
totfds > 256Description
TRUEevaluated 1170 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 229 times by 1 test
Evaluated by:
  • Self test
0-1399
5533 totfds = 256;
executed 1170 times by 1 test: totfds = 256;
Executed by:
  • Self test
1170
5534 if (fd >= totfds)
fd >= totfdsDescription
TRUEnever evaluated
FALSEevaluated 1399 times by 1 test
Evaluated by:
  • Self test
0-1399
5535 totfds = fd + 2;
never executed: totfds = fd + 2;
0
5536-
5537 dev_fd_list = (pid_t *)xrealloc (dev_fd_list, totfds * sizeof (dev_fd_list[0]));-
5538 /* XXX - might need a loop for this */-
5539 memset (dev_fd_list + ofds, '\0', (totfds - ofds) * sizeof (pid_t));-
5540 }
executed 1399 times by 1 test: end of block
Executed by:
  • Self test
1399
5541-
5542 dev_fd_list[fd] = 1; /* marker; updated later */-
5543 nfds++;-
5544}
executed 679044 times by 1 test: end of block
Executed by:
  • Self test
679044
5545-
5546int-
5547fifos_pending ()-
5548{-
5549 return 0; /* used for cleanup; not needed with /dev/fd */
executed 10 times by 1 test: return 0;
Executed by:
  • Self test
10
5550}-
5551-
5552int-
5553num_fifos ()-
5554{-
5555 return nfds;
executed 399301301 times by 1 test: return nfds;
Executed by:
  • Self test
399301301
5556}-
5557-
5558void-
5559unlink_fifo (fd)-
5560 int fd;-
5561{-
5562 if (dev_fd_list[fd])
dev_fd_list[fd]Description
TRUEevaluated 677655 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 126333184 times by 1 test
Evaluated by:
  • Self test
677655-126333184
5563 {-
5564 close (fd);-
5565 dev_fd_list[fd] = 0;-
5566 nfds--;-
5567 }
executed 677655 times by 1 test: end of block
Executed by:
  • Self test
677655
5568}
executed 127010839 times by 1 test: end of block
Executed by:
  • Self test
127010839
5569-
5570void-
5571unlink_fifo_list ()-
5572{-
5573 register int i;-
5574-
5575 if (nfds == 0)
nfds == 0Description
TRUEevaluated 1942537 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 675388 times by 1 test
Evaluated by:
  • Self test
675388-1942537
5576 return;
executed 1942537 times by 1 test: return;
Executed by:
  • Self test
1942537
5577-
5578 for (i = totfds-1; nfds && i >= 0; i--)
nfdsDescription
TRUEevaluated 127010842 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 675384 times by 1 test
Evaluated by:
  • Self test
i >= 0Description
TRUEevaluated 127010838 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
4-127010842
5579 unlink_fifo (i);
executed 127010838 times by 1 test: unlink_fifo (i);
Executed by:
  • Self test
127010838
5580-
5581 nfds = 0;-
5582}
executed 675388 times by 1 test: end of block
Executed by:
  • Self test
675388
5583-
5584/* Take LIST, which is a snapshot copy of dev_fd_list from some point in-
5585 the past, and close all open fds in dev_fd_list that are not marked-
5586 as open in LIST. If LIST is NULL, close everything in dev_fd_list.-
5587 LSIZE is the number of elements in LIST, in case it's larger than-
5588 totfds (size of dev_fd_list). */-
5589void-
5590close_new_fifos (list, lsize)-
5591 char *list;-
5592 int lsize;-
5593{-
5594 int i;-
5595-
5596 if (list == 0)
list == 0Description
TRUEevaluated 660612 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-660612
5597 {-
5598 unlink_fifo_list ();-
5599 return;
executed 660612 times by 1 test: return;
Executed by:
  • Self test
660612
5600 }-
5601-
5602 for (i = 0; i < lsize; i++)
i < lsizeDescription
TRUEevaluated 256 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-256
5603 if (list[i] == 0 && i < totfds && dev_fd_list[i])
list[i] == 0Description
TRUEevaluated 256 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
i < totfdsDescription
TRUEevaluated 256 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
dev_fd_list[i]Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 255 times by 1 test
Evaluated by:
  • Self test
0-256
5604 unlink_fifo (i);
executed 1 time by 1 test: unlink_fifo (i);
Executed by:
  • Self test
1
5605-
5606 for (i = lsize; i < totfds; i++)
i < totfdsDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-1
5607 unlink_fifo (i);
never executed: unlink_fifo (i);
0
5608}
executed 1 time by 1 test: end of block
Executed by:
  • Self test
1
5609-
5610int-
5611find_procsub_child (pid)-
5612 pid_t pid;-
5613{-
5614 int i;-
5615-
5616 if (nfds == 0)
nfds == 0Description
TRUEevaluated 3285888 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 699943 times by 1 test
Evaluated by:
  • Self test
699943-3285888
5617 return -1;
executed 3285888 times by 1 test: return -1;
Executed by:
  • Self test
3285888
5618-
5619 for (i = 0; i < totfds; i++)
i < totfdsDescription
TRUEevaluated 86753058 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 223925 times by 1 test
Evaluated by:
  • Self test
223925-86753058
5620 if (dev_fd_list[i] == pid)
dev_fd_list[i] == pidDescription
TRUEevaluated 476018 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 86277040 times by 1 test
Evaluated by:
  • Self test
476018-86277040
5621 return i;
executed 476018 times by 1 test: return i;
Executed by:
  • Self test
476018
5622-
5623 return -1;
executed 223925 times by 1 test: return -1;
Executed by:
  • Self test
223925
5624}-
5625-
5626void-
5627set_procsub_status (ind, pid, status)-
5628 int ind;-
5629 pid_t pid;-
5630 int status;-
5631{-
5632 if (ind >= 0 && ind < totfds)
ind >= 0Description
TRUEevaluated 476018 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
ind < totfdsDescription
TRUEevaluated 476018 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-476018
5633 dev_fd_list[ind] = (pid_t)-1; /* sentinel */
executed 476018 times by 1 test: dev_fd_list[ind] = (pid_t)-1;
Executed by:
  • Self test
476018
5634}
executed 476018 times by 1 test: end of block
Executed by:
  • Self test
476018
5635-
5636/* If we've marked the process for this procsub as dead, close the-
5637 associated file descriptor. */-
5638void-
5639reap_procsubs ()-
5640{-
5641 int i;-
5642-
5643 for (i = 0; nfds > 0 && i < totfds; i++)
nfds > 0Description
TRUEnever evaluated
FALSEevaluated 138 times by 1 test
Evaluated by:
  • Self test
i < totfdsDescription
TRUEnever evaluated
FALSEnever evaluated
0-138
5644 if (dev_fd_list[i] == (pid_t)-1)
dev_fd_list[i] == (pid_t)-1Description
TRUEnever evaluated
FALSEnever evaluated
0
5645 unlink_fifo (i);
never executed: unlink_fifo (i);
0
5646}
executed 138 times by 1 test: end of block
Executed by:
  • Self test
138
5647-
5648void-
5649wait_procsubs ()-
5650{-
5651 int i, r;-
5652-
5653 for (i = 0; nfds > 0 && i < totfds; i++)
nfds > 0Description
TRUEnever evaluated
FALSEevaluated 138 times by 1 test
Evaluated by:
  • Self test
i < totfdsDescription
TRUEnever evaluated
FALSEnever evaluated
0-138
5654 {-
5655 if (dev_fd_list[i] != (pid_t)-1 && dev_fd_list[i] > 0)
dev_fd_list[i] != (pid_t)-1Description
TRUEnever evaluated
FALSEnever evaluated
dev_fd_list[i] > 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5656 {-
5657 r = wait_for (dev_fd_list[i]);-
5658 dev_fd_list[i] = (pid_t)-1;-
5659 }
never executed: end of block
0
5660 }
never executed: end of block
0
5661}
executed 138 times by 1 test: end of block
Executed by:
  • Self test
138
5662-
5663#if defined (NOTDEF)-
5664print_dev_fd_list ()-
5665{-
5666 register int i;-
5667-
5668 fprintf (stderr, "pid %ld: dev_fd_list:", (long)getpid ());-
5669 fflush (stderr);-
5670-
5671 for (i = 0; i < totfds; i++)-
5672 {-
5673 if (dev_fd_list[i])-
5674 fprintf (stderr, " %d", i);-
5675 }-
5676 fprintf (stderr, "\n");-
5677}-
5678#endif /* NOTDEF */-
5679-
5680static char *-
5681make_dev_fd_filename (fd)-
5682 int fd;-
5683{-
5684 char *ret, intbuf[INT_STRLEN_BOUND (int) + 1], *p;-
5685-
5686 ret = (char *)xmalloc (sizeof (DEV_FD_PREFIX) + 8);-
5687-
5688 strcpy (ret, DEV_FD_PREFIX);-
5689 p = inttostr (fd, intbuf, sizeof (intbuf));-
5690 strcpy (ret + sizeof (DEV_FD_PREFIX) - 1, p);-
5691-
5692 add_fifo_list (fd);-
5693 return (ret);
executed 679044 times by 1 test: return (ret);
Executed by:
  • Self test
679044
5694}-
5695-
5696#endif /* HAVE_DEV_FD */-
5697-
5698/* Return a filename that will open a connection to the process defined by-
5699 executing STRING. HAVE_DEV_FD, if defined, means open a pipe and return-
5700 a filename in /dev/fd corresponding to a descriptor that is one of the-
5701 ends of the pipe. If not defined, we use named pipes on systems that have-
5702 them. Systems without /dev/fd and named pipes are out of luck.-
5703-
5704 OPEN_FOR_READ_IN_CHILD, if 1, means open the named pipe for reading or-
5705 use the read end of the pipe and dup that file descriptor to fd 0 in-
5706 the child. If OPEN_FOR_READ_IN_CHILD is 0, we open the named pipe for-
5707 writing or use the write end of the pipe in the child, and dup that-
5708 file descriptor to fd 1 in the child. The parent does the opposite. */-
5709-
5710static char *-
5711process_substitute (string, open_for_read_in_child)-
5712 char *string;-
5713 int open_for_read_in_child;-
5714{-
5715 char *pathname;-
5716 int fd, result;-
5717 pid_t old_pid, pid;-
5718#if defined (HAVE_DEV_FD)-
5719 int parent_pipe_fd, child_pipe_fd;-
5720 int fildes[2];-
5721#endif /* HAVE_DEV_FD */-
5722#if defined (JOB_CONTROL)-
5723 pid_t old_pipeline_pgrp;-
5724#endif-
5725-
5726 if (!string || !*string || wordexp_only)
!stringDescription
TRUEnever evaluated
FALSEevaluated 679044 times by 1 test
Evaluated by:
  • Self test
!*stringDescription
TRUEnever evaluated
FALSEevaluated 679044 times by 1 test
Evaluated by:
  • Self test
wordexp_onlyDescription
TRUEnever evaluated
FALSEevaluated 679044 times by 1 test
Evaluated by:
  • Self test
0-679044
5727 return ((char *)NULL);
never executed: return ((char *) ((void *)0) );
0
5728-
5729#if !defined (HAVE_DEV_FD)-
5730 pathname = make_named_pipe ();-
5731#else /* HAVE_DEV_FD */-
5732 if (pipe (fildes) < 0)
pipe (fildes) < 0Description
TRUEnever evaluated
FALSEevaluated 679044 times by 1 test
Evaluated by:
  • Self test
0-679044
5733 {-
5734 sys_error ("%s", _("cannot make pipe for process substitution"));-
5735 return ((char *)NULL);
never executed: return ((char *) ((void *)0) );
0
5736 }-
5737 /* If OPEN_FOR_READ_IN_CHILD == 1, we want to use the write end of-
5738 the pipe in the parent, otherwise the read end. */-
5739 parent_pipe_fd = fildes[open_for_read_in_child];-
5740 child_pipe_fd = fildes[1 - open_for_read_in_child];-
5741 /* Move the parent end of the pipe to some high file descriptor, to-
5742 avoid clashes with FDs used by the script. */-
5743 parent_pipe_fd = move_to_high_fd (parent_pipe_fd, 1, 64);-
5744-
5745 pathname = make_dev_fd_filename (parent_pipe_fd);-
5746#endif /* HAVE_DEV_FD */-
5747-
5748 if (pathname == 0)
pathname == 0Description
TRUEnever evaluated
FALSEevaluated 679044 times by 1 test
Evaluated by:
  • Self test
0-679044
5749 {-
5750 sys_error ("%s", _("cannot make pipe for process substitution"));-
5751 return ((char *)NULL);
never executed: return ((char *) ((void *)0) );
0
5752 }-
5753-
5754 old_pid = last_made_pid;-
5755-
5756#if defined (JOB_CONTROL)-
5757 old_pipeline_pgrp = pipeline_pgrp;-
5758 if (pipeline_pgrp == 0 || (subshell_environment & (SUBSHELL_PIPE|SUBSHELL_FORK|SUBSHELL_ASYNC)) == 0)
pipeline_pgrp == 0Description
TRUEevaluated 679041 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
(subshell_envi...08|0x01)) == 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
0-679041
5759 pipeline_pgrp = shell_pgrp;
executed 679041 times by 1 test: pipeline_pgrp = shell_pgrp;
Executed by:
  • Self test
679041
5760 save_pipeline (1);-
5761#endif /* JOB_CONTROL */-
5762-
5763 pid = make_child ((char *)NULL, 1);-
5764 if (pid == 0)
pid == 0Description
TRUEevaluated 1384 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 677660 times by 1 test
Evaluated by:
  • Self test
1384-677660
5765 {-
5766 reset_terminating_signals (); /* XXX */-
5767 free_pushed_string_input ();-
5768 /* Cancel traps, in trap.c. */-
5769 restore_original_signals (); /* XXX - what about special builtins? bash-4.2 */-
5770 QUIT; /* catch any interrupts we got post-fork */
never executed: termsig_handler (terminating_signal);
never executed: throw_to_top_level ();
terminating_signalDescription
TRUEnever evaluated
FALSEevaluated 1384 times by 1 test
Evaluated by:
  • Self test
interrupt_stateDescription
TRUEnever evaluated
FALSEevaluated 1384 times by 1 test
Evaluated by:
  • Self test
0-1384
5771 setup_async_signals ();-
5772 subshell_environment |= SUBSHELL_COMSUB|SUBSHELL_PROCSUB;-
5773-
5774 /* We don't inherit the verbose option for command substitutions now, so-
5775 let's try it for process substitutions. */-
5776 change_flag ('v', FLAG_OFF);-
5777-
5778 /* if we're expanding a redirection, we shouldn't have access to the-
5779 temporary environment, but commands in the subshell should have-
5780 access to their own temporary environment. */-
5781 if (expanding_redir)
expanding_redirDescription
TRUEevaluated 1362 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 22 times by 1 test
Evaluated by:
  • Self test
22-1362
5782 flush_temporary_env ();
executed 1362 times by 1 test: flush_temporary_env ();
Executed by:
  • Self test
1362
5783 }
executed 1384 times by 1 test: end of block
Executed by:
  • Self test
1384
5784-
5785#if defined (JOB_CONTROL)-
5786 set_sigchld_handler ();-
5787 stop_making_children ();-
5788 /* XXX - should we only do this in the parent? (as in command subst) */-
5789 pipeline_pgrp = old_pipeline_pgrp;-
5790#else-
5791 stop_making_children ();-
5792#endif /* JOB_CONTROL */-
5793-
5794 if (pid < 0)
pid < 0Description
TRUEnever evaluated
FALSEevaluated 679044 times by 1 test
Evaluated by:
  • Self test
0-679044
5795 {-
5796 sys_error ("%s", _("cannot make child for process substitution"));-
5797 free (pathname);-
5798#if defined (HAVE_DEV_FD)-
5799 close (parent_pipe_fd);-
5800 close (child_pipe_fd);-
5801#endif /* HAVE_DEV_FD */-
5802#if defined (JOB_CONTROL)-
5803 restore_pipeline (1);-
5804#endif-
5805 return ((char *)NULL);
never executed: return ((char *) ((void *)0) );
0
5806 }-
5807-
5808 if (pid > 0)
pid > 0Description
TRUEevaluated 677660 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1384 times by 1 test
Evaluated by:
  • Self test
1384-677660
5809 {-
5810#if defined (JOB_CONTROL)-
5811 if (last_procsub_child)
last_procsub_childDescription
TRUEevaluated 220153 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 457507 times by 1 test
Evaluated by:
  • Self test
220153-457507
5812 discard_last_procsub_child ();
executed 220153 times by 1 test: discard_last_procsub_child ();
Executed by:
  • Self test
220153
5813 last_procsub_child = restore_pipeline (0);-
5814#endif-
5815-
5816#if defined (HAVE_DEV_FD)-
5817 dev_fd_list[parent_pipe_fd] = pid;-
5818#else-
5819 fifo_list[nfifo-1].proc = pid;-
5820#endif-
5821-
5822 last_made_pid = old_pid;-
5823-
5824#if defined (JOB_CONTROL) && defined (PGRP_PIPE)-
5825 close_pgrp_pipe ();-
5826#endif /* JOB_CONTROL && PGRP_PIPE */-
5827-
5828#if defined (HAVE_DEV_FD)-
5829 close (child_pipe_fd);-
5830#endif /* HAVE_DEV_FD */-
5831-
5832 return (pathname);
executed 677660 times by 1 test: return (pathname);
Executed by:
  • Self test
677660
5833 }-
5834-
5835 set_sigint_handler ();-
5836-
5837#if defined (JOB_CONTROL)-
5838 set_job_control (0);-
5839#endif /* JOB_CONTROL */-
5840-
5841#if !defined (HAVE_DEV_FD)-
5842 /* Open the named pipe in the child. */-
5843 fd = open (pathname, open_for_read_in_child ? O_RDONLY : O_WRONLY);-
5844 if (fd < 0)-
5845 {-
5846 /* Two separate strings for ease of translation. */-
5847 if (open_for_read_in_child)-
5848 sys_error (_("cannot open named pipe %s for reading"), pathname);-
5849 else-
5850 sys_error (_("cannot open named pipe %s for writing"), pathname);-
5851-
5852 exit (127);-
5853 }-
5854 if (open_for_read_in_child)-
5855 {-
5856 if (sh_unset_nodelay_mode (fd) < 0)-
5857 {-
5858 sys_error (_("cannot reset nodelay mode for fd %d"), fd);-
5859 exit (127);-
5860 }-
5861 }-
5862#else /* HAVE_DEV_FD */-
5863 fd = child_pipe_fd;-
5864#endif /* HAVE_DEV_FD */-
5865-
5866 /* Discard buffered stdio output before replacing the underlying file-
5867 descriptor. */-
5868 if (open_for_read_in_child == 0)
open_for_read_in_child == 0Description
TRUEevaluated 1382 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2-1382
5869 fpurge (stdout);
executed 1382 times by 1 test: fpurge ( stdout );
Executed by:
  • Self test
1382
5870-
5871 if (dup2 (fd, open_for_read_in_child ? 0 : 1) < 0)
dup2 (fd, open...d ? 0 : 1) < 0Description
TRUEnever evaluated
FALSEevaluated 1384 times by 1 test
Evaluated by:
  • Self test
0-1384
5872 {-
5873 sys_error (_("cannot duplicate named pipe %s as fd %d"), pathname,-
5874 open_for_read_in_child ? 0 : 1);-
5875 exit (127);
never executed: exit (127);
0
5876 }-
5877-
5878 if (fd != (open_for_read_in_child ? 0 : 1))
fd != (open_fo...child ? 0 : 1)Description
TRUEevaluated 1384 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
open_for_read_in_childDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1382 times by 1 test
Evaluated by:
  • Self test
0-1384
5879 close (fd);
executed 1384 times by 1 test: close (fd);
Executed by:
  • Self test
1384
5880-
5881 /* Need to close any files that this process has open to pipes inherited-
5882 from its parent. */-
5883 if (current_fds_to_close)
current_fds_to_closeDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1362 times by 1 test
Evaluated by:
  • Self test
22-1362
5884 {-
5885 close_fd_bitmap (current_fds_to_close);-
5886 current_fds_to_close = (struct fd_bitmap *)NULL;-
5887 }
executed 22 times by 1 test: end of block
Executed by:
  • Self test
22
5888-
5889#if defined (HAVE_DEV_FD)-
5890 /* Make sure we close the parent's end of the pipe and clear the slot-
5891 in the fd list so it is not closed later, if reallocated by, for-
5892 instance, pipe(2). */-
5893 close (parent_pipe_fd);-
5894 dev_fd_list[parent_pipe_fd] = 0;-
5895#endif /* HAVE_DEV_FD */-
5896-
5897 /* subshells shouldn't have this flag, which controls using the temporary-
5898 environment for variable lookups. We have already flushed the temporary-
5899 environment above in the case we're expanding a redirection, so processes-
5900 executed by this command need to be able to set it independently of their-
5901 parent. */-
5902 expanding_redir = 0;-
5903-
5904 remove_quoted_escapes (string);-
5905-
5906 subshell_level++;-
5907 result = parse_and_execute (string, "process substitution", (SEVAL_NONINT|SEVAL_NOHIST));-
5908 /* leave subshell level intact for any exit trap */-
5909-
5910#if !defined (HAVE_DEV_FD)-
5911 /* Make sure we close the named pipe in the child before we exit. */-
5912 close (open_for_read_in_child ? 0 : 1);-
5913#endif /* !HAVE_DEV_FD */-
5914-
5915 last_command_exit_value = result;-
5916 result = run_exit_trap ();-
5917 exit (result);
executed 1380 times by 1 test: exit (result);
Executed by:
  • Self test
1380
5918 /*NOTREACHED*/-
5919}-
5920#endif /* PROCESS_SUBSTITUTION */-
5921-
5922/***********************************/-
5923/* */-
5924/* Command Substitution */-
5925/* */-
5926/***********************************/-
5927-
5928static char *-
5929read_comsub (fd, quoted, flags, rflag)-
5930 int fd, quoted, flags;-
5931 int *rflag;-
5932{-
5933 char *istring, buf[128], *bufp;-
5934 int istring_index, c, tflag, skip_ctlesc, skip_ctlnul;-
5935 size_t istring_size;-
5936 ssize_t bufn;-
5937 int nullbyte;-
5938-
5939 istring = (char *)NULL;-
5940 istring_index = istring_size = bufn = tflag = 0;-
5941-
5942 skip_ctlesc = ifs_cmap[CTLESC];-
5943 skip_ctlnul = ifs_cmap[CTLNUL];-
5944-
5945 nullbyte = 0;-
5946-
5947 /* Read the output of the command through the pipe. This may need to be-
5948 changed to understand multibyte characters in the future. */-
5949 while (1)-
5950 {-
5951 if (fd < 0)
fd < 0Description
TRUEnever evaluated
FALSEevaluated 31091420 times by 1 test
Evaluated by:
  • Self test
0-31091420
5952 break;
never executed: break;
0
5953 if (--bufn <= 0)
--bufn <= 0Description
TRUEevaluated 6510680 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 24580740 times by 1 test
Evaluated by:
  • Self test
6510680-24580740
5954 {-
5955 bufn = zread (fd, buf, sizeof (buf));-
5956 if (bufn <= 0)
bufn <= 0Description
TRUEevaluated 3253577 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3257103 times by 1 test
Evaluated by:
  • Self test
3253577-3257103
5957 break;
executed 3253577 times by 1 test: break;
Executed by:
  • Self test
3253577
5958 bufp = buf;-
5959 }
executed 3257103 times by 1 test: end of block
Executed by:
  • Self test
3257103
5960 c = *bufp++;-
5961-
5962 if (c == 0)
c == 0Description
TRUEnever evaluated
FALSEevaluated 27837843 times by 1 test
Evaluated by:
  • Self test
0-27837843
5963 {-
5964#if 1-
5965 if (nullbyte == 0)
nullbyte == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
5966 {-
5967 internal_warning ("%s", _("command substitution: ignored null byte in input"));-
5968 nullbyte = 1;-
5969 }
never executed: end of block
0
5970#endif-
5971 continue;
never executed: continue;
0
5972 }-
5973-
5974 /* Add the character to ISTRING, possibly after resizing it. */-
5975 RESIZE_MALLOCED_BUFFER (istring, istring_index, 2, istring_size, DEFAULT_ARRAY_SIZE);
executed 3257517 times by 1 test: istring_size += (128);
Executed by:
  • Self test
executed 3257517 times by 1 test: end of block
Executed by:
  • Self test
(istring_index...= istring_sizeDescription
TRUEevaluated 3257517 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 24580326 times by 1 test
Evaluated by:
  • Self test
(istring_index...= istring_sizeDescription
TRUEevaluated 3257517 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3257517 times by 1 test
Evaluated by:
  • Self test
3257517-24580326
5976-
5977 /* This is essentially quote_string inline */-
5978 if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) /* || c == CTLESC || c == CTLNUL */)
(quoted & (0x002|0x001))Description
TRUEevaluated 104068 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 27733775 times by 1 test
Evaluated by:
  • Self test
104068-27733775
5979 istring[istring_index++] = CTLESC;
executed 104068 times by 1 test: istring[istring_index++] = '\001';
Executed by:
  • Self test
104068
5980 else if ((flags & PF_ASSIGNRHS) && skip_ctlesc && c == CTLESC)
(flags & 0x08)Description
TRUEevaluated 14540 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 27719235 times by 1 test
Evaluated by:
  • Self test
skip_ctlescDescription
TRUEnever evaluated
FALSEevaluated 14540 times by 1 test
Evaluated by:
  • Self test
c == '\001'Description
TRUEnever evaluated
FALSEnever evaluated
0-27719235
5981 istring[istring_index++] = CTLESC;
never executed: istring[istring_index++] = '\001';
0
5982 /* Escape CTLESC and CTLNUL in the output to protect those characters-
5983 from the rest of the word expansions (word splitting and globbing.)-
5984 This is essentially quote_escapes inline. */-
5985 else if (skip_ctlesc == 0 && c == CTLESC)
skip_ctlesc == 0Description
TRUEevaluated 27733604 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 171 times by 1 test
Evaluated by:
  • Self test
c == '\001'Description
TRUEevaluated 237 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 27733367 times by 1 test
Evaluated by:
  • Self test
171-27733604
5986 {-
5987 tflag |= W_HASCTLESC;-
5988 istring[istring_index++] = CTLESC;-
5989 }
executed 237 times by 1 test: end of block
Executed by:
  • Self test
237
5990 else if ((skip_ctlnul == 0 && c == CTLNUL) || (c == ' ' && (ifs_value && *ifs_value == 0)))
skip_ctlnul == 0Description
TRUEevaluated 27733538 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
c == '\177'Description
TRUEevaluated 253 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 27733285 times by 1 test
Evaluated by:
  • Self test
c == ' 'Description
TRUEevaluated 2663488 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 25069797 times by 1 test
Evaluated by:
  • Self test
ifs_valueDescription
TRUEevaluated 2663488 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*ifs_value == 0Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2663482 times by 1 test
Evaluated by:
  • Self test
0-27733538
5991 istring[istring_index++] = CTLESC;
executed 259 times by 1 test: istring[istring_index++] = '\001';
Executed by:
  • Self test
259
5992-
5993 istring[istring_index++] = c;-
5994-
5995#if 0-
5996#if defined (__CYGWIN__)-
5997 if (c == '\n' && istring_index > 1 && istring[istring_index - 2] == '\r')-
5998 {-
5999 istring_index--;-
6000 istring[istring_index - 1] = '\n';-
6001 }-
6002#endif-
6003#endif-
6004 }
executed 27837843 times by 1 test: end of block
Executed by:
  • Self test
27837843
6005-
6006 if (istring)
istringDescription
TRUEevaluated 3253379 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 198 times by 1 test
Evaluated by:
  • Self test
198-3253379
6007 istring[istring_index] = '\0';
executed 3253379 times by 1 test: istring[istring_index] = '\0';
Executed by:
  • Self test
3253379
6008-
6009 /* If we read no output, just return now and save ourselves some-
6010 trouble. */-
6011 if (istring_index == 0)
istring_index == 0Description
TRUEevaluated 198 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3253379 times by 1 test
Evaluated by:
  • Self test
198-3253379
6012 {-
6013 FREE (istring);
never executed: sh_xfree((istring), "subst.c", 6013);
istringDescription
TRUEnever evaluated
FALSEevaluated 198 times by 1 test
Evaluated by:
  • Self test
0-198
6014 if (rflag)
rflagDescription
TRUEevaluated 198 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-198
6015 *rflag = tflag;
executed 198 times by 1 test: *rflag = tflag;
Executed by:
  • Self test
198
6016 return (char *)NULL;
executed 198 times by 1 test: return (char *) ((void *)0) ;
Executed by:
  • Self test
198
6017 }-
6018-
6019 /* Strip trailing newlines from the output of the command. */-
6020 if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
quoted & (0x002|0x001)Description
TRUEevaluated 628 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3252751 times by 1 test
Evaluated by:
  • Self test
628-3252751
6021 {-
6022 while (istring_index > 0)
istring_index > 0Description
TRUEevaluated 1224 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
13-1224
6023 {-
6024 if (istring[istring_index - 1] == '\n')
istring[istrin...x - 1] == '\n'Description
TRUEevaluated 609 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 615 times by 1 test
Evaluated by:
  • Self test
609-615
6025 {-
6026 --istring_index;-
6027-
6028 /* If the newline was quoted, remove the quoting char. */-
6029 if (istring[istring_index - 1] == CTLESC)
istring[istrin...- 1] == '\001'Description
TRUEevaluated 609 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-609
6030 --istring_index;
executed 609 times by 1 test: --istring_index;
Executed by:
  • Self test
609
6031 }
executed 609 times by 1 test: end of block
Executed by:
  • Self test
609
6032 else-
6033 break;
executed 615 times by 1 test: break;
Executed by:
  • Self test
615
6034 }-
6035 istring[istring_index] = '\0';-
6036 }
executed 628 times by 1 test: end of block
Executed by:
  • Self test
628
6037 else-
6038 strip_trailing (istring, istring_index - 1, 1);
executed 3252751 times by 1 test: strip_trailing (istring, istring_index - 1, 1);
Executed by:
  • Self test
3252751
6039-
6040 if (rflag)
rflagDescription
TRUEevaluated 3253379 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3253379
6041 *rflag = tflag;
executed 3253379 times by 1 test: *rflag = tflag;
Executed by:
  • Self test
3253379
6042 return istring;
executed 3253379 times by 1 test: return istring;
Executed by:
  • Self test
3253379
6043}-
6044-
6045/* Perform command substitution on STRING. This returns a WORD_DESC * with the-
6046 contained string possibly quoted. */-
6047WORD_DESC *-
6048command_substitute (string, quoted, flags)-
6049 char *string;-
6050 int quoted;-
6051 int flags;-
6052{-
6053 pid_t pid, old_pid, old_pipeline_pgrp, old_async_pid;-
6054 char *istring, *s;-
6055 int result, fildes[2], function_value, pflags, rc, tflag;-
6056 WORD_DESC *ret;-
6057-
6058 istring = (char *)NULL;-
6059-
6060 /* Don't fork () if there is no need to. In the case of no command to-
6061 run, just return NULL. */-
6062#if 1-
6063 for (s = string; s && *s && (shellblank (*s) || *s == '\n'); s++)
sDescription
TRUEevaluated 3277452 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*sDescription
TRUEevaluated 3277305 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 147 times by 1 test
Evaluated by:
  • Self test
(sh_syntaxtab[...*s)] & 0x2000)Description
TRUEevaluated 20409 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3256896 times by 1 test
Evaluated by:
  • Self test
*s == '\n'Description
TRUEevaluated 371 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3256525 times by 1 test
Evaluated by:
  • Self test
0-3277452
6064 ;
executed 20780 times by 1 test: ;
Executed by:
  • Self test
20780
6065 if (s == 0 || *s == 0)
s == 0Description
TRUEnever evaluated
FALSEevaluated 3256672 times by 1 test
Evaluated by:
  • Self test
*s == 0Description
TRUEevaluated 147 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3256525 times by 1 test
Evaluated by:
  • Self test
0-3256672
6066 return ((WORD_DESC *)NULL);
executed 147 times by 1 test: return ((WORD_DESC *) ((void *)0) );
Executed by:
  • Self test
147
6067#else-
6068 if (!string || !*string || (string[0] == '\n' && !string[1]))-
6069 return ((WORD_DESC *)NULL);-
6070#endif-
6071-
6072 if (wordexp_only && read_but_dont_execute)
wordexp_onlyDescription
TRUEnever evaluated
FALSEevaluated 3256525 times by 1 test
Evaluated by:
  • Self test
read_but_dont_executeDescription
TRUEnever evaluated
FALSEnever evaluated
0-3256525
6073 {-
6074 last_command_exit_value = EX_WEXPCOMSUB;-
6075 jump_to_top_level (EXITPROG);-
6076 }
never executed: end of block
0
6077-
6078 /* We're making the assumption here that the command substitution will-
6079 eventually run a command from the file system. Since we'll run-
6080 maybe_make_export_env in this subshell before executing that command,-
6081 the parent shell and any other shells it starts will have to remake-
6082 the environment. If we make it before we fork, other shells won't-
6083 have to. Don't bother if we have any temporary variable assignments,-
6084 though, because the export environment will be remade after this-
6085 command completes anyway, but do it if all the words to be expanded-
6086 are variable assignments. */-
6087 if (subst_assign_varlist == 0 || garglist == 0)
subst_assign_varlist == 0Description
TRUEevaluated 23321 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3233204 times by 1 test
Evaluated by:
  • Self test
garglist == 0Description
TRUEevaluated 3233195 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
9-3233204
6088 maybe_make_export_env (); /* XXX */
executed 3256516 times by 1 test: maybe_make_export_env ();
Executed by:
  • Self test
3256516
6089-
6090 /* Flags to pass to parse_and_execute() */-
6091 pflags = (interactive && sourcelevel == 0) ? SEVAL_RESETLINE : 0;
interactiveDescription
TRUEnever evaluated
FALSEevaluated 3256525 times by 1 test
Evaluated by:
  • Self test
sourcelevel == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-3256525
6092-
6093 old_pid = last_made_pid;-
6094-
6095 /* Pipe the output of executing STRING into the current shell. */-
6096 if (pipe (fildes) < 0)
pipe (fildes) < 0Description
TRUEnever evaluated
FALSEevaluated 3256525 times by 1 test
Evaluated by:
  • Self test
0-3256525
6097 {-
6098 sys_error ("%s", _("cannot make pipe for command substitution"));-
6099 goto error_exit;
never executed: goto error_exit;
0
6100 }-
6101-
6102#if defined (JOB_CONTROL)-
6103 old_pipeline_pgrp = pipeline_pgrp;-
6104 /* Don't reset the pipeline pgrp if we're already a subshell in a pipeline. */-
6105 if ((subshell_environment & SUBSHELL_PIPE) == 0)
(subshell_envi...t & 0x10) == 0Description
TRUEevaluated 3256517 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
8-3256517
6106 pipeline_pgrp = shell_pgrp;
executed 3256517 times by 1 test: pipeline_pgrp = shell_pgrp;
Executed by:
  • Self test
3256517
6107 cleanup_the_pipeline ();-
6108#endif /* JOB_CONTROL */-
6109-
6110 old_async_pid = last_asynchronous_pid;-
6111 pid = make_child ((char *)NULL, subshell_environment&SUBSHELL_ASYNC);-
6112 last_asynchronous_pid = old_async_pid;-
6113-
6114 if (pid == 0)
pid == 0Description
TRUEevaluated 2948 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3253577 times by 1 test
Evaluated by:
  • Self test
2948-3253577
6115 {-
6116 /* Reset the signal handlers in the child, but don't free the-
6117 trap strings. Set a flag noting that we have to free the-
6118 trap strings if we run trap to change a signal disposition. */-
6119 reset_signal_handlers ();-
6120 if (ISINTERRUPT)
interrupt_state != 0Description
TRUEnever evaluated
FALSEevaluated 2948 times by 1 test
Evaluated by:
  • Self test
0-2948
6121 {-
6122 kill (getpid (), SIGINT);-
6123 CLRINTERRUPT; /* if we're ignoring SIGINT somehow */-
6124 }
never executed: end of block
0
6125 QUIT; /* catch any interrupts we got post-fork */
never executed: termsig_handler (terminating_signal);
never executed: throw_to_top_level ();
terminating_signalDescription
TRUEnever evaluated
FALSEevaluated 2948 times by 1 test
Evaluated by:
  • Self test
interrupt_stateDescription
TRUEnever evaluated
FALSEevaluated 2948 times by 1 test
Evaluated by:
  • Self test
0-2948
6126 subshell_environment |= SUBSHELL_RESETTRAP;-
6127 }
executed 2948 times by 1 test: end of block
Executed by:
  • Self test
2948
6128-
6129#if defined (JOB_CONTROL)-
6130 /* XXX DO THIS ONLY IN PARENT ? XXX */-
6131 set_sigchld_handler ();-
6132 stop_making_children ();-
6133 if (pid != 0)
pid != 0Description
TRUEevaluated 3253577 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2948 times by 1 test
Evaluated by:
  • Self test
2948-3253577
6134 pipeline_pgrp = old_pipeline_pgrp;
executed 3253577 times by 1 test: pipeline_pgrp = old_pipeline_pgrp;
Executed by:
  • Self test
3253577
6135#else-
6136 stop_making_children ();-
6137#endif /* JOB_CONTROL */-
6138-
6139 if (pid < 0)
pid < 0Description
TRUEnever evaluated
FALSEevaluated 3256525 times by 1 test
Evaluated by:
  • Self test
0-3256525
6140 {-
6141 sys_error (_("cannot make child for command substitution"));-
6142 error_exit:
code before this statement never executed: error_exit:
0
6143-
6144 last_made_pid = old_pid;-
6145-
6146 FREE (istring);
never executed: sh_xfree((istring), "subst.c", 6146);
istringDescription
TRUEnever evaluated
FALSEnever evaluated
0
6147 close (fildes[0]);-
6148 close (fildes[1]);-
6149 return ((WORD_DESC *)NULL);
never executed: return ((WORD_DESC *) ((void *)0) );
0
6150 }-
6151-
6152 if (pid == 0)
pid == 0Description
TRUEevaluated 2948 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3253577 times by 1 test
Evaluated by:
  • Self test
2948-3253577
6153 {-
6154 /* The currently executing shell is not interactive. */-
6155 interactive = 0;-
6156-
6157 set_sigint_handler (); /* XXX */-
6158-
6159 free_pushed_string_input ();-
6160-
6161 /* Discard buffered stdio output before replacing the underlying file-
6162 descriptor. */-
6163 fpurge (stdout);-
6164-
6165 if (dup2 (fildes[1], 1) < 0)
dup2 (fildes[1], 1) < 0Description
TRUEnever evaluated
FALSEevaluated 2948 times by 1 test
Evaluated by:
  • Self test
0-2948
6166 {-
6167 sys_error ("%s", _("command_substitute: cannot duplicate pipe as fd 1"));-
6168 exit (EXECUTION_FAILURE);
never executed: exit (1);
0
6169 }-
6170-
6171 /* If standard output is closed in the parent shell-
6172 (such as after `exec >&-'), file descriptor 1 will be-
6173 the lowest available file descriptor, and end up in-
6174 fildes[0]. This can happen for stdin and stderr as well,-
6175 but stdout is more important -- it will cause no output-
6176 to be generated from this command. */-
6177 if ((fildes[1] != fileno (stdin)) &&
(fildes[1] != ...eno ( stdin ))Description
TRUEevaluated 2948 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2948
6178 (fildes[1] != fileno (stdout)) &&
(fildes[1] != ...no ( stdout ))Description
TRUEevaluated 2948 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2948
6179 (fildes[1] != fileno (stderr)))
(fildes[1] != ...no ( stderr ))Description
TRUEevaluated 2948 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2948
6180 close (fildes[1]);
executed 2948 times by 1 test: close (fildes[1]);
Executed by:
  • Self test
2948
6181-
6182 if ((fildes[0] != fileno (stdin)) &&
(fildes[0] != ...eno ( stdin ))Description
TRUEevaluated 2948 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2948
6183 (fildes[0] != fileno (stdout)) &&
(fildes[0] != ...no ( stdout ))Description
TRUEevaluated 2948 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2948
6184 (fildes[0] != fileno (stderr)))
(fildes[0] != ...no ( stderr ))Description
TRUEevaluated 2938 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
10-2938
6185 close (fildes[0]);
executed 2938 times by 1 test: close (fildes[0]);
Executed by:
  • Self test
2938
6186-
6187#ifdef __CYGWIN__-
6188 /* Let stdio know the fd may have changed from text to binary mode, and-
6189 make sure to preserve stdout line buffering. */-
6190 freopen (NULL, "w", stdout);-
6191 sh_setlinebuf (stdout);-
6192#endif /* __CYGWIN__ */-
6193-
6194 /* This is a subshell environment. */-
6195 subshell_environment |= SUBSHELL_COMSUB;-
6196-
6197 /* Many shells do not appear to inherit the -v option for command-
6198 substitutions. */-
6199 change_flag ('v', FLAG_OFF);-
6200-
6201 /* When inherit_errexit option is not enabled, command substitution does-
6202 not inherit the -e flag. It is enabled when Posix mode is enabled */-
6203 if (inherit_errexit == 0)
inherit_errexit == 0Description
TRUEevaluated 2923 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 25 times by 1 test
Evaluated by:
  • Self test
25-2923
6204 {-
6205 builtin_ignoring_errexit = 0;-
6206 change_flag ('e', FLAG_OFF);-
6207 }
executed 2923 times by 1 test: end of block
Executed by:
  • Self test
2923
6208 set_shellopts ();-
6209-
6210 /* If we are expanding a redirection, we can dispose of any temporary-
6211 environment we received, since redirections are not supposed to have-
6212 access to the temporary environment. We will have to see whether this-
6213 affects temporary environments supplied to `eval', but the temporary-
6214 environment gets copied to builtin_env at some point. */-
6215 if (expanding_redir)
expanding_redirDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2937 times by 1 test
Evaluated by:
  • Self test
11-2937
6216 {-
6217 flush_temporary_env ();-
6218 expanding_redir = 0;-
6219 }
executed 11 times by 1 test: end of block
Executed by:
  • Self test
11
6220-
6221 remove_quoted_escapes (string);-
6222-
6223 startup_state = 2; /* see if we can avoid a fork */-
6224 parse_and_execute_level = 0;-
6225-
6226 /* Give command substitution a place to jump back to on failure,-
6227 so we don't go back up to main (). */-
6228 result = setjmp_nosigs (top_level);-
6229-
6230 /* If we're running a command substitution inside a shell function,-
6231 trap `return' so we don't return from the function in the subshell-
6232 and go off to never-never land. */-
6233 if (result == 0 && return_catch_flag)
result == 0Description
TRUEevaluated 2948 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
return_catch_flagDescription
TRUEevaluated 2360 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 588 times by 1 test
Evaluated by:
  • Self test
2-2948
6234 function_value = setjmp_nosigs (return_catch);
executed 2360 times by 1 test: function_value = __sigsetjmp ( (return_catch) , 0 ) ;
Executed by:
  • Self test
2360
6235 else-
6236 function_value = 0;
executed 590 times by 1 test: function_value = 0;
Executed by:
  • Self test
590
6237-
6238 if (result == ERREXIT)
result == 4Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2948 times by 1 test
Evaluated by:
  • Self test
2-2948
6239 rc = last_command_exit_value;
executed 2 times by 1 test: rc = last_command_exit_value;
Executed by:
  • Self test
2
6240 else if (result == EXITPROG)
result == 3Description
TRUEnever evaluated
FALSEevaluated 2948 times by 1 test
Evaluated by:
  • Self test
0-2948
6241 rc = last_command_exit_value;
never executed: rc = last_command_exit_value;
0
6242 else if (result)
resultDescription
TRUEnever evaluated
FALSEevaluated 2948 times by 1 test
Evaluated by:
  • Self test
0-2948
6243 rc = EXECUTION_FAILURE;
never executed: rc = 1;
0
6244 else if (function_value)
function_valueDescription
TRUEnever evaluated
FALSEevaluated 2948 times by 1 test
Evaluated by:
  • Self test
0-2948
6245 rc = return_catch_value;
never executed: rc = return_catch_value;
0
6246 else-
6247 {-
6248 subshell_level++;-
6249 rc = parse_and_execute (string, "command substitution", pflags|SEVAL_NOHIST);-
6250 /* leave subshell level intact for any exit trap */-
6251 }
executed 1348 times by 1 test: end of block
Executed by:
  • Self test
1348
6252-
6253 last_command_exit_value = rc;-
6254 rc = run_exit_trap ();-
6255#if defined (PROCESS_SUBSTITUTION)-
6256 unlink_fifo_list ();-
6257#endif-
6258 exit (rc);
executed 1350 times by 1 test: exit (rc);
Executed by:
  • Self test
1350
6259 }-
6260 else-
6261 {-
6262#if defined (JOB_CONTROL) && defined (PGRP_PIPE)-
6263 close_pgrp_pipe ();-
6264#endif /* JOB_CONTROL && PGRP_PIPE */-
6265-
6266 close (fildes[1]);-
6267-
6268 tflag = 0;-
6269 istring = read_comsub (fildes[0], quoted, flags, &tflag);-
6270-
6271 close (fildes[0]);-
6272-
6273 current_command_subst_pid = pid;-
6274 last_command_exit_value = wait_for (pid);-
6275 last_command_subst_pid = pid;-
6276 last_made_pid = old_pid;-
6277-
6278#if defined (JOB_CONTROL)-
6279 /* If last_command_exit_value > 128, then the substituted command-
6280 was terminated by a signal. If that signal was SIGINT, then send-
6281 SIGINT to ourselves. This will break out of loops, for instance. */-
6282 if (last_command_exit_value == (128 + SIGINT) && last_command_exit_signal == SIGINT)
last_command_e... == (128 + 2 )Description
TRUEnever evaluated
FALSEevaluated 3253577 times by 1 test
Evaluated by:
  • Self test
last_command_exit_signal == 2Description
TRUEnever evaluated
FALSEnever evaluated
0-3253577
6283 kill (getpid (), SIGINT);
never executed: kill (getpid (), 2 );
0
6284-
6285 /* wait_for gives the terminal back to shell_pgrp. If some other-
6286 process group should have it, give it away to that group here.-
6287 pipeline_pgrp is non-zero only while we are constructing a-
6288 pipeline, so what we are concerned about is whether or not that-
6289 pipeline was started in the background. A pipeline started in-
6290 the background should never get the tty back here. We duplicate-
6291 the conditions that wait_for tests to make sure we only give-
6292 the terminal back to pipeline_pgrp under the conditions that wait_for-
6293 gave it to shell_pgrp. If wait_for doesn't mess with the terminal-
6294 pgrp, we should not either. */-
6295 if (interactive && pipeline_pgrp != (pid_t)0 && running_in_background == 0 &&
interactiveDescription
TRUEnever evaluated
FALSEevaluated 3253577 times by 1 test
Evaluated by:
  • Self test
pipeline_pgrp != (pid_t)0Description
TRUEnever evaluated
FALSEnever evaluated
running_in_background == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-3253577
6296 (subshell_environment & (SUBSHELL_ASYNC|SUBSHELL_PIPE)) == 0)
(subshell_envi...01|0x10)) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
6297 give_terminal_to (pipeline_pgrp, 0);
never executed: give_terminal_to (pipeline_pgrp, 0);
0
6298#endif /* JOB_CONTROL */-
6299-
6300 ret = alloc_word_desc ();-
6301 ret->word = istring;-
6302 ret->flags = tflag;-
6303-
6304 return ret;
executed 3253577 times by 1 test: return ret;
Executed by:
  • Self test
3253577
6305 }-
6306}-
6307-
6308/********************************************************-
6309 * *-
6310 * Utility functions for parameter expansion *-
6311 * *-
6312 ********************************************************/-
6313-
6314#if defined (ARRAY_VARS)-
6315-
6316static arrayind_t-
6317array_length_reference (s)-
6318 char *s;-
6319{-
6320 int len;-
6321 arrayind_t ind;-
6322 char *akey;-
6323 char *t, c;-
6324 ARRAY *array;-
6325 HASH_TABLE *h;-
6326 SHELL_VAR *var;-
6327-
6328 var = array_variable_part (s, 0, &t, &len);-
6329-
6330 /* If unbound variables should generate an error, report one and return-
6331 failure. */-
6332 if ((var == 0 || invisible_p (var) || (assoc_p (var) == 0 && array_p (var) == 0)) && unbound_vars_is_error)
var == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 264 times by 1 test
Evaluated by:
  • Self test
((((var)->attr... (0x0001000)))Description
TRUEnever evaluated
FALSEevaluated 264 times by 1 test
Evaluated by:
  • Self test
((((var)->attr...000040))) == 0Description
TRUEevaluated 252 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test
((((var)->attr...000004))) == 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 248 times by 1 test
Evaluated by:
  • Self test
unbound_vars_is_errorDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
0-264
6333 {-
6334 c = *--t;-
6335 *t = '\0';-
6336 last_command_exit_value = EXECUTION_FAILURE;-
6337 err_unboundvar (s);-
6338 *t = c;-
6339 return (-1);
executed 1 time by 1 test: return (-1);
Executed by:
  • Self test
1
6340 }-
6341 else if (var == 0 || invisible_p (var))
var == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 264 times by 1 test
Evaluated by:
  • Self test
((((var)->attr... (0x0001000)))Description
TRUEnever evaluated
FALSEevaluated 264 times by 1 test
Evaluated by:
  • Self test
0-264
6342 return 0;
executed 1 time by 1 test: return 0;
Executed by:
  • Self test
1
6343-
6344 /* We support a couple of expansions for variables that are not arrays.-
6345 We'll return the length of the value for v[0], and 1 for v[@] or-
6346 v[*]. Return 0 for everything else. */-
6347-
6348 array = array_p (var) ? array_cell (var) : (ARRAY *)NULL;
((((var)->attr... (0x0000004)))Description
TRUEevaluated 248 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16 times by 1 test
Evaluated by:
  • Self test
16-248
6349 h = assoc_p (var) ? assoc_cell (var) : (HASH_TABLE *)NULL;
((((var)->attr... (0x0000040)))Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 252 times by 1 test
Evaluated by:
  • Self test
12-252
6350-
6351 if (ALL_ELEMENT_SUB (t[0]) && t[1] == RBRACK)
(t[0]) == '@'Description
TRUEevaluated 229 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 35 times by 1 test
Evaluated by:
  • Self test
(t[0]) == '*'Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 26 times by 1 test
Evaluated by:
  • Self test
t[1] == ']'Description
TRUEevaluated 238 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-238
6352 {-
6353 if (assoc_p (var))
((((var)->attr... (0x0000040)))Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 228 times by 1 test
Evaluated by:
  • Self test
10-228
6354 return (h ? assoc_num_elements (h) : 0);
executed 10 times by 1 test: return (h ? ((h)->nentries) : 0);
Executed by:
  • Self test
10
6355 else if (array_p (var))
((((var)->attr... (0x0000004)))Description
TRUEevaluated 226 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2-226
6356 return (array ? array_num_elements (array) : 0);
executed 226 times by 1 test: return (array ? ((array)->num_elements) : 0);
Executed by:
  • Self test
226
6357 else-
6358 return (var_isset (var) ? 1 : 0);
executed 2 times by 1 test: return (((var)->value != 0) ? 1 : 0);
Executed by:
  • Self test
2
6359 }-
6360-
6361 if (assoc_p (var))
((((var)->attr... (0x0000040)))Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 24 times by 1 test
Evaluated by:
  • Self test
2-24
6362 {-
6363 t[len - 1] = '\0';-
6364 akey = expand_assignment_string_to_string (t, 0); /* [ */-
6365 t[len - 1] = RBRACK;-
6366 if (akey == 0 || *akey == 0)
akey == 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
*akey == 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
0-2
6367 {-
6368 err_badarraysub (t);-
6369 FREE (akey);
never executed: sh_xfree((akey), "subst.c", 6369);
akeyDescription
TRUEnever evaluated
FALSEnever evaluated
0
6370 return (-1);
never executed: return (-1);
0
6371 }-
6372 t = assoc_reference (assoc_cell (var), akey);-
6373 free (akey);-
6374 }
executed 2 times by 1 test: end of block
Executed by:
  • Self test
2
6375 else-
6376 {-
6377 ind = array_expand_index (var, t, len, 0);-
6378 /* negative subscripts to indexed arrays count back from end */-
6379 if (var && array_p (var) && ind < 0)
varDescription
TRUEevaluated 24 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((((var)->attr... (0x0000004)))Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
ind < 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 21 times by 1 test
Evaluated by:
  • Self test
0-24
6380 ind = array_max_index (array_cell (var)) + 1 + ind;
executed 1 time by 1 test: ind = (((ARRAY *)((var)->value))->max_index) + 1 + ind;
Executed by:
  • Self test
1
6381 if (ind < 0)
ind < 0Description
TRUEnever evaluated
FALSEevaluated 24 times by 1 test
Evaluated by:
  • Self test
0-24
6382 {-
6383 err_badarraysub (t);-
6384 return (-1);
never executed: return (-1);
0
6385 }-
6386 if (array_p (var))
((((var)->attr... (0x0000004)))Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2-22
6387 t = array_reference (array, ind);
executed 22 times by 1 test: t = array_reference (array, ind);
Executed by:
  • Self test
22
6388 else-
6389 t = (ind == 0) ? value_cell (var) : (char *)NULL;
executed 2 times by 1 test: t = (ind == 0) ? ((var)->value) : (char *) ((void *)0) ;
Executed by:
  • Self test
(ind == 0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
6390 }-
6391-
6392 len = MB_STRLEN (t);
( (__ctype_get...r_max ()) > 1)Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(t)[1]Description
TRUEevaluated 25 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(t)[1]Description
TRUEnever evaluated
FALSEnever evaluated
(t)[2]Description
TRUEnever evaluated
FALSEnever evaluated
(t)Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(t)[0]Description
TRUEevaluated 25 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
(t)Description
TRUEnever evaluated
FALSEnever evaluated
(t)[0]Description
TRUEnever evaluated
FALSEnever evaluated
0-26
6393 return (len);
executed 26 times by 1 test: return (len);
Executed by:
  • Self test
26
6394}-
6395#endif /* ARRAY_VARS */-
6396-
6397static int-
6398valid_brace_expansion_word (name, var_is_special)-
6399 char *name;-
6400 int var_is_special;-
6401{-
6402 if (DIGIT (*name) && all_digits (name))
(*name) >= '0'Description
TRUEevaluated 2369043 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 414 times by 1 test
Evaluated by:
  • Self test
(*name) <= '9'Description
TRUEevaluated 14868 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2354175 times by 1 test
Evaluated by:
  • Self test
all_digits (name)Description
TRUEevaluated 14867 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-2369043
6403 return 1;
executed 14867 times by 1 test: return 1;
Executed by:
  • Self test
14867
6404 else if (var_is_special)
var_is_specialDescription
TRUEevaluated 797 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2353793 times by 1 test
Evaluated by:
  • Self test
797-2353793
6405 return 1;
executed 797 times by 1 test: return 1;
Executed by:
  • Self test
797
6406#if defined (ARRAY_VARS)-
6407 else if (valid_array_reference (name, 0))
valid_array_re...ence (name, 0)Description
TRUEevaluated 5915 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2347878 times by 1 test
Evaluated by:
  • Self test
5915-2347878
6408 return 1;
executed 5915 times by 1 test: return 1;
Executed by:
  • Self test
5915
6409#endif /* ARRAY_VARS */-
6410 else if (legal_identifier (name))
legal_identifier (name)Description
TRUEevaluated 2347838 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 40 times by 1 test
Evaluated by:
  • Self test
40-2347838
6411 return 1;
executed 2347838 times by 1 test: return 1;
Executed by:
  • Self test
2347838
6412 else-
6413 return 0;
executed 40 times by 1 test: return 0;
Executed by:
  • Self test
40
6414}-
6415-
6416static int-
6417chk_atstar (name, quoted, quoted_dollar_atp, contains_dollar_at)-
6418 char *name;-
6419 int quoted;-
6420 int *quoted_dollar_atp, *contains_dollar_at;-
6421{-
6422 char *temp1;-
6423-
6424 if (name == 0)
name == 0Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5981 times by 1 test
Evaluated by:
  • Self test
13-5981
6425 {-
6426 if (quoted_dollar_atp)
quoted_dollar_atpDescription
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-13
6427 *quoted_dollar_atp = 0;
executed 13 times by 1 test: *quoted_dollar_atp = 0;
Executed by:
  • Self test
13
6428 if (contains_dollar_at)
contains_dollar_atDescription
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-13
6429 *contains_dollar_at = 0;
executed 13 times by 1 test: *contains_dollar_at = 0;
Executed by:
  • Self test
13
6430 return 0;
executed 13 times by 1 test: return 0;
Executed by:
  • Self test
13
6431 }-
6432-
6433 /* check for $@ and $* */-
6434 if (name[0] == '@' && name[1] == 0)
name[0] == '@'Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5961 times by 1 test
Evaluated by:
  • Self test
name[1] == 0Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-5961
6435 {-
6436 if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && quoted_dollar_atp)
(quoted & (0x002|0x001))Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
quoted_dollar_atpDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-10
6437 *quoted_dollar_atp = 1;
executed 10 times by 1 test: *quoted_dollar_atp = 1;
Executed by:
  • Self test
10
6438 if (contains_dollar_at)
contains_dollar_atDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-20
6439 *contains_dollar_at = 1;
executed 20 times by 1 test: *contains_dollar_at = 1;
Executed by:
  • Self test
20
6440 return 1;
executed 20 times by 1 test: return 1;
Executed by:
  • Self test
20
6441 }-
6442 else if (name[0] == '*' && name[1] == '\0' && quoted == 0)
name[0] == '*'Description
TRUEnever evaluated
FALSEevaluated 5961 times by 1 test
Evaluated by:
  • Self test
name[1] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
quoted == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-5961
6443 {-
6444 if (contains_dollar_at)
contains_dollar_atDescription
TRUEnever evaluated
FALSEnever evaluated
0
6445 *contains_dollar_at = 1;
never executed: *contains_dollar_at = 1;
0
6446 return 1;
never executed: return 1;
0
6447 }-
6448-
6449 /* Now check for ${array[@]} and ${array[*]} */-
6450#if defined (ARRAY_VARS)-
6451 else if (valid_array_reference (name, 0))
valid_array_re...ence (name, 0)Description
TRUEevaluated 5904 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 57 times by 1 test
Evaluated by:
  • Self test
57-5904
6452 {-
6453 temp1 = mbschr (name, LBRACK);-
6454 if (temp1 && temp1[1] == '@' && temp1[2] == RBRACK)
temp1Description
TRUEevaluated 5904 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
temp1[1] == '@'Description
TRUEevaluated 665 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5239 times by 1 test
Evaluated by:
  • Self test
temp1[2] == ']'Description
TRUEevaluated 665 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-5904
6455 {-
6456 if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && quoted_dollar_atp)
(quoted & (0x002|0x001))Description
TRUEevaluated 234 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 431 times by 1 test
Evaluated by:
  • Self test
quoted_dollar_atpDescription
TRUEevaluated 234 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-431
6457 *quoted_dollar_atp = 1;
executed 234 times by 1 test: *quoted_dollar_atp = 1;
Executed by:
  • Self test
234
6458 if (contains_dollar_at)
contains_dollar_atDescription
TRUEevaluated 665 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-665
6459 *contains_dollar_at = 1;
executed 665 times by 1 test: *contains_dollar_at = 1;
Executed by:
  • Self test
665
6460 return 1;
executed 665 times by 1 test: return 1;
Executed by:
  • Self test
665
6461 }-
6462 /* ${array[*]}, when unquoted, should be treated like ${array[@]},-
6463 which should result in separate words even when IFS is unset. */-
6464 if (temp1 && temp1[1] == '*' && temp1[2] == RBRACK && quoted == 0)
temp1Description
TRUEevaluated 5239 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
temp1[1] == '*'Description
TRUEevaluated 156 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5083 times by 1 test
Evaluated by:
  • Self test
temp1[2] == ']'Description
TRUEevaluated 156 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
quoted == 0Description
TRUEevaluated 102 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 54 times by 1 test
Evaluated by:
  • Self test
0-5239
6465 {-
6466 if (contains_dollar_at)
contains_dollar_atDescription
TRUEevaluated 102 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-102
6467 *contains_dollar_at = 1;
executed 102 times by 1 test: *contains_dollar_at = 1;
Executed by:
  • Self test
102
6468 return 1;
executed 102 times by 1 test: return 1;
Executed by:
  • Self test
102
6469 }-
6470 }
executed 5137 times by 1 test: end of block
Executed by:
  • Self test
5137
6471#endif-
6472 return 0;
executed 5194 times by 1 test: return 0;
Executed by:
  • Self test
5194
6473}-
6474-
6475/* Parameter expand NAME, and return a new string which is the expansion,-
6476 or NULL if there was no expansion. NAME is as given in ${NAMEcWORD}.-
6477 VAR_IS_SPECIAL is non-zero if NAME is one of the special variables in-
6478 the shell, e.g., "@", "$", "*", etc. QUOTED, if non-zero, means that-
6479 NAME was found inside of a double-quoted expression. */-
6480static WORD_DESC *-
6481parameter_brace_expand_word (name, var_is_special, quoted, pflags, indp)-
6482 char *name;-
6483 int var_is_special, quoted, pflags;-
6484 arrayind_t *indp;-
6485{-
6486 WORD_DESC *ret;-
6487 char *temp, *tt;-
6488 intmax_t arg_index;-
6489 SHELL_VAR *var;-
6490 int atype, rflags;-
6491 arrayind_t ind;-
6492-
6493 ret = 0;-
6494 temp = 0;-
6495 rflags = 0;-
6496-
6497 if (indp)
indpDescription
TRUEevaluated 2369206 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 208 times by 1 test
Evaluated by:
  • Self test
208-2369206
6498 *indp = INTMAX_MIN;
executed 2369206 times by 1 test: *indp = (-9223372036854775807L -1) ;
Executed by:
  • Self test
2369206
6499-
6500 /* Handle multiple digit arguments, as in ${11}. */ -
6501 if (legal_number (name, &arg_index))
legal_number (...e, &arg_index)Description
TRUEevaluated 14867 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2354547 times by 1 test
Evaluated by:
  • Self test
14867-2354547
6502 {-
6503 tt = get_dollar_var_value (arg_index);-
6504 if (tt)
ttDescription
TRUEevaluated 14627 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 240 times by 1 test
Evaluated by:
  • Self test
240-14627
6505 temp = (*tt && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)))
executed 14627 times by 1 test: temp = (*tt && (quoted & (0x001|0x002))) ? quote_string (tt) : quote_escapes (tt);
Executed by:
  • Self test
*ttDescription
TRUEevaluated 14609 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 18 times by 1 test
Evaluated by:
  • Self test
(quoted & (0x001|0x002))Description
TRUEevaluated 14244 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 365 times by 1 test
Evaluated by:
  • Self test
18-14627
6506 ? quote_string (tt)
executed 14627 times by 1 test: temp = (*tt && (quoted & (0x001|0x002))) ? quote_string (tt) : quote_escapes (tt);
Executed by:
  • Self test
14627
6507 : quote_escapes (tt);
executed 14627 times by 1 test: temp = (*tt && (quoted & (0x001|0x002))) ? quote_string (tt) : quote_escapes (tt);
Executed by:
  • Self test
14627
6508 else-
6509 temp = (char *)NULL;
executed 240 times by 1 test: temp = (char *) ((void *)0) ;
Executed by:
  • Self test
240
6510 FREE (tt);
executed 14627 times by 1 test: sh_xfree((tt), "subst.c", 6510);
Executed by:
  • Self test
ttDescription
TRUEevaluated 14627 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 240 times by 1 test
Evaluated by:
  • Self test
240-14627
6511 }
executed 14867 times by 1 test: end of block
Executed by:
  • Self test
14867
6512 else if (var_is_special) /* ${@} */
var_is_specialDescription
TRUEevaluated 797 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2353750 times by 1 test
Evaluated by:
  • Self test
797-2353750
6513 {-
6514 int sindex;-
6515 tt = (char *)xmalloc (2 + strlen (name));-
6516 tt[sindex = 0] = '$';-
6517 strcpy (tt + 1, name);-
6518-
6519 ret = param_expand (tt, &sindex, quoted, (int *)NULL, (int *)NULL,-
6520 (int *)NULL, (int *)NULL, pflags);-
6521 free (tt);-
6522 }
executed 797 times by 1 test: end of block
Executed by:
  • Self test
797
6523#if defined (ARRAY_VARS)-
6524 else if (valid_array_reference (name, 0))
valid_array_re...ence (name, 0)Description
TRUEevaluated 5936 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2347814 times by 1 test
Evaluated by:
  • Self test
5936-2347814
6525 {-
6526expand_arrayref:-
6527 var = array_variable_part (name, 0, &tt, (int *)0);-
6528 /* These are the cases where word splitting will not be performed */-
6529 if (pflags & PF_ASSIGNRHS)
pflags & 0x08Description
TRUEevaluated 56 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5884 times by 1 test
Evaluated by:
  • Self test
56-5884
6530 {-
6531 if (ALL_ELEMENT_SUB (tt[0]) && tt[1] == RBRACK)
(tt[0]) == '@'Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 45 times by 1 test
Evaluated by:
  • Self test
(tt[0]) == '*'Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 34 times by 1 test
Evaluated by:
  • Self test
tt[1] == ']'Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-45
6532 {-
6533 /* Only treat as double quoted if array variable */-
6534 if (var && (array_p (var) || assoc_p (var)))
varDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((((var)->attr... (0x0000004)))Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
((((var)->attr... (0x0000040)))Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-22
6535 /* XXX - bash-4.4/bash-5.0 pass AV_ASSIGNRHS */-
6536 temp = array_value (name, quoted|Q_DOUBLE_QUOTES, AV_ASSIGNRHS, &atype, &ind);
executed 21 times by 1 test: temp = array_value (name, quoted|0x001, 0x010, &atype, &ind);
Executed by:
  • Self test
21
6537 else -
6538 temp = array_value (name, quoted, 0, &atype, &ind);
executed 1 time by 1 test: temp = array_value (name, quoted, 0, &atype, &ind);
Executed by:
  • Self test
1
6539 }-
6540 else-
6541 temp = array_value (name, quoted, 0, &atype, &ind);
executed 34 times by 1 test: temp = array_value (name, quoted, 0, &atype, &ind);
Executed by:
  • Self test
34
6542 }-
6543 /* Posix interp 888 */-
6544 else if (pflags & PF_NOSPLIT2)
pflags & 0x04Description
TRUEevaluated 19 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5865 times by 1 test
Evaluated by:
  • Self test
19-5865
6545 {-
6546 /* Special cases, then general case, for each of A[@], A[*], A[n] */-
6547#if defined (HANDLE_MULTIBYTE)-
6548 if (tt[0] == '@' && tt[1] == RBRACK && var && quoted == 0 && ifs_is_set && ifs_is_null == 0 && ifs_firstc[0] != ' ')
tt[0] == '@'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 15 times by 1 test
Evaluated by:
  • Self test
tt[1] == ']'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
varDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
quoted == 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
ifs_is_setDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
ifs_is_null == 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
ifs_firstc[0] != ' 'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
0-15
6549#else-
6550 if (tt[0] == '@' && tt[1] == RBRACK && var && quoted == 0 && ifs_is_set && ifs_is_null == 0 && ifs_firstc != ' ')-
6551#endif-
6552 temp = array_value (name, Q_DOUBLE_QUOTES, AV_ASSIGNRHS, &atype, &ind);
executed 1 time by 1 test: temp = array_value (name, 0x001, 0x010, &atype, &ind);
Executed by:
  • Self test
1
6553 else if (tt[0] == '@' && tt[1] == RBRACK)
tt[0] == '@'Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 15 times by 1 test
Evaluated by:
  • Self test
tt[1] == ']'Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-15
6554 temp = array_value (name, quoted, 0, &atype, &ind);
executed 3 times by 1 test: temp = array_value (name, quoted, 0, &atype, &ind);
Executed by:
  • Self test
3
6555 else if (tt[0] == '*' && tt[1] == RBRACK && expand_no_split_dollar_star && ifs_is_null)
tt[0] == '*'Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
tt[1] == ']'Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
expand_no_split_dollar_starDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
ifs_is_nullDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
0-8
6556 temp = array_value (name, Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT, 0, &atype, &ind);
executed 1 time by 1 test: temp = array_value (name, 0x001|0x002, 0, &atype, &ind);
Executed by:
  • Self test
1
6557 else if (tt[0] == '*' && tt[1] == RBRACK)
tt[0] == '*'Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
tt[1] == ']'Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
6558 temp = array_value (name, quoted, 0, &atype, &ind);
executed 7 times by 1 test: temp = array_value (name, quoted, 0, &atype, &ind);
Executed by:
  • Self test
7
6559 else-
6560 temp = array_value (name, quoted, 0, &atype, &ind);
executed 7 times by 1 test: temp = array_value (name, quoted, 0, &atype, &ind);
Executed by:
  • Self test
7
6561 } -
6562 else if (tt[0] == '*' && tt[1] == RBRACK && expand_no_split_dollar_star && ifs_is_null)
tt[0] == '*'Description
TRUEevaluated 137 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5728 times by 1 test
Evaluated by:
  • Self test
tt[1] == ']'Description
TRUEevaluated 137 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
expand_no_split_dollar_starDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 130 times by 1 test
Evaluated by:
  • Self test
ifs_is_nullDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
0-5728
6563 temp = array_value (name, Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT, 0, &atype, &ind);
executed 1 time by 1 test: temp = array_value (name, 0x001|0x002, 0, &atype, &ind);
Executed by:
  • Self test
1
6564 else-
6565 temp = array_value (name, quoted, 0, &atype, &ind);
executed 5864 times by 1 test: temp = array_value (name, quoted, 0, &atype, &ind);
Executed by:
  • Self test
5864
6566 if (atype == 0 && temp)
atype == 0Description
TRUEevaluated 5107 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 821 times by 1 test
Evaluated by:
  • Self test
tempDescription
TRUEevaluated 4634 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 473 times by 1 test
Evaluated by:
  • Self test
473-5107
6567 {-
6568 temp = (*temp && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)))
*tempDescription
TRUEevaluated 4618 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16 times by 1 test
Evaluated by:
  • Self test
(quoted & (0x001|0x002))Description
TRUEevaluated 4079 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 539 times by 1 test
Evaluated by:
  • Self test
16-4618
6569 ? quote_string (temp)-
6570 : quote_escapes (temp);-
6571 rflags |= W_ARRAYIND;-
6572 if (indp)
indpDescription
TRUEevaluated 4610 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 24 times by 1 test
Evaluated by:
  • Self test
24-4610
6573 *indp = ind;
executed 4610 times by 1 test: *indp = ind;
Executed by:
  • Self test
4610
6574 }
executed 4634 times by 1 test: end of block
Executed by:
  • Self test
4634
6575 else if (atype == 1 && temp && QUOTED_NULL (temp) && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)))
atype == 1Description
TRUEevaluated 156 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1138 times by 1 test
Evaluated by:
  • Self test
tempDescription
TRUEevaluated 156 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(temp)[0] == '\177'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 155 times by 1 test
Evaluated by:
  • Self test
(temp)[1] == '\0'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(quoted & (0x001|0x002))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1138
6576 rflags |= W_HASQUOTEDNULL;
executed 1 time by 1 test: rflags |= 0x040000;
Executed by:
  • Self test
1
6577 }
executed 5928 times by 1 test: end of block
Executed by:
  • Self test
5928
6578#endif-
6579 else if (var = find_variable (name))
var = find_variable (name)Description
TRUEevaluated 2340452 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7362 times by 1 test
Evaluated by:
  • Self test
7362-2340452
6580 {-
6581 if (var_isset (var) && invisible_p (var) == 0)
((var)->value != 0)Description
TRUEevaluated 2340446 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
((((var)->attr...001000))) == 0Description
TRUEevaluated 2340408 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 38 times by 1 test
Evaluated by:
  • Self test
6-2340446
6582 {-
6583#if defined (ARRAY_VARS)-
6584 if (assoc_p (var))
((((var)->attr... (0x0000040)))Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2340402 times by 1 test
Evaluated by:
  • Self test
6-2340402
6585 temp = assoc_reference (assoc_cell (var), "0");
executed 6 times by 1 test: temp = assoc_reference ((HASH_TABLE *)((var)->value), "0");
Executed by:
  • Self test
6
6586 else if (array_p (var))
((((var)->attr... (0x0000004)))Description
TRUEevaluated 125 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2340277 times by 1 test
Evaluated by:
  • Self test
125-2340277
6587 temp = array_reference (array_cell (var), 0);
executed 125 times by 1 test: temp = array_reference ((ARRAY *)((var)->value), 0);
Executed by:
  • Self test
125
6588 else-
6589 temp = value_cell (var);
executed 2340277 times by 1 test: temp = ((var)->value);
Executed by:
  • Self test
2340277
6590#else-
6591 temp = value_cell (var);-
6592#endif-
6593-
6594 if (temp)
tempDescription
TRUEevaluated 2340390 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 18 times by 1 test
Evaluated by:
  • Self test
18-2340390
6595 temp = (*temp && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)))
executed 2340390 times by 1 test: temp = (*temp && (quoted & (0x001|0x002))) ? quote_string (temp) : quote_escapes (temp);
Executed by:
  • Self test
*tempDescription
TRUEevaluated 2334174 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6216 times by 1 test
Evaluated by:
  • Self test
(quoted & (0x001|0x002))Description
TRUEevaluated 8388 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2325786 times by 1 test
Evaluated by:
  • Self test
6216-2340390
6596 ? quote_string (temp)
executed 2340390 times by 1 test: temp = (*temp && (quoted & (0x001|0x002))) ? quote_string (temp) : quote_escapes (temp);
Executed by:
  • Self test
2340390
6597 : quote_escapes (temp);
executed 2340390 times by 1 test: temp = (*temp && (quoted & (0x001|0x002))) ? quote_string (temp) : quote_escapes (temp);
Executed by:
  • Self test
2340390
6598 }
executed 2340408 times by 1 test: end of block
Executed by:
  • Self test
2340408
6599 else-
6600 temp = (char *)NULL;
executed 44 times by 1 test: temp = (char *) ((void *)0) ;
Executed by:
  • Self test
44
6601 }-
6602 else if (var = find_variable_last_nameref (name, 0))
var = find_var...eref (name, 0)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7356 times by 1 test
Evaluated by:
  • Self test
6-7356
6603 {-
6604 temp = nameref_cell (var);-
6605#if defined (ARRAY_VARS)-
6606 /* Handle expanding nameref whose value is x[n] */-
6607 if (temp && *temp && valid_array_reference (temp, 0))
tempDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*tempDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
valid_array_re...ence (temp, 0)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
0-6
6608 {-
6609 name = temp;-
6610 goto expand_arrayref;
executed 4 times by 1 test: goto expand_arrayref;
Executed by:
  • Self test
4
6611 }-
6612 else-
6613#endif-
6614 /* y=2 ; typeset -n x=y; echo ${x} is not the same as echo ${2} in ksh */-
6615 if (temp && *temp && legal_identifier (temp) == 0)
tempDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*tempDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
legal_identifier (temp) == 0Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
0-2
6616 {-
6617 last_command_exit_value = EXECUTION_FAILURE;-
6618 report_error (_("%s: invalid variable name for name reference"), temp);-
6619 temp = &expand_param_error;-
6620 }
never executed: end of block
0
6621 else-
6622 temp = (char *)NULL;
executed 2 times by 1 test: temp = (char *) ((void *)0) ;
Executed by:
  • Self test
2
6623 }-
6624 else-
6625 temp = (char *)NULL;
executed 7356 times by 1 test: temp = (char *) ((void *)0) ;
Executed by:
  • Self test
7356
6626-
6627 if (ret == 0)
ret == 0Description
TRUEevaluated 2368605 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 797 times by 1 test
Evaluated by:
  • Self test
797-2368605
6628 {-
6629 ret = alloc_word_desc ();-
6630 ret->word = temp;-
6631 ret->flags |= rflags;-
6632 }
executed 2368605 times by 1 test: end of block
Executed by:
  • Self test
2368605
6633 return ret;
executed 2369402 times by 1 test: return ret;
Executed by:
  • Self test
2369402
6634}-
6635-
6636static char *-
6637parameter_brace_find_indir (name, var_is_special, quoted, find_nameref)-
6638 char *name;-
6639 int var_is_special, quoted, find_nameref;-
6640{-
6641 char *temp, *t;-
6642 WORD_DESC *w;-
6643 SHELL_VAR *v;-
6644 int pflags, oldex;-
6645-
6646 if (find_nameref && var_is_special == 0 && (v = find_variable_last_nameref (name, 0)) &&
find_namerefDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 104 times by 1 test
Evaluated by:
  • Self test
var_is_special == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(v = find_vari...ref (name, 0))Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-104
6647 nameref_p (v) && (t = nameref_cell (v)) && *t)
((((v)->attrib... (0x0000800)))Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
(t = ((v)->value))Description
TRUEnever evaluated
FALSEnever evaluated
*tDescription
TRUEnever evaluated
FALSEnever evaluated
0-2
6648 return (savestring (t));
never executed: return ((char *)strcpy (sh_xmalloc((1 + strlen (t)), "subst.c", 6648), (t)));
0
6649-
6650 /* If var_is_special == 0, and name is not an array reference, this does-
6651 more expansion than necessary. It should really look up the variable's-
6652 value and not try to expand it. */-
6653 pflags = PF_IGNUNBOUND;-
6654 /* Note that we're not going to be doing word splitting here */-
6655 if (var_is_special)
var_is_specialDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 94 times by 1 test
Evaluated by:
  • Self test
12-94
6656 {-
6657 pflags |= PF_ASSIGNRHS; /* suppresses word splitting */-
6658 oldex = expand_no_split_dollar_star;-
6659 expand_no_split_dollar_star = 1;-
6660 }
executed 12 times by 1 test: end of block
Executed by:
  • Self test
12
6661 w = parameter_brace_expand_word (name, var_is_special, quoted, pflags, 0);-
6662 if (var_is_special)
var_is_specialDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 94 times by 1 test
Evaluated by:
  • Self test
12-94
6663 expand_no_split_dollar_star = oldex;
executed 12 times by 1 test: expand_no_split_dollar_star = oldex;
Executed by:
  • Self test
12
6664-
6665 t = w->word;-
6666 /* Have to dequote here if necessary */-
6667 if (t)
tDescription
TRUEevaluated 93 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
13-93
6668 {-
6669 temp = ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) || var_is_special)
(quoted & (0x001|0x002))Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 71 times by 1 test
Evaluated by:
  • Self test
var_is_specialDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 61 times by 1 test
Evaluated by:
  • Self test
10-71
6670 ? dequote_string (t)-
6671 : dequote_escapes (t);-
6672 free (t);-
6673 t = temp;-
6674 }
executed 93 times by 1 test: end of block
Executed by:
  • Self test
93
6675 dispose_word_desc (w);-
6676-
6677 return t;
executed 106 times by 1 test: return t;
Executed by:
  • Self test
106
6678}-
6679 -
6680/* Expand an indirect reference to a variable: ${!NAME} expands to the-
6681 value of the variable whose name is the value of NAME. */-
6682static WORD_DESC *-
6683parameter_brace_expand_indir (name, var_is_special, quoted, quoted_dollar_atp, contains_dollar_at)-
6684 char *name;-
6685 int var_is_special, quoted;-
6686 int *quoted_dollar_atp, *contains_dollar_at;-
6687{-
6688 char *t;-
6689 WORD_DESC *w;-
6690 SHELL_VAR *v;-
6691-
6692 /* See if it's a nameref first, behave in ksh93-compatible fashion.-
6693 There is at least one incompatibility: given ${!foo[0]} where foo=bar,-
6694 bash performs an indirect lookup on foo[0] and expands the result;-
6695 ksh93 expands bar[0]. We could do that here -- there are enough usable-
6696 primitives to do that -- but do not at this point. */-
6697 if (var_is_special == 0 && (v = find_variable_last_nameref (name, 0)))
var_is_special == 0Description
TRUEevaluated 118 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test
(v = find_vari...ref (name, 0))Description
TRUEevaluated 65 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 53 times by 1 test
Evaluated by:
  • Self test
12-118
6698 {-
6699 if (nameref_p (v) && (t = nameref_cell (v)) && *t)
((((v)->attrib... (0x0000800)))Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 45 times by 1 test
Evaluated by:
  • Self test
(t = ((v)->value))Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*tDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-45
6700 {-
6701 w = alloc_word_desc ();-
6702 w->word = savestring (t);-
6703 w->flags = 0;-
6704 return w;
executed 20 times by 1 test: return w;
Executed by:
  • Self test
20
6705 }-
6706 }
executed 45 times by 1 test: end of block
Executed by:
  • Self test
45
6707-
6708 /* An indirect reference to a positional parameter or a special parameter-
6709 is ok. Indirect references to array references, as explained above, are-
6710 ok (currently). Only references to unset variables are errors at this-
6711 point. */-
6712 if (legal_identifier (name) && v == 0)
legal_identifier (name)Description
TRUEevaluated 51 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 59 times by 1 test
Evaluated by:
  • Self test
v == 0Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 45 times by 1 test
Evaluated by:
  • Self test
6-59
6713 {-
6714 report_error (_("%s: invalid indirect expansion"), name);-
6715 w = alloc_word_desc ();-
6716 w->word = &expand_param_error;-
6717 w->flags = 0;-
6718 return (w);
executed 6 times by 1 test: return (w);
Executed by:
  • Self test
6
6719 }-
6720 -
6721 t = parameter_brace_find_indir (name, var_is_special, quoted, 0);-
6722-
6723 chk_atstar (t, quoted, quoted_dollar_atp, contains_dollar_at);-
6724-
6725#if defined (ARRAY_VARS)-
6726 /* Array references to unset variables are also an error */-
6727 if (t == 0 && valid_array_reference (name, 0))
t == 0Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 91 times by 1 test
Evaluated by:
  • Self test
valid_array_re...ence (name, 0)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test
1-91
6728 {-
6729 v = array_variable_part (name, 0, (char **)0, (int *)0);-
6730 if (v == 0)
v == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1
6731 {-
6732 report_error (_("%s: invalid indirect expansion"), name);-
6733 w = alloc_word_desc ();-
6734 w->word = &expand_param_error;-
6735 w->flags = 0;-
6736 return (w);
executed 1 time by 1 test: return (w);
Executed by:
  • Self test
1
6737 }-
6738 else-
6739 return (WORD_DESC *)NULL;
never executed: return (WORD_DESC *) ((void *)0) ;
0
6740 }-
6741#endif-
6742-
6743 if (t == 0)
t == 0Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 91 times by 1 test
Evaluated by:
  • Self test
12-91
6744 return (WORD_DESC *)NULL;
executed 12 times by 1 test: return (WORD_DESC *) ((void *)0) ;
Executed by:
  • Self test
12
6745-
6746 if (valid_brace_expansion_word (t, SPECIAL_VAR (t, 0)) == 0)
valid_brace_ex... '*'))))) == 0Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 81 times by 1 test
Evaluated by:
  • Self test
10-81
6747 {-
6748 report_error (_("%s: invalid variable name"), t);-
6749 free (t);-
6750 w = alloc_word_desc ();-
6751 w->word = &expand_param_error;-
6752 w->flags = 0;-
6753 return (w);
executed 10 times by 1 test: return (w);
Executed by:
  • Self test
10
6754 }-
6755 -
6756 w = parameter_brace_expand_word (t, SPECIAL_VAR(t, 0), quoted, 0, 0);-
6757 free (t);-
6758-
6759 return w;
executed 80 times by 1 test: return w;
Executed by:
  • Self test
80
6760}-
6761-
6762/* Expand the right side of a parameter expansion of the form ${NAMEcVALUE},-
6763 depending on the value of C, the separating character. C can be one of-
6764 "-", "+", or "=". QUOTED is true if the entire brace expression occurs-
6765 between double quotes. */-
6766static WORD_DESC *-
6767parameter_brace_expand_rhs (name, value, op, quoted, pflags, qdollaratp, hasdollarat)-
6768 char *name, *value;-
6769 int op, quoted, pflags, *qdollaratp, *hasdollarat;-
6770{-
6771 WORD_DESC *w;-
6772 WORD_LIST *l;-
6773 char *t, *t1, *temp, *vname;-
6774 int l_hasdollat, sindex;-
6775-
6776/*itrace("parameter_brace_expand_rhs: %s:%s pflags = %d", name, value, pflags);*/-
6777 /* If the entire expression is between double quotes, we want to treat-
6778 the value as a double-quoted string, with the exception that we strip-
6779 embedded unescaped double quotes (for sh backwards compatibility). */-
6780 if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && *value)
(quoted & (0x002|0x001))Description
TRUEevaluated 2055 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8935 times by 1 test
Evaluated by:
  • Self test
*valueDescription
TRUEevaluated 2049 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
6-8935
6781 {-
6782 sindex = 0;-
6783 temp = string_extract_double_quoted (value, &sindex, SX_STRIPDQ);-
6784 }
executed 2049 times by 1 test: end of block
Executed by:
  • Self test
2049
6785 else-
6786 temp = value;
executed 8941 times by 1 test: temp = value;
Executed by:
  • Self test
8941
6787-
6788 w = alloc_word_desc ();-
6789 l_hasdollat = 0;-
6790 l = *temp ? expand_string_for_rhs (temp, quoted, op, pflags, &l_hasdollat, (int *)NULL)
*tempDescription
TRUEevaluated 10971 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 19 times by 1 test
Evaluated by:
  • Self test
19-10971
6791 : (WORD_LIST *)0;-
6792 if (hasdollarat)
hasdollaratDescription
TRUEevaluated 10975 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-10975
6793 *hasdollarat = l_hasdollat || (l && l->next);
executed 10975 times by 1 test: *hasdollarat = l_hasdollat || (l && l->next);
Executed by:
  • Self test
l_hasdollatDescription
TRUEevaluated 2433 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8542 times by 1 test
Evaluated by:
  • Self test
lDescription
TRUEevaluated 8483 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 59 times by 1 test
Evaluated by:
  • Self test
l->nextDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8469 times by 1 test
Evaluated by:
  • Self test
14-10975
6794 if (temp != value)
temp != valueDescription
TRUEevaluated 2044 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8931 times by 1 test
Evaluated by:
  • Self test
2044-8931
6795 free (temp);
executed 2044 times by 1 test: sh_xfree((temp), "subst.c", 6795);
Executed by:
  • Self test
2044
6796 if (l)
lDescription
TRUEevaluated 10880 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 95 times by 1 test
Evaluated by:
  • Self test
95-10880
6797 {-
6798 /* If l->next is not null, we know that TEMP contained "$@", since that-
6799 is the only expansion that creates more than one word. */-
6800 if (qdollaratp && ((l_hasdollat && quoted) || l->next))
qdollaratpDescription
TRUEevaluated 10880 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
l_hasdollatDescription
TRUEevaluated 2397 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8483 times by 1 test
Evaluated by:
  • Self test
quotedDescription
TRUEevaluated 763 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1634 times by 1 test
Evaluated by:
  • Self test
l->nextDescription
TRUEevaluated 77 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10040 times by 1 test
Evaluated by:
  • Self test
0-10880
6801 {-
6802/*itrace("parameter_brace_expand_rhs: %s:%s: l != NULL, set *qdollaratp", name, value);*/-
6803 *qdollaratp = 1;-
6804 }
executed 840 times by 1 test: end of block
Executed by:
  • Self test
840
6805-
6806 /* The expansion of TEMP returned something. We need to treat things-
6807 slightly differently if L_HASDOLLAT is non-zero. If we have "$@",-
6808 the individual words have already been quoted. We need to turn them-
6809 into a string with the words separated by the first character of-
6810 $IFS without any additional quoting, so string_list_dollar_at won't-
6811 do the right thing. If IFS is null, we want "$@" to split into-
6812 separate arguments, not be concatenated, so we use string_list_internal-
6813 and mark the word to be split on spaces later. We use-
6814 string_list_dollar_star for "$@" otherwise. */-
6815 if (l->next && ifs_is_null)
l->nextDescription
TRUEevaluated 114 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10766 times by 1 test
Evaluated by:
  • Self test
ifs_is_nullDescription
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 93 times by 1 test
Evaluated by:
  • Self test
21-10766
6816 {-
6817 temp = string_list_internal (l, " ");-
6818 w->flags |= W_SPLITSPACE;-
6819 }
executed 21 times by 1 test: end of block
Executed by:
  • Self test
21
6820 else-
6821 temp = (l_hasdollat || l->next) ? string_list_dollar_star (l, quoted, 0) : string_list (l);
executed 10859 times by 1 test: temp = (l_hasdollat || l->next) ? string_list_dollar_star (l, quoted, 0) : string_list (l);
Executed by:
  • Self test
l_hasdollatDescription
TRUEevaluated 2379 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8480 times by 1 test
Evaluated by:
  • Self test
l->nextDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8469 times by 1 test
Evaluated by:
  • Self test
11-10859
6822-
6823 /* If we have a quoted null result (QUOTED_NULL(temp)) and the word is-
6824 a quoted null (l->next == 0 && QUOTED_NULL(l->word->word)), the-
6825 flags indicate it (l->word->flags & W_HASQUOTEDNULL), and the-
6826 expansion is quoted (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))-
6827 (which is more paranoia than anything else), we need to return the-
6828 quoted null string and set the flags to indicate it. */-
6829 if (l->next == 0 && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && QUOTED_NULL (temp) && QUOTED_NULL (l->word->word) && (l->word->flags & W_HASQUOTEDNULL))
l->next == 0Description
TRUEevaluated 10766 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 114 times by 1 test
Evaluated by:
  • Self test
(quoted & (0x002|0x001))Description
TRUEevaluated 1972 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8794 times by 1 test
Evaluated by:
  • Self test
(temp)[0] == '\177'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1968 times by 1 test
Evaluated by:
  • Self test
(temp)[1] == '\0'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(l->word->word)[0] == '\177'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(l->word->word)[1] == '\0'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(l->word->flags & 0x040000)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-10766
6830 {-
6831 w->flags |= W_HASQUOTEDNULL;-
6832/*itrace("parameter_brace_expand_rhs (%s:%s): returning quoted null, turning off qdollaratp", name, value);*/-
6833 /* If we return a quoted null with L_HASDOLLARAT, we either have a-
6834 construct like "${@-$@}" or "${@-${@-$@}}" with no positional-
6835 parameters or a quoted expansion of "$@" with $1 == ''. In either-
6836 case, we don't want to enable special handling of $@. */-
6837 if (qdollaratp && l_hasdollat)
qdollaratpDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
l_hasdollatDescription
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
0-4
6838 *qdollaratp = 0;
never executed: *qdollaratp = 0;
0
6839 }
executed 4 times by 1 test: end of block
Executed by:
  • Self test
4
6840 dispose_words (l);-
6841 }
executed 10880 times by 1 test: end of block
Executed by:
  • Self test
10880
6842 else if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && l_hasdollat)
(quoted & (0x002|0x001))Description
TRUEevaluated 41 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 54 times by 1 test
Evaluated by:
  • Self test
l_hasdollatDescription
TRUEevaluated 35 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
6-54
6843 {-
6844 /* Posix interp 221 changed the rules on this. The idea is that-
6845 something like "$xxx$@" should expand the same as "${foo-$xxx$@}"-
6846 when foo and xxx are unset. The problem is that it's not in any-
6847 way backwards compatible and few other shells do it. We're eventually-
6848 going to try and split the difference (heh) a little bit here. */-
6849 /* l_hasdollat == 1 means we saw a quoted dollar at. */-
6850-
6851 /* The brace expansion occurred between double quotes and there was-
6852 a $@ in TEMP. It does not matter if the $@ is quoted, as long as-
6853 it does not expand to anything. In this case, we want to return-
6854 a quoted empty string. Posix interp 888 */-
6855 temp = make_quoted_char ('\0');-
6856 w->flags |= W_HASQUOTEDNULL;-
6857/*itrace("parameter_brace_expand_rhs (%s:%s): returning quoted null", name, value);*/-
6858 }
executed 35 times by 1 test: end of block
Executed by:
  • Self test
35
6859 else-
6860 temp = (char *)NULL;
executed 60 times by 1 test: temp = (char *) ((void *)0) ;
Executed by:
  • Self test
60
6861-
6862 if (op == '-' || op == '+')
op == '-'Description
TRUEevaluated 949 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10026 times by 1 test
Evaluated by:
  • Self test
op == '+'Description
TRUEevaluated 4881 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5145 times by 1 test
Evaluated by:
  • Self test
949-10026
6863 {-
6864 w->word = temp;-
6865 return w;
executed 5830 times by 1 test: return w;
Executed by:
  • Self test
5830
6866 }-
6867-
6868 /* op == '=' */-
6869 t1 = temp ? dequote_string (temp) : savestring ("");
tempDescription
TRUEevaluated 5136 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
9-5136
6870 free (temp);-
6871-
6872 /* bash-4.4/5.0 */-
6873 vname = name;-
6874 if (*name == '!' &&
*name == '!'Description
TRUEnever evaluated
FALSEevaluated 5145 times by 1 test
Evaluated by:
  • Self test
0-5145
6875 (legal_variable_starter ((unsigned char)name[1]) || DIGIT (name[1]) || VALID_INDIR_PARAM (name[1])))
((*__ctype_b_l...int) _ISalpha)Description
TRUEnever evaluated
FALSEnever evaluated
((unsigned cha...ame[1] == '_')Description
TRUEnever evaluated
FALSEnever evaluated
(name[1]) >= '0'Description
TRUEnever evaluated
FALSEnever evaluated
(name[1]) <= '9'Description
TRUEnever evaluated
FALSEnever evaluated
posixly_correct == 0Description
TRUEnever evaluated
FALSEnever evaluated
(name[1]) == '#'Description
TRUEnever evaluated
FALSEnever evaluated
posixly_correct == 0Description
TRUEnever evaluated
FALSEnever evaluated
(name[1]) == '?'Description
TRUEnever evaluated
FALSEnever evaluated
(name[1]) == '@'Description
TRUEnever evaluated
FALSEnever evaluated
(name[1]) == '*'Description
TRUEnever evaluated
FALSEnever evaluated
0
6876 {-
6877 vname = parameter_brace_find_indir (name + 1, SPECIAL_VAR (name, 1), quoted, 1);-
6878 if (vname == 0 || *vname == 0)
vname == 0Description
TRUEnever evaluated
FALSEnever evaluated
*vname == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
6879 {-
6880 report_error (_("%s: invalid indirect expansion"), name);-
6881 free (vname);-
6882 dispose_word (w);-
6883 return &expand_wdesc_error;
never executed: return &expand_wdesc_error;
0
6884 }-
6885 if (legal_identifier (vname) == 0)
legal_identifier (vname) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
6886 {-
6887 report_error (_("%s: invalid variable name"), vname);-
6888 free (vname);-
6889 dispose_word (w);-
6890 return &expand_wdesc_error;
never executed: return &expand_wdesc_error;
0
6891 }-
6892 }
never executed: end of block
0
6893 -
6894#if defined (ARRAY_VARS)-
6895 if (valid_array_reference (vname, 0))
valid_array_re...nce (vname, 0)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5144 times by 1 test
Evaluated by:
  • Self test
1-5144
6896 assign_array_element (vname, t1, 0);
executed 1 time by 1 test: assign_array_element (vname, t1, 0);
Executed by:
  • Self test
1
6897 else-
6898#endif /* ARRAY_VARS */-
6899 bind_variable (vname, t1, 0);
executed 5144 times by 1 test: bind_variable (vname, t1, 0);
Executed by:
  • Self test
5144
6900-
6901 stupidly_hack_special_variables (vname);-
6902-
6903 if (vname != name)
vname != nameDescription
TRUEnever evaluated
FALSEevaluated 5145 times by 1 test
Evaluated by:
  • Self test
0-5145
6904 free (vname);
never executed: sh_xfree((vname), "subst.c", 6904);
0
6905-
6906 /* From Posix group discussion Feb-March 2010. Issue 7 0000221 */-
6907-
6908 /* If we are double-quoted or if we are not going to be performing word-
6909 splitting, we want to quote the value we return appropriately, like-
6910 the other expansions this function handles. */-
6911 w->word = (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) ? quote_string (t1) : quote_escapes (t1);
(quoted & (0x001|0x002))Description
TRUEevaluated 1656 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3489 times by 1 test
Evaluated by:
  • Self test
1656-3489
6912 free (t1);-
6913-
6914 return w;
executed 5145 times by 1 test: return w;
Executed by:
  • Self test
5145
6915}-
6916-
6917/* Deal with the right hand side of a ${name:?value} expansion in the case-
6918 that NAME is null or not set. If VALUE is non-null it is expanded and-
6919 used as the error message to print, otherwise a standard message is-
6920 printed. */-
6921static void-
6922parameter_brace_expand_error (name, value, check_null)-
6923 char *name, *value;-
6924 int check_null;-
6925{-
6926 WORD_LIST *l;-
6927 char *temp;-
6928-
6929 last_command_exit_value = EXECUTION_FAILURE; /* ensure it's non-zero */-
6930 if (value && *value)
valueDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*valueDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test
0-14
6931 {-
6932 l = expand_string (value, 0);-
6933 temp = string_list (l);-
6934 report_error ("%s: %s", name, temp ? temp : ""); /* XXX was value not "" */-
6935 FREE (temp);
executed 2 times by 1 test: sh_xfree((temp), "subst.c", 6935);
Executed by:
  • Self test
tempDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
6936 dispose_words (l);-
6937 }
executed 2 times by 1 test: end of block
Executed by:
  • Self test
2
6938 else if (check_null == 0)
check_null == 0Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
5-7
6939 report_error (_("%s: parameter not set"), name);
executed 7 times by 1 test: report_error ( dcgettext (((void *)0), "%s: parameter not set" , 5) , name);
Executed by:
  • Self test
7
6940 else-
6941 report_error (_("%s: parameter null or not set"), name);
executed 5 times by 1 test: report_error ( dcgettext (((void *)0), "%s: parameter null or not set" , 5) , name);
Executed by:
  • Self test
5
6942-
6943 /* Free the data we have allocated during this expansion, since we-
6944 are about to longjmp out. */-
6945 free (name);-
6946 FREE (value);
executed 14 times by 1 test: sh_xfree((value), "subst.c", 6946);
Executed by:
  • Self test
valueDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-14
6947}
executed 14 times by 1 test: end of block
Executed by:
  • Self test
14
6948-
6949/* Return 1 if NAME is something for which parameter_brace_expand_length is-
6950 OK to do. */-
6951static int-
6952valid_length_expression (name)-
6953 char *name;-
6954{-
6955 return (name[1] == '\0' || /* ${#} */
executed 521 times by 1 test: return (name[1] == '\0' || ((sh_syntaxtab[(unsigned char) name[1]] & 0x0800) && name[2] == '\0') || (((name[1]) >= '0' && (name[1]) <= '9') && all_digits (name + 1)) || valid_array_reference (name + 1, 0) || legal_identifier (name + 1));
Executed by:
  • Self test
521
6956 ((sh_syntaxtab[(unsigned char) name[1]] & CSPECVAR) && name[2] == '\0') || /* special param */
executed 521 times by 1 test: return (name[1] == '\0' || ((sh_syntaxtab[(unsigned char) name[1]] & 0x0800) && name[2] == '\0') || (((name[1]) >= '0' && (name[1]) <= '9') && all_digits (name + 1)) || valid_array_reference (name + 1, 0) || legal_identifier (name + 1));
Executed by:
  • Self test
521
6957 (DIGIT (name[1]) && all_digits (name + 1)) || /* ${#11} */
executed 521 times by 1 test: return (name[1] == '\0' || ((sh_syntaxtab[(unsigned char) name[1]] & 0x0800) && name[2] == '\0') || (((name[1]) >= '0' && (name[1]) <= '9') && all_digits (name + 1)) || valid_array_reference (name + 1, 0) || legal_identifier (name + 1));
Executed by:
  • Self test
521
6958#if defined (ARRAY_VARS)
executed 521 times by 1 test: return (name[1] == '\0' || ((sh_syntaxtab[(unsigned char) name[1]] & 0x0800) && name[2] == '\0') || (((name[1]) >= '0' && (name[1]) <= '9') && all_digits (name + 1)) || valid_array_reference (name + 1, 0) || legal_identifier (name + 1));
Executed by:
  • Self test
521
6959 valid_array_reference (name + 1, 0) || /* ${#a[7]} */
executed 521 times by 1 test: return (name[1] == '\0' || ((sh_syntaxtab[(unsigned char) name[1]] & 0x0800) && name[2] == '\0') || (((name[1]) >= '0' && (name[1]) <= '9') && all_digits (name + 1)) || valid_array_reference (name + 1, 0) || legal_identifier (name + 1));
Executed by:
  • Self test
521
6960#endif
executed 521 times by 1 test: return (name[1] == '\0' || ((sh_syntaxtab[(unsigned char) name[1]] & 0x0800) && name[2] == '\0') || (((name[1]) >= '0' && (name[1]) <= '9') && all_digits (name + 1)) || valid_array_reference (name + 1, 0) || legal_identifier (name + 1));
Executed by:
  • Self test
521
6961 legal_identifier (name + 1)); /* ${#PS1} */
executed 521 times by 1 test: return (name[1] == '\0' || ((sh_syntaxtab[(unsigned char) name[1]] & 0x0800) && name[2] == '\0') || (((name[1]) >= '0' && (name[1]) <= '9') && all_digits (name + 1)) || valid_array_reference (name + 1, 0) || legal_identifier (name + 1));
Executed by:
  • Self test
521
6962}-
6963-
6964/* Handle the parameter brace expansion that requires us to return the-
6965 length of a parameter. */-
6966static intmax_t-
6967parameter_brace_expand_length (name)-
6968 char *name;-
6969{-
6970 char *t, *newname;-
6971 intmax_t number, arg_index;-
6972 WORD_LIST *list;-
6973#if defined (ARRAY_VARS)-
6974 SHELL_VAR *var;-
6975#endif-
6976-
6977 if (name[1] == '\0') /* ${#} */
name[1] == '\0'Description
TRUEnever evaluated
FALSEevaluated 518 times by 1 test
Evaluated by:
  • Self test
0-518
6978 number = number_of_args ();
never executed: number = number_of_args ();
0
6979 else if (DOLLAR_AT_STAR (name[1]) && name[2] == '\0') /* ${#@}, ${#*} */
(name[1]) == '@'Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 511 times by 1 test
Evaluated by:
  • Self test
(name[1]) == '*'Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 506 times by 1 test
Evaluated by:
  • Self test
name[2] == '\0'Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-511
6980 number = number_of_args ();
executed 12 times by 1 test: number = number_of_args ();
Executed by:
  • Self test
12
6981 else if ((sh_syntaxtab[(unsigned char) name[1]] & CSPECVAR) && name[2] == '\0')
(sh_syntaxtab[...[1]] & 0x0800)Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 498 times by 1 test
Evaluated by:
  • Self test
name[2] == '\0'Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-498
6982 {-
6983 /* Take the lengths of some of the shell's special parameters. */-
6984 switch (name[1])-
6985 {-
6986 case '-':
executed 1 time by 1 test: case '-':
Executed by:
  • Self test
1
6987 t = which_set_flags ();-
6988 break;
executed 1 time by 1 test: break;
Executed by:
  • Self test
1
6989 case '?':
executed 4 times by 1 test: case '?':
Executed by:
  • Self test
4
6990 t = itos (last_command_exit_value);-
6991 break;
executed 4 times by 1 test: break;
Executed by:
  • Self test
4
6992 case '$':
never executed: case '$':
0
6993 t = itos (dollar_dollar_pid);-
6994 break;
never executed: break;
0
6995 case '!':
executed 1 time by 1 test: case '!':
Executed by:
  • Self test
1
6996 if (last_asynchronous_pid == NO_PID)
last_asynchron...d == (pid_t)-1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1
6997 t = (char *)NULL; /* XXX - error if set -u set? */
executed 1 time by 1 test: t = (char *) ((void *)0) ;
Executed by:
  • Self test
1
6998 else-
6999 t = itos (last_asynchronous_pid);
never executed: t = itos (last_asynchronous_pid);
0
7000 break;
executed 1 time by 1 test: break;
Executed by:
  • Self test
1
7001 case '#':
executed 2 times by 1 test: case '#':
Executed by:
  • Self test
2
7002 t = itos (number_of_args ());-
7003 break;
executed 2 times by 1 test: break;
Executed by:
  • Self test
2
7004 }-
7005 number = STRLEN (t);
(t)[1]Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
(t)[2]Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
(t)Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
(t)[0]Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7
7006 FREE (t);
executed 7 times by 1 test: sh_xfree((t), "subst.c", 7006);
Executed by:
  • Self test
tDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-7
7007 }
executed 8 times by 1 test: end of block
Executed by:
  • Self test
8
7008#if defined (ARRAY_VARS)-
7009 else if (valid_array_reference (name + 1, 0))
valid_array_re... (name + 1, 0)Description
TRUEevaluated 266 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 232 times by 1 test
Evaluated by:
  • Self test
232-266
7010 number = array_length_reference (name + 1);
executed 266 times by 1 test: number = array_length_reference (name + 1);
Executed by:
  • Self test
266
7011#endif /* ARRAY_VARS */-
7012 else-
7013 {-
7014 number = 0;-
7015-
7016 if (legal_number (name + 1, &arg_index)) /* ${#1} */
legal_number (...1, &arg_index)Description
TRUEevaluated 27 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 205 times by 1 test
Evaluated by:
  • Self test
27-205
7017 {-
7018 t = get_dollar_var_value (arg_index);-
7019 if (t == 0 && unbound_vars_is_error)
t == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 26 times by 1 test
Evaluated by:
  • Self test
unbound_vars_is_errorDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-26
7020 return INTMAX_MIN;
executed 1 time by 1 test: return (-9223372036854775807L -1) ;
Executed by:
  • Self test
1
7021 number = MB_STRLEN (t);
( (__ctype_get...r_max ()) > 1)Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(t)[1]Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(t)[1]Description
TRUEnever evaluated
FALSEnever evaluated
(t)[2]Description
TRUEnever evaluated
FALSEnever evaluated
(t)Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(t)[0]Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(t)Description
TRUEnever evaluated
FALSEnever evaluated
(t)[0]Description
TRUEnever evaluated
FALSEnever evaluated
0-26
7022 FREE (t);
executed 26 times by 1 test: sh_xfree((t), "subst.c", 7022);
Executed by:
  • Self test
tDescription
TRUEevaluated 26 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-26
7023 }
executed 26 times by 1 test: end of block
Executed by:
  • Self test
26
7024#if defined (ARRAY_VARS)-
7025 else if ((var = find_variable (name + 1)) && (invisible_p (var) == 0) && (array_p (var) || assoc_p (var)))
(var = find_va...le (name + 1))Description
TRUEevaluated 201 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
(((((var)->att...01000))) == 0)Description
TRUEevaluated 201 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((((var)->attr... (0x0000004)))Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 197 times by 1 test
Evaluated by:
  • Self test
((((var)->attr... (0x0000040)))Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 195 times by 1 test
Evaluated by:
  • Self test
0-201
7026 {-
7027 if (assoc_p (var))
((((var)->attr... (0x0000040)))Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
2-4
7028 t = assoc_reference (assoc_cell (var), "0");
executed 2 times by 1 test: t = assoc_reference ((HASH_TABLE *)((var)->value), "0");
Executed by:
  • Self test
2
7029 else-
7030 t = array_reference (array_cell (var), 0);
executed 4 times by 1 test: t = array_reference ((ARRAY *)((var)->value), 0);
Executed by:
  • Self test
4
7031 if (t == 0 && unbound_vars_is_error)
t == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
unbound_vars_is_errorDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-5
7032 return INTMAX_MIN;
executed 1 time by 1 test: return (-9223372036854775807L -1) ;
Executed by:
  • Self test
1
7033 number = MB_STRLEN (t);
( (__ctype_get...r_max ()) > 1)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(t)[1]Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(t)[1]Description
TRUEnever evaluated
FALSEnever evaluated
(t)[2]Description
TRUEnever evaluated
FALSEnever evaluated
(t)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(t)[0]Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(t)Description
TRUEnever evaluated
FALSEnever evaluated
(t)[0]Description
TRUEnever evaluated
FALSEnever evaluated
0-5
7034 }
executed 5 times by 1 test: end of block
Executed by:
  • Self test
5
7035#endif-
7036 else /* ${#PS1} */-
7037 {-
7038 newname = savestring (name);-
7039 newname[0] = '$';-
7040 list = expand_string (newname, Q_DOUBLE_QUOTES);-
7041 t = list ? string_list (list) : (char *)NULL;
listDescription
TRUEevaluated 190 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
6-190
7042 free (newname);-
7043 if (list)
listDescription
TRUEevaluated 190 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
6-190
7044 dispose_words (list);
executed 190 times by 1 test: dispose_words (list);
Executed by:
  • Self test
190
7045-
7046 number = t ? MB_STRLEN (t) : 0;
tDescription
TRUEevaluated 190 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
( (__ctype_get...r_max ()) > 1)Description
TRUEevaluated 186 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
(t)[1]Description
TRUEevaluated 173 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
(t)[1]Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(t)[2]Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(t)Description
TRUEevaluated 186 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(t)[0]Description
TRUEevaluated 186 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(t)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(t)[0]Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-190
7047 FREE (t);
executed 190 times by 1 test: sh_xfree((t), "subst.c", 7047);
Executed by:
  • Self test
tDescription
TRUEevaluated 190 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
6-190
7048 }
executed 196 times by 1 test: end of block
Executed by:
  • Self test
196
7049 }-
7050-
7051 return (number);
executed 513 times by 1 test: return (number);
Executed by:
  • Self test
513
7052}-
7053-
7054/* Skip characters in SUBSTR until DELIM. SUBSTR is an arithmetic expression,-
7055 so we do some ad-hoc parsing of an arithmetic expression to find-
7056 the first DELIM, instead of using strchr(3). Two rules:-
7057 1. If the substring contains a `(', read until closing `)'.-
7058 2. If the substring contains a `?', read past one `:' for each `?'.-
7059 The SD_ARITHEXP flag to skip_to_delim takes care of doing this.-
7060*/-
7061-
7062static char *-
7063skiparith (substr, delim)-
7064 char *substr;-
7065 int delim;-
7066{-
7067 int i;-
7068 char delims[2];-
7069-
7070 delims[0] = delim;-
7071 delims[1] = '\0';-
7072-
7073 i = skip_to_delim (substr, 0, delims, SD_ARITHEXP);-
7074 return (substr + i);
executed 792 times by 1 test: return (substr + i);
Executed by:
  • Self test
792
7075}-
7076-
7077/* Verify and limit the start and end of the desired substring. If-
7078 VTYPE == 0, a regular shell variable is being used; if it is 1,-
7079 then the positional parameters are being used; if it is 2, then-
7080 VALUE is really a pointer to an array variable that should be used.-
7081 Return value is 1 if both values were OK, 0 if there was a problem-
7082 with an invalid expression, or -1 if the values were out of range. */-
7083static int-
7084verify_substring_values (v, value, substr, vtype, e1p, e2p)-
7085 SHELL_VAR *v;-
7086 char *value, *substr;-
7087 int vtype;-
7088 intmax_t *e1p, *e2p;-
7089{-
7090 char *t, *temp1, *temp2;-
7091 arrayind_t len;-
7092 int expok;-
7093#if defined (ARRAY_VARS)-
7094 ARRAY *a;-
7095 HASH_TABLE *h;-
7096#endif-
7097-
7098 /* duplicate behavior of strchr(3) */-
7099 t = skiparith (substr, ':');-
7100 if (*t && *t == ':')
*tDescription
TRUEevaluated 525 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 267 times by 1 test
Evaluated by:
  • Self test
*t == ':'Description
TRUEevaluated 525 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-525
7101 *t = '\0';
executed 525 times by 1 test: *t = '\0';
Executed by:
  • Self test
525
7102 else-
7103 t = (char *)0;
executed 267 times by 1 test: t = (char *)0;
Executed by:
  • Self test
267
7104-
7105 temp1 = expand_arith_string (substr, Q_DOUBLE_QUOTES);-
7106 *e1p = evalexp (temp1, 0, &expok); /* XXX - EXP_EXPANDED? */-
7107 free (temp1);-
7108 if (expok == 0)
expok == 0Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 773 times by 1 test
Evaluated by:
  • Self test
18-773
7109 return (0);
executed 18 times by 1 test: return (0);
Executed by:
  • Self test
18
7110-
7111 len = -1; /* paranoia */-
7112 switch (vtype)-
7113 {-
7114 case VT_VARIABLE:
executed 439 times by 1 test: case 0:
Executed by:
  • Self test
439
7115 case VT_ARRAYMEMBER:
executed 30 times by 1 test: case 3:
Executed by:
  • Self test
30
7116 len = MB_STRLEN (value);
( (__ctype_get...r_max ()) > 1)Description
TRUEevaluated 469 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(value)[1]Description
TRUEevaluated 421 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 30 times by 1 test
Evaluated by:
  • Self test
(value)[1]Description
TRUEnever evaluated
FALSEnever evaluated
(value)[2]Description
TRUEnever evaluated
FALSEnever evaluated
(value)Description
TRUEevaluated 469 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(value)[0]Description
TRUEevaluated 451 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 18 times by 1 test
Evaluated by:
  • Self test
(value)Description
TRUEnever evaluated
FALSEnever evaluated
(value)[0]Description
TRUEnever evaluated
FALSEnever evaluated
0-469
7117 break;
executed 469 times by 1 test: break;
Executed by:
  • Self test
469
7118 case VT_POSPARMS:
executed 223 times by 1 test: case 1:
Executed by:
  • Self test
223
7119 len = number_of_args () + 1;-
7120 if (*e1p == 0)
*e1p == 0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 215 times by 1 test
Evaluated by:
  • Self test
8-215
7121 len++; /* add one arg if counting from $0 */
executed 8 times by 1 test: len++;
Executed by:
  • Self test
8
7122 break;
executed 223 times by 1 test: break;
Executed by:
  • Self test
223
7123#if defined (ARRAY_VARS)-
7124 case VT_ARRAYVAR:
executed 81 times by 1 test: case 2:
Executed by:
  • Self test
81
7125 /* For arrays, the first value deals with array indices. Negative-
7126 offsets count from one past the array's maximum index. Associative-
7127 arrays treat the number of elements as the maximum index. */-
7128 if (assoc_p (v))
((((v)->attrib... (0x0000040)))Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 79 times by 1 test
Evaluated by:
  • Self test
2-79
7129 {-
7130 h = assoc_cell (v);-
7131 len = assoc_num_elements (h) + (*e1p < 0);-
7132 }
executed 2 times by 1 test: end of block
Executed by:
  • Self test
2
7133 else-
7134 {-
7135 a = (ARRAY *)value;-
7136 len = array_max_index (a) + (*e1p < 0); /* arrays index from 0 to n - 1 */-
7137 }
executed 79 times by 1 test: end of block
Executed by:
  • Self test
79
7138 break;
executed 81 times by 1 test: break;
Executed by:
  • Self test
81
7139#endif-
7140 }-
7141-
7142 if (len == -1) /* paranoia */
len == -1Description
TRUEnever evaluated
FALSEevaluated 773 times by 1 test
Evaluated by:
  • Self test
0-773
7143 return -1;
never executed: return -1;
0
7144-
7145 if (*e1p < 0) /* negative offsets count from end */
*e1p < 0Description
TRUEevaluated 31 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 742 times by 1 test
Evaluated by:
  • Self test
31-742
7146 *e1p += len;
executed 31 times by 1 test: *e1p += len;
Executed by:
  • Self test
31
7147-
7148 if (*e1p > len || *e1p < 0)
*e1p > lenDescription
TRUEevaluated 26 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 747 times by 1 test
Evaluated by:
  • Self test
*e1p < 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 745 times by 1 test
Evaluated by:
  • Self test
2-747
7149 return (-1);
executed 28 times by 1 test: return (-1);
Executed by:
  • Self test
28
7150-
7151#if defined (ARRAY_VARS)-
7152 /* For arrays, the second offset deals with the number of elements. */-
7153 if (vtype == VT_ARRAYVAR)
vtype == 2Description
TRUEevaluated 77 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 668 times by 1 test
Evaluated by:
  • Self test
77-668
7154 len = assoc_p (v) ? assoc_num_elements (h) : array_num_elements (a);
executed 77 times by 1 test: len = ((((v)->attributes) & (0x0000040))) ? ((h)->nentries) : ((a)->num_elements);
Executed by:
  • Self test
((((v)->attrib... (0x0000040)))Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 75 times by 1 test
Evaluated by:
  • Self test
2-77
7155#endif-
7156-
7157 if (t)
tDescription
TRUEevaluated 510 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 235 times by 1 test
Evaluated by:
  • Self test
235-510
7158 {-
7159 t++;-
7160 temp2 = savestring (t);-
7161 temp1 = expand_arith_string (temp2, Q_DOUBLE_QUOTES);-
7162 free (temp2);-
7163 t[-1] = ':';-
7164 *e2p = evalexp (temp1, 0, &expok); /* XXX - EXP_EXPANDED? */-
7165 free (temp1);-
7166 if (expok == 0)
expok == 0Description
TRUEnever evaluated
FALSEevaluated 510 times by 1 test
Evaluated by:
  • Self test
0-510
7167 return (0);
never executed: return (0);
0
7168-
7169 /* Should we allow positional parameter length < 0 to count backwards-
7170 from end of positional parameters? */-
7171#if 1-
7172 if ((vtype == VT_ARRAYVAR || vtype == VT_POSPARMS) && *e2p < 0)
vtype == 2Description
TRUEevaluated 54 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 456 times by 1 test
Evaluated by:
  • Self test
vtype == 1Description
TRUEevaluated 103 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 353 times by 1 test
Evaluated by:
  • Self test
*e2p < 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 155 times by 1 test
Evaluated by:
  • Self test
2-456
7173#else-
7174 /* XXX - bash-5.0 */-
7175 if (vtype == VT_ARRAYVAR && *e2p < 0)-
7176#endif-
7177 {-
7178 internal_error (_("%s: substring expression < 0"), t);-
7179 return (0);
executed 2 times by 1 test: return (0);
Executed by:
  • Self test
2
7180 }-
7181#if defined (ARRAY_VARS)-
7182 /* In order to deal with sparse arrays, push the intelligence about how-
7183 to deal with the number of elements desired down to the array--
7184 specific functions. */-
7185 if (vtype != VT_ARRAYVAR)
vtype != 2Description
TRUEevaluated 454 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 54 times by 1 test
Evaluated by:
  • Self test
54-454
7186#endif-
7187 {-
7188 if (*e2p < 0)
*e2p < 0Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 445 times by 1 test
Evaluated by:
  • Self test
9-445
7189 {-
7190 *e2p += len;-
7191 if (*e2p < 0 || *e2p < *e1p)
*e2p < 0Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
*e2p < *e1pDescription
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
0-9
7192 {-
7193 internal_error (_("%s: substring expression < 0"), t);-
7194 return (0);
never executed: return (0);
0
7195 }-
7196 }
executed 9 times by 1 test: end of block
Executed by:
  • Self test
9
7197 else-
7198 *e2p += *e1p; /* want E2 chars starting at E1 */
executed 445 times by 1 test: *e2p += *e1p;
Executed by:
  • Self test
445
7199 if (*e2p > len)
*e2p > lenDescription
TRUEevaluated 70 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 384 times by 1 test
Evaluated by:
  • Self test
70-384
7200 *e2p = len;
executed 70 times by 1 test: *e2p = len;
Executed by:
  • Self test
70
7201 }
executed 454 times by 1 test: end of block
Executed by:
  • Self test
454
7202 }
executed 508 times by 1 test: end of block
Executed by:
  • Self test
508
7203 else-
7204 *e2p = len;
executed 235 times by 1 test: *e2p = len;
Executed by:
  • Self test
235
7205-
7206 return (1);
executed 743 times by 1 test: return (1);
Executed by:
  • Self test
743
7207}-
7208-
7209/* Return the type of variable specified by VARNAME (simple variable,-
7210 positional param, or array variable). Also return the value specified-
7211 by VARNAME (value of a variable or a reference to an array element).-
7212 QUOTED is the standard description of quoting state, using Q_* defines.-
7213 FLAGS is currently a set of flags to pass to array_value. If IND is-
7214 non-null and not INTMAX_MIN, and FLAGS includes AV_USEIND, IND is-
7215 passed to array_value so the array index is not computed again.-
7216 If this returns VT_VARIABLE, the caller assumes that CTLESC and CTLNUL-
7217 characters in the value are quoted with CTLESC and takes appropriate-
7218 steps. For convenience, *VALP is set to the dequoted VALUE. */-
7219static int-
7220get_var_and_type (varname, value, ind, quoted, flags, varp, valp)-
7221 char *varname, *value;-
7222 arrayind_t ind;-
7223 int quoted, flags;-
7224 SHELL_VAR **varp;-
7225 char **valp;-
7226{-
7227 int vtype, want_indir;-
7228 char *temp, *vname;-
7229 SHELL_VAR *v;-
7230 arrayind_t lind;-
7231-
7232 want_indir = *varname == '!' &&
*varname == '!'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2317594 times by 1 test
Evaluated by:
  • Self test
2-2317594
7233 (legal_variable_starter ((unsigned char)varname[1]) || DIGIT (varname[1])
((*__ctype_b_l...int) _ISalpha)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((unsigned cha...ame[1] == '_')Description
TRUEnever evaluated
FALSEnever evaluated
(varname[1]) >= '0'Description
TRUEnever evaluated
FALSEnever evaluated
(varname[1]) <= '9'Description
TRUEnever evaluated
FALSEnever evaluated
0-2
7234 || VALID_INDIR_PARAM (varname[1]));
posixly_correct == 0Description
TRUEnever evaluated
FALSEnever evaluated
(varname[1]) == '#'Description
TRUEnever evaluated
FALSEnever evaluated
posixly_correct == 0Description
TRUEnever evaluated
FALSEnever evaluated
(varname[1]) == '?'Description
TRUEnever evaluated
FALSEnever evaluated
(varname[1]) == '@'Description
TRUEnever evaluated
FALSEnever evaluated
(varname[1]) == '*'Description
TRUEnever evaluated
FALSEnever evaluated
0
7235 if (want_indir)
want_indirDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2317594 times by 1 test
Evaluated by:
  • Self test
2-2317594
7236 vname = parameter_brace_find_indir (varname+1, SPECIAL_VAR (varname, 1), quoted, 1);
executed 2 times by 1 test: vname = parameter_brace_find_indir (varname+1, (*varname && ((((*varname) >= '0' && (*varname) <= '9') && all_digits (varname)) || (varname[1] == '\0' && (sh_syntaxtab[(unsigned char)*varname] & 0x0800)) || (1 && varname[2] == '\0' && ((posixly_correct == 0 && (varname[1]) == '#') || (posixly_correct == 0 && (varname[1]) == '?') || (varname[1]) == '@' || (varname[1]) == '*')))), quoted, 1);
Executed by:
  • Self test
2
7237 /* XXX - what if vname == 0 || *vname == 0 ? */-
7238 else-
7239 vname = varname;
executed 2317594 times by 1 test: vname = varname;
Executed by:
  • Self test
2317594
7240-
7241 if (vname == 0)
vname == 0Description
TRUEnever evaluated
FALSEevaluated 2317596 times by 1 test
Evaluated by:
  • Self test
0-2317596
7242 {-
7243 vtype = VT_VARIABLE;-
7244 *varp = (SHELL_VAR *)NULL;-
7245 *valp = (char *)NULL;-
7246 return (vtype);
never executed: return (vtype);
0
7247 }-
7248-
7249 /* This sets vtype to VT_VARIABLE or VT_POSPARMS */-
7250 vtype = STR_DOLLAR_AT_STAR (vname);
((vname)[0]) == '@'Description
TRUEevaluated 258 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2317338 times by 1 test
Evaluated by:
  • Self test
((vname)[0]) == '*'Description
TRUEevaluated 191 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2317147 times by 1 test
Evaluated by:
  • Self test
(vname)[1] == '\0'Description
TRUEevaluated 449 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2317338
7251 if (vtype == VT_POSPARMS && vname[0] == '*')
vtype == 1Description
TRUEevaluated 449 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2317147 times by 1 test
Evaluated by:
  • Self test
vname[0] == '*'Description
TRUEevaluated 191 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 258 times by 1 test
Evaluated by:
  • Self test
191-2317147
7252 vtype |= VT_STARSUB;
executed 191 times by 1 test: vtype |= 128;
Executed by:
  • Self test
191
7253 *varp = (SHELL_VAR *)NULL;-
7254-
7255#if defined (ARRAY_VARS)-
7256 if (valid_array_reference (vname, 0))
valid_array_re...nce (vname, 0)Description
TRUEevaluated 488 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2317108 times by 1 test
Evaluated by:
  • Self test
488-2317108
7257 {-
7258 v = array_variable_part (vname, 0, &temp, (int *)0);-
7259 /* If we want to signal array_value to use an already-computed index,-
7260 set LIND to that index */-
7261 lind = (ind != INTMAX_MIN && (flags & AV_USEIND)) ? ind : 0;
ind != (-92233...854775807L -1)Description
TRUEevaluated 488 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(flags & 0x004)Description
TRUEevaluated 149 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 339 times by 1 test
Evaluated by:
  • Self test
0-488
7262 if (v && invisible_p (v))
vDescription
TRUEevaluated 488 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((((v)->attrib... (0x0001000)))Description
TRUEnever evaluated
FALSEevaluated 488 times by 1 test
Evaluated by:
  • Self test
0-488
7263 {-
7264 vtype = VT_ARRAYMEMBER;-
7265 *varp = (SHELL_VAR *)NULL;-
7266 *valp = (char *)NULL;-
7267 }
never executed: end of block
0
7268 if (v && (array_p (v) || assoc_p (v)))
vDescription
TRUEevaluated 488 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((((v)->attrib... (0x0000004)))Description
TRUEevaluated 434 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 54 times by 1 test
Evaluated by:
  • Self test
((((v)->attrib... (0x0000040)))Description
TRUEevaluated 42 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test
0-488
7269 {-
7270 if (ALL_ELEMENT_SUB (temp[0]) && temp[1] == RBRACK)
(temp[0]) == '@'Description
TRUEevaluated 268 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 208 times by 1 test
Evaluated by:
  • Self test
(temp[0]) == '*'Description
TRUEevaluated 64 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 144 times by 1 test
Evaluated by:
  • Self test
temp[1] == ']'Description
TRUEevaluated 332 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-332
7271 {-
7272 /* Callers have to differentiate between indexed and associative */-
7273 vtype = VT_ARRAYVAR;-
7274 if (temp[0] == '*')
temp[0] == '*'Description
TRUEevaluated 64 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 268 times by 1 test
Evaluated by:
  • Self test
64-268
7275 vtype |= VT_STARSUB;
executed 64 times by 1 test: vtype |= 128;
Executed by:
  • Self test
64
7276 *valp = array_p (v) ? (char *)array_cell (v) : (char *)assoc_cell (v);
((((v)->attrib... (0x0000004)))Description
TRUEevaluated 298 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 34 times by 1 test
Evaluated by:
  • Self test
34-298
7277 }
executed 332 times by 1 test: end of block
Executed by:
  • Self test
332
7278 else-
7279 {-
7280 vtype = VT_ARRAYMEMBER;-
7281 *valp = array_value (vname, Q_DOUBLE_QUOTES, flags, (int *)NULL, &lind);-
7282 }
executed 144 times by 1 test: end of block
Executed by:
  • Self test
144
7283 *varp = v;-
7284 }
executed 476 times by 1 test: end of block
Executed by:
  • Self test
476
7285 else if (v && (ALL_ELEMENT_SUB (temp[0]) && temp[1] == RBRACK))
vDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(temp[0]) == '@'Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
(temp[0]) == '*'Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
temp[1] == ']'Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-12
7286 {-
7287 vtype = VT_VARIABLE;-
7288 *varp = v;-
7289 if (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))
quoted & (0x001|0x002)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
2-4
7290 *valp = dequote_string (value);
executed 2 times by 1 test: *valp = dequote_string (value);
Executed by:
  • Self test
2
7291 else-
7292 *valp = dequote_escapes (value);
executed 4 times by 1 test: *valp = dequote_escapes (value);
Executed by:
  • Self test
4
7293 }-
7294 else-
7295 {-
7296 vtype = VT_ARRAYMEMBER;-
7297 *varp = v;-
7298 *valp = array_value (vname, Q_DOUBLE_QUOTES, flags, (int *)NULL, &lind);-
7299 }
executed 6 times by 1 test: end of block
Executed by:
  • Self test
6
7300 }-
7301 else if ((v = find_variable (vname)) && (invisible_p (v) == 0) && (assoc_p (v) || array_p (v)))
(v = find_variable (vname))Description
TRUEevaluated 2316546 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 562 times by 1 test
Evaluated by:
  • Self test
(((((v)->attri...01000))) == 0)Description
TRUEevaluated 2316546 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((((v)->attrib... (0x0000040)))Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2316541 times by 1 test
Evaluated by:
  • Self test
((((v)->attrib... (0x0000004)))Description
TRUEevaluated 44 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2316497 times by 1 test
Evaluated by:
  • Self test
0-2316546
7302 {-
7303 vtype = VT_ARRAYMEMBER;-
7304 *varp = v;-
7305 *valp = assoc_p (v) ? assoc_reference (assoc_cell (v), "0") : array_reference (array_cell (v), 0);
((((v)->attrib... (0x0000040)))Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 44 times by 1 test
Evaluated by:
  • Self test
5-44
7306 }
executed 49 times by 1 test: end of block
Executed by:
  • Self test
49
7307 else-
7308#endif-
7309 {-
7310 if (value && vtype == VT_VARIABLE)
valueDescription
TRUEevaluated 2317050 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
vtype == 0Description
TRUEevaluated 2316609 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 441 times by 1 test
Evaluated by:
  • Self test
9-2317050
7311 {-
7312 *varp = find_variable (vname);-
7313 if (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))
quoted & (0x001|0x002)Description
TRUEevaluated 426 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2316183 times by 1 test
Evaluated by:
  • Self test
426-2316183
7314 *valp = dequote_string (value);
executed 426 times by 1 test: *valp = dequote_string (value);
Executed by:
  • Self test
426
7315 else-
7316 *valp = dequote_escapes (value);
executed 2316183 times by 1 test: *valp = dequote_escapes (value);
Executed by:
  • Self test
2316183
7317 }-
7318 else-
7319 *valp = value;
executed 450 times by 1 test: *valp = value;
Executed by:
  • Self test
450
7320 }-
7321-
7322 if (want_indir)
want_indirDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2317594 times by 1 test
Evaluated by:
  • Self test
2-2317594
7323 free (vname);
executed 2 times by 1 test: sh_xfree((vname), "subst.c", 7323);
Executed by:
  • Self test
2
7324-
7325 return vtype;
executed 2317596 times by 1 test: return vtype;
Executed by:
  • Self test
2317596
7326}-
7327-
7328/***********************************************************/-
7329/* */-
7330/* Functions to perform transformations on variable values */-
7331/* */-
7332/***********************************************************/-
7333-
7334static char *-
7335string_var_assignment (v, s)-
7336 SHELL_VAR *v;-
7337 char *s;-
7338{-
7339 char flags[MAX_ATTRIBUTES], *ret, *val;-
7340 int i;-
7341-
7342 val = sh_quote_reusable (s, 0);-
7343 i = var_attribute_string (v, 0, flags);-
7344 ret = (char *)xmalloc (i + strlen (val) + strlen (v->name) + 16 + MAX_ATTRIBUTES);-
7345 if (i > 0)
i > 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-3
7346 sprintf (ret, "declare -%s %s=%s", flags, v->name, val);
executed 3 times by 1 test: sprintf (ret, "declare -%s %s=%s", flags, v->name, val);
Executed by:
  • Self test
3
7347 else-
7348 sprintf (ret, "%s=%s", v->name, val);
executed 1 time by 1 test: sprintf (ret, "%s=%s", v->name, val);
Executed by:
  • Self test
1
7349 free (val);-
7350 return ret;
executed 4 times by 1 test: return ret;
Executed by:
  • Self test
4
7351}-
7352-
7353#if defined (ARRAY_VARS)-
7354static char *-
7355array_var_assignment (v, itype, quoted)-
7356 SHELL_VAR *v;-
7357 int itype, quoted;-
7358{-
7359 char *ret, *val, flags[MAX_ATTRIBUTES];-
7360 int i;-
7361-
7362 if (v == 0)
v == 0Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
0-6
7363 return (char *)NULL;
never executed: return (char *) ((void *)0) ;
0
7364 val = array_p (v) ? array_to_assign (array_cell (v), 0)
((((v)->attrib... (0x0000004)))Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2-4
7365 : assoc_to_assign (assoc_cell (v), 0);-
7366 if (val == 0)
val == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
2-4
7367 {-
7368 val = (char *)xmalloc (3);-
7369 val[0] = LPAREN;-
7370 val[1] = RPAREN;-
7371 val[2] = 0;-
7372 }
executed 2 times by 1 test: end of block
Executed by:
  • Self test
2
7373 else-
7374 {-
7375 ret = (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) ? quote_string (val) : quote_escapes (val);
(quoted & (0x001|0x002))Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2
7376 free (val);-
7377 val = ret;-
7378 }
executed 4 times by 1 test: end of block
Executed by:
  • Self test
4
7379 i = var_attribute_string (v, 0, flags);-
7380 ret = (char *)xmalloc (i + strlen (val) + strlen (v->name) + 16);-
7381 sprintf (ret, "declare -%s %s=%s", flags, v->name, val);-
7382 free (val);-
7383 return ret;
executed 6 times by 1 test: return ret;
Executed by:
  • Self test
6
7384}-
7385#endif-
7386-
7387static char *-
7388pos_params_assignment (list, itype, quoted)-
7389 WORD_LIST *list;-
7390 int itype;-
7391 int quoted;-
7392{-
7393 char *temp, *ret;-
7394-
7395 /* first, we transform the list to quote each word. */-
7396 temp = list_transform ('Q', (SHELL_VAR *)0, list, itype, quoted);-
7397 ret = (char *)xmalloc (strlen (temp) + 8);-
7398 strcpy (ret, "set -- ");-
7399 strcpy (ret + 7, temp);-
7400 free (temp);-
7401 return ret;
executed 1 time by 1 test: return ret;
Executed by:
  • Self test
1
7402}-
7403-
7404static char *-
7405string_transform (xc, v, s)-
7406 int xc;-
7407 SHELL_VAR *v;-
7408 char *s;-
7409{-
7410 char *ret, flags[MAX_ATTRIBUTES], *t;-
7411 int i;-
7412-
7413 if (((xc == 'A' || xc == 'a') && v == 0) || (xc != 'a' && s == 0))
xc == 'A'Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 62 times by 1 test
Evaluated by:
  • Self test
xc == 'a'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 58 times by 1 test
Evaluated by:
  • Self test
v == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
xc != 'a'Description
TRUEevaluated 62 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
s == 0Description
TRUEnever evaluated
FALSEevaluated 62 times by 1 test
Evaluated by:
  • Self test
0-62
7414 return (char *)NULL;
executed 1 time by 1 test: return (char *) ((void *)0) ;
Executed by:
  • Self test
1
7415-
7416 switch (xc)-
7417 {-
7418 /* Transformations that interrogate the variable */-
7419 case 'a':
executed 4 times by 1 test: case 'a':
Executed by:
  • Self test
4
7420 i = var_attribute_string (v, 0, flags);-
7421 ret = (i > 0) ? savestring (flags) : (char *)NULL;
(i > 0)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-4
7422 break;
executed 4 times by 1 test: break;
Executed by:
  • Self test
4
7423 case 'A':
executed 4 times by 1 test: case 'A':
Executed by:
  • Self test
4
7424 ret = string_var_assignment (v, s);-
7425 break;
executed 4 times by 1 test: break;
Executed by:
  • Self test
4
7426 /* Transformations that modify the variable's value */-
7427 case 'E':
executed 11 times by 1 test: case 'E':
Executed by:
  • Self test
11
7428 t = ansiexpand (s, 0, strlen (s), (int *)0);-
7429 ret = dequote_escapes (t);-
7430 free (t);-
7431 break;
executed 11 times by 1 test: break;
Executed by:
  • Self test
11
7432 case 'P':
executed 2 times by 1 test: case 'P':
Executed by:
  • Self test
2
7433 ret = decode_prompt_string (s);-
7434 break;
executed 2 times by 1 test: break;
Executed by:
  • Self test
2
7435 case 'Q':
executed 45 times by 1 test: case 'Q':
Executed by:
  • Self test
45
7436 ret = sh_quote_reusable (s, 0);-
7437 break;
executed 45 times by 1 test: break;
Executed by:
  • Self test
45
7438 default:
never executed: default:
0
7439 ret = (char *)NULL;-
7440 break;
never executed: break;
0
7441 }-
7442 return ret;
executed 66 times by 1 test: return ret;
Executed by:
  • Self test
66
7443}-
7444-
7445static char *-
7446list_transform (xc, v, list, itype, quoted)-
7447 int xc;-
7448 SHELL_VAR *v;-
7449 WORD_LIST *list;-
7450 int itype, quoted;-
7451{-
7452 WORD_LIST *new, *l;-
7453 WORD_DESC *w;-
7454 char *tword;-
7455 int qflags;-
7456-
7457 for (new = (WORD_LIST *)NULL, l = list; l; l = l->next)
lDescription
TRUEevaluated 49 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20 times by 1 test
Evaluated by:
  • Self test
20-49
7458 {-
7459 tword = string_transform (xc, v, l->word->word);-
7460 w = alloc_word_desc ();-
7461 w->word = tword ? tword : savestring (""); /* XXX */
twordDescription
TRUEevaluated 49 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-49
7462 new = make_word_list (w, new);-
7463 }
executed 49 times by 1 test: end of block
Executed by:
  • Self test
49
7464 l = REVERSE_LIST (new, WORD_LIST *);
newDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
new->nextDescription
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
0-20
7465-
7466 qflags = quoted;-
7467 /* If we are expanding in a context where word splitting will not be-
7468 performed, treat as quoted. This changes how $* will be expanded. */-
7469 if (itype == '*' && expand_no_split_dollar_star && ifs_is_null)
itype == '*'Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11 times by 1 test
Evaluated by:
  • Self test
expand_no_split_dollar_starDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
ifs_is_nullDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-11
7470 qflags |= Q_DOUBLE_QUOTES; /* Posix interp 888 */
executed 5 times by 1 test: qflags |= 0x001;
Executed by:
  • Self test
5
7471-
7472 tword = string_list_pos_params (itype, l, qflags);-
7473 dispose_words (l);-
7474-
7475 return (tword);
executed 20 times by 1 test: return (tword);
Executed by:
  • Self test
20
7476}-
7477-
7478static char *-
7479parameter_list_transform (xc, itype, quoted)-
7480 int xc;-
7481 int itype;-
7482 int quoted;-
7483{-
7484 char *ret;-
7485 WORD_LIST *list;-
7486-
7487 list = list_rest_of_args ();-
7488 if (list == 0)
list == 0Description
TRUEnever evaluated
FALSEevaluated 11 times by 1 test
Evaluated by:
  • Self test
0-11
7489 return ((char *)NULL);
never executed: return ((char *) ((void *)0) );
0
7490 if (xc == 'A')
xc == 'A'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
1-10
7491 return (pos_params_assignment (list, itype, quoted));
executed 1 time by 1 test: return (pos_params_assignment (list, itype, quoted));
Executed by:
  • Self test
1
7492 ret = list_transform (xc, (SHELL_VAR *)0, list, itype, quoted);-
7493 dispose_words (list);-
7494 return (ret);
executed 10 times by 1 test: return (ret);
Executed by:
  • Self test
10
7495}-
7496-
7497#if defined (ARRAY_VARS)-
7498static char *-
7499array_transform (xc, var, varname, quoted)-
7500 int xc;-
7501 SHELL_VAR *var;-
7502 char *varname; /* so we can figure out how it's indexed */-
7503 int quoted;-
7504{-
7505 ARRAY *a;-
7506 HASH_TABLE *h;-
7507 int itype;-
7508 char *ret;-
7509 WORD_LIST *list;-
7510 SHELL_VAR *v;-
7511-
7512 /* compute itype from varname here */-
7513 v = array_variable_part (varname, 0, &ret, 0);-
7514-
7515 /* XXX */-
7516 if (v && invisible_p (v))
vDescription
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((((v)->attrib... (0x0001000)))Description
TRUEnever evaluated
FALSEevaluated 15 times by 1 test
Evaluated by:
  • Self test
0-15
7517 return ((char *)NULL);
never executed: return ((char *) ((void *)0) );
0
7518-
7519 itype = ret[0];-
7520-
7521 if (xc == 'A')
xc == 'A'Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
6-9
7522 return (array_var_assignment (v, itype, quoted));
executed 6 times by 1 test: return (array_var_assignment (v, itype, quoted));
Executed by:
  • Self test
6
7523-
7524 a = (v && array_p (v)) ? array_cell (v) : 0;
vDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((((v)->attrib... (0x0000004)))Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-9
7525 h = (v && assoc_p (v)) ? assoc_cell (v) : 0;
vDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((((v)->attrib... (0x0000040)))Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
0-9
7526 -
7527 list = a ? array_to_word_list (a) : (h ? assoc_to_word_list (h) : 0);
aDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
hDescription
TRUEnever evaluated
FALSEnever evaluated
0-9
7528 if (list == 0)
list == 0Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
0-9
7529 return ((char *)NULL);
never executed: return ((char *) ((void *)0) );
0
7530 ret = list_transform (xc, v, list, itype, quoted);-
7531 dispose_words (list);-
7532-
7533 return ret;
executed 9 times by 1 test: return ret;
Executed by:
  • Self test
9
7534}-
7535#endif /* ARRAY_VARS */-
7536-
7537static char *-
7538parameter_brace_transform (varname, value, ind, xform, rtype, quoted, pflags, flags)-
7539 char *varname, *value;-
7540 int ind;-
7541 char *xform;-
7542 int rtype, quoted, pflags, flags;-
7543{-
7544 int vtype, xc;-
7545 char *temp1, *val, *oname;-
7546 SHELL_VAR *v;-
7547-
7548 xc = xform[0];-
7549 if (value == 0 && xc != 'A' && xc != 'a')
value == 0Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 41 times by 1 test
Evaluated by:
  • Self test
xc != 'A'Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
xc != 'a'Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-41
7550 return ((char *)NULL);
executed 5 times by 1 test: return ((char *) ((void *)0) );
Executed by:
  • Self test
5
7551-
7552 oname = this_command_name;-
7553 this_command_name = varname;-
7554-
7555 vtype = get_var_and_type (varname, value, ind, quoted, flags, &v, &val);-
7556 if (vtype == -1)
vtype == -1Description
TRUEnever evaluated
FALSEevaluated 45 times by 1 test
Evaluated by:
  • Self test
0-45
7557 {-
7558 this_command_name = oname;-
7559 return ((char *)NULL);
never executed: return ((char *) ((void *)0) );
0
7560 }-
7561-
7562 /* check for valid values of xc */-
7563 switch (xc)-
7564 {-
7565 case 'a': /* expand to a string with just attributes */
executed 4 times by 1 test: case 'a':
Executed by:
  • Self test
4
7566 case 'A': /* expand as an assignment statement with attributes */
executed 12 times by 1 test: case 'A':
Executed by:
  • Self test
12
7567 case 'E': /* expand like $'...' */
executed 9 times by 1 test: case 'E':
Executed by:
  • Self test
9
7568 case 'P': /* expand like prompt string */
executed 2 times by 1 test: case 'P':
Executed by:
  • Self test
2
7569 case 'Q': /* quote reusably */
executed 17 times by 1 test: case 'Q':
Executed by:
  • Self test
17
7570 break;
executed 44 times by 1 test: break;
Executed by:
  • Self test
44
7571 default:
executed 1 time by 1 test: default:
Executed by:
  • Self test
1
7572 this_command_name = oname;-
7573 return &expand_param_error;
executed 1 time by 1 test: return &expand_param_error;
Executed by:
  • Self test
1
7574 }-
7575-
7576 temp1 = (char *)NULL; /* shut up gcc */-
7577 switch (vtype & ~VT_STARSUB)-
7578 {-
7579 case VT_VARIABLE:
executed 15 times by 1 test: case 0:
Executed by:
  • Self test
15
7580 case VT_ARRAYMEMBER:
executed 3 times by 1 test: case 3:
Executed by:
  • Self test
3
7581 temp1 = string_transform (xc, v, val);-
7582 if (vtype == VT_VARIABLE)
vtype == 0Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
3-15
7583 FREE (val);
executed 14 times by 1 test: sh_xfree((val), "subst.c", 7583);
Executed by:
  • Self test
executed 15 times by 1 test: end of block
Executed by:
  • Self test
valDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-15
7584 if (temp1)
temp1Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-17
7585 {-
7586 val = (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
(quoted & (0x002|0x001))Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
5-12
7587 ? quote_string (temp1)-
7588 : quote_escapes (temp1);-
7589 free (temp1);-
7590 temp1 = val;-
7591 }
executed 17 times by 1 test: end of block
Executed by:
  • Self test
17
7592 break;
executed 18 times by 1 test: break;
Executed by:
  • Self test
18
7593#if defined (ARRAY_VARS)-
7594 case VT_ARRAYVAR:
executed 15 times by 1 test: case 2:
Executed by:
  • Self test
15
7595 temp1 = array_transform (xc, v, varname, quoted);-
7596 if (temp1 && quoted == 0 && ifs_is_null)
temp1Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
quoted == 0Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
ifs_is_nullDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
0-15
7597 {-
7598 /* Posix interp 888 */-
7599 }
executed 4 times by 1 test: end of block
Executed by:
  • Self test
4
7600 else if (temp1 && ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) == 0))
temp1Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((quoted & (0x...|0x001)) == 0)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
0-11
7601 {-
7602 val = quote_escapes (temp1);-
7603 free (temp1);-
7604 temp1 = val;-
7605 }
executed 5 times by 1 test: end of block
Executed by:
  • Self test
5
7606 break;
executed 15 times by 1 test: break;
Executed by:
  • Self test
15
7607#endif-
7608 case VT_POSPARMS:
executed 11 times by 1 test: case 1:
Executed by:
  • Self test
11
7609 temp1 = parameter_list_transform (xc, varname[0], quoted);-
7610 if (temp1 && quoted == 0 && ifs_is_null)
temp1Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
quoted == 0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
ifs_is_nullDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
0-11
7611 {-
7612 /* Posix interp 888 */-
7613 }
executed 6 times by 1 test: end of block
Executed by:
  • Self test
6
7614 else if (temp1 && ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) == 0))
temp1Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((quoted & (0x...|0x001)) == 0)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
0-5
7615 {-
7616 val = quote_escapes (temp1);-
7617 free (temp1);-
7618 temp1 = val;-
7619 }
executed 2 times by 1 test: end of block
Executed by:
  • Self test
2
7620 break;
executed 11 times by 1 test: break;
Executed by:
  • Self test
11
7621 }-
7622-
7623 this_command_name = oname;-
7624 return temp1;
executed 44 times by 1 test: return temp1;
Executed by:
  • Self test
44
7625}-
7626-
7627/******************************************************/-
7628/* */-
7629/* Functions to extract substrings of variable values */-
7630/* */-
7631/******************************************************/-
7632-
7633#if defined (HANDLE_MULTIBYTE)-
7634/* Character-oriented rather than strictly byte-oriented substrings. S and-
7635 E, rather being strict indices into STRING, indicate character (possibly-
7636 multibyte character) positions that require calculation.-
7637 Used by the ${param:offset[:length]} expansion. */-
7638static char *-
7639mb_substring (string, s, e)-
7640 char *string;-
7641 int s, e;-
7642{-
7643 char *tt;-
7644 int start, stop, i;-
7645 size_t slen;-
7646 DECLARE_MBSTATE;-
7647-
7648 start = 0;-
7649 /* Don't need string length in ADVANCE_CHAR unless multibyte chars possible. */-
7650 slen = (MB_CUR_MAX > 1) ? STRLEN (string) : 0;
( (__ctype_get...r_max ()) > 1)Description
TRUEevaluated 445 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(string)[1]Description
TRUEevaluated 399 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 30 times by 1 test
Evaluated by:
  • Self test
(string)[2]Description
TRUEevaluated 396 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
(string)Description
TRUEevaluated 445 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(string)[0]Description
TRUEevaluated 429 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16 times by 1 test
Evaluated by:
  • Self test
0-445
7651-
7652 i = s;-
7653 while (string[start] && i--)
string[start]Description
TRUEevaluated 1880 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 28 times by 1 test
Evaluated by:
  • Self test
i--Description
TRUEevaluated 1463 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 417 times by 1 test
Evaluated by:
  • Self test
28-1880
7654 ADVANCE_CHAR (string, slen, start);
executed 1458 times by 1 test: mblength = 1;
Executed by:
  • Self test
never executed: mblength = 1;
executed 5 times by 1 test: end of block
Executed by:
  • Self test
never executed: end of block
never executed: (start)++;
executed 1463 times by 1 test: (start) += mblength;
Executed by:
  • Self test
never executed: (start)++;
executed 1463 times by 1 test: end of block
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 1463 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
_fDescription
TRUEevaluated 1458 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 1463 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((string)[sta... & 0x80) == 0)Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 1463 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 1463 times by 1 test
Evaluated by:
  • Self test
0-1463
7655 stop = start;-
7656 i = e - s;-
7657 while (string[stop] && i--)
string[stop]Description
TRUEevaluated 2953 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 218 times by 1 test
Evaluated by:
  • Self test
i--Description
TRUEevaluated 2726 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 227 times by 1 test
Evaluated by:
  • Self test
218-2953
7658 ADVANCE_CHAR (string, slen, stop);
executed 2601 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 125 times by 1 test: mblength = 1;
Executed by:
  • Self test
never executed: end of block
never executed: end of block
never executed: (stop)++;
executed 2726 times by 1 test: (stop) += mblength;
Executed by:
  • Self test
never executed: (stop)++;
executed 2726 times by 1 test: end of block
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 2726 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
_fDescription
TRUEevaluated 2601 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 125 times by 1 test
Evaluated by:
  • Self test
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 2726 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 125 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((string)[stop] & 0x80) == 0)Description
TRUEevaluated 125 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 2726 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 2726 times by 1 test
Evaluated by:
  • Self test
0-2726
7659 tt = substring (string, start, stop);-
7660 return tt;
executed 445 times by 1 test: return tt;
Executed by:
  • Self test
445
7661}-
7662#endif-
7663 -
7664/* Process a variable substring expansion: ${name:e1[:e2]}. If VARNAME-
7665 is `@', use the positional parameters; otherwise, use the value of-
7666 VARNAME. If VARNAME is an array variable, use the array elements. */-
7667-
7668static char *-
7669parameter_brace_substring (varname, value, ind, substr, quoted, pflags, flags)-
7670 char *varname, *value;-
7671 int ind;-
7672 char *substr;-
7673 int quoted, pflags, flags;-
7674{-
7675 intmax_t e1, e2;-
7676 int vtype, r, starsub, qflags;-
7677 char *temp, *val, *tt, *oname;-
7678 SHELL_VAR *v;-
7679-
7680 if (value == 0 && ((varname[0] != '@' && varname[0] != '*') || varname[1]))
value == 0Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 784 times by 1 test
Evaluated by:
  • Self test
varname[0] != '@'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
varname[0] != '*'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
varname[1]Description
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
0-784
7681 return ((char *)NULL);
executed 2 times by 1 test: return ((char *) ((void *)0) );
Executed by:
  • Self test
2
7682-
7683 oname = this_command_name;-
7684 this_command_name = varname;-
7685-
7686 vtype = get_var_and_type (varname, value, ind, quoted, flags, &v, &val);-
7687 if (vtype == -1)
vtype == -1Description
TRUEnever evaluated
FALSEevaluated 792 times by 1 test
Evaluated by:
  • Self test
0-792
7688 {-
7689 this_command_name = oname;-
7690 return ((char *)NULL);
never executed: return ((char *) ((void *)0) );
0
7691 }-
7692-
7693 starsub = vtype & VT_STARSUB;-
7694 vtype &= ~VT_STARSUB;-
7695-
7696 r = verify_substring_values (v, val, substr, vtype, &e1, &e2);-
7697 this_command_name = oname;-
7698 if (r <= 0)
r <= 0Description
TRUEevaluated 48 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 743 times by 1 test
Evaluated by:
  • Self test
48-743
7699 {-
7700 if (vtype == VT_VARIABLE)
vtype == 0Description
TRUEevaluated 42 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
6-42
7701 FREE (val);
executed 42 times by 1 test: sh_xfree((val), "subst.c", 7701);
Executed by:
  • Self test
executed 42 times by 1 test: end of block
Executed by:
  • Self test
valDescription
TRUEevaluated 42 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-42
7702 return ((r == 0) ? &expand_param_error : (char *)NULL);
executed 48 times by 1 test: return ((r == 0) ? &expand_param_error : (char *) ((void *)0) );
Executed by:
  • Self test
48
7703 }-
7704-
7705 switch (vtype)-
7706 {-
7707 case VT_VARIABLE:
executed 415 times by 1 test: case 0:
Executed by:
  • Self test
415
7708 case VT_ARRAYMEMBER:
executed 30 times by 1 test: case 3:
Executed by:
  • Self test
30
7709#if defined (HANDLE_MULTIBYTE)-
7710 if (MB_CUR_MAX > 1)
(__ctype_get_m...ur_max ()) > 1Description
TRUEevaluated 445 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-445
7711 tt = mb_substring (val, e1, e2);
executed 445 times by 1 test: tt = mb_substring (val, e1, e2);
Executed by:
  • Self test
445
7712 else-
7713#endif-
7714 tt = substring (val, e1, e2);
never executed: tt = substring (val, e1, e2);
0
7715-
7716 if (vtype == VT_VARIABLE)
vtype == 0Description
TRUEevaluated 415 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 30 times by 1 test
Evaluated by:
  • Self test
30-415
7717 FREE (val);
executed 415 times by 1 test: sh_xfree((val), "subst.c", 7717);
Executed by:
  • Self test
executed 415 times by 1 test: end of block
Executed by:
  • Self test
valDescription
TRUEevaluated 415 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-415
7718 if (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT))
quoted & (0x001|0x002)Description
TRUEevaluated 126 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 319 times by 1 test
Evaluated by:
  • Self test
126-319
7719 temp = quote_string (tt);
executed 126 times by 1 test: temp = quote_string (tt);
Executed by:
  • Self test
126
7720 else-
7721 temp = tt ? quote_escapes (tt) : (char *)NULL;
executed 319 times by 1 test: temp = tt ? quote_escapes (tt) : (char *) ((void *)0) ;
Executed by:
  • Self test
ttDescription
TRUEevaluated 319 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-319
7722 FREE (tt);
executed 445 times by 1 test: sh_xfree((tt), "subst.c", 7722);
Executed by:
  • Self test
ttDescription
TRUEevaluated 445 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-445
7723 break;
executed 445 times by 1 test: break;
Executed by:
  • Self test
445
7724 case VT_POSPARMS:
executed 221 times by 1 test: case 1:
Executed by:
  • Self test
221
7725 qflags = quoted;-
7726 tt = pos_params (varname, e1, e2, qflags);-
7727 /* string_list_dollar_at will quote the list if ifs_is_null != 0 */-
7728 /* We want to leave this alone in every case where pos_params/-
7729 string_list_pos_params quotes the list members */-
7730 if (tt && quoted == 0 && ifs_is_null)
ttDescription
TRUEevaluated 215 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
quoted == 0Description
TRUEevaluated 86 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 129 times by 1 test
Evaluated by:
  • Self test
ifs_is_nullDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 82 times by 1 test
Evaluated by:
  • Self test
4-215
7731 {-
7732 temp = tt; /* Posix interp 888 */-
7733 }
executed 4 times by 1 test: end of block
Executed by:
  • Self test
4
7734 else if ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) == 0)
(quoted & (0x001|0x002)) == 0Description
TRUEevaluated 86 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 131 times by 1 test
Evaluated by:
  • Self test
86-131
7735 {-
7736 temp = tt ? quote_escapes (tt) : (char *)NULL;
ttDescription
TRUEevaluated 82 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
4-82
7737 FREE (tt);
executed 82 times by 1 test: sh_xfree((tt), "subst.c", 7737);
Executed by:
  • Self test
ttDescription
TRUEevaluated 82 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
4-82
7738 }
executed 86 times by 1 test: end of block
Executed by:
  • Self test
86
7739 else-
7740 temp = tt;
executed 131 times by 1 test: temp = tt;
Executed by:
  • Self test
131
7741 break;
executed 221 times by 1 test: break;
Executed by:
  • Self test
221
7742#if defined (ARRAY_VARS)-
7743 case VT_ARRAYVAR:
executed 77 times by 1 test: case 2:
Executed by:
  • Self test
77
7744 if (assoc_p (v))
((((v)->attrib... (0x0000040)))Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 75 times by 1 test
Evaluated by:
  • Self test
2-75
7745 /* we convert to list and take first e2 elements starting at e1th-
7746 element -- officially undefined for now */ -
7747 temp = assoc_subrange (assoc_cell (v), e1, e2, starsub, quoted);
executed 2 times by 1 test: temp = assoc_subrange ((HASH_TABLE *)((v)->value), e1, e2, starsub, quoted);
Executed by:
  • Self test
2
7748 else-
7749 /* We want E2 to be the number of elements desired (arrays can be sparse,-
7750 so verify_substring_values just returns the numbers specified and we-
7751 rely on array_subrange to understand how to deal with them). */-
7752 temp = array_subrange (array_cell (v), e1, e2, starsub, quoted);
executed 75 times by 1 test: temp = array_subrange ((ARRAY *)((v)->value), e1, e2, starsub, quoted);
Executed by:
  • Self test
75
7753 /* array_subrange now calls array_quote_escapes as appropriate, so the-
7754 caller no longer needs to. */-
7755 break;
executed 77 times by 1 test: break;
Executed by:
  • Self test
77
7756#endif-
7757 default:
never executed: default:
0
7758 temp = (char *)NULL;-
7759 }
never executed: end of block
0
7760-
7761 return temp;
executed 743 times by 1 test: return temp;
Executed by:
  • Self test
743
7762}-
7763-
7764/****************************************************************/-
7765/* */-
7766/* Functions to perform pattern substitution on variable values */-
7767/* */-
7768/****************************************************************/-
7769-
7770#ifdef INCLUDE_UNUSED-
7771static int-
7772shouldexp_replacement (s)-
7773 char *s;-
7774{-
7775 register char *p;-
7776-
7777 for (p = s; p && *p; p++)-
7778 {-
7779 if (*p == '\\')-
7780 p++;-
7781 else if (*p == '&')-
7782 return 1;-
7783 }-
7784 return 0;-
7785}-
7786#endif-
7787-
7788char *-
7789pat_subst (string, pat, rep, mflags)-
7790 char *string, *pat, *rep;-
7791 int mflags;-
7792{-
7793 char *ret, *s, *e, *str, *rstr, *mstr;-
7794 int rptr, mtype, rxpand, mlen;-
7795 size_t rsize, l, replen, rslen;-
7796-
7797 if (string == 0)
string == 0Description
TRUEnever evaluated
FALSEevaluated 2176 times by 1 test
Evaluated by:
  • Self test
0-2176
7798 return (savestring (""));
never executed: return ((char *)strcpy (sh_xmalloc((1 + strlen ("")), "subst.c", 7798), ("")));
0
7799-
7800 mtype = mflags & MATCH_TYPEMASK;-
7801-
7802#if 0 /* bash-4.2 ? */-
7803 rxpand = (rep && *rep) ? shouldexp_replacement (rep) : 0;-
7804#else-
7805 rxpand = 0;-
7806#endif-
7807-
7808 /* Special cases:-
7809 * 1. A null pattern with mtype == MATCH_BEG means to prefix STRING-
7810 * with REP and return the result.-
7811 * 2. A null pattern with mtype == MATCH_END means to append REP to-
7812 * STRING and return the result.-
7813 * 3. A null STRING with a matching pattern means to append REP to-
7814 * STRING and return the result.-
7815 * These don't understand or process `&' in the replacement string.-
7816 */-
7817 if ((pat == 0 || *pat == 0) && (mtype == MATCH_BEG || mtype == MATCH_END))
pat == 0Description
TRUEevaluated 31 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2145 times by 1 test
Evaluated by:
  • Self test
*pat == 0Description
TRUEevaluated 112 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2033 times by 1 test
Evaluated by:
  • Self test
mtype == 0x001Description
TRUEevaluated 110 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 33 times by 1 test
Evaluated by:
  • Self test
mtype == 0x002Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31 times by 1 test
Evaluated by:
  • Self test
2-2145
7818 {-
7819 replen = STRLEN (rep);
(rep)[1]Description
TRUEevaluated 80 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 30 times by 1 test
Evaluated by:
  • Self test
(rep)[2]Description
TRUEevaluated 78 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
(rep)Description
TRUEevaluated 110 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
(rep)[0]Description
TRUEevaluated 110 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-110
7820 l = STRLEN (string);
(string)[1]Description
TRUEevaluated 79 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 24 times by 1 test
Evaluated by:
  • Self test
(string)[2]Description
TRUEevaluated 79 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(string)Description
TRUEevaluated 112 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(string)[0]Description
TRUEevaluated 103 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
0-112
7821 ret = (char *)xmalloc (replen + l + 2);-
7822 if (replen == 0)
replen == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 110 times by 1 test
Evaluated by:
  • Self test
2-110
7823 strcpy (ret, string);
executed 2 times by 1 test: strcpy (ret, string);
Executed by:
  • Self test
2
7824 else if (mtype == MATCH_BEG)
mtype == 0x001Description
TRUEevaluated 109 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-109
7825 {-
7826 strcpy (ret, rep);-
7827 strcpy (ret + replen, string);-
7828 }
executed 109 times by 1 test: end of block
Executed by:
  • Self test
109
7829 else-
7830 {-
7831 strcpy (ret, string);-
7832 strcpy (ret + l, rep);-
7833 }
executed 1 time by 1 test: end of block
Executed by:
  • Self test
1
7834 return (ret);
executed 112 times by 1 test: return (ret);
Executed by:
  • Self test
112
7835 }-
7836 else if (*string == 0 && (match_pattern (string, pat, mtype, &s, &e) != 0))
*string == 0Description
TRUEevaluated 32 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2032 times by 1 test
Evaluated by:
  • Self test
(match_pattern... &s, &e) != 0)Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test
14-2032
7837 {-
7838 replen = STRLEN (rep);
(rep)[1]Description
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • Self test
(rep)[2]Description
TRUEnever evaluated
FALSEnever evaluated
(rep)Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(rep)[0]Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-18
7839 ret = (char *)xmalloc (replen + 1);-
7840 if (replen == 0)
replen == 0Description
TRUEnever evaluated
FALSEevaluated 18 times by 1 test
Evaluated by:
  • Self test
0-18
7841 ret[0] = '\0';
never executed: ret[0] = '\0';
0
7842 else-
7843 strcpy (ret, rep);
executed 18 times by 1 test: strcpy (ret, rep);
Executed by:
  • Self test
18
7844 return (ret);
executed 18 times by 1 test: return (ret);
Executed by:
  • Self test
18
7845 }-
7846-
7847 ret = (char *)xmalloc (rsize = 64);-
7848 ret[0] = '\0';-
7849-
7850 for (replen = STRLEN (rep), rptr = 0, str = string; *str;)
*strDescription
TRUEevaluated 60180 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 174 times by 1 test
Evaluated by:
  • Self test
174-60180
7851 {-
7852 if (match_pattern (str, pat, mtype, &s, &e) == 0)
match_pattern ..., &s, &e) == 0Description
TRUEevaluated 832 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 59348 times by 1 test
Evaluated by:
  • Self test
832-59348
7853 break;
executed 832 times by 1 test: break;
Executed by:
  • Self test
832
7854 l = s - str;-
7855-
7856 if (rep && rxpand)
repDescription
TRUEevaluated 1185 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 58163 times by 1 test
Evaluated by:
  • Self test
rxpandDescription
TRUEnever evaluated
FALSEevaluated 1185 times by 1 test
Evaluated by:
  • Self test
0-58163
7857 {-
7858 int x;-
7859 mlen = e - s;-
7860 mstr = xmalloc (mlen + 1);-
7861 for (x = 0; x < mlen; x++)
x < mlenDescription
TRUEnever evaluated
FALSEnever evaluated
0
7862 mstr[x] = s[x];
never executed: mstr[x] = s[x];
0
7863 mstr[mlen] = '\0';-
7864 rstr = strcreplace (rep, '&', mstr, 0);-
7865 free (mstr);-
7866 rslen = strlen (rstr);-
7867 }
never executed: end of block
0
7868 else-
7869 {-
7870 rstr = rep;-
7871 rslen = replen;-
7872 }
executed 59348 times by 1 test: end of block
Executed by:
  • Self test
59348
7873 -
7874 RESIZE_MALLOCED_BUFFER (ret, rptr, (l + rslen), rsize, 64);
executed 826 times by 1 test: rsize += (64);
Executed by:
  • Self test
executed 520 times by 1 test: end of block
Executed by:
  • Self test
(rptr) + ((l +...len)) >= rsizeDescription
TRUEevaluated 520 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 58828 times by 1 test
Evaluated by:
  • Self test
(rptr) + ((l +...len)) >= rsizeDescription
TRUEevaluated 826 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 520 times by 1 test
Evaluated by:
  • Self test
520-58828
7875-
7876 /* OK, now copy the leading unmatched portion of the string (from-
7877 str to s) to ret starting at rptr (the current offset). Then copy-
7878 the replacement string at ret + rptr + (s - str). Increment-
7879 rptr (if necessary) and str and go on. */-
7880 if (l)
lDescription
TRUEevaluated 10505 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 48843 times by 1 test
Evaluated by:
  • Self test
10505-48843
7881 {-
7882 strncpy (ret + rptr, str, l);-
7883 rptr += l;-
7884 }
executed 10505 times by 1 test: end of block
Executed by:
  • Self test
10505
7885 if (replen)
replenDescription
TRUEevaluated 1185 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 58163 times by 1 test
Evaluated by:
  • Self test
1185-58163
7886 {-
7887 strncpy (ret + rptr, rstr, rslen);-
7888 rptr += rslen;-
7889 }
executed 1185 times by 1 test: end of block
Executed by:
  • Self test
1185
7890 str = e; /* e == end of match */-
7891-
7892 if (rstr != rep)
rstr != repDescription
TRUEnever evaluated
FALSEevaluated 59348 times by 1 test
Evaluated by:
  • Self test
0-59348
7893 free (rstr);
never executed: sh_xfree((rstr), "subst.c", 7893);
0
7894-
7895 if (((mflags & MATCH_GLOBREP) == 0) || mtype != MATCH_ANY)
((mflags & 0x010) == 0)Description
TRUEevaluated 1040 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 58308 times by 1 test
Evaluated by:
  • Self test
mtype != 0x000Description
TRUEnever evaluated
FALSEevaluated 58308 times by 1 test
Evaluated by:
  • Self test
0-58308
7896 break;
executed 1040 times by 1 test: break;
Executed by:
  • Self test
1040
7897-
7898 if (s == e)
s == eDescription
TRUEnever evaluated
FALSEevaluated 58308 times by 1 test
Evaluated by:
  • Self test
0-58308
7899 {-
7900 /* On a zero-length match, make sure we copy one character, since-
7901 we increment one character to avoid infinite recursion. */-
7902 RESIZE_MALLOCED_BUFFER (ret, rptr, 1, rsize, 64);
never executed: rsize += (64);
never executed: end of block
(rptr) + (1) >= rsizeDescription
TRUEnever evaluated
FALSEnever evaluated
(rptr) + (1) >= rsizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
7903 ret[rptr++] = *str++;-
7904 e++; /* avoid infinite recursion on zero-length match */-
7905 }
never executed: end of block
0
7906 }
executed 58308 times by 1 test: end of block
Executed by:
  • Self test
58308
7907-
7908 /* Now copy the unmatched portion of the input string */-
7909 if (str && *str)
strDescription
TRUEevaluated 2046 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*strDescription
TRUEevaluated 1459 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 587 times by 1 test
Evaluated by:
  • Self test
0-2046
7910 {-
7911 RESIZE_MALLOCED_BUFFER (ret, rptr, STRLEN(str) + 1, rsize, 64);
executed 1241 times by 1 test: rsize += (64);
Executed by:
  • Self test
executed 17 times by 1 test: end of block
Executed by:
  • Self test
(rptr) + ((((s... + 1) >= rsizeDescription
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1442 times by 1 test
Evaluated by:
  • Self test
(rptr) + ((((s... + 1) >= rsizeDescription
TRUEevaluated 1241 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 17 times by 1 test
Evaluated by:
  • Self test
(str)[1]Description
TRUEevaluated 701 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 758 times by 1 test
Evaluated by:
  • Self test
(str)[2]Description
TRUEevaluated 519 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 182 times by 1 test
Evaluated by:
  • Self test
(str)[1]Description
TRUEevaluated 1258 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(str)[2]Description
TRUEevaluated 1258 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(str)Description
TRUEevaluated 1459 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(str)[0]Description
TRUEevaluated 1459 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(str)Description
TRUEevaluated 1258 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(str)[0]Description
TRUEevaluated 1258 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-1459
7912 strcpy (ret + rptr, str);-
7913 }
executed 1459 times by 1 test: end of block
Executed by:
  • Self test
1459
7914 else-
7915 ret[rptr] = '\0';
executed 587 times by 1 test: ret[rptr] = '\0';
Executed by:
  • Self test
587
7916-
7917 return ret;
executed 2046 times by 1 test: return ret;
Executed by:
  • Self test
2046
7918}-
7919-
7920/* Do pattern match and replacement on the positional parameters. */-
7921static char *-
7922pos_params_pat_subst (string, pat, rep, mflags)-
7923 char *string, *pat, *rep;-
7924 int mflags;-
7925{-
7926 WORD_LIST *save, *params;-
7927 WORD_DESC *w;-
7928 char *ret;-
7929 int pchar, qflags;-
7930-
7931 save = params = list_rest_of_args ();-
7932 if (save == 0)
save == 0Description
TRUEnever evaluated
FALSEevaluated 140 times by 1 test
Evaluated by:
  • Self test
0-140
7933 return ((char *)NULL);
never executed: return ((char *) ((void *)0) );
0
7934-
7935 for ( ; params; params = params->next)
paramsDescription
TRUEevaluated 779 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 140 times by 1 test
Evaluated by:
  • Self test
140-779
7936 {-
7937 ret = pat_subst (params->word->word, pat, rep, mflags);-
7938 w = alloc_word_desc ();-
7939 w->word = ret ? ret : savestring ("");
retDescription
TRUEevaluated 779 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-779
7940 dispose_word (params->word);-
7941 params->word = w;-
7942 }
executed 779 times by 1 test: end of block
Executed by:
  • Self test
779
7943-
7944 pchar = (mflags & MATCH_STARSUB) == MATCH_STARSUB ? '*' : '@';
(mflags & 0x080) == 0x080Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 114 times by 1 test
Evaluated by:
  • Self test
26-114
7945 qflags = (mflags & MATCH_QUOTED) == MATCH_QUOTED ? Q_DOUBLE_QUOTES : 0;
(mflags & 0x020) == 0x020Description
TRUEevaluated 28 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 112 times by 1 test
Evaluated by:
  • Self test
28-112
7946-
7947 /* If we are expanding in a context where word splitting will not be-
7948 performed, treat as quoted. This changes how $* will be expanded. */-
7949 if (pchar == '*' && (mflags & MATCH_ASSIGNRHS) && expand_no_split_dollar_star && ifs_is_null)
pchar == '*'Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 114 times by 1 test
Evaluated by:
  • Self test
(mflags & 0x040)Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20 times by 1 test
Evaluated by:
  • Self test
expand_no_split_dollar_starDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
ifs_is_nullDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-114
7950 qflags |= Q_DOUBLE_QUOTES; /* Posix interp 888 */
executed 3 times by 1 test: qflags |= 0x001;
Executed by:
  • Self test
3
7951-
7952 ret = string_list_pos_params (pchar, save, qflags);-
7953 dispose_words (save);-
7954-
7955 return (ret);
executed 140 times by 1 test: return (ret);
Executed by:
  • Self test
140
7956}-
7957-
7958/* Perform pattern substitution on VALUE, which is the expansion of-
7959 VARNAME. PATSUB is an expression supplying the pattern to match-
7960 and the string to substitute. QUOTED is a flags word containing-
7961 the type of quoting currently in effect. */-
7962static char *-
7963parameter_brace_patsub (varname, value, ind, patsub, quoted, pflags, flags)-
7964 char *varname, *value;-
7965 int ind;-
7966 char *patsub;-
7967 int quoted, pflags, flags;-
7968{-
7969 int vtype, mflags, starsub, delim;-
7970 char *val, *temp, *pat, *rep, *p, *lpatsub, *tt, *oname;-
7971 SHELL_VAR *v;-
7972-
7973 if (value == 0)
value == 0Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 861 times by 1 test
Evaluated by:
  • Self test
16-861
7974 return ((char *)NULL);
executed 16 times by 1 test: return ((char *) ((void *)0) );
Executed by:
  • Self test
16
7975-
7976 oname = this_command_name;-
7977 this_command_name = varname; /* error messages */-
7978-
7979 vtype = get_var_and_type (varname, value, ind, quoted, flags, &v, &val);-
7980 if (vtype == -1)
vtype == -1Description
TRUEnever evaluated
FALSEevaluated 861 times by 1 test
Evaluated by:
  • Self test
0-861
7981 {-
7982 this_command_name = oname;-
7983 return ((char *)NULL);
never executed: return ((char *) ((void *)0) );
0
7984 }-
7985-
7986 starsub = vtype & VT_STARSUB;-
7987 vtype &= ~VT_STARSUB;-
7988-
7989 mflags = 0;-
7990 /* PATSUB is never NULL when this is called. */-
7991 if (*patsub == '/')
*patsub == '/'Description
TRUEevaluated 304 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 557 times by 1 test
Evaluated by:
  • Self test
304-557
7992 {-
7993 mflags |= MATCH_GLOBREP;-
7994 patsub++;-
7995 }
executed 304 times by 1 test: end of block
Executed by:
  • Self test
304
7996-
7997 /* Malloc this because expand_string_if_necessary or one of the expansion-
7998 functions in its call chain may free it on a substitution error. */-
7999 lpatsub = savestring (patsub);-
8000-
8001 if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
quoted & (0x002|0x001)Description
TRUEevaluated 223 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 638 times by 1 test
Evaluated by:
  • Self test
223-638
8002 mflags |= MATCH_QUOTED;
executed 223 times by 1 test: mflags |= 0x020;
Executed by:
  • Self test
223
8003-
8004 if (starsub)
starsubDescription
TRUEevaluated 51 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 810 times by 1 test
Evaluated by:
  • Self test
51-810
8005 mflags |= MATCH_STARSUB;
executed 51 times by 1 test: mflags |= 0x080;
Executed by:
  • Self test
51
8006-
8007 if (pflags & PF_ASSIGNRHS)
pflags & 0x08Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 849 times by 1 test
Evaluated by:
  • Self test
12-849
8008 mflags |= MATCH_ASSIGNRHS;
executed 12 times by 1 test: mflags |= 0x040;
Executed by:
  • Self test
12
8009-
8010 /* If the pattern starts with a `/', make sure we skip over it when looking-
8011 for the replacement delimiter. */-
8012 delim = skip_to_delim (lpatsub, ((*patsub == '/') ? 1 : 0), "/", 0);-
8013 if (lpatsub[delim] == '/')
lpatsub[delim] == '/'Description
TRUEevaluated 745 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 116 times by 1 test
Evaluated by:
  • Self test
116-745
8014 {-
8015 lpatsub[delim] = 0;-
8016 rep = lpatsub + delim + 1;-
8017 }
executed 745 times by 1 test: end of block
Executed by:
  • Self test
745
8018 else-
8019 rep = (char *)NULL;
executed 116 times by 1 test: rep = (char *) ((void *)0) ;
Executed by:
  • Self test
116
8020-
8021 if (rep && *rep == '\0')
repDescription
TRUEevaluated 745 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 116 times by 1 test
Evaluated by:
  • Self test
*rep == '\0'Description
TRUEevaluated 154 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 591 times by 1 test
Evaluated by:
  • Self test
116-745
8022 rep = (char *)NULL;
executed 154 times by 1 test: rep = (char *) ((void *)0) ;
Executed by:
  • Self test
154
8023-
8024 /* Perform the same expansions on the pattern as performed by the-
8025 pattern removal expansions. */-
8026 pat = getpattern (lpatsub, quoted, 1);-
8027-
8028 if (rep)
repDescription
TRUEevaluated 589 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 268 times by 1 test
Evaluated by:
  • Self test
268-589
8029 {-
8030 /* We want to perform quote removal on the expanded replacement even if-
8031 the entire expansion is double-quoted because the parser and string-
8032 extraction functions treated quotes in the replacement string as-
8033 special. THIS IS NOT BACKWARDS COMPATIBLE WITH BASH-4.2. */-
8034 if (shell_compatibility_level > 42)
shell_compatibility_level > 42Description
TRUEevaluated 589 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-589
8035 rep = expand_string_if_necessary (rep, quoted & ~(Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT), expand_string_unsplit);
executed 589 times by 1 test: rep = expand_string_if_necessary (rep, quoted & ~(0x001|0x002), expand_string_unsplit);
Executed by:
  • Self test
589
8036 /* This is the bash-4.2 code. */ -
8037 else if ((mflags & MATCH_QUOTED) == 0)
(mflags & 0x020) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
8038 rep = expand_string_if_necessary (rep, quoted, expand_string_unsplit);
never executed: rep = expand_string_if_necessary (rep, quoted, expand_string_unsplit);
0
8039 else-
8040 rep = expand_string_to_string_internal (rep, quoted, expand_string_unsplit);
never executed: rep = expand_string_to_string_internal (rep, quoted, expand_string_unsplit);
0
8041 }-
8042-
8043 /* ksh93 doesn't allow the match specifier to be a part of the expanded-
8044 pattern. This is an extension. Make sure we don't anchor the pattern-
8045 at the beginning or end of the string if we're doing global replacement,-
8046 though. */-
8047 p = pat;-
8048 if (mflags & MATCH_GLOBREP)
mflags & 0x010Description
TRUEevaluated 300 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 557 times by 1 test
Evaluated by:
  • Self test
300-557
8049 mflags |= MATCH_ANY;
executed 300 times by 1 test: mflags |= 0x000;
Executed by:
  • Self test
300
8050 else if (pat && pat[0] == '#')
patDescription
TRUEevaluated 541 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16 times by 1 test
Evaluated by:
  • Self test
pat[0] == '#'Description
TRUEevaluated 122 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 419 times by 1 test
Evaluated by:
  • Self test
16-541
8051 {-
8052 mflags |= MATCH_BEG;-
8053 p++;-
8054 }
executed 122 times by 1 test: end of block
Executed by:
  • Self test
122
8055 else if (pat && pat[0] == '%')
patDescription
TRUEevaluated 419 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16 times by 1 test
Evaluated by:
  • Self test
pat[0] == '%'Description
TRUEevaluated 97 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 322 times by 1 test
Evaluated by:
  • Self test
16-419
8056 {-
8057 mflags |= MATCH_END;-
8058 p++;-
8059 }
executed 97 times by 1 test: end of block
Executed by:
  • Self test
97
8060 else-
8061 mflags |= MATCH_ANY;
executed 338 times by 1 test: mflags |= 0x000;
Executed by:
  • Self test
338
8062-
8063 /* OK, we now want to substitute REP for PAT in VAL. If-
8064 flags & MATCH_GLOBREP is non-zero, the substitution is done-
8065 everywhere, otherwise only the first occurrence of PAT is-
8066 replaced. The pattern matching code doesn't understand-
8067 CTLESC quoting CTLESC and CTLNUL so we use the dequoted variable-
8068 values passed in (VT_VARIABLE) so the pattern substitution-
8069 code works right. We need to requote special chars after-
8070 we're done for VT_VARIABLE and VT_ARRAYMEMBER, and for the-
8071 other cases if QUOTED == 0, since the posparams and arrays-
8072 indexed by * or @ do special things when QUOTED != 0. */-
8073-
8074 switch (vtype)-
8075 {-
8076 case VT_VARIABLE:
executed 463 times by 1 test: case 0:
Executed by:
  • Self test
463
8077 case VT_ARRAYMEMBER:
executed 108 times by 1 test: case 3:
Executed by:
  • Self test
108
8078 temp = pat_subst (val, p, rep, mflags);-
8079 if (vtype == VT_VARIABLE)
vtype == 0Description
TRUEevaluated 463 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 108 times by 1 test
Evaluated by:
  • Self test
108-463
8080 FREE (val);
executed 463 times by 1 test: sh_xfree((val), "subst.c", 8080);
Executed by:
  • Self test
executed 463 times by 1 test: end of block
Executed by:
  • Self test
valDescription
TRUEevaluated 463 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-463
8081 if (temp)
tempDescription
TRUEevaluated 571 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-571
8082 {-
8083 tt = (mflags & MATCH_QUOTED) ? quote_string (temp) : quote_escapes (temp);
(mflags & 0x020)Description
TRUEevaluated 143 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 428 times by 1 test
Evaluated by:
  • Self test
143-428
8084 free (temp);-
8085 temp = tt;-
8086 }
executed 571 times by 1 test: end of block
Executed by:
  • Self test
571
8087 break;
executed 571 times by 1 test: break;
Executed by:
  • Self test
571
8088 case VT_POSPARMS:
executed 140 times by 1 test: case 1:
Executed by:
  • Self test
140
8089 /* This does the right thing for the case where we are not performing-
8090 word splitting. MATCH_STARSUB restricts it to ${* /foo/bar}, and-
8091 pos_params_pat_subst/string_list_pos_params will do the right thing-
8092 in turn for the case where ifs_is_null. Posix interp 888 */-
8093 if ((pflags & PF_NOSPLIT2) && (mflags & MATCH_STARSUB))
(pflags & 0x04)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 137 times by 1 test
Evaluated by:
  • Self test
(mflags & 0x080)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-137
8094 mflags |= MATCH_ASSIGNRHS;
executed 3 times by 1 test: mflags |= 0x040;
Executed by:
  • Self test
3
8095 temp = pos_params_pat_subst (val, p, rep, mflags);-
8096 if (temp && quoted == 0 && ifs_is_null)
tempDescription
TRUEevaluated 140 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
quoted == 0Description
TRUEevaluated 112 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 28 times by 1 test
Evaluated by:
  • Self test
ifs_is_nullDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 106 times by 1 test
Evaluated by:
  • Self test
0-140
8097 {-
8098 /* Posix interp 888 */-
8099 }
executed 6 times by 1 test: end of block
Executed by:
  • Self test
6
8100 else if (temp && (mflags & MATCH_QUOTED) == 0)
tempDescription
TRUEevaluated 134 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(mflags & 0x020) == 0Description
TRUEevaluated 106 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 28 times by 1 test
Evaluated by:
  • Self test
0-134
8101 {-
8102 tt = quote_escapes (temp);-
8103 free (temp);-
8104 temp = tt;-
8105 }
executed 106 times by 1 test: end of block
Executed by:
  • Self test
106
8106 break;
executed 140 times by 1 test: break;
Executed by:
  • Self test
140
8107#if defined (ARRAY_VARS)-
8108 case VT_ARRAYVAR:
executed 146 times by 1 test: case 2:
Executed by:
  • Self test
146
8109 /* If we are expanding in a context where word splitting will not be-
8110 performed, treat as quoted. This changes how ${A[*]} will be-
8111 expanded to make it identical to $*. */-
8112 if ((mflags & MATCH_STARSUB) && (mflags & MATCH_ASSIGNRHS) && ifs_is_null)
(mflags & 0x080)Description
TRUEevaluated 25 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 121 times by 1 test
Evaluated by:
  • Self test
(mflags & 0x040)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 24 times by 1 test
Evaluated by:
  • Self test
ifs_is_nullDescription
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-121
8113 mflags |= MATCH_QUOTED; /* Posix interp 888 */
never executed: mflags |= 0x020;
0
8114-
8115 temp = assoc_p (v) ? assoc_patsub (assoc_cell (v), p, rep, mflags)
((((v)->attrib... (0x0000040)))Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 138 times by 1 test
Evaluated by:
  • Self test
8-138
8116 : array_patsub (array_cell (v), p, rep, mflags);-
8117 /* Don't call quote_escapes anymore; array_patsub calls-
8118 array_quote_escapes as appropriate before adding the-
8119 space separators; ditto for assoc_patsub. */-
8120 break;
executed 146 times by 1 test: break;
Executed by:
  • Self test
146
8121#endif-
8122 }-
8123-
8124 FREE (pat);
executed 832 times by 1 test: sh_xfree((pat), "subst.c", 8124);
Executed by:
  • Self test
patDescription
TRUEevaluated 832 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 25 times by 1 test
Evaluated by:
  • Self test
25-832
8125 FREE (rep);
executed 588 times by 1 test: sh_xfree((rep), "subst.c", 8125);
Executed by:
  • Self test
repDescription
TRUEevaluated 588 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 269 times by 1 test
Evaluated by:
  • Self test
269-588
8126 free (lpatsub);-
8127-
8128 this_command_name = oname;-
8129-
8130 return temp;
executed 857 times by 1 test: return temp;
Executed by:
  • Self test
857
8131}-
8132-
8133/****************************************************************/-
8134/* */-
8135/* Functions to perform case modification on variable values */-
8136/* */-
8137/****************************************************************/-
8138-
8139/* Do case modification on the positional parameters. */-
8140-
8141static char *-
8142pos_params_modcase (string, pat, modop, mflags)-
8143 char *string, *pat;-
8144 int modop;-
8145 int mflags;-
8146{-
8147 WORD_LIST *save, *params;-
8148 WORD_DESC *w;-
8149 char *ret;-
8150 int pchar, qflags;-
8151-
8152 save = params = list_rest_of_args ();-
8153 if (save == 0)
save == 0Description
TRUEnever evaluated
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test
0-14
8154 return ((char *)NULL);
never executed: return ((char *) ((void *)0) );
0
8155-
8156 for ( ; params; params = params->next)
paramsDescription
TRUEevaluated 27 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test
14-27
8157 {-
8158 ret = sh_modcase (params->word->word, pat, modop);-
8159 w = alloc_word_desc ();-
8160 w->word = ret ? ret : savestring ("");
retDescription
TRUEevaluated 27 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-27
8161 dispose_word (params->word);-
8162 params->word = w;-
8163 }
executed 27 times by 1 test: end of block
Executed by:
  • Self test
27
8164-
8165 pchar = (mflags & MATCH_STARSUB) == MATCH_STARSUB ? '*' : '@';
(mflags & 0x080) == 0x080Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
4-10
8166 qflags = (mflags & MATCH_QUOTED) == MATCH_QUOTED ? Q_DOUBLE_QUOTES : 0;
(mflags & 0x020) == 0x020Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
1-13
8167-
8168 /* If we are expanding in a context where word splitting will not be-
8169 performed, treat as quoted. This changes how $* will be expanded. */-
8170 if (pchar == '*' && (mflags & MATCH_ASSIGNRHS) && ifs_is_null)
pchar == '*'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
(mflags & 0x040)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
ifs_is_nullDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-10
8171 qflags |= Q_DOUBLE_QUOTES; /* Posix interp 888 */
executed 1 time by 1 test: qflags |= 0x001;
Executed by:
  • Self test
1
8172-
8173 ret = string_list_pos_params (pchar, save, qflags);-
8174 dispose_words (save);-
8175-
8176 return (ret);
executed 14 times by 1 test: return (ret);
Executed by:
  • Self test
14
8177}-
8178-
8179/* Perform case modification on VALUE, which is the expansion of-
8180 VARNAME. MODSPEC is an expression supplying the type of modification-
8181 to perform. QUOTED is a flags word containing the type of quoting-
8182 currently in effect. */-
8183static char *-
8184parameter_brace_casemod (varname, value, ind, modspec, patspec, quoted, pflags, flags)-
8185 char *varname, *value;-
8186 int ind, modspec;-
8187 char *patspec;-
8188 int quoted, pflags, flags;-
8189{-
8190 int vtype, starsub, modop, mflags, x;-
8191 char *val, *temp, *pat, *p, *lpat, *tt, *oname;-
8192 SHELL_VAR *v;-
8193-
8194 if (value == 0)
value == 0Description
TRUEnever evaluated
FALSEevaluated 80 times by 1 test
Evaluated by:
  • Self test
0-80
8195 return ((char *)NULL);
never executed: return ((char *) ((void *)0) );
0
8196-
8197 oname = this_command_name;-
8198 this_command_name = varname;-
8199-
8200 vtype = get_var_and_type (varname, value, ind, quoted, flags, &v, &val);-
8201 if (vtype == -1)
vtype == -1Description
TRUEnever evaluated
FALSEevaluated 80 times by 1 test
Evaluated by:
  • Self test
0-80
8202 {-
8203 this_command_name = oname;-
8204 return ((char *)NULL);
never executed: return ((char *) ((void *)0) );
0
8205 }-
8206-
8207 starsub = vtype & VT_STARSUB;-
8208 vtype &= ~VT_STARSUB;-
8209-
8210 modop = 0;-
8211 mflags = 0;-
8212 if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
quoted & (0x002|0x001)Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 59 times by 1 test
Evaluated by:
  • Self test
21-59
8213 mflags |= MATCH_QUOTED;
executed 21 times by 1 test: mflags |= 0x020;
Executed by:
  • Self test
21
8214 if (starsub)
starsubDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 72 times by 1 test
Evaluated by:
  • Self test
8-72
8215 mflags |= MATCH_STARSUB;
executed 8 times by 1 test: mflags |= 0x080;
Executed by:
  • Self test
8
8216 if (pflags & PF_ASSIGNRHS)
pflags & 0x08Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 75 times by 1 test
Evaluated by:
  • Self test
5-75
8217 mflags |= MATCH_ASSIGNRHS;
executed 5 times by 1 test: mflags |= 0x040;
Executed by:
  • Self test
5
8218 -
8219 p = patspec;-
8220 if (modspec == '^')
modspec == '^'Description
TRUEevaluated 38 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 42 times by 1 test
Evaluated by:
  • Self test
38-42
8221 {-
8222 x = p && p[0] == modspec;
pDescription
TRUEevaluated 38 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
p[0] == modspecDescription
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 17 times by 1 test
Evaluated by:
  • Self test
0-38
8223 modop = x ? CASE_UPPER : CASE_UPFIRST;
xDescription
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 17 times by 1 test
Evaluated by:
  • Self test
17-21
8224 p += x;-
8225 }
executed 38 times by 1 test: end of block
Executed by:
  • Self test
38
8226 else if (modspec == ',')
modspec == ','Description
TRUEevaluated 40 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2-40
8227 {-
8228 x = p && p[0] == modspec;
pDescription
TRUEevaluated 40 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
p[0] == modspecDescription
TRUEevaluated 29 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11 times by 1 test
Evaluated by:
  • Self test
0-40
8229 modop = x ? CASE_LOWER : CASE_LOWFIRST;
xDescription
TRUEevaluated 29 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11 times by 1 test
Evaluated by:
  • Self test
11-29
8230 p += x;-
8231 }
executed 40 times by 1 test: end of block
Executed by:
  • Self test
40
8232 else if (modspec == '~')
modspec == '~'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
8233 {-
8234 x = p && p[0] == modspec;
pDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
p[0] == modspecDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-2
8235 modop = x ? CASE_TOGGLEALL : CASE_TOGGLE;
xDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1
8236 p += x;-
8237 }
executed 2 times by 1 test: end of block
Executed by:
  • Self test
2
8238 -
8239 lpat = p ? savestring (p) : 0;
pDescription
TRUEevaluated 80 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-80
8240 /* Perform the same expansions on the pattern as performed by the-
8241 pattern removal expansions. */-
8242 pat = lpat ? getpattern (lpat, quoted, 1) : 0;
lpatDescription
TRUEevaluated 80 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-80
8243-
8244 /* OK, now we do the case modification. */-
8245 switch (vtype)-
8246 {-
8247 case VT_VARIABLE:
executed 34 times by 1 test: case 0:
Executed by:
  • Self test
34
8248 case VT_ARRAYMEMBER:
executed 9 times by 1 test: case 3:
Executed by:
  • Self test
9
8249 temp = sh_modcase (val, pat, modop);-
8250 if (vtype == VT_VARIABLE)
vtype == 0Description
TRUEevaluated 34 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
9-34
8251 FREE (val);
executed 34 times by 1 test: sh_xfree((val), "subst.c", 8251);
Executed by:
  • Self test
executed 34 times by 1 test: end of block
Executed by:
  • Self test
valDescription
TRUEevaluated 34 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-34
8252 if (temp)
tempDescription
TRUEevaluated 43 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-43
8253 {-
8254 tt = (mflags & MATCH_QUOTED) ? quote_string (temp) : quote_escapes (temp);
(mflags & 0x020)Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 32 times by 1 test
Evaluated by:
  • Self test
11-32
8255 free (temp);-
8256 temp = tt;-
8257 }
executed 43 times by 1 test: end of block
Executed by:
  • Self test
43
8258 break;
executed 43 times by 1 test: break;
Executed by:
  • Self test
43
8259-
8260 case VT_POSPARMS:
executed 14 times by 1 test: case 1:
Executed by:
  • Self test
14
8261 temp = pos_params_modcase (val, pat, modop, mflags);-
8262 if (temp && quoted == 0 && ifs_is_null)
tempDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
quoted == 0Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
ifs_is_nullDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
0-14
8263 {-
8264 /* Posix interp 888 */-
8265 }
executed 5 times by 1 test: end of block
Executed by:
  • Self test
5
8266 else if (temp && (mflags & MATCH_QUOTED) == 0)
tempDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(mflags & 0x020) == 0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-9
8267 {-
8268 tt = quote_escapes (temp);-
8269 free (temp);-
8270 temp = tt;-
8271 }
executed 8 times by 1 test: end of block
Executed by:
  • Self test
8
8272 break;
executed 14 times by 1 test: break;
Executed by:
  • Self test
14
8273-
8274#if defined (ARRAY_VARS)-
8275 case VT_ARRAYVAR:
executed 23 times by 1 test: case 2:
Executed by:
  • Self test
23
8276 /* If we are expanding in a context where word splitting will not be-
8277 performed, treat as quoted. This changes how ${A[*]} will be-
8278 expanded to make it identical to $*. */-
8279 if ((mflags & MATCH_STARSUB) && (mflags & MATCH_ASSIGNRHS) && ifs_is_null)
(mflags & 0x080)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 19 times by 1 test
Evaluated by:
  • Self test
(mflags & 0x040)Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
ifs_is_nullDescription
TRUEnever evaluated
FALSEnever evaluated
0-19
8280 mflags |= MATCH_QUOTED; /* Posix interp 888 */
never executed: mflags |= 0x020;
0
8281-
8282 temp = assoc_p (v) ? assoc_modcase (assoc_cell (v), pat, modop, mflags)
((((v)->attrib... (0x0000040)))Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11 times by 1 test
Evaluated by:
  • Self test
11-12
8283 : array_modcase (array_cell (v), pat, modop, mflags);-
8284 /* Don't call quote_escapes; array_modcase calls array_quote_escapes-
8285 as appropriate before adding the space separators; ditto for-
8286 assoc_modcase. */-
8287 break;
executed 23 times by 1 test: break;
Executed by:
  • Self test
23
8288#endif-
8289 }-
8290-
8291 FREE (pat);
executed 42 times by 1 test: sh_xfree((pat), "subst.c", 8291);
Executed by:
  • Self test
patDescription
TRUEevaluated 42 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 38 times by 1 test
Evaluated by:
  • Self test
38-42
8292 free (lpat);-
8293-
8294 this_command_name = oname;-
8295-
8296 return temp;
executed 80 times by 1 test: return temp;
Executed by:
  • Self test
80
8297}-
8298-
8299/* Check for unbalanced parens in S, which is the contents of $(( ... )). If-
8300 any occur, this must be a nested command substitution, so return 0.-
8301 Otherwise, return 1. A valid arithmetic expression must always have a-
8302 ( before a matching ), so any cases where there are more right parens-
8303 means that this must not be an arithmetic expression, though the parser-
8304 will not accept it without a balanced total number of parens. */-
8305static int-
8306chk_arithsub (s, len)-
8307 const char *s;-
8308 int len;-
8309{-
8310 int i, count;-
8311 DECLARE_MBSTATE;-
8312-
8313 i = count = 0;-
8314 while (i < len)
i < lenDescription
TRUEevaluated 36416 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6365 times by 1 test
Evaluated by:
  • Self test
6365-36416
8315 {-
8316 if (s[i] == LPAREN)
s[i] == '('Description
TRUEevaluated 287 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 36129 times by 1 test
Evaluated by:
  • Self test
287-36129
8317 count++;
executed 287 times by 1 test: count++;
Executed by:
  • Self test
287
8318 else if (s[i] == RPAREN)
s[i] == ')'Description
TRUEevaluated 334 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 35795 times by 1 test
Evaluated by:
  • Self test
334-35795
8319 {-
8320 count--;-
8321 if (count < 0)
count < 0Description
TRUEevaluated 47 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 287 times by 1 test
Evaluated by:
  • Self test
47-287
8322 return 0;
executed 47 times by 1 test: return 0;
Executed by:
  • Self test
47
8323 }
executed 287 times by 1 test: end of block
Executed by:
  • Self test
287
8324-
8325 switch (s[i])-
8326 {-
8327 default:
executed 36340 times by 1 test: default:
Executed by:
  • Self test
36340
8328 ADVANCE_CHAR (s, len, i);
executed 35571 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 668 times by 1 test: mblength = 1;
Executed by:
  • Self test
never executed: end of block
never executed: end of block
never executed: (i)++;
executed 36239 times by 1 test: (i) += mblength;
Executed by:
  • Self test
executed 101 times by 1 test: (i)++;
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 36239 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 101 times by 1 test
Evaluated by:
  • Self test
_fDescription
TRUEevaluated 35571 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 668 times by 1 test
Evaluated by:
  • Self test
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 36239 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 668 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((s)[i] & 0x80) == 0)Description
TRUEevaluated 668 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 36239 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 36239 times by 1 test
Evaluated by:
  • Self test
0-36239
8329 break;
executed 36340 times by 1 test: break;
Executed by:
  • Self test
36340
8330-
8331 case '\\':
executed 10 times by 1 test: case '\\':
Executed by:
  • Self test
10
8332 i++;-
8333 if (s[i])
s[i]Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-10
8334 ADVANCE_CHAR (s, len, i);
never executed: mblength = 1;
executed 10 times by 1 test: mblength = 1;
Executed by:
  • Self test
never executed: end of block
never executed: end of block
never executed: (i)++;
executed 10 times by 1 test: (i) += mblength;
Executed by:
  • Self test
never executed: (i)++;
executed 10 times by 1 test: end of block
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
_fDescription
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
mblength == 0Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
locale_utf8localeDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(((s)[i] & 0x80) == 0)Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
0-10
8335 break;
executed 10 times by 1 test: break;
Executed by:
  • Self test
10
8336-
8337 case '\'':
executed 1 time by 1 test: case '\'':
Executed by:
  • Self test
1
8338 i = skip_single_quoted (s, len, ++i, 0);-
8339 break;
executed 1 time by 1 test: break;
Executed by:
  • Self test
1
8340-
8341 case '"':
executed 18 times by 1 test: case '"':
Executed by:
  • Self test
18
8342 i = skip_double_quoted ((char *)s, len, ++i, 0);-
8343 break;
executed 18 times by 1 test: break;
Executed by:
  • Self test
18
8344 }-
8345 }-
8346-
8347 return (count == 0);
executed 6365 times by 1 test: return (count == 0);
Executed by:
  • Self test
6365
8348}-
8349-
8350/****************************************************************/-
8351/* */-
8352/* Functions to perform parameter expansion on a string */-
8353/* */-
8354/****************************************************************/-
8355-
8356/* ${[#][!]name[[:][^[^]][,[,]]#[#]%[%]-=?+[word][:e1[:e2]]]} */-
8357static WORD_DESC *-
8358parameter_brace_expand (string, indexp, quoted, pflags, quoted_dollar_atp, contains_dollar_at)-
8359 char *string;-
8360 int *indexp, quoted, pflags, *quoted_dollar_atp, *contains_dollar_at;-
8361{-
8362 int check_nullness, var_is_set, var_is_null, var_is_special;-
8363 int want_substring, want_indir, want_patsub, want_casemod;-
8364 char *name, *value, *temp, *temp1;-
8365 WORD_DESC *tdesc, *ret;-
8366 int t_index, sindex, c, tflag, modspec, all_element_arrayref;-
8367 intmax_t number;-
8368 arrayind_t ind;-
8369-
8370 temp = temp1 = value = (char *)NULL;-
8371 var_is_set = var_is_null = var_is_special = check_nullness = 0;-
8372 want_substring = want_indir = want_patsub = want_casemod = 0;-
8373-
8374 all_element_arrayref = 0;-
8375-
8376 sindex = *indexp;-
8377 t_index = ++sindex;-
8378 /* ${#var} doesn't have any of the other parameter expansions on it. */-
8379 if (string[t_index] == '#' && legal_variable_starter (string[t_index+1])) /* {{ */
string[t_index] == '#'Description
TRUEevaluated 600 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2369350 times by 1 test
Evaluated by:
  • Self test
((*__ctype_b_l...int) _ISalpha)Description
TRUEevaluated 473 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 127 times by 1 test
Evaluated by:
  • Self test
(string[t_index+1] == '_')Description
TRUEnever evaluated
FALSEevaluated 127 times by 1 test
Evaluated by:
  • Self test
0-2369350
8380 name = string_extract (string, &t_index, "}", SX_VARNAME);
executed 473 times by 1 test: name = string_extract (string, &t_index, "}", 0x0002);
Executed by:
  • Self test
473
8381 else-
8382#if defined (CASEMOD_EXPANSIONS)-
8383 /* To enable case-toggling expansions using the `~' operator character-
8384 change the 1 to 0. */-
8385# if defined (CASEMOD_CAPCASE)-
8386 name = string_extract (string, &t_index, "#%^,~:-=?+/@}", SX_VARNAME);
executed 2369477 times by 1 test: name = string_extract (string, &t_index, "#%^,~:-=?+/@}", 0x0002);
Executed by:
  • Self test
2369477
8387# else-
8388 name = string_extract (string, &t_index, "#%^,:-=?+/@}", SX_VARNAME);-
8389# endif /* CASEMOD_CAPCASE */-
8390#else-
8391 name = string_extract (string, &t_index, "#%:-=?+/@}", SX_VARNAME);-
8392#endif /* CASEMOD_EXPANSIONS */-
8393-
8394 /* Handle ${@[stuff]} now that @ is a word expansion operator. Not exactly-
8395 the cleanest code ever. */-
8396 if (*name == 0 && sindex == t_index && string[sindex] == '@')
*name == 0Description
TRUEevaluated 536 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2369414 times by 1 test
Evaluated by:
  • Self test
sindex == t_indexDescription
TRUEevaluated 536 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
string[sindex] == '@'Description
TRUEevaluated 373 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 163 times by 1 test
Evaluated by:
  • Self test
0-2369414
8397 {-
8398 name = (char *)xrealloc (name, 2);-
8399 name[0] = '@';-
8400 name[1] = '\0';-
8401 t_index++;-
8402 }
executed 373 times by 1 test: end of block
Executed by:
  • Self test
373
8403 else if (*name == '!' && t_index > sindex && string[t_index] == '@' && string[t_index+1] == RBRACE)
*name == '!'Description
TRUEevaluated 186 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2369391 times by 1 test
Evaluated by:
  • Self test
t_index > sindexDescription
TRUEevaluated 186 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
string[t_index] == '@'Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 181 times by 1 test
Evaluated by:
  • Self test
string[t_index+1] == '}'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-2369391
8404 {-
8405 name = (char *)xrealloc (name, t_index - sindex + 2);-
8406 name[t_index - sindex] = '@';-
8407 name[t_index - sindex + 1] = '\0';-
8408 t_index++;-
8409 }
executed 4 times by 1 test: end of block
Executed by:
  • Self test
4
8410-
8411 ret = 0;-
8412 tflag = 0;-
8413-
8414 ind = INTMAX_MIN;-
8415-
8416 /* If the name really consists of a special variable, then make sure-
8417 that we have the entire name. We don't allow indirect references-
8418 to special variables except `#', `?', `@' and `*'. This clause is-
8419 designed to handle ${#SPECIAL} and ${!SPECIAL}, not anything more-
8420 general. */-
8421 if ((sindex == t_index && VALID_SPECIAL_LENGTH_PARAM (string[t_index])) ||
sindex == t_indexDescription
TRUEevaluated 163 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2369787 times by 1 test
Evaluated by:
  • Self test
(string[t_index]) == '-'Description
TRUEevaluated 36 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 127 times by 1 test
Evaluated by:
  • Self test
(string[t_index]) == '?'Description
TRUEnever evaluated
FALSEevaluated 127 times by 1 test
Evaluated by:
  • Self test
(string[t_index]) == '#'Description
TRUEevaluated 127 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(string[t_index]) == '@'Description
TRUEnever evaluated
FALSEnever evaluated
0-2369787
8422 (sindex == t_index && string[sindex] == '#' && VALID_SPECIAL_LENGTH_PARAM (string[sindex + 1])) ||
sindex == t_indexDescription
TRUEnever evaluated
FALSEevaluated 2369787 times by 1 test
Evaluated by:
  • Self test
string[sindex] == '#'Description
TRUEnever evaluated
FALSEnever evaluated
(string[sindex + 1]) == '-'Description
TRUEnever evaluated
FALSEnever evaluated
(string[sindex + 1]) == '?'Description
TRUEnever evaluated
FALSEnever evaluated
(string[sindex + 1]) == '#'Description
TRUEnever evaluated
FALSEnever evaluated
(string[sindex + 1]) == '@'Description
TRUEnever evaluated
FALSEnever evaluated
0-2369787
8423 (sindex == t_index - 1 && string[sindex] == '!' && VALID_INDIR_PARAM (string[t_index])))
sindex == t_index - 1Description
TRUEevaluated 2335370 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 34417 times by 1 test
Evaluated by:
  • Self test
string[sindex] == '!'Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2335353 times by 1 test
Evaluated by:
  • Self test
posixly_correct == 0Description
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
(string[t_index]) == '#'Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
posixly_correct == 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
(string[t_index]) == '?'Description
TRUEnever evaluated
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
(string[t_index]) == '@'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
(string[t_index]) == '*'Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
0-2335370
8424 {-
8425 t_index++;-
8426 temp1 = string_extract (string, &t_index, "#%:-=?+/@}", 0);-
8427 name = (char *)xrealloc (name, 3 + (strlen (temp1)));-
8428 *name = string[sindex];-
8429 if (string[sindex] == '!')
string[sindex] == '!'Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 163 times by 1 test
Evaluated by:
  • Self test
11-163
8430 {-
8431 /* indirect reference of $#, $?, $@, or $* */-
8432 name[1] = string[sindex + 1];-
8433 strcpy (name + 2, temp1);-
8434 }
executed 11 times by 1 test: end of block
Executed by:
  • Self test
11
8435 else -
8436 strcpy (name + 1, temp1);
executed 163 times by 1 test: strcpy (name + 1, temp1);
Executed by:
  • Self test
163
8437 free (temp1);-
8438 }
executed 174 times by 1 test: end of block
Executed by:
  • Self test
174
8439 sindex = t_index;-
8440-
8441 /* Find out what character ended the variable name. Then-
8442 do the appropriate thing. */-
8443 if (c = string[sindex])
c = string[sindex]Description
TRUEevaluated 2369950 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2369950
8444 sindex++;
executed 2369950 times by 1 test: sindex++;
Executed by:
  • Self test
2369950
8445-
8446 /* If c is followed by one of the valid parameter expansion-
8447 characters, move past it as normal. If not, assume that-
8448 a substring specification is being given, and do not move-
8449 past it. */-
8450 if (c == ':' && VALID_PARAM_EXPAND_CHAR (string[sindex]))
c == ':'Description
TRUEevaluated 17957 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2351993 times by 1 test
Evaluated by:
  • Self test
(sh_syntaxtab[...ex]] & 0x1000)Description
TRUEevaluated 17153 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 804 times by 1 test
Evaluated by:
  • Self test
804-2351993
8451 {-
8452 check_nullness++;-
8453 if (c = string[sindex])
c = string[sindex]Description
TRUEevaluated 17153 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-17153
8454 sindex++;
executed 17153 times by 1 test: sindex++;
Executed by:
  • Self test
17153
8455 }
executed 17153 times by 1 test: end of block
Executed by:
  • Self test
17153
8456 else if (c == ':' && string[sindex] != RBRACE)
c == ':'Description
TRUEevaluated 804 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2351993 times by 1 test
Evaluated by:
  • Self test
string[sindex] != '}'Description
TRUEevaluated 794 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
10-2351993
8457 want_substring = 1;
executed 794 times by 1 test: want_substring = 1;
Executed by:
  • Self test
794
8458 else if (c == '/' /* && string[sindex] != RBRACE */) /* XXX */
c == '/'Description
TRUEevaluated 878 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2351125 times by 1 test
Evaluated by:
  • Self test
878-2351125
8459 want_patsub = 1;
executed 878 times by 1 test: want_patsub = 1;
Executed by:
  • Self test
878
8460#if defined (CASEMOD_EXPANSIONS)-
8461 else if (c == '^' || c == ',' || c == '~')
c == '^'Description
TRUEevaluated 38 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2351087 times by 1 test
Evaluated by:
  • Self test
c == ','Description
TRUEevaluated 40 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2351047 times by 1 test
Evaluated by:
  • Self test
c == '~'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2351045 times by 1 test
Evaluated by:
  • Self test
2-2351087
8462 {-
8463 modspec = c;-
8464 want_casemod = 1;-
8465 }
executed 80 times by 1 test: end of block
Executed by:
  • Self test
80
8466#endif-
8467-
8468 /* Catch the valid and invalid brace expressions that made it through the-
8469 tests above. */-
8470 /* ${#-} is a valid expansion and means to take the length of $-.-
8471 Similarly for ${#?} and ${##}... */-
8472 if (name[0] == '#' && name[1] == '\0' && check_nullness == 0 &&
name[0] == '#'Description
TRUEevaluated 600 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2369350 times by 1 test
Evaluated by:
  • Self test
name[1] == '\0'Description
TRUEevaluated 93 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 507 times by 1 test
Evaluated by:
  • Self test
check_nullness == 0Description
TRUEevaluated 78 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 15 times by 1 test
Evaluated by:
  • Self test
15-2369350
8473 VALID_SPECIAL_LENGTH_PARAM (c) && string[sindex] == RBRACE)
(c) == '-'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 74 times by 1 test
Evaluated by:
  • Self test
(c) == '?'Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 68 times by 1 test
Evaluated by:
  • Self test
(c) == '#'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 66 times by 1 test
Evaluated by:
  • Self test
(c) == '@'Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 59 times by 1 test
Evaluated by:
  • Self test
string[sindex] == '}'Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
2-74
8474 {-
8475 name = (char *)xrealloc (name, 3);-
8476 name[1] = c;-
8477 name[2] = '\0';-
8478 c = string[sindex++];-
8479 }
executed 14 times by 1 test: end of block
Executed by:
  • Self test
14
8480-
8481 /* ...but ${#%}, ${#:}, ${#=}, ${#+}, and ${#/} are errors. */-
8482 if (name[0] == '#' && name[1] == '\0' && check_nullness == 0 &&
name[0] == '#'Description
TRUEevaluated 600 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2369350 times by 1 test
Evaluated by:
  • Self test
name[1] == '\0'Description
TRUEevaluated 79 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 521 times by 1 test
Evaluated by:
  • Self test
check_nullness == 0Description
TRUEevaluated 64 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 15 times by 1 test
Evaluated by:
  • Self test
15-2369350
8483 member (c, "%:=+/") && string[sindex] == RBRACE)
(c)Description
TRUEevaluated 64 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((c) ? ((char ...id *)0) ) : 0)Description
TRUEevaluated 19 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 45 times by 1 test
Evaluated by:
  • Self test
string[sindex] == '}'Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
0-64
8484 {-
8485 temp = (char *)NULL;-
8486 goto bad_substitution; /* XXX - substitution error */
executed 16 times by 1 test: goto bad_substitution;
Executed by:
  • Self test
16
8487 }-
8488-
8489 /* Indirect expansion begins with a `!'. A valid indirect expansion is-
8490 either a variable name, one of the positional parameters or a special-
8491 variable that expands to one of the positional parameters. */-
8492 want_indir = *name == '!' &&
*name == '!'Description
TRUEevaluated 186 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2369748 times by 1 test
Evaluated by:
  • Self test
186-2369748
8493 (legal_variable_starter ((unsigned char)name[1]) || DIGIT (name[1])
((*__ctype_b_l...int) _ISalpha)Description
TRUEevaluated 113 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 73 times by 1 test
Evaluated by:
  • Self test
((unsigned cha...ame[1] == '_')Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 65 times by 1 test
Evaluated by:
  • Self test
(name[1]) >= '0'Description
TRUEevaluated 48 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 17 times by 1 test
Evaluated by:
  • Self test
(name[1]) <= '9'Description
TRUEevaluated 46 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2-113
8494 || VALID_INDIR_PARAM (name[1]));
posixly_correct == 0Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
(name[1]) == '#'Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
posixly_correct == 0Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
(name[1]) == '?'Description
TRUEnever evaluated
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
(name[1]) == '@'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
(name[1]) == '*'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
0-17
8495-
8496 /* Determine the value of this variable whose name is NAME. */-
8497-
8498 /* Check for special variables, directly referenced. */-
8499 if (SPECIAL_VAR (name, want_indir))
*nameDescription
TRUEevaluated 2369934 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(*name) >= '0'Description
TRUEevaluated 2368834 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1100 times by 1 test
Evaluated by:
  • Self test
(*name) <= '9'Description
TRUEevaluated 14812 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2354022 times by 1 test
Evaluated by:
  • Self test
all_digits (name)Description
TRUEevaluated 14812 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
name[1] == '\0'Description
TRUEevaluated 2320643 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 34479 times by 1 test
Evaluated by:
  • Self test
(sh_syntaxtab[...ame] & 0x0800)Description
TRUEevaluated 765 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2319878 times by 1 test
Evaluated by:
  • Self test
want_indirDescription
TRUEevaluated 180 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2354177 times by 1 test
Evaluated by:
  • Self test
name[2] == '\0'Description
TRUEevaluated 64 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 116 times by 1 test
Evaluated by:
  • Self test
posixly_correct == 0Description
TRUEevaluated 64 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(name[1]) == '#'Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 54 times by 1 test
Evaluated by:
  • Self test
posixly_correct == 0Description
TRUEevaluated 54 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(name[1]) == '?'Description
TRUEnever evaluated
FALSEevaluated 54 times by 1 test
Evaluated by:
  • Self test
(name[1]) == '@'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 53 times by 1 test
Evaluated by:
  • Self test
(name[1]) == '*'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 52 times by 1 test
Evaluated by:
  • Self test
0-2369934
8500 var_is_special++;
executed 15589 times by 1 test: var_is_special++;
Executed by:
  • Self test
15589
8501-
8502 /* Check for special expansion things, like the length of a parameter */-
8503 if (*name == '#' && name[1])
*name == '#'Description
TRUEevaluated 584 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2369350 times by 1 test
Evaluated by:
  • Self test
name[1]Description
TRUEevaluated 521 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 63 times by 1 test
Evaluated by:
  • Self test
63-2369350
8504 {-
8505 /* If we are not pointing at the character just after the-
8506 closing brace, then we haven't gotten all of the name.-
8507 Since it begins with a special character, this is a bad-
8508 substitution. Also check NAME for validity before trying-
8509 to go on. */-
8510 if (string[sindex - 1] != RBRACE || (valid_length_expression (name) == 0))
string[sindex - 1] != '}'Description
TRUEnever evaluated
FALSEevaluated 521 times by 1 test
Evaluated by:
  • Self test
(valid_length_...n (name) == 0)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 518 times by 1 test
Evaluated by:
  • Self test
0-521
8511 {-
8512 temp = (char *)NULL;-
8513 goto bad_substitution; /* substitution error */
executed 3 times by 1 test: goto bad_substitution;
Executed by:
  • Self test
3
8514 }-
8515-
8516 number = parameter_brace_expand_length (name);-
8517 if (number == INTMAX_MIN && unbound_vars_is_error)
number == (-92...854775807L -1)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 513 times by 1 test
Evaluated by:
  • Self test
unbound_vars_is_errorDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-513
8518 {-
8519 last_command_exit_value = EXECUTION_FAILURE;-
8520 err_unboundvar (name+1);-
8521 free (name);-
8522 return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal);
executed 2 times by 1 test: return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal);
Executed by:
  • Self test
2
8523 }-
8524 free (name);-
8525-
8526 *indexp = sindex;-
8527 if (number < 0)
number < 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 512 times by 1 test
Evaluated by:
  • Self test
1-512
8528 return (&expand_wdesc_error);
executed 1 time by 1 test: return (&expand_wdesc_error);
Executed by:
  • Self test
1
8529 else-
8530 {-
8531 ret = alloc_word_desc ();-
8532 ret->word = itos (number);-
8533 return ret;
executed 512 times by 1 test: return ret;
Executed by:
  • Self test
512
8534 }-
8535 }-
8536-
8537 /* ${@} is identical to $@. */-
8538 if (name[0] == '@' && name[1] == '\0')
name[0] == '@'Description
TRUEevaluated 373 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2369040 times by 1 test
Evaluated by:
  • Self test
name[1] == '\0'Description
TRUEevaluated 373 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2369040
8539 {-
8540 if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && quoted_dollar_atp)
(quoted & (0x002|0x001))Description
TRUEevaluated 178 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 195 times by 1 test
Evaluated by:
  • Self test
quoted_dollar_atpDescription
TRUEevaluated 178 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-195
8541 *quoted_dollar_atp = 1;
executed 178 times by 1 test: *quoted_dollar_atp = 1;
Executed by:
  • Self test
178
8542-
8543 if (contains_dollar_at)
contains_dollar_atDescription
TRUEevaluated 373 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-373
8544 *contains_dollar_at = 1;
executed 373 times by 1 test: *contains_dollar_at = 1;
Executed by:
  • Self test
373
8545-
8546 tflag |= W_DOLLARAT;-
8547 }
executed 373 times by 1 test: end of block
Executed by:
  • Self test
373
8548-
8549 /* Process ${!PREFIX*} expansion. */-
8550 if (want_indir && string[sindex - 1] == RBRACE &&
want_indirDescription
TRUEevaluated 180 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2369233 times by 1 test
Evaluated by:
  • Self test
string[sindex - 1] == '}'Description
TRUEevaluated 135 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 45 times by 1 test
Evaluated by:
  • Self test
45-2369233
8551 (string[sindex - 2] == '*' || string[sindex - 2] == '@') &&
string[sindex - 2] == '*'Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 128 times by 1 test
Evaluated by:
  • Self test
string[sindex - 2] == '@'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 124 times by 1 test
Evaluated by:
  • Self test
4-128
8552 legal_variable_starter ((unsigned char) name[1]))
((*__ctype_b_l...int) _ISalpha)Description
TRUEnever evaluated
FALSEevaluated 11 times by 1 test
Evaluated by:
  • Self test
((unsigned cha...ame[1] == '_')Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
0-11
8553 {-
8554 char **x;-
8555 WORD_LIST *xlist;-
8556-
8557 temp1 = savestring (name + 1);-
8558 number = strlen (temp1);-
8559 temp1[number - 1] = '\0';-
8560 x = all_variables_matching_prefix (temp1);-
8561 xlist = strvec_to_word_list (x, 0, 0);-
8562 if (string[sindex - 2] == '*')
string[sindex - 2] == '*'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
3-4
8563 temp = string_list_dollar_star (xlist, quoted, 0);
executed 4 times by 1 test: temp = string_list_dollar_star (xlist, quoted, 0);
Executed by:
  • Self test
4
8564 else-
8565 {-
8566 temp = string_list_dollar_at (xlist, quoted, 0);-
8567 if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && quoted_dollar_atp)
(quoted & (0x002|0x001))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
quoted_dollar_atpDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
8568 *quoted_dollar_atp = 1;
executed 1 time by 1 test: *quoted_dollar_atp = 1;
Executed by:
  • Self test
1
8569 if (contains_dollar_at)
contains_dollar_atDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3
8570 *contains_dollar_at = 1;
executed 3 times by 1 test: *contains_dollar_at = 1;
Executed by:
  • Self test
3
8571-
8572 tflag |= W_DOLLARAT;-
8573 }
executed 3 times by 1 test: end of block
Executed by:
  • Self test
3
8574 free (x);-
8575 dispose_words (xlist);-
8576 free (temp1);-
8577 *indexp = sindex;-
8578-
8579 free (name);-
8580-
8581 ret = alloc_word_desc ();-
8582 ret->word = temp;-
8583 ret->flags = tflag; /* XXX */-
8584 return ret;
executed 7 times by 1 test: return ret;
Executed by:
  • Self test
7
8585 }-
8586-
8587#if defined (ARRAY_VARS) -
8588 /* Process ${!ARRAY[@]} and ${!ARRAY[*]} expansion. */-
8589 if (want_indir && string[sindex - 1] == RBRACE &&
want_indirDescription
TRUEevaluated 173 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2369233 times by 1 test
Evaluated by:
  • Self test
string[sindex - 1] == '}'Description
TRUEevaluated 128 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 45 times by 1 test
Evaluated by:
  • Self test
45-2369233
8590 string[sindex - 2] == RBRACK && valid_array_reference (name+1, 0))
string[sindex - 2] == ']'Description
TRUEevaluated 42 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 86 times by 1 test
Evaluated by:
  • Self test
valid_array_re...ce (name+1, 0)Description
TRUEevaluated 42 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-86
8591 {-
8592 char *x, *x1;-
8593-
8594 temp1 = savestring (name + 1);-
8595 x = array_variable_name (temp1, 0, &x1, (int *)0);-
8596 FREE (x);
executed 42 times by 1 test: sh_xfree((x), "subst.c", 8596);
Executed by:
  • Self test
xDescription
TRUEevaluated 42 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-42
8597 if (ALL_ELEMENT_SUB (x1[0]) && x1[1] == RBRACK)
(x1[0]) == '@'Description
TRUEevaluated 38 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
(x1[0]) == '*'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
x1[1] == ']'Description
TRUEevaluated 40 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-40
8598 {-
8599 temp = array_keys (temp1, quoted); /* handles assoc vars too */-
8600 if (x1[0] == '@')
x1[0] == '@'Description
TRUEevaluated 38 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2-38
8601 {-
8602 if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && quoted_dollar_atp)
(quoted & (0x002|0x001))Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 28 times by 1 test
Evaluated by:
  • Self test
quoted_dollar_atpDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-28
8603 *quoted_dollar_atp = 1;
executed 10 times by 1 test: *quoted_dollar_atp = 1;
Executed by:
  • Self test
10
8604 if (contains_dollar_at)
contains_dollar_atDescription
TRUEevaluated 38 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-38
8605 *contains_dollar_at = 1;
executed 38 times by 1 test: *contains_dollar_at = 1;
Executed by:
  • Self test
38
8606-
8607 tflag |= W_DOLLARAT;-
8608 }
executed 38 times by 1 test: end of block
Executed by:
  • Self test
38
8609-
8610 free (name);-
8611 free (temp1);-
8612 *indexp = sindex;-
8613-
8614 ret = alloc_word_desc ();-
8615 ret->word = temp;-
8616 ret->flags = tflag; /* XXX */-
8617 return ret;
executed 40 times by 1 test: return ret;
Executed by:
  • Self test
40
8618 }-
8619-
8620 free (temp1);-
8621 }
executed 2 times by 1 test: end of block
Executed by:
  • Self test
2
8622#endif /* ARRAY_VARS */-
8623 -
8624 /* Make sure that NAME is valid before trying to go on. */-
8625 if (valid_brace_expansion_word (want_indir ? name + 1 : name,
valid_brace_ex..._special) == 0Description
TRUEevaluated 30 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2369336 times by 1 test
Evaluated by:
  • Self test
30-2369336
8626 var_is_special) == 0)
valid_brace_ex..._special) == 0Description
TRUEevaluated 30 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2369336 times by 1 test
Evaluated by:
  • Self test
30-2369336
8627 {-
8628 temp = (char *)NULL;-
8629 goto bad_substitution; /* substitution error */
executed 30 times by 1 test: goto bad_substitution;
Executed by:
  • Self test
30
8630 }-
8631-
8632 if (want_indir)
want_indirDescription
TRUEevaluated 130 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2369206 times by 1 test
Evaluated by:
  • Self test
130-2369206
8633 {-
8634 tdesc = parameter_brace_expand_indir (name + 1, var_is_special, quoted, quoted_dollar_atp, contains_dollar_at);-
8635 if (tdesc == &expand_wdesc_error || tdesc == &expand_wdesc_fatal)
tdesc == &expand_wdesc_errorDescription
TRUEnever evaluated
FALSEevaluated 129 times by 1 test
Evaluated by:
  • Self test
tdesc == &expand_wdesc_fatalDescription
TRUEnever evaluated
FALSEevaluated 129 times by 1 test
Evaluated by:
  • Self test
0-129
8636 {-
8637 temp = (char *)NULL;-
8638 goto bad_substitution;
never executed: goto bad_substitution;
0
8639 }-
8640-
8641 /* Turn off the W_ARRAYIND flag because there is no way for this function-
8642 to return the index we're supposed to be using. */-
8643 if (tdesc && tdesc->flags)
tdescDescription
TRUEevaluated 117 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test
tdesc->flagsDescription
TRUEevaluated 24 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 93 times by 1 test
Evaluated by:
  • Self test
12-117
8644 tdesc->flags &= ~W_ARRAYIND;
executed 24 times by 1 test: tdesc->flags &= ~0x1000000;
Executed by:
  • Self test
24
8645 }
executed 129 times by 1 test: end of block
Executed by:
  • Self test
129
8646 else-
8647 tdesc = parameter_brace_expand_word (name, var_is_special, quoted, PF_IGNUNBOUND|(pflags&(PF_NOSPLIT2|PF_ASSIGNRHS)), &ind);
executed 2369206 times by 1 test: tdesc = parameter_brace_expand_word (name, var_is_special, quoted, 0x02|(pflags&(0x04|0x08)), &ind);
Executed by:
  • Self test
2369206
8648-
8649 if (tdesc)
tdescDescription
TRUEevaluated 2369314 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test
12-2369314
8650 {-
8651 temp = tdesc->word;-
8652 tflag = tdesc->flags;-
8653 dispose_word_desc (tdesc);-
8654 }
executed 2369314 times by 1 test: end of block
Executed by:
  • Self test
2369314
8655 else-
8656 temp = (char *)0;
executed 12 times by 1 test: temp = (char *)0;
Executed by:
  • Self test
12
8657-
8658 if (temp == &expand_param_error || temp == &expand_param_fatal)
temp == &expand_param_errorDescription
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2369309 times by 1 test
Evaluated by:
  • Self test
temp == &expand_param_fatalDescription
TRUEnever evaluated
FALSEevaluated 2369309 times by 1 test
Evaluated by:
  • Self test
0-2369309
8659 {-
8660 FREE (name);
executed 17 times by 1 test: sh_xfree((name), "subst.c", 8660);
Executed by:
  • Self test
nameDescription
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-17
8661 FREE (value);
never executed: sh_xfree((value), "subst.c", 8661);
valueDescription
TRUEnever evaluated
FALSEevaluated 17 times by 1 test
Evaluated by:
  • Self test
0-17
8662 return (temp == &expand_param_error ? &expand_wdesc_error : &expand_wdesc_fatal);
executed 17 times by 1 test: return (temp == &expand_param_error ? &expand_wdesc_error : &expand_wdesc_fatal);
Executed by:
  • Self test
17
8663 }-
8664-
8665#if defined (ARRAY_VARS)-
8666 if (valid_array_reference (name, 0))
valid_array_re...ence (name, 0)Description
TRUEevaluated 5890 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2363419 times by 1 test
Evaluated by:
  • Self test
5890-2363419
8667 {-
8668 int qflags;-
8669 char *t;-
8670-
8671 qflags = quoted;-
8672 /* If in a context where word splitting will not take place, treat as-
8673 if double-quoted. Has effects with $* and ${array[*]} */-
8674-
8675 if (pflags & PF_ASSIGNRHS)
pflags & 0x08Description
TRUEevaluated 56 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5834 times by 1 test
Evaluated by:
  • Self test
56-5834
8676 qflags |= Q_DOUBLE_QUOTES;
executed 56 times by 1 test: qflags |= 0x001;
Executed by:
  • Self test
56
8677 /* We duplicate a little code here */-
8678 t = mbschr (name, LBRACK);-
8679 if (t && ALL_ELEMENT_SUB (t[1]) && t[2] == RBRACK)
tDescription
TRUEevaluated 5890 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(t[1]) == '@'Description
TRUEevaluated 658 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5232 times by 1 test
Evaluated by:
  • Self test
(t[1]) == '*'Description
TRUEevaluated 154 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5078 times by 1 test
Evaluated by:
  • Self test
t[2] == ']'Description
TRUEevaluated 812 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-5890
8680 {-
8681 all_element_arrayref = 1;-
8682 if (expand_no_split_dollar_star && t[1] == '*') /* XXX */
expand_no_split_dollar_starDescription
TRUEevaluated 42 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 770 times by 1 test
Evaluated by:
  • Self test
t[1] == '*'Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 21 times by 1 test
Evaluated by:
  • Self test
21-770
8683 qflags |= Q_DOUBLE_QUOTES;
executed 21 times by 1 test: qflags |= 0x001;
Executed by:
  • Self test
21
8684 }
executed 812 times by 1 test: end of block
Executed by:
  • Self test
812
8685 chk_atstar (name, qflags, quoted_dollar_atp, contains_dollar_at);-
8686 }
executed 5890 times by 1 test: end of block
Executed by:
  • Self test
5890
8687#endif-
8688-
8689 var_is_set = temp != (char *)0;-
8690 var_is_null = check_nullness && (var_is_set == 0 || *temp == 0);
check_nullnessDescription
TRUEevaluated 17145 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2352164 times by 1 test
Evaluated by:
  • Self test
var_is_set == 0Description
TRUEevaluated 2288 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14857 times by 1 test
Evaluated by:
  • Self test
*temp == 0Description
TRUEevaluated 4104 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10753 times by 1 test
Evaluated by:
  • Self test
2288-2352164
8691 /* XXX - this may not need to be restricted to special variables */-
8692 if (check_nullness)
check_nullnessDescription
TRUEevaluated 17145 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2352164 times by 1 test
Evaluated by:
  • Self test
17145-2352164
8693 var_is_null |= var_is_set && var_is_special && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && QUOTED_NULL (temp);
executed 17145 times by 1 test: var_is_null |= var_is_set && var_is_special && (quoted & (0x002|0x001)) && ((temp)[0] == '\177' && (temp)[1] == '\0');
Executed by:
  • Self test
var_is_setDescription
TRUEevaluated 14857 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2288 times by 1 test
Evaluated by:
  • Self test
var_is_specialDescription
TRUEevaluated 8889 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5968 times by 1 test
Evaluated by:
  • Self test
(quoted & (0x002|0x001))Description
TRUEevaluated 8866 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 23 times by 1 test
Evaluated by:
  • Self test
(temp)[0] == '\177'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8862 times by 1 test
Evaluated by:
  • Self test
(temp)[1] == '\0'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
2-17145
8694-
8695 /* Get the rest of the stuff inside the braces. */-
8696 if (c && c != RBRACE)
cDescription
TRUEevaluated 2369309 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
c != '}'Description
TRUEevaluated 2343676 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 25633 times by 1 test
Evaluated by:
  • Self test
0-2369309
8697 {-
8698 /* Extract the contents of the ${ ... } expansion-
8699 according to the Posix.2 rules. */-
8700 value = extract_dollar_brace_string (string, &sindex, quoted, (c == '%' || c == '#' || c =='/' || c == '^' || c == ',' || c ==':') ? SX_POSIXEXP|SX_WORD : SX_WORD);-
8701 if (string[sindex] == RBRACE)
string[sindex] == '}'Description
TRUEevaluated 2343676 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2343676
8702 sindex++;
executed 2343676 times by 1 test: sindex++;
Executed by:
  • Self test
2343676
8703 else-
8704 goto bad_substitution; /* substitution error */
never executed: goto bad_substitution;
0
8705 }-
8706 else-
8707 value = (char *)NULL;
executed 25633 times by 1 test: value = (char *) ((void *)0) ;
Executed by:
  • Self test
25633
8708-
8709 *indexp = sindex;-
8710-
8711 /* All the cases where an expansion can possibly generate an unbound-
8712 variable error. */-
8713 if (want_substring || want_patsub || want_casemod || c == '#' || c == '%' || c == RBRACE)
want_substringDescription
TRUEevaluated 794 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2368515 times by 1 test
Evaluated by:
  • Self test
want_patsubDescription
TRUEevaluated 877 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2367638 times by 1 test
Evaluated by:
  • Self test
want_casemodDescription
TRUEevaluated 80 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2367558 times by 1 test
Evaluated by:
  • Self test
c == '#'Description
TRUEevaluated 1157932 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1209626 times by 1 test
Evaluated by:
  • Self test
c == '%'Description
TRUEevaluated 1157909 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 51717 times by 1 test
Evaluated by:
  • Self test
c == '}'Description
TRUEevaluated 25633 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 26084 times by 1 test
Evaluated by:
  • Self test
80-2368515
8714 {-
8715 if (var_is_set == 0 && unbound_vars_is_error && ((name[0] != '@' && name[0] != '*') || name[1]) && all_element_arrayref == 0)
var_is_set == 0Description
TRUEevaluated 805 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2342420 times by 1 test
Evaluated by:
  • Self test
unbound_vars_is_errorDescription
TRUEevaluated 19 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 786 times by 1 test
Evaluated by:
  • Self test
name[0] != '@'Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
name[0] != '*'Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
name[1]Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
all_element_arrayref == 0Description
TRUEevaluated 17 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2342420
8716 {-
8717 last_command_exit_value = EXECUTION_FAILURE;-
8718 err_unboundvar (name);-
8719 FREE (value);
executed 8 times by 1 test: sh_xfree((value), "subst.c", 8719);
Executed by:
  • Self test
valueDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
8-9
8720 FREE (temp);
never executed: sh_xfree((temp), "subst.c", 8720);
tempDescription
TRUEnever evaluated
FALSEevaluated 17 times by 1 test
Evaluated by:
  • Self test
0-17
8721 free (name);-
8722 return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal);
executed 17 times by 1 test: return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal);
Executed by:
  • Self test
17
8723 }-
8724 }
executed 2343208 times by 1 test: end of block
Executed by:
  • Self test
2343208
8725 -
8726 /* If this is a substring spec, process it and add the result. */-
8727 if (want_substring)
want_substringDescription
TRUEevaluated 794 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2368498 times by 1 test
Evaluated by:
  • Self test
794-2368498
8728 {-
8729 temp1 = parameter_brace_substring (name, temp, ind, value, quoted, pflags, (tflag & W_ARRAYIND) ? AV_USEIND : 0);-
8730 FREE (value);
executed 793 times by 1 test: sh_xfree((value), "subst.c", 8730);
Executed by:
  • Self test
valueDescription
TRUEevaluated 793 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-793
8731 FREE (temp);
executed 783 times by 1 test: sh_xfree((temp), "subst.c", 8731);
Executed by:
  • Self test
tempDescription
TRUEevaluated 783 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
10-783
8732-
8733 if (temp1 == &expand_param_error || temp1 == &expand_param_fatal)
temp1 == &expand_param_errorDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 773 times by 1 test
Evaluated by:
  • Self test
temp1 == &expand_param_fatalDescription
TRUEnever evaluated
FALSEevaluated 773 times by 1 test
Evaluated by:
  • Self test
0-773
8734 {-
8735 FREE (name);
executed 20 times by 1 test: sh_xfree((name), "subst.c", 8735);
Executed by:
  • Self test
nameDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-20
8736 return (temp1 == &expand_param_error ? &expand_wdesc_error : &expand_wdesc_fatal);
executed 20 times by 1 test: return (temp1 == &expand_param_error ? &expand_wdesc_error : &expand_wdesc_fatal);
Executed by:
  • Self test
20
8737 }-
8738-
8739 ret = alloc_word_desc ();-
8740 ret->word = temp1;-
8741 /* We test quoted_dollar_atp because we want variants with double-quoted-
8742 "$@" to take a different code path. In fact, we make sure at the end-
8743 of expand_word_internal that we're only looking at these flags if-
8744 quoted_dollar_at == 0. */-
8745 if (temp1 &&
temp1Description
TRUEevaluated 737 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 36 times by 1 test
Evaluated by:
  • Self test
36-737
8746 (quoted_dollar_atp == 0 || *quoted_dollar_atp == 0) &&
quoted_dollar_atp == 0Description
TRUEnever evaluated
FALSEevaluated 737 times by 1 test
Evaluated by:
  • Self test
*quoted_dollar_atp == 0Description
TRUEevaluated 651 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 86 times by 1 test
Evaluated by:
  • Self test
0-737
8747 QUOTED_NULL (temp1) && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))
(temp1)[0] == '\177'Description
TRUEevaluated 23 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 628 times by 1 test
Evaluated by:
  • Self test
(temp1)[1] == '\0'Description
TRUEevaluated 23 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(quoted & (0x002|0x001))Description
TRUEevaluated 23 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-628
8748 ret->flags |= W_QUOTED|W_HASQUOTEDNULL;
executed 23 times by 1 test: ret->flags |= 0x000002|0x040000;
Executed by:
  • Self test
23
8749 /* Special handling for $* when unquoted and $IFS is null. Posix interp 888 */-
8750 else if (temp1 && (name[0] == '*' && name[1] == 0) && quoted == 0 && ifs_is_null)
temp1Description
TRUEevaluated 714 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 36 times by 1 test
Evaluated by:
  • Self test
name[0] == '*'Description
TRUEevaluated 133 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 581 times by 1 test
Evaluated by:
  • Self test
name[1] == 0Description
TRUEevaluated 133 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
quoted == 0Description
TRUEevaluated 60 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 73 times by 1 test
Evaluated by:
  • Self test
ifs_is_nullDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 57 times by 1 test
Evaluated by:
  • Self test
0-714
8751 ret->flags |= W_SPLITSPACE; /* Posix interp 888 */
executed 3 times by 1 test: ret->flags |= 0x000008;
Executed by:
  • Self test
3
8752-
8753 FREE (name);
executed 773 times by 1 test: sh_xfree((name), "subst.c", 8753);
Executed by:
  • Self test
nameDescription
TRUEevaluated 773 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-773
8754 return ret;
executed 773 times by 1 test: return ret;
Executed by:
  • Self test
773
8755 }-
8756 else if (want_patsub)
want_patsubDescription
TRUEevaluated 877 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2367621 times by 1 test
Evaluated by:
  • Self test
877-2367621
8757 {-
8758 temp1 = parameter_brace_patsub (name, temp, ind, value, quoted, pflags, (tflag & W_ARRAYIND) ? AV_USEIND : 0);-
8759 FREE (value);
executed 873 times by 1 test: sh_xfree((value), "subst.c", 8759);
Executed by:
  • Self test
valueDescription
TRUEevaluated 873 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-873
8760 FREE (temp);
executed 857 times by 1 test: sh_xfree((temp), "subst.c", 8760);
Executed by:
  • Self test
tempDescription
TRUEevaluated 857 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16 times by 1 test
Evaluated by:
  • Self test
16-857
8761-
8762 if (temp1 == &expand_param_error || temp1 == &expand_param_fatal)
temp1 == &expand_param_errorDescription
TRUEnever evaluated
FALSEevaluated 873 times by 1 test
Evaluated by:
  • Self test
temp1 == &expand_param_fatalDescription
TRUEnever evaluated
FALSEevaluated 873 times by 1 test
Evaluated by:
  • Self test
0-873
8763 {-
8764 FREE (name);
never executed: sh_xfree((name), "subst.c", 8764);
nameDescription
TRUEnever evaluated
FALSEnever evaluated
0
8765 return (temp1 == &expand_param_error ? &expand_wdesc_error : &expand_wdesc_fatal);
never executed: return (temp1 == &expand_param_error ? &expand_wdesc_error : &expand_wdesc_fatal);
0
8766 }-
8767-
8768 ret = alloc_word_desc ();-
8769 ret->word = temp1;-
8770 if (temp1 &&
temp1Description
TRUEevaluated 857 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16 times by 1 test
Evaluated by:
  • Self test
16-857
8771 (quoted_dollar_atp == 0 || *quoted_dollar_atp == 0) &&
quoted_dollar_atp == 0Description
TRUEnever evaluated
FALSEevaluated 857 times by 1 test
Evaluated by:
  • Self test
*quoted_dollar_atp == 0Description
TRUEevaluated 781 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 76 times by 1 test
Evaluated by:
  • Self test
0-857
8772 QUOTED_NULL (temp1) && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))
(temp1)[0] == '\177'Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 778 times by 1 test
Evaluated by:
  • Self test
(temp1)[1] == '\0'Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(quoted & (0x002|0x001))Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-778
8773 ret->flags |= W_QUOTED|W_HASQUOTEDNULL;
executed 3 times by 1 test: ret->flags |= 0x000002|0x040000;
Executed by:
  • Self test
3
8774 /* Special handling for $* when unquoted and $IFS is null. Posix interp 888 */-
8775 else if (temp1 && (name[0] == '*' && name[1] == 0) && quoted == 0 && ifs_is_null)
temp1Description
TRUEevaluated 854 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16 times by 1 test
Evaluated by:
  • Self test
name[0] == '*'Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 828 times by 1 test
Evaluated by:
  • Self test
name[1] == 0Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
quoted == 0Description
TRUEevaluated 25 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
ifs_is_nullDescription
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20 times by 1 test
Evaluated by:
  • Self test
0-854
8776 ret->flags |= W_SPLITSPACE; /* Posix interp 888 */
executed 5 times by 1 test: ret->flags |= 0x000008;
Executed by:
  • Self test
5
8777-
8778 FREE (name);
executed 873 times by 1 test: sh_xfree((name), "subst.c", 8778);
Executed by:
  • Self test
nameDescription
TRUEevaluated 873 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-873
8779 return ret;
executed 873 times by 1 test: return ret;
Executed by:
  • Self test
873
8780 }-
8781#if defined (CASEMOD_EXPANSIONS)-
8782 else if (want_casemod)
want_casemodDescription
TRUEevaluated 80 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2367541 times by 1 test
Evaluated by:
  • Self test
80-2367541
8783 {-
8784 temp1 = parameter_brace_casemod (name, temp, ind, modspec, value, quoted, pflags, (tflag & W_ARRAYIND) ? AV_USEIND : 0);-
8785 FREE (value);
executed 80 times by 1 test: sh_xfree((value), "subst.c", 8785);
Executed by:
  • Self test
valueDescription
TRUEevaluated 80 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-80
8786 FREE (temp);
executed 80 times by 1 test: sh_xfree((temp), "subst.c", 8786);
Executed by:
  • Self test
tempDescription
TRUEevaluated 80 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-80
8787-
8788 if (temp1 == &expand_param_error || temp1 == &expand_param_fatal)
temp1 == &expand_param_errorDescription
TRUEnever evaluated
FALSEevaluated 80 times by 1 test
Evaluated by:
  • Self test
temp1 == &expand_param_fatalDescription
TRUEnever evaluated
FALSEevaluated 80 times by 1 test
Evaluated by:
  • Self test
0-80
8789 {-
8790 FREE (name);
never executed: sh_xfree((name), "subst.c", 8790);
nameDescription
TRUEnever evaluated
FALSEnever evaluated
0
8791 return (temp1 == &expand_param_error ? &expand_wdesc_error : &expand_wdesc_fatal);
never executed: return (temp1 == &expand_param_error ? &expand_wdesc_error : &expand_wdesc_fatal);
0
8792 }-
8793-
8794 ret = alloc_word_desc ();-
8795 ret->word = temp1;-
8796 if (temp1 &&
temp1Description
TRUEevaluated 80 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-80
8797 (quoted_dollar_atp == 0 || *quoted_dollar_atp == 0) &&
quoted_dollar_atp == 0Description
TRUEnever evaluated
FALSEevaluated 80 times by 1 test
Evaluated by:
  • Self test
*quoted_dollar_atp == 0Description
TRUEevaluated 74 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
0-80
8798 QUOTED_NULL (temp1) && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))
(temp1)[0] == '\177'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 72 times by 1 test
Evaluated by:
  • Self test
(temp1)[1] == '\0'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(quoted & (0x002|0x001))Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-72
8799 ret->flags |= W_QUOTED|W_HASQUOTEDNULL;
executed 2 times by 1 test: ret->flags |= 0x000002|0x040000;
Executed by:
  • Self test
2
8800 /* Special handling for $* when unquoted and $IFS is null. Posix interp 888 */-
8801 else if (temp1 && (name[0] == '*' && name[1] == 0) && quoted == 0 && ifs_is_null)
temp1Description
TRUEevaluated 78 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
name[0] == '*'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 74 times by 1 test
Evaluated by:
  • Self test
name[1] == 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
quoted == 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
ifs_is_nullDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-78
8802 ret->flags |= W_SPLITSPACE; /* Posix interp 888 */
executed 4 times by 1 test: ret->flags |= 0x000008;
Executed by:
  • Self test
4
8803-
8804 FREE (name);
executed 80 times by 1 test: sh_xfree((name), "subst.c", 8804);
Executed by:
  • Self test
nameDescription
TRUEevaluated 80 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-80
8805 return ret;
executed 80 times by 1 test: return ret;
Executed by:
  • Self test
80
8806 }-
8807#endif-
8808-
8809 /* Do the right thing based on which character ended the variable name. */-
8810 switch (c)-
8811 {-
8812 default:
never executed: default:
0
8813 case '\0':
never executed: case '\0':
0
8814bad_substitution:-
8815 last_command_exit_value = EXECUTION_FAILURE;-
8816 report_error (_("%s: bad substitution"), string ? string : "??");-
8817 FREE (value);
never executed: sh_xfree((value), "subst.c", 8817);
valueDescription
TRUEnever evaluated
FALSEevaluated 48 times by 1 test
Evaluated by:
  • Self test
0-48
8818 FREE (temp);
never executed: sh_xfree((temp), "subst.c", 8818);
tempDescription
TRUEnever evaluated
FALSEevaluated 48 times by 1 test
Evaluated by:
  • Self test
0-48
8819 free (name);-
8820 if (shell_compatibility_level <= 43)
shell_compatib...ty_level <= 43Description
TRUEnever evaluated
FALSEevaluated 48 times by 1 test
Evaluated by:
  • Self test
0-48
8821 return &expand_wdesc_error;
never executed: return &expand_wdesc_error;
0
8822 else-
8823 return ((posixly_correct && interactive_shell == 0) ? &expand_wdesc_fatal : &expand_wdesc_error);
executed 48 times by 1 test: return ((posixly_correct && interactive_shell == 0) ? &expand_wdesc_fatal : &expand_wdesc_error);
Executed by:
  • Self test
48
8824-
8825 case RBRACE:
executed 25624 times by 1 test: case '}':
Executed by:
  • Self test
25624
8826 break;
executed 25624 times by 1 test: break;
Executed by:
  • Self test
25624
8827-
8828 case '@':
executed 50 times by 1 test: case '@':
Executed by:
  • Self test
50
8829 temp1 = parameter_brace_transform (name, temp, ind, value, c, quoted, pflags, (tflag & W_ARRAYIND) ? AV_USEIND : 0);-
8830 free (temp);-
8831 free (value);-
8832-
8833 if (temp1 == &expand_param_error || temp1 == &expand_param_fatal)
temp1 == &expand_param_errorDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 49 times by 1 test
Evaluated by:
  • Self test
temp1 == &expand_param_fatalDescription
TRUEnever evaluated
FALSEevaluated 49 times by 1 test
Evaluated by:
  • Self test
0-49
8834 {-
8835 free (name);-
8836 last_command_exit_value = EXECUTION_FAILURE;-
8837 report_error (_("%s: bad substitution"), string ? string : "??");-
8838 return (temp1 == &expand_param_error ? &expand_wdesc_error : &expand_wdesc_fatal);
executed 1 time by 1 test: return (temp1 == &expand_param_error ? &expand_wdesc_error : &expand_wdesc_fatal);
Executed by:
  • Self test
1
8839 }-
8840-
8841 ret = alloc_word_desc ();-
8842 ret->word = temp1;-
8843 if (temp1 && QUOTED_NULL (temp1) && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))
temp1Description
TRUEevaluated 43 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
(temp1)[0] == '\177'Description
TRUEnever evaluated
FALSEevaluated 43 times by 1 test
Evaluated by:
  • Self test
(temp1)[1] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
(quoted & (0x002|0x001))Description
TRUEnever evaluated
FALSEnever evaluated
0-43
8844 ret->flags |= W_QUOTED|W_HASQUOTEDNULL;
never executed: ret->flags |= 0x000002|0x040000;
0
8845 /* Special handling for $* when unquoted and $IFS is null. Posix interp 888 */-
8846 else if (temp1 && (name[0] == '*' && name[1] == 0) && quoted == 0 && ifs_is_null)
temp1Description
TRUEevaluated 43 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
name[0] == '*'Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 37 times by 1 test
Evaluated by:
  • Self test
name[1] == 0Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
quoted == 0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
ifs_is_nullDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-43
8847 ret->flags |= W_SPLITSPACE; /* Posix interp 888 */
executed 4 times by 1 test: ret->flags |= 0x000008;
Executed by:
  • Self test
4
8848-
8849 free (name);-
8850 return ret;
executed 49 times by 1 test: return ret;
Executed by:
  • Self test
49
8851-
8852 case '#': /* ${param#[#]pattern} */
executed 1157928 times by 1 test: case '#':
Executed by:
  • Self test
1157928
8853 case '%': /* ${param%[%]pattern} */
executed 1157905 times by 1 test: case '%':
Executed by:
  • Self test
1157905
8854 if (value == 0 || *value == '\0' || temp == 0 || *temp == '\0')
value == 0Description
TRUEnever evaluated
FALSEevaluated 2315833 times by 1 test
Evaluated by:
  • Self test
*value == '\0'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2315829 times by 1 test
Evaluated by:
  • Self test
temp == 0Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2315819 times by 1 test
Evaluated by:
  • Self test
*temp == '\0'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2315818 times by 1 test
Evaluated by:
  • Self test
0-2315833
8855 {-
8856 FREE (value);
executed 15 times by 1 test: sh_xfree((value), "subst.c", 8856);
Executed by:
  • Self test
valueDescription
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-15
8857 break;
executed 15 times by 1 test: break;
Executed by:
  • Self test
15
8858 }-
8859 temp1 = parameter_brace_remove_pattern (name, temp, ind, value, c, quoted, (tflag & W_ARRAYIND) ? AV_USEIND : 0);-
8860 free (temp);-
8861 free (value);-
8862-
8863 ret = alloc_word_desc ();-
8864 ret->word = temp1;-
8865 if (temp1 && QUOTED_NULL (temp1) && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))
temp1Description
TRUEevaluated 2315818 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(temp1)[0] == '\177'Description
TRUEevaluated 25 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2315793 times by 1 test
Evaluated by:
  • Self test
(temp1)[1] == '\0'Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
(quoted & (0x002|0x001))Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2315818
8866 ret->flags |= W_QUOTED|W_HASQUOTEDNULL;
executed 21 times by 1 test: ret->flags |= 0x000002|0x040000;
Executed by:
  • Self test
21
8867 /* Special handling for $* when unquoted and $IFS is null. Posix interp 888 */-
8868 else if (temp1 && (name[0] == '*' && name[1] == 0) && quoted == 0 && ifs_is_null)
temp1Description
TRUEevaluated 2315797 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
name[0] == '*'Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2315777 times by 1 test
Evaluated by:
  • Self test
name[1] == 0Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
quoted == 0Description
TRUEevaluated 19 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
ifs_is_nullDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 18 times by 1 test
Evaluated by:
  • Self test
0-2315797
8869 ret->flags |= W_SPLITSPACE; /* Posix interp 888 */
executed 1 time by 1 test: ret->flags |= 0x000008;
Executed by:
  • Self test
1
8870-
8871 free (name);-
8872 return ret;
executed 2315818 times by 1 test: return ret;
Executed by:
  • Self test
2315818
8873-
8874 case '-':
executed 1513 times by 1 test: case '-':
Executed by:
  • Self test
1513
8875 case '=':
executed 5333 times by 1 test: case '=':
Executed by:
  • Self test
5333
8876 case '?':
executed 8895 times by 1 test: case '?':
Executed by:
  • Self test
8895
8877 case '+':
executed 10293 times by 1 test: case '+':
Executed by:
  • Self test
10293
8878 if (var_is_set && var_is_null == 0)
var_is_setDescription
TRUEevaluated 18612 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7422 times by 1 test
Evaluated by:
  • Self test
var_is_null == 0Description
TRUEevaluated 14506 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4106 times by 1 test
Evaluated by:
  • Self test
4106-18612
8879 {-
8880 /* If the operator is `+', we don't want the value of the named-
8881 variable for anything, just the value of the right hand side. */-
8882 if (c == '+')
c == '+'Description
TRUEevaluated 4889 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9617 times by 1 test
Evaluated by:
  • Self test
4889-9617
8883 {-
8884 /* XXX -- if we're double-quoted and the named variable is "$@",-
8885 we want to turn off any special handling of "$@" ---
8886 we're not using it, so whatever is on the rhs applies. */-
8887 if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && quoted_dollar_atp)
(quoted & (0x002|0x001))Description
TRUEevaluated 137 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4752 times by 1 test
Evaluated by:
  • Self test
quoted_dollar_atpDescription
TRUEevaluated 137 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-4752
8888 *quoted_dollar_atp = 0;
executed 137 times by 1 test: *quoted_dollar_atp = 0;
Executed by:
  • Self test
137
8889 if (contains_dollar_at)
contains_dollar_atDescription
TRUEevaluated 4889 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-4889
8890 *contains_dollar_at = 0;
executed 4889 times by 1 test: *contains_dollar_at = 0;
Executed by:
  • Self test
4889
8891-
8892 FREE (temp);
executed 4889 times by 1 test: sh_xfree((temp), "subst.c", 8892);
Executed by:
  • Self test
tempDescription
TRUEevaluated 4889 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-4889
8893 if (value)
valueDescription
TRUEevaluated 4889 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-4889
8894 {-
8895 /* From Posix discussion on austin-group list. Issue 221-
8896 requires that backslashes escaping `}' inside-
8897 double-quoted ${...} be removed. */-
8898 if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
quoted & (0x002|0x001)Description
TRUEevaluated 137 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4752 times by 1 test
Evaluated by:
  • Self test
137-4752
8899 quoted |= Q_DOLBRACE;
executed 137 times by 1 test: quoted |= 0x080;
Executed by:
  • Self test
137
8900 ret = parameter_brace_expand_rhs (name, value, c,-
8901 quoted,-
8902 pflags,-
8903 quoted_dollar_atp,-
8904 contains_dollar_at);-
8905 /* XXX - fix up later, esp. noting presence of-
8906 W_HASQUOTEDNULL in ret->flags */-
8907 free (value);-
8908 }
executed 4881 times by 1 test: end of block
Executed by:
  • Self test
4881
8909 else-
8910 temp = (char *)NULL;
never executed: temp = (char *) ((void *)0) ;
0
8911 }-
8912 else-
8913 {-
8914 FREE (value);
executed 9617 times by 1 test: sh_xfree((value), "subst.c", 8914);
Executed by:
  • Self test
valueDescription
TRUEevaluated 9617 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-9617
8915 }
executed 9617 times by 1 test: end of block
Executed by:
  • Self test
9617
8916 /* Otherwise do nothing; just use the value in TEMP. */-
8917 }-
8918 else /* VAR not set or VAR is NULL. */-
8919 {-
8920 FREE (temp);
executed 4106 times by 1 test: sh_xfree((temp), "subst.c", 8920);
Executed by:
  • Self test
tempDescription
TRUEevaluated 4106 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7422 times by 1 test
Evaluated by:
  • Self test
4106-7422
8921 temp = (char *)NULL;-
8922 if (c == '=' && var_is_special)
c == '='Description
TRUEevaluated 5154 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6374 times by 1 test
Evaluated by:
  • Self test
var_is_specialDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5145 times by 1 test
Evaluated by:
  • Self test
9-6374
8923 {-
8924 last_command_exit_value = EXECUTION_FAILURE;-
8925 report_error (_("$%s: cannot assign in this way"), name);-
8926 free (name);-
8927 free (value);-
8928 return &expand_wdesc_error;
executed 9 times by 1 test: return &expand_wdesc_error;
Executed by:
  • Self test
9
8929 }-
8930 else if (c == '?')
c == '?'Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11505 times by 1 test
Evaluated by:
  • Self test
14-11505
8931 {-
8932 parameter_brace_expand_error (name, value, check_nullness);-
8933 return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal);
executed 14 times by 1 test: return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal);
Executed by:
  • Self test
14
8934 }-
8935 else if (c != '+')
c != '+'Description
TRUEevaluated 6101 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5404 times by 1 test
Evaluated by:
  • Self test
5404-6101
8936 {-
8937 /* XXX -- if we're double-quoted and the named variable is "$@",-
8938 we want to turn off any special handling of "$@" ---
8939 we're not using it, so whatever is on the rhs applies. */-
8940 if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && quoted_dollar_atp)
(quoted & (0x002|0x001))Description
TRUEevaluated 1918 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4183 times by 1 test
Evaluated by:
  • Self test
quoted_dollar_atpDescription
TRUEevaluated 1918 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-4183
8941 *quoted_dollar_atp = 0;
executed 1918 times by 1 test: *quoted_dollar_atp = 0;
Executed by:
  • Self test
1918
8942 if (contains_dollar_at)
contains_dollar_atDescription
TRUEevaluated 6101 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-6101
8943 *contains_dollar_at = 0;
executed 6101 times by 1 test: *contains_dollar_at = 0;
Executed by:
  • Self test
6101
8944-
8945 /* From Posix discussion on austin-group list. Issue 221 requires-
8946 that backslashes escaping `}' inside double-quoted ${...} be-
8947 removed. */-
8948 if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
quoted & (0x002|0x001)Description
TRUEevaluated 1918 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4183 times by 1 test
Evaluated by:
  • Self test
1918-4183
8949 quoted |= Q_DOLBRACE;
executed 1918 times by 1 test: quoted |= 0x080;
Executed by:
  • Self test
1918
8950 ret = parameter_brace_expand_rhs (name, value, c, quoted, pflags,-
8951 quoted_dollar_atp,-
8952 contains_dollar_at);-
8953 /* XXX - fix up later, esp. noting presence of-
8954 W_HASQUOTEDNULL in tdesc->flags */-
8955 }
executed 6094 times by 1 test: end of block
Executed by:
  • Self test
6094
8956 free (value);-
8957 }
executed 11498 times by 1 test: end of block
Executed by:
  • Self test
11498
8958-
8959 break;
executed 25996 times by 1 test: break;
Executed by:
  • Self test
25996
8960 }-
8961 free (name);-
8962-
8963 if (ret == 0)
ret == 0Description
TRUEevaluated 40660 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10975 times by 1 test
Evaluated by:
  • Self test
10975-40660
8964 {-
8965 ret = alloc_word_desc ();-
8966 ret->flags = tflag;-
8967 ret->word = temp;-
8968 }
executed 40660 times by 1 test: end of block
Executed by:
  • Self test
40660
8969 return (ret);
executed 51635 times by 1 test: return (ret);
Executed by:
  • Self test
51635
8970}-
8971-
8972/* Expand a single ${xxx} expansion. The braces are optional. When-
8973 the braces are used, parameter_brace_expand() does the work,-
8974 possibly calling param_expand recursively. */-
8975static WORD_DESC *-
8976param_expand (string, sindex, quoted, expanded_something,-
8977 contains_dollar_at, quoted_dollar_at_p, had_quoted_null_p,-
8978 pflags)-
8979 char *string;-
8980 int *sindex, quoted, *expanded_something, *contains_dollar_at;-
8981 int *quoted_dollar_at_p, *had_quoted_null_p, pflags;-
8982{-
8983 char *temp, *temp1, uerror[3], *savecmd;-
8984 int zindex, t_index, expok;-
8985 unsigned char c;-
8986 intmax_t number;-
8987 SHELL_VAR *var;-
8988 WORD_LIST *list;-
8989 WORD_DESC *tdesc, *ret;-
8990 int tflag;-
8991-
8992/*itrace("param_expand: `%s' pflags = %d", string+*sindex, pflags);*/-
8993 zindex = *sindex;-
8994 c = string[++zindex];-
8995-
8996 temp = (char *)NULL;-
8997 ret = tdesc = (WORD_DESC *)NULL;-
8998 tflag = 0;-
8999-
9000 /* Do simple cases first. Switch on what follows '$'. */-
9001 switch (c)-
9002 {-
9003 /* $0 .. $9? */-
9004 case '0':
executed 112 times by 1 test: case '0':
Executed by:
  • Self test
112
9005 case '1':
executed 10276962 times by 1 test: case '1':
Executed by:
  • Self test
10276962
9006 case '2':
executed 1615239 times by 1 test: case '2':
Executed by:
  • Self test
1615239
9007 case '3':
executed 1615184 times by 1 test: case '3':
Executed by:
  • Self test
1615184
9008 case '4':
never executed: case '4':
0
9009 case '5':
never executed: case '5':
0
9010 case '6':
never executed: case '6':
0
9011 case '7':
never executed: case '7':
0
9012 case '8':
executed 3 times by 1 test: case '8':
Executed by:
  • Self test
3
9013 case '9':
executed 1 time by 1 test: case '9':
Executed by:
  • Self test
1
9014 temp1 = dollar_vars[TODIGIT (c)];-
9015 if (unbound_vars_is_error && temp1 == (char *)NULL)
unbound_vars_is_errorDescription
TRUEevaluated 19 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 13507482 times by 1 test
Evaluated by:
  • Self test
temp1 == (char *) ((void *)0)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test
5-13507482
9016 {-
9017 uerror[0] = '$';-
9018 uerror[1] = c;-
9019 uerror[2] = '\0';-
9020 last_command_exit_value = EXECUTION_FAILURE;-
9021 err_unboundvar (uerror);-
9022 return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal);
executed 5 times by 1 test: return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal);
Executed by:
  • Self test
5
9023 }-
9024 if (temp1)
temp1Description
TRUEevaluated 13507417 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 79 times by 1 test
Evaluated by:
  • Self test
79-13507417
9025 temp = (*temp1 && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))
executed 13507417 times by 1 test: temp = (*temp1 && (quoted & (0x002|0x001))) ? quote_string (temp1) : quote_escapes (temp1);
Executed by:
  • Self test
*temp1Description
TRUEevaluated 9415760 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4091657 times by 1 test
Evaluated by:
  • Self test
(quoted & (0x002|0x001))Description
TRUEevaluated 4529714 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4886046 times by 1 test
Evaluated by:
  • Self test
4091657-13507417
9026 ? quote_string (temp1)
executed 13507417 times by 1 test: temp = (*temp1 && (quoted & (0x002|0x001))) ? quote_string (temp1) : quote_escapes (temp1);
Executed by:
  • Self test
13507417
9027 : quote_escapes (temp1);
executed 13507417 times by 1 test: temp = (*temp1 && (quoted & (0x002|0x001))) ? quote_string (temp1) : quote_escapes (temp1);
Executed by:
  • Self test
13507417
9028 else-
9029 temp = (char *)NULL;
executed 79 times by 1 test: temp = (char *) ((void *)0) ;
Executed by:
  • Self test
79
9030-
9031 break;
executed 13507496 times by 1 test: break;
Executed by:
  • Self test
13507496
9032-
9033 /* $$ -- pid of the invoking shell. */-
9034 case '$':
executed 1261 times by 1 test: case '$':
Executed by:
  • Self test
1261
9035 temp = itos (dollar_dollar_pid);-
9036 break;
executed 1261 times by 1 test: break;
Executed by:
  • Self test
1261
9037-
9038 /* $# -- number of positional parameters. */-
9039 case '#':
executed 15128456 times by 1 test: case '#':
Executed by:
  • Self test
15128456
9040 temp = itos (number_of_args ());-
9041 break;
executed 15128456 times by 1 test: break;
Executed by:
  • Self test
15128456
9042-
9043 /* $? -- return value of the last synchronous command. */-
9044 case '?':
executed 1147 times by 1 test: case '?':
Executed by:
  • Self test
1147
9045 temp = itos (last_command_exit_value);-
9046 break;
executed 1147 times by 1 test: break;
Executed by:
  • Self test
1147
9047-
9048 /* $- -- flags supplied to the shell on invocation or by `set'. */-
9049 case '-':
executed 75 times by 1 test: case '-':
Executed by:
  • Self test
75
9050 temp = which_set_flags ();-
9051 break;
executed 75 times by 1 test: break;
Executed by:
  • Self test
75
9052-
9053 /* $! -- Pid of the last asynchronous command. */-
9054 case '!':
executed 38 times by 1 test: case '!':
Executed by:
  • Self test
38
9055 /* If no asynchronous pids have been created, expand to nothing.-
9056 If `set -u' has been executed, and no async processes have-
9057 been created, this is an expansion error. */-
9058 if (last_asynchronous_pid == NO_PID)
last_asynchron...d == (pid_t)-1Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 29 times by 1 test
Evaluated by:
  • Self test
9-29
9059 {-
9060 if (expanded_something)
expanded_somethingDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
4-5
9061 *expanded_something = 0;
executed 4 times by 1 test: *expanded_something = 0;
Executed by:
  • Self test
4
9062 temp = (char *)NULL;-
9063 if (unbound_vars_is_error)
unbound_vars_is_errorDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7 times by 1 test
Evaluated by:
  • Self test
2-7
9064 {-
9065 uerror[0] = '$';-
9066 uerror[1] = c;-
9067 uerror[2] = '\0';-
9068 last_command_exit_value = EXECUTION_FAILURE;-
9069 err_unboundvar (uerror);-
9070 return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal);
executed 2 times by 1 test: return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal);
Executed by:
  • Self test
2
9071 }-
9072 }
executed 7 times by 1 test: end of block
Executed by:
  • Self test
7
9073 else-
9074 temp = itos (last_asynchronous_pid);
executed 29 times by 1 test: temp = itos (last_asynchronous_pid);
Executed by:
  • Self test
29
9075 break;
executed 36 times by 1 test: break;
Executed by:
  • Self test
36
9076-
9077 /* The only difference between this and $@ is when the arg is quoted. */-
9078 case '*': /* `$*' */
executed 3868 times by 1 test: case '*':
Executed by:
  • Self test
3868
9079 list = list_rest_of_args ();-
9080-
9081#if 0-
9082 /* According to austin-group posix proposal by Geoff Clare in-
9083 <20090505091501.GA10097@squonk.masqnet> of 5 May 2009:-
9084-
9085 "The shell shall write a message to standard error and-
9086 immediately exit when it tries to expand an unset parameter-
9087 other than the '@' and '*' special parameters."-
9088 */-
9089-
9090 if (list == 0 && unbound_vars_is_error && (pflags & PF_IGNUNBOUND) == 0)-
9091 {-
9092 uerror[0] = '$';-
9093 uerror[1] = '*';-
9094 uerror[2] = '\0';-
9095 last_command_exit_value = EXECUTION_FAILURE;-
9096 err_unboundvar (uerror);-
9097 return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal);-
9098 }-
9099#endif-
9100-
9101 /* If there are no command-line arguments, this should just-
9102 disappear if there are other characters in the expansion,-
9103 even if it's quoted. */-
9104 if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && list == 0)
(quoted & (0x002|0x001))Description
TRUEevaluated 2610 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1258 times by 1 test
Evaluated by:
  • Self test
list == 0Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2590 times by 1 test
Evaluated by:
  • Self test
20-2610
9105 temp = (char *)NULL;
executed 20 times by 1 test: temp = (char *) ((void *)0) ;
Executed by:
  • Self test
20
9106 else if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES|Q_PATQUOTE))
quoted & (0x002|0x001|0x008)Description
TRUEevaluated 2594 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1254 times by 1 test
Evaluated by:
  • Self test
1254-2594
9107 {-
9108 /* If we have "$*" we want to make a string of the positional-
9109 parameters, separated by the first character of $IFS, and-
9110 quote the whole string, including the separators. If IFS-
9111 is unset, the parameters are separated by ' '; if $IFS is-
9112 null, the parameters are concatenated. */-
9113 temp = (quoted & (Q_DOUBLE_QUOTES|Q_PATQUOTE)) ? string_list_dollar_star (list, quoted, 0) : string_list (list);
(quoted & (0x001|0x008))Description
TRUEevaluated 2594 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2594
9114 if (temp)
tempDescription
TRUEevaluated 2594 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2594
9115 {-
9116 temp1 = (quoted & Q_DOUBLE_QUOTES) ? quote_string (temp) : temp;
(quoted & 0x001)Description
TRUEevaluated 2590 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
4-2590
9117 if (*temp == 0)
*temp == 0Description
TRUEevaluated 118 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2476 times by 1 test
Evaluated by:
  • Self test
118-2476
9118 tflag |= W_HASQUOTEDNULL;
executed 118 times by 1 test: tflag |= 0x040000;
Executed by:
  • Self test
118
9119 if (temp != temp1)
temp != temp1Description
TRUEevaluated 2590 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
4-2590
9120 free (temp);
executed 2590 times by 1 test: sh_xfree((temp), "subst.c", 9120);
Executed by:
  • Self test
2590
9121 temp = temp1;-
9122 }
executed 2594 times by 1 test: end of block
Executed by:
  • Self test
2594
9123 }
executed 2594 times by 1 test: end of block
Executed by:
  • Self test
2594
9124 else-
9125 {-
9126 /* We check whether or not we're eventually going to split $* here,-
9127 for example when IFS is empty and we are processing the rhs of-
9128 an assignment statement. In that case, we don't separate the-
9129 arguments at all. Otherwise, if the $* is not quoted it is-
9130 identical to $@ */-
9131 if (expand_no_split_dollar_star && quoted == 0 && ifs_is_set == 0 && (pflags & PF_ASSIGNRHS))
expand_no_split_dollar_starDescription
TRUEevaluated 1068 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 186 times by 1 test
Evaluated by:
  • Self test
quoted == 0Description
TRUEevaluated 1068 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
ifs_is_set == 0Description
TRUEevaluated 348 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 720 times by 1 test
Evaluated by:
  • Self test
(pflags & 0x08)Description
TRUEevaluated 344 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
0-1068
9132 {-
9133 /* Posix interp 888: RHS of assignment, IFS unset */-
9134 temp = string_list_dollar_at (list, Q_DOUBLE_QUOTES, pflags);-
9135 tflag |= W_SPLITSPACE;-
9136 }
executed 344 times by 1 test: end of block
Executed by:
  • Self test
344
9137 else if (expand_no_split_dollar_star && quoted == 0 && ifs_is_null && (pflags & PF_ASSIGNRHS))
expand_no_split_dollar_starDescription
TRUEevaluated 724 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 186 times by 1 test
Evaluated by:
  • Self test
quoted == 0Description
TRUEevaluated 724 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
ifs_is_nullDescription
TRUEevaluated 320 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 404 times by 1 test
Evaluated by:
  • Self test
(pflags & 0x08)Description
TRUEevaluated 314 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
0-724
9138 {-
9139 /* Posix interp 888: RHS of assignment, IFS set to '' */-
9140 temp1 = string_list_dollar_star (list, quoted, pflags);-
9141 temp = temp1 ? quote_escapes (temp1) : temp1;
temp1Description
TRUEevaluated 314 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-314
9142 FREE (temp1);
executed 314 times by 1 test: sh_xfree((temp1), "subst.c", 9142);
Executed by:
  • Self test
temp1Description
TRUEevaluated 314 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-314
9143 }
executed 314 times by 1 test: end of block
Executed by:
  • Self test
314
9144 else if (expand_no_split_dollar_star && quoted == 0 && ifs_is_set && ifs_is_null == 0 && (pflags & PF_ASSIGNRHS))
expand_no_split_dollar_starDescription
TRUEevaluated 410 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 186 times by 1 test
Evaluated by:
  • Self test
quoted == 0Description
TRUEevaluated 410 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
ifs_is_setDescription
TRUEevaluated 406 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
ifs_is_null == 0Description
TRUEevaluated 400 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
(pflags & 0x08)Description
TRUEevaluated 371 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 29 times by 1 test
Evaluated by:
  • Self test
0-410
9145 {-
9146 /* Posix interp 888: RHS of assignment, IFS set to non-null value */-
9147 temp1 = string_list_dollar_star (list, quoted, pflags);-
9148 temp = temp1 ? quote_string (temp1) : temp1;
temp1Description
TRUEevaluated 368 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
3-368
9149 FREE (temp1);
executed 368 times by 1 test: sh_xfree((temp1), "subst.c", 9149);
Executed by:
  • Self test
temp1Description
TRUEevaluated 368 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
3-368
9150 }
executed 371 times by 1 test: end of block
Executed by:
  • Self test
371
9151 /* XXX - should we check ifs_is_set here as well? */-
9152# if defined (HANDLE_MULTIBYTE)-
9153 else if (expand_no_split_dollar_star && ifs_firstc[0] == 0)
expand_no_split_dollar_starDescription
TRUEevaluated 39 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 186 times by 1 test
Evaluated by:
  • Self test
ifs_firstc[0] == 0Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 33 times by 1 test
Evaluated by:
  • Self test
6-186
9154# else-
9155 else if (expand_no_split_dollar_star && ifs_firstc == 0)-
9156# endif-
9157 /* Posix interp 888: not RHS, no splitting, IFS set to '' */-
9158 temp = string_list_dollar_star (list, quoted, 0);
executed 6 times by 1 test: temp = string_list_dollar_star (list, quoted, 0);
Executed by:
  • Self test
6
9159 else-
9160 {-
9161 temp = string_list_dollar_at (list, quoted, 0);-
9162 /* Set W_SPLITSPACE to make sure the individual positional-
9163 parameters are split into separate arguments */-
9164 if (quoted == 0 && (ifs_is_set == 0 || ifs_is_null))
quoted == 0Description
TRUEevaluated 219 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
ifs_is_set == 0Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 209 times by 1 test
Evaluated by:
  • Self test
ifs_is_nullDescription
TRUEevaluated 32 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 177 times by 1 test
Evaluated by:
  • Self test
0-219
9165 tflag |= W_SPLITSPACE;
executed 42 times by 1 test: tflag |= 0x000008;
Executed by:
  • Self test
42
9166 /* If we're not quoted but we still don't want word splitting, make-
9167 we quote the IFS characters to protect them from splitting (e.g.,-
9168 when $@ is in the string as well). */-
9169 else if (temp && quoted == 0 && ifs_is_set && (pflags & PF_ASSIGNRHS))
tempDescription
TRUEevaluated 172 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
quoted == 0Description
TRUEevaluated 172 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
ifs_is_setDescription
TRUEevaluated 172 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(pflags & 0x08)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 170 times by 1 test
Evaluated by:
  • Self test
0-172
9170 {-
9171 temp1 = quote_string (temp);-
9172 free (temp);-
9173 temp = temp1;-
9174 }
executed 2 times by 1 test: end of block
Executed by:
  • Self test
2
9175 }
executed 219 times by 1 test: end of block
Executed by:
  • Self test
219
9176-
9177 if (expand_no_split_dollar_star == 0 && contains_dollar_at)
expand_no_spli...llar_star == 0Description
TRUEevaluated 186 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1068 times by 1 test
Evaluated by:
  • Self test
contains_dollar_atDescription
TRUEevaluated 64 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 122 times by 1 test
Evaluated by:
  • Self test
64-1068
9178 *contains_dollar_at = 1;
executed 64 times by 1 test: *contains_dollar_at = 1;
Executed by:
  • Self test
64
9179 }
executed 1254 times by 1 test: end of block
Executed by:
  • Self test
1254
9180-
9181 dispose_words (list);-
9182 break;
executed 3868 times by 1 test: break;
Executed by:
  • Self test
3868
9183-
9184 /* When we have "$@" what we want is "$1" "$2" "$3" ... This-
9185 means that we have to turn quoting off after we split into-
9186 the individually quoted arguments so that the final split-
9187 on the first character of $IFS is still done. */-
9188 case '@': /* `$@' */
executed 3372 times by 1 test: case '@':
Executed by:
  • Self test
3372
9189 list = list_rest_of_args ();-
9190-
9191#if 0-
9192 /* According to austin-group posix proposal by Geoff Clare in-
9193 <20090505091501.GA10097@squonk.masqnet> of 5 May 2009:-
9194-
9195 "The shell shall write a message to standard error and-
9196 immediately exit when it tries to expand an unset parameter-
9197 other than the '@' and '*' special parameters."-
9198 */-
9199-
9200 if (list == 0 && unbound_vars_is_error && (pflags & PF_IGNUNBOUND) == 0)-
9201 {-
9202 uerror[0] = '$';-
9203 uerror[1] = '@';-
9204 uerror[2] = '\0';-
9205 last_command_exit_value = EXECUTION_FAILURE;-
9206 err_unboundvar (uerror);-
9207 return (interactive_shell ? &expand_wdesc_error : &expand_wdesc_fatal);-
9208 }-
9209#endif-
9210-
9211 /* We want to flag the fact that we saw this. We can't turn-
9212 off quoting entirely, because other characters in the-
9213 string might need it (consider "\"$@\""), but we need some-
9214 way to signal that the final split on the first character-
9215 of $IFS should be done, even though QUOTED is 1. */-
9216 /* XXX - should this test include Q_PATQUOTE? */-
9217 if (quoted_dollar_at_p && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))
quoted_dollar_at_pDescription
TRUEevaluated 2978 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 394 times by 1 test
Evaluated by:
  • Self test
(quoted & (0x002|0x001))Description
TRUEevaluated 1864 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1114 times by 1 test
Evaluated by:
  • Self test
394-2978
9218 *quoted_dollar_at_p = 1;
executed 1864 times by 1 test: *quoted_dollar_at_p = 1;
Executed by:
  • Self test
1864
9219 if (contains_dollar_at)
contains_dollar_atDescription
TRUEevaluated 2978 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 394 times by 1 test
Evaluated by:
  • Self test
394-2978
9220 *contains_dollar_at = 1;
executed 2978 times by 1 test: *contains_dollar_at = 1;
Executed by:
  • Self test
2978
9221-
9222 /* We want to separate the positional parameters with the first-
9223 character of $IFS in case $IFS is something other than a space.-
9224 We also want to make sure that splitting is done no matter what ---
9225 according to POSIX.2, this expands to a list of the positional-
9226 parameters no matter what IFS is set to. */-
9227 /* XXX - what to do when in a context where word splitting is not-
9228 performed? Even when IFS is not the default, posix seems to imply-
9229 that we behave like unquoted $* ? See below for how we use-
9230 PF_NOSPLIT2 here. */-
9231-
9232 /* These are the cases where word splitting will not be performed. */-
9233 if (pflags & PF_ASSIGNRHS)
pflags & 0x08Description
TRUEevaluated 1544 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1828 times by 1 test
Evaluated by:
  • Self test
1544-1828
9234 temp = string_list_dollar_at (list, (quoted|Q_DOUBLE_QUOTES), pflags);
executed 1544 times by 1 test: temp = string_list_dollar_at (list, (quoted|0x001), pflags);
Executed by:
  • Self test
1544
9235 /* This needs to match what expand_word_internal does with non-quoted $@-
9236 does with separating with spaces. Passing Q_DOUBLE_QUOTES means that-
9237 the characters in LIST will be quoted, and PF_ASSIGNRHS ensures that-
9238 they will separated by spaces. After doing this, we need the special-
9239 handling for PF_NOSPLIT2 in expand_word_internal to remove the CTLESC-
9240 quotes. */-
9241 else if (pflags & PF_NOSPLIT2)
pflags & 0x04Description
TRUEevaluated 110 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1718 times by 1 test
Evaluated by:
  • Self test
110-1718
9242 {-
9243#if defined (HANDLE_MULTIBYTE)-
9244 if (quoted == 0 && ifs_is_set && ifs_is_null == 0 && ifs_firstc[0] != ' ')
quoted == 0Description
TRUEevaluated 40 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 70 times by 1 test
Evaluated by:
  • Self test
ifs_is_setDescription
TRUEevaluated 40 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
ifs_is_null == 0Description
TRUEevaluated 37 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
ifs_firstc[0] != ' 'Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 16 times by 1 test
Evaluated by:
  • Self test
0-70
9245#else-
9246 if (quoted == 0 && ifs_is_set && ifs_is_null == 0 && ifs_firstc != ' ')-
9247#endif-
9248 /* Posix interp 888 */-
9249 temp = string_list_dollar_at (list, Q_DOUBLE_QUOTES, pflags);
executed 21 times by 1 test: temp = string_list_dollar_at (list, 0x001, pflags);
Executed by:
  • Self test
21
9250 else-
9251 temp = string_list_dollar_at (list, quoted, pflags);
executed 89 times by 1 test: temp = string_list_dollar_at (list, quoted, pflags);
Executed by:
  • Self test
89
9252 }-
9253 else-
9254 temp = string_list_dollar_at (list, quoted, pflags);
executed 1718 times by 1 test: temp = string_list_dollar_at (list, quoted, pflags);
Executed by:
  • Self test
1718
9255-
9256 tflag |= W_DOLLARAT;-
9257 dispose_words (list);-
9258 break;
executed 3372 times by 1 test: break;
Executed by:
  • Self test
3372
9259-
9260 case LBRACE:
executed 2369950 times by 1 test: case '{':
Executed by:
  • Self test
2369950
9261 tdesc = parameter_brace_expand (string, &zindex, quoted, pflags,-
9262 quoted_dollar_at_p,-
9263 contains_dollar_at);-
9264-
9265 if (tdesc == &expand_wdesc_error || tdesc == &expand_wdesc_fatal)
tdesc == &expand_wdesc_errorDescription
TRUEevaluated 91 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2369825 times by 1 test
Evaluated by:
  • Self test
tdesc == &expand_wdesc_fatalDescription
TRUEevaluated 38 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2369787 times by 1 test
Evaluated by:
  • Self test
38-2369825
9266 return (tdesc);
executed 129 times by 1 test: return (tdesc);
Executed by:
  • Self test
129
9267 temp = tdesc ? tdesc->word : (char *)0;
tdescDescription
TRUEevaluated 2369787 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2369787
9268-
9269 /* XXX */-
9270 /* Quoted nulls should be removed if there is anything else-
9271 in the string. */-
9272 /* Note that we saw the quoted null so we can add one back at-
9273 the end of this function if there are no other characters-
9274 in the string, discard TEMP, and go on. The exception to-
9275 this is when we have "${@}" and $1 is '', since $@ needs-
9276 special handling. */-
9277 if (tdesc && tdesc->word && (tdesc->flags & W_HASQUOTEDNULL) && QUOTED_NULL (temp))
tdescDescription
TRUEevaluated 2369787 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
tdesc->wordDescription
TRUEevaluated 2363511 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6276 times by 1 test
Evaluated by:
  • Self test
(tdesc->flags & 0x040000)Description
TRUEevaluated 106 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2363405 times by 1 test
Evaluated by:
  • Self test
(temp)[0] == '\177'Description
TRUEevaluated 106 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(temp)[1] == '\0'Description
TRUEevaluated 106 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2369787
9278 {-
9279 if (had_quoted_null_p)
had_quoted_null_pDescription
TRUEevaluated 106 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-106
9280 *had_quoted_null_p = 1;
executed 106 times by 1 test: *had_quoted_null_p = 1;
Executed by:
  • Self test
106
9281 if (*quoted_dollar_at_p == 0)
*quoted_dollar_at_p == 0Description
TRUEevaluated 97 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
9-97
9282 {-
9283 free (temp);-
9284 tdesc->word = temp = (char *)NULL;-
9285 }
executed 97 times by 1 test: end of block
Executed by:
  • Self test
97
9286 -
9287 }
executed 106 times by 1 test: end of block
Executed by:
  • Self test
106
9288-
9289 ret = tdesc;-
9290 goto return0;
executed 2369787 times by 1 test: goto return0;
Executed by:
  • Self test
2369787
9291-
9292 /* Do command or arithmetic substitution. */-
9293 case LPAREN:
executed 31931 times by 1 test: case '(':
Executed by:
  • Self test
31931
9294 /* We have to extract the contents of this paren substitution. */-
9295 t_index = zindex + 1;-
9296 /* XXX - might want to check for string[t_index+2] == LPAREN and parse-
9297 as arithmetic substitution immediately. */-
9298 temp = extract_command_subst (string, &t_index, (pflags&PF_COMPLETE) ? SX_COMPLETE : 0);-
9299 zindex = t_index;-
9300-
9301 /* For Posix.2-style `$(( ))' arithmetic substitution,-
9302 extract the expression and pass it to the evaluator. */-
9303 if (temp && *temp == LPAREN)
tempDescription
TRUEevaluated 31924 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*temp == '('Description
TRUEevaluated 6415 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 25509 times by 1 test
Evaluated by:
  • Self test
0-31924
9304 {-
9305 char *temp2;-
9306 temp1 = temp + 1;-
9307 temp2 = savestring (temp1);-
9308 t_index = strlen (temp2) - 1;-
9309-
9310 if (temp2[t_index] != RPAREN)
temp2[t_index] != ')'Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6412 times by 1 test
Evaluated by:
  • Self test
3-6412
9311 {-
9312 free (temp2);-
9313 goto comsub;
executed 3 times by 1 test: goto comsub;
Executed by:
  • Self test
3
9314 }-
9315-
9316 /* Cut off ending `)' */-
9317 temp2[t_index] = '\0';-
9318-
9319 if (chk_arithsub (temp2, t_index) == 0)
chk_arithsub (... t_index) == 0Description
TRUEevaluated 47 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6365 times by 1 test
Evaluated by:
  • Self test
47-6365
9320 {-
9321 free (temp2);-
9322#if 0-
9323 internal_warning (_("future versions of the shell will force evaluation as an arithmetic substitution"));-
9324#endif-
9325 goto comsub;
executed 47 times by 1 test: goto comsub;
Executed by:
  • Self test
47
9326 }-
9327-
9328 /* Expand variables found inside the expression. */-
9329 temp1 = expand_arith_string (temp2, Q_DOUBLE_QUOTES|Q_ARITH);-
9330 free (temp2);-
9331-
9332arithsub:
code before this statement executed 6346 times by 1 test: arithsub:
Executed by:
  • Self test
6346
9333 /* No error messages. */-
9334 savecmd = this_command_name;-
9335 this_command_name = (char *)NULL;-
9336 number = evalexp (temp1, EXP_EXPANDED, &expok);-
9337 this_command_name = savecmd;-
9338 free (temp);-
9339 free (temp1);-
9340 if (expok == 0)
expok == 0Description
TRUEevaluated 134 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6211 times by 1 test
Evaluated by:
  • Self test
134-6211
9341 {-
9342 if (interactive_shell == 0 && posixly_correct)
interactive_shell == 0Description
TRUEevaluated 134 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
posixly_correctDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 133 times by 1 test
Evaluated by:
  • Self test
0-134
9343 {-
9344 last_command_exit_value = EXECUTION_FAILURE;-
9345 return (&expand_wdesc_fatal);
executed 1 time by 1 test: return (&expand_wdesc_fatal);
Executed by:
  • Self test
1
9346 }-
9347 else-
9348 return (&expand_wdesc_error);
executed 133 times by 1 test: return (&expand_wdesc_error);
Executed by:
  • Self test
133
9349 }-
9350 temp = itos (number);-
9351 break;
executed 6211 times by 1 test: break;
Executed by:
  • Self test
6211
9352 }-
9353-
9354comsub:
code before this statement executed 25509 times by 1 test: comsub:
Executed by:
  • Self test
25509
9355 if (pflags & PF_NOCOMSUB)
pflags & 0x01Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 25554 times by 1 test
Evaluated by:
  • Self test
5-25554
9356 /* we need zindex+1 because string[zindex] == RPAREN */-
9357 temp1 = substring (string, *sindex, zindex+1);
executed 5 times by 1 test: temp1 = substring (string, *sindex, zindex+1);
Executed by:
  • Self test
5
9358 else-
9359 {-
9360 tdesc = command_substitute (temp, quoted, pflags&PF_ASSIGNRHS);-
9361 temp1 = tdesc ? tdesc->word : (char *)NULL;
tdescDescription
TRUEevaluated 24862 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 147 times by 1 test
Evaluated by:
  • Self test
147-24862
9362 if (tdesc)
tdescDescription
TRUEevaluated 24862 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 147 times by 1 test
Evaluated by:
  • Self test
147-24862
9363 dispose_word_desc (tdesc);
executed 24862 times by 1 test: dispose_word_desc (tdesc);
Executed by:
  • Self test
24862
9364 }
executed 25009 times by 1 test: end of block
Executed by:
  • Self test
25009
9365 FREE (temp);
executed 25014 times by 1 test: sh_xfree((temp), "subst.c", 9365);
Executed by:
  • Self test
tempDescription
TRUEevaluated 25014 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-25014
9366 temp = temp1;-
9367 break;
executed 25014 times by 1 test: break;
Executed by:
  • Self test
25014
9368-
9369 /* Do POSIX.2d9-style arithmetic substitution. This will probably go-
9370 away in a future bash release. */-
9371 case '[': /*]*/
executed 3 times by 1 test: case '[':
Executed by:
  • Self test
3
9372 /* Extract the contents of this arithmetic substitution. */-
9373 t_index = zindex + 1;-
9374 temp = extract_arithmetic_subst (string, &t_index);-
9375 zindex = t_index;-
9376 if (temp == 0)
temp == 0Description
TRUEnever evaluated
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
0-3
9377 {-
9378 temp = savestring (string);-
9379 if (expanded_something)
expanded_somethingDescription
TRUEnever evaluated
FALSEnever evaluated
0
9380 *expanded_something = 0;
never executed: *expanded_something = 0;
0
9381 goto return0;
never executed: goto return0;
0
9382 } -
9383-
9384 /* Do initial variable expansion. */-
9385 temp1 = expand_arith_string (temp, Q_DOUBLE_QUOTES|Q_ARITH);-
9386-
9387 goto arithsub;
executed 3 times by 1 test: goto arithsub;
Executed by:
  • Self test
3
9388-
9389 default:
executed 78856768 times by 1 test: default:
Executed by:
  • Self test
78856768
9390 /* Find the variable in VARIABLE_LIST. */-
9391 temp = (char *)NULL;-
9392-
9393 for (t_index = zindex; (c = string[zindex]) && legal_variable_char (c); zindex++)
(c = string[zindex])Description
TRUEevaluated 218086332 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 47631049 times by 1 test
Evaluated by:
  • Self test
((*__ctype_b_l...int) _ISalnum)Description
TRUEevaluated 177174838 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 40911494 times by 1 test
Evaluated by:
  • Self test
c == '_'Description
TRUEevaluated 9685775 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31225719 times by 1 test
Evaluated by:
  • Self test
9685775-218086332
9394 ;
executed 186860613 times by 1 test: ;
Executed by:
  • Self test
186860613
9395 temp1 = (zindex > t_index) ? substring (string, t_index, zindex) : (char *)NULL;
(zindex > t_index)Description
TRUEevaluated 78856747 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 21 times by 1 test
Evaluated by:
  • Self test
21-78856747
9396-
9397 /* If this isn't a variable name, then just output the `$'. */-
9398 if (temp1 == 0 || *temp1 == '\0')
temp1 == 0Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 78856747 times by 1 test
Evaluated by:
  • Self test
*temp1 == '\0'Description
TRUEnever evaluated
FALSEevaluated 78856747 times by 1 test
Evaluated by:
  • Self test
0-78856747
9399 {-
9400 FREE (temp1);
never executed: sh_xfree((temp1), "subst.c", 9400);
temp1Description
TRUEnever evaluated
FALSEevaluated 21 times by 1 test
Evaluated by:
  • Self test
0-21
9401 temp = (char *)xmalloc (2);-
9402 temp[0] = '$';-
9403 temp[1] = '\0';-
9404 if (expanded_something)
expanded_somethingDescription
TRUEnever evaluated
FALSEevaluated 21 times by 1 test
Evaluated by:
  • Self test
0-21
9405 *expanded_something = 0;
never executed: *expanded_something = 0;
0
9406 goto return0;
executed 21 times by 1 test: goto return0;
Executed by:
  • Self test
21
9407 }-
9408-
9409 /* If the variable exists, return its value cell. */-
9410 var = find_variable (temp1);-
9411-
9412 if (var && invisible_p (var) == 0 && var_isset (var))
varDescription
TRUEevaluated 78856251 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 496 times by 1 test
Evaluated by:
  • Self test
((((var)->attr...001000))) == 0Description
TRUEevaluated 78856237 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test
((var)->value != 0)Description
TRUEevaluated 78856237 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-78856251
9413 {-
9414#if defined (ARRAY_VARS)-
9415 if (assoc_p (var) || array_p (var))
((((var)->attr... (0x0000040)))Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 78856236 times by 1 test
Evaluated by:
  • Self test
((((var)->attr... (0x0000004)))Description
TRUEevaluated 82 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 78856154 times by 1 test
Evaluated by:
  • Self test
1-78856236
9416 {-
9417 temp = array_p (var) ? array_reference (array_cell (var), 0)
((((var)->attr... (0x0000004)))Description
TRUEevaluated 82 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-82
9418 : assoc_reference (assoc_cell (var), "0");-
9419 if (temp)
tempDescription
TRUEevaluated 83 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-83
9420 temp = (*temp && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))
executed 83 times by 1 test: temp = (*temp && (quoted & (0x002|0x001))) ? quote_string (temp) : quote_escapes (temp);
Executed by:
  • Self test
*tempDescription
TRUEevaluated 83 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(quoted & (0x002|0x001))Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 67 times by 1 test
Evaluated by:
  • Self test
0-83
9421 ? quote_string (temp)
executed 83 times by 1 test: temp = (*temp && (quoted & (0x002|0x001))) ? quote_string (temp) : quote_escapes (temp);
Executed by:
  • Self test
83
9422 : quote_escapes (temp);
executed 83 times by 1 test: temp = (*temp && (quoted & (0x002|0x001))) ? quote_string (temp) : quote_escapes (temp);
Executed by:
  • Self test
83
9423 else if (unbound_vars_is_error)
unbound_vars_is_errorDescription
TRUEnever evaluated
FALSEnever evaluated
0
9424 goto unbound_variable;
never executed: goto unbound_variable;
0
9425 }
executed 83 times by 1 test: end of block
Executed by:
  • Self test
83
9426 else-
9427#endif-
9428 {-
9429 temp = value_cell (var);-
9430-
9431 temp = (*temp && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))
*tempDescription
TRUEevaluated 66398726 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12457428 times by 1 test
Evaluated by:
  • Self test
(quoted & (0x002|0x001))Description
TRUEevaluated 29934933 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 36463793 times by 1 test
Evaluated by:
  • Self test
12457428-66398726
9432 ? quote_string (temp)-
9433 : quote_escapes (temp);-
9434 }
executed 78856154 times by 1 test: end of block
Executed by:
  • Self test
78856154
9435-
9436 free (temp1);-
9437-
9438 goto return0;
executed 78856237 times by 1 test: goto return0;
Executed by:
  • Self test
78856237
9439 }-
9440 else if (var && (invisible_p (var) || var_isset (var) == 0))
varDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 496 times by 1 test
Evaluated by:
  • Self test
((((var)->attr... (0x0001000)))Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((var)->value != 0) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-496
9441 temp = (char *)NULL;
executed 14 times by 1 test: temp = (char *) ((void *)0) ;
Executed by:
  • Self test
14
9442 else if ((var = find_variable_last_nameref (temp1, 0)) && var_isset (var) && invisible_p (var) == 0)
(var = find_va...ef (temp1, 0))Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 474 times by 1 test
Evaluated by:
  • Self test
((var)->value != 0)Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
((((var)->attr...001000))) == 0Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-474
9443 {-
9444 temp = nameref_cell (var);-
9445#if defined (ARRAY_VARS)-
9446 if (temp && *temp && valid_array_reference (temp, 0))
tempDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*tempDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
valid_array_re...ence (temp, 0)Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-22
9447 {-
9448 tdesc = parameter_brace_expand_word (temp, SPECIAL_VAR (temp, 0), quoted, pflags, (arrayind_t *)NULL);-
9449 if (tdesc == &expand_wdesc_error || tdesc == &expand_wdesc_fatal)
tdesc == &expand_wdesc_errorDescription
TRUEnever evaluated
FALSEevaluated 19 times by 1 test
Evaluated by:
  • Self test
tdesc == &expand_wdesc_fatalDescription
TRUEnever evaluated
FALSEevaluated 19 times by 1 test
Evaluated by:
  • Self test
0-19
9450 return (tdesc);
never executed: return (tdesc);
0
9451 ret = tdesc;-
9452 goto return0;
executed 19 times by 1 test: goto return0;
Executed by:
  • Self test
19
9453 }-
9454 else-
9455#endif-
9456 /* y=2 ; typeset -n x=y; echo $x is not the same as echo $2 in ksh */-
9457 if (temp && *temp && legal_identifier (temp) == 0)
tempDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*tempDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
legal_identifier (temp) == 0Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-1
9458 {-
9459 last_command_exit_value = EXECUTION_FAILURE;-
9460 report_error (_("%s: invalid variable name for name reference"), temp);-
9461 return (&expand_wdesc_error); /* XXX */
never executed: return (&expand_wdesc_error);
0
9462 }-
9463 else-
9464 temp = (char *)NULL;
executed 1 time by 1 test: temp = (char *) ((void *)0) ;
Executed by:
  • Self test
1
9465 }-
9466-
9467 temp = (char *)NULL;-
9468-
9469unbound_variable:
code before this statement executed 489 times by 1 test: unbound_variable:
Executed by:
  • Self test
489
9470 if (unbound_vars_is_error)
unbound_vars_is_errorDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 482 times by 1 test
Evaluated by:
  • Self test
7-482
9471 {-
9472 last_command_exit_value = EXECUTION_FAILURE;-
9473 err_unboundvar (temp1);-
9474 }
executed 7 times by 1 test: end of block
Executed by:
  • Self test
7
9475 else-
9476 {-
9477 free (temp1);-
9478 goto return0;
executed 482 times by 1 test: goto return0;
Executed by:
  • Self test
482
9479 }-
9480-
9481 free (temp1);-
9482 last_command_exit_value = EXECUTION_FAILURE;-
9483 return ((unbound_vars_is_error && interactive_shell == 0)
executed 7 times by 1 test: return ((unbound_vars_is_error && interactive_shell == 0) ? &expand_wdesc_fatal : &expand_wdesc_error);
Executed by:
  • Self test
7
9484 ? &expand_wdesc_fatal
executed 7 times by 1 test: return ((unbound_vars_is_error && interactive_shell == 0) ? &expand_wdesc_fatal : &expand_wdesc_error);
Executed by:
  • Self test
7
9485 : &expand_wdesc_error);
executed 7 times by 1 test: return ((unbound_vars_is_error && interactive_shell == 0) ? &expand_wdesc_fatal : &expand_wdesc_error);
Executed by:
  • Self test
7
9486 }-
9487-
9488 if (string[zindex])
string[zindex]Description
TRUEevaluated 28676936 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-28676936
9489 zindex++;
executed 28676936 times by 1 test: zindex++;
Executed by:
  • Self test
28676936
9490-
9491return0:
code before this statement executed 28676936 times by 1 test: return0:
Executed by:
  • Self test
28676936
9492 *sindex = zindex;-
9493-
9494 if (ret == 0)
ret == 0Description
TRUEevaluated 107533676 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2369806 times by 1 test
Evaluated by:
  • Self test
2369806-107533676
9495 {-
9496 ret = alloc_word_desc ();-
9497 ret->flags = tflag; /* XXX */-
9498 ret->word = temp;-
9499 }
executed 107533676 times by 1 test: end of block
Executed by:
  • Self test
107533676
9500 return ret;
executed 109903482 times by 1 test: return ret;
Executed by:
  • Self test
109903482
9501}-
9502-
9503void-
9504invalidate_cached_quoted_dollar_at ()-
9505{-
9506 dispose_words (cached_quoted_dollar_at);-
9507 cached_quoted_dollar_at = 0;-
9508}
executed 18438315 times by 1 test: end of block
Executed by:
  • Self test
18438315
9509-
9510/* Make a word list which is the result of parameter and variable-
9511 expansion, command substitution, arithmetic substitution, and-
9512 quote removal of WORD. Return a pointer to a WORD_LIST which is-
9513 the result of the expansion. If WORD contains a null word, the-
9514 word list returned is also null.-
9515-
9516 QUOTED contains flag values defined in shell.h.-
9517-
9518 ISEXP is used to tell expand_word_internal that the word should be-
9519 treated as the result of an expansion. This has implications for-
9520 how IFS characters in the word are treated.-
9521-
9522 CONTAINS_DOLLAR_AT and EXPANDED_SOMETHING are return values; when non-null-
9523 they point to an integer value which receives information about expansion.-
9524 CONTAINS_DOLLAR_AT gets non-zero if WORD contained "$@", else zero.-
9525 EXPANDED_SOMETHING get non-zero if WORD contained any parameter expansions,-
9526 else zero.-
9527-
9528 This only does word splitting in the case of $@ expansion. In that-
9529 case, we split on ' '. */-
9530-
9531/* Values for the local variable quoted_state. */-
9532#define UNQUOTED 0-
9533#define PARTIALLY_QUOTED 1-
9534#define WHOLLY_QUOTED 2-
9535-
9536static WORD_LIST *-
9537expand_word_internal (word, quoted, isexp, contains_dollar_at, expanded_something)-
9538 WORD_DESC *word;-
9539 int quoted, isexp;-
9540 int *contains_dollar_at;-
9541 int *expanded_something;-
9542{-
9543 WORD_LIST *list;-
9544 WORD_DESC *tword;-
9545-
9546 /* The intermediate string that we build while expanding. */-
9547 char *istring;-
9548-
9549 /* The current size of the above object. */-
9550 size_t istring_size;-
9551-
9552 /* Index into ISTRING. */-
9553 int istring_index;-
9554-
9555 /* Temporary string storage. */-
9556 char *temp, *temp1;-
9557-
9558 /* The text of WORD. */-
9559 register char *string;-
9560-
9561 /* The size of STRING. */-
9562 size_t string_size;-
9563-
9564 /* The index into STRING. */-
9565 int sindex;-
9566-
9567 /* This gets 1 if we see a $@ while quoted. */-
9568 int quoted_dollar_at;-
9569-
9570 /* One of UNQUOTED, PARTIALLY_QUOTED, or WHOLLY_QUOTED, depending on-
9571 whether WORD contains no quoting characters, a partially quoted-
9572 string (e.g., "xx"ab), or is fully quoted (e.g., "xxab"). */-
9573 int quoted_state;-
9574-
9575 /* State flags */-
9576 int had_quoted_null;-
9577 int has_quoted_ifs; /* did we add a quoted $IFS character here? */-
9578 int has_dollar_at, temp_has_dollar_at;-
9579 int split_on_spaces;-
9580 int local_expanded;-
9581 int tflag;-
9582 int pflags; /* flags passed to param_expand */-
9583 int mb_cur_max;-
9584-
9585 int assignoff; /* If assignment, offset of `=' */-
9586-
9587 register unsigned char c; /* Current character. */-
9588 int t_index; /* For calls to string_extract_xxx. */-
9589-
9590 char twochars[2];-
9591-
9592 DECLARE_MBSTATE;-
9593-
9594 /* OK, let's see if we can optimize a common idiom: "$@" */-
9595 if (STREQ (word->word, "\"$@\"") &&
never executed: __result = (((const unsigned char *) (const char *) ( word->word ))[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
(word->word)[0... ("\"$@\"")[0]Description
TRUEevaluated 26475363 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 179679486 times by 1 test
Evaluated by:
  • Self test
__extension__ ... )))); }) == 0Description
TRUEevaluated 3919 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 26471444 times by 1 test
Evaluated by:
  • Self test
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-179679486
9596 (word->flags == (W_HASDOLLAR|W_QUOTED)) &&
(word->flags =...001|0x000002))Description
TRUEevaluated 3069 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 850 times by 1 test
Evaluated by:
  • Self test
850-3069
9597 dollar_vars[1]) /* XXX - check IFS here as well? */
dollar_vars[1]Description
TRUEevaluated 3037 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 32 times by 1 test
Evaluated by:
  • Self test
32-3037
9598 {-
9599 if (contains_dollar_at)
contains_dollar_atDescription
TRUEevaluated 3037 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3037
9600 *contains_dollar_at = 1;
executed 3037 times by 1 test: *contains_dollar_at = 1;
Executed by:
  • Self test
3037
9601 if (expanded_something)
expanded_somethingDescription
TRUEevaluated 3037 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3037
9602 *expanded_something = 1;
executed 3037 times by 1 test: *expanded_something = 1;
Executed by:
  • Self test
3037
9603 if (cached_quoted_dollar_at)
cached_quoted_dollar_atDescription
TRUEevaluated 50 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2987 times by 1 test
Evaluated by:
  • Self test
50-2987
9604 return (copy_word_list (cached_quoted_dollar_at));
executed 50 times by 1 test: return (copy_word_list (cached_quoted_dollar_at));
Executed by:
  • Self test
50
9605 list = list_rest_of_args ();-
9606 list = quote_list (list);-
9607 cached_quoted_dollar_at = copy_word_list (list);-
9608 return (list);
executed 2987 times by 1 test: return (list);
Executed by:
  • Self test
2987
9609 }-
9610-
9611 istring = (char *)xmalloc (istring_size = DEFAULT_INITIAL_ARRAY_SIZE);-
9612 istring[istring_index = 0] = '\0';-
9613 quoted_dollar_at = had_quoted_null = has_dollar_at = 0;-
9614 has_quoted_ifs = 0;-
9615 split_on_spaces = 0;-
9616 quoted_state = UNQUOTED;-
9617-
9618 string = word->word;-
9619 if (string == 0)
string == 0Description
TRUEnever evaluated
FALSEevaluated 206151812 times by 1 test
Evaluated by:
  • Self test
0-206151812
9620 goto finished_with_string;
never executed: goto finished_with_string;
0
9621 mb_cur_max = MB_CUR_MAX;-
9622-
9623 /* Don't need the string length for the SADD... and COPY_ macros unless-
9624 multibyte characters are possible, but do need it for bounds checking. */-
9625 string_size = (mb_cur_max > 1) ? strlen (string) : 1;
(mb_cur_max > 1)Description
TRUEevaluated 205817154 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 334658 times by 1 test
Evaluated by:
  • Self test
334658-205817154
9626-
9627 if (contains_dollar_at)
contains_dollar_atDescription
TRUEevaluated 90126274 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 116025538 times by 1 test
Evaluated by:
  • Self test
90126274-116025538
9628 *contains_dollar_at = 0;
executed 90126274 times by 1 test: *contains_dollar_at = 0;
Executed by:
  • Self test
90126274
9629-
9630 assignoff = -1;-
9631-
9632 /* Begin the expansion. */-
9633-
9634 for (sindex = 0; ;)-
9635 {-
9636 c = string[sindex];-
9637-
9638 /* Case on top-level character. */-
9639 switch (c)-
9640 {-
9641 case '\0':
executed 206147021 times by 1 test: case '\0':
Executed by:
  • Self test
206147021
9642 goto finished_with_string;
executed 206147021 times by 1 test: goto finished_with_string;
Executed by:
  • Self test
206147021
9643-
9644 case CTLESC:
executed 122 times by 1 test: case '\001':
Executed by:
  • Self test
122
9645 sindex++;-
9646#if HANDLE_MULTIBYTE-
9647 if (mb_cur_max > 1 && string[sindex])
mb_cur_max > 1Description
TRUEevaluated 122 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
string[sindex]Description
TRUEevaluated 112 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
0-122
9648 {-
9649 SADD_MBQCHAR_BODY(temp, string, sindex, string_size);
executed 1 time by 1 test: mblength = 1;
Executed by:
  • Self test
executed 111 times by 1 test: end of block
Executed by:
  • Self test
never executed: end of block
never executed: mblength = 1;
executed 112 times by 1 test: (temp)[i+1] = (string)[(sindex)++];
Executed by:
  • Self test
executed 112 times by 1 test: goto add_string;
Executed by:
  • Self test
mblength < 1Description
TRUEnever evaluated
FALSEevaluated 112 times by 1 test
Evaluated by:
  • Self test
iDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 111 times by 1 test
Evaluated by:
  • Self test
i < mblengthDescription
TRUEevaluated 112 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 112 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 112 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 112 times by 1 test
Evaluated by:
  • Self test
0-112
9650 }-
9651 else-
9652#endif-
9653 {-
9654 temp = (char *)xmalloc (3);-
9655 temp[0] = CTLESC;-
9656 temp[1] = c = string[sindex];-
9657 temp[2] = '\0';-
9658 }
executed 10 times by 1 test: end of block
Executed by:
  • Self test
10
9659-
9660dollar_add_string:
code before this statement executed 10 times by 1 test: dollar_add_string:
Executed by:
  • Self test
10
9661 if (string[sindex])
string[sindex]Description
TRUEevaluated 3906375 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
10-3906375
9662 sindex++;
executed 3906375 times by 1 test: sindex++;
Executed by:
  • Self test
3906375
9663-
9664add_string:
code before this statement executed 3906385 times by 1 test: add_string:
Executed by:
  • Self test
3906385
9665 if (temp)
tempDescription
TRUEevaluated 390464859 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7583 times by 1 test
Evaluated by:
  • Self test
7583-390464859
9666 {-
9667 istring = sub_append_string (temp, istring, &istring_index, &istring_size);-
9668 temp = (char *)0;-
9669 }
executed 390464859 times by 1 test: end of block
Executed by:
  • Self test
390464859
9670-
9671 break;
executed 390472442 times by 1 test: break;
Executed by:
  • Self test
390472442
9672-
9673#if defined (PROCESS_SUBSTITUTION)-
9674 /* Process substitution. */-
9675 case '<':
executed 713851 times by 1 test: case '<':
Executed by:
  • Self test
713851
9676 case '>':
executed 6829 times by 1 test: case '>':
Executed by:
  • Self test
6829
9677 {-
9678 /* bash-4.4/bash-5.0-
9679 XXX - technically this should only be expanded at the start-
9680 of a word */-
9681 if (string[++sindex] != LPAREN || (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) || (word->flags & (W_DQUOTE|W_NOPROCSUB)) || posixly_correct)
string[++sindex] != '('Description
TRUEevaluated 41570 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 679110 times by 1 test
Evaluated by:
  • Self test
(quoted & (0x002|0x001))Description
TRUEevaluated 66 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 679044 times by 1 test
Evaluated by:
  • Self test
(word->flags &...000|0x100000))Description
TRUEnever evaluated
FALSEevaluated 679044 times by 1 test
Evaluated by:
  • Self test
posixly_correctDescription
TRUEnever evaluated
FALSEevaluated 679044 times by 1 test
Evaluated by:
  • Self test
0-679110
9682 {-
9683 sindex--; /* add_character: label increments sindex */-
9684 goto add_character;
executed 41636 times by 1 test: goto add_character;
Executed by:
  • Self test
41636
9685 }-
9686 else-
9687 t_index = sindex + 1; /* skip past both '<' and LPAREN */
executed 679044 times by 1 test: t_index = sindex + 1;
Executed by:
  • Self test
679044
9688-
9689 temp1 = extract_process_subst (string, (c == '<') ? "<(" : ">(", &t_index, 0); /*))*/-
9690 sindex = t_index;-
9691-
9692 /* If the process substitution specification is `<()', we want to-
9693 open the pipe for writing in the child and produce output; if-
9694 it is `>()', we want to open the pipe for reading in the child-
9695 and consume input. */-
9696 temp = temp1 ? process_substitute (temp1, (c == '>')) : (char *)0;
temp1Description
TRUEevaluated 679044 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-679044
9697-
9698 FREE (temp1);
executed 677660 times by 1 test: sh_xfree((temp1), "subst.c", 9698);
Executed by:
  • Self test
temp1Description
TRUEevaluated 677660 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-677660
9699-
9700 goto dollar_add_string;
executed 677660 times by 1 test: goto dollar_add_string;
Executed by:
  • Self test
677660
9701 }-
9702#endif /* PROCESS_SUBSTITUTION */-
9703-
9704 case '=':
executed 6532391 times by 1 test: case '=':
Executed by:
  • Self test
6532391
9705 /* Posix.2 section 3.6.1 says that tildes following `=' in words-
9706 which are not assignment statements are not expanded. If the-
9707 shell isn't in posix mode, though, we perform tilde expansion-
9708 on `likely candidate' unquoted assignment statements (flags-
9709 include W_ASSIGNMENT but not W_QUOTED). A likely candidate-
9710 contains an unquoted :~ or =~. Something to think about: we-
9711 now have a flag that says to perform tilde expansion on arguments-
9712 to `assignment builtins' like declare and export that look like-
9713 assignment statements. We now do tilde expansion on such words-
9714 even in POSIX mode. */ -
9715 if (word->flags & (W_ASSIGNRHS|W_NOTILDE))
word->flags & ...0800|0x001000)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6532387 times by 1 test
Evaluated by:
  • Self test
4-6532387
9716 {-
9717 if (isexp == 0 && (word->flags & (W_NOSPLIT|W_NOSPLIT2)) == 0 && isifs (c))
isexp == 0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
(word->flags &...x000040)) == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
(ifs_cmap[(uns...har)(c)] != 0)Description
TRUEnever evaluated
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test
0-3
9718 goto add_ifs_character;
never executed: goto add_ifs_character;
0
9719 else-
9720 goto add_character;
executed 4 times by 1 test: goto add_character;
Executed by:
  • Self test
4
9721 }-
9722 /* If we're not in posix mode or forcing assignment-statement tilde-
9723 expansion, note where the `=' appears in the word and prepare to-
9724 do tilde expansion following the first `='. */-
9725 if ((word->flags & W_ASSIGNMENT) &&
(word->flags & 0x000004)Description
TRUEevaluated 7474 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6524913 times by 1 test
Evaluated by:
  • Self test
7474-6524913
9726 (posixly_correct == 0 || (word->flags & W_TILDEEXP)) &&
posixly_correct == 0Description
TRUEevaluated 7466 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test
(word->flags & 0x000080)Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-7466
9727 assignoff == -1 && sindex > 0)
assignoff == -1Description
TRUEevaluated 7444 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 29 times by 1 test
Evaluated by:
  • Self test
sindex > 0Description
TRUEevaluated 7444 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-7444
9728 assignoff = sindex;
executed 7444 times by 1 test: assignoff = sindex;
Executed by:
  • Self test
7444
9729 if (sindex == assignoff && string[sindex+1] == '~') /* XXX */
sindex == assignoffDescription
TRUEevaluated 7444 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6524943 times by 1 test
Evaluated by:
  • Self test
string[sindex+1] == '~'Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7436 times by 1 test
Evaluated by:
  • Self test
8-6524943
9730 word->flags |= W_ITILDE;
executed 8 times by 1 test: word->flags |= 0x002000;
Executed by:
  • Self test
8
9731#if 0-
9732 else if ((word->flags & W_ASSIGNMENT) &&-
9733 (posixly_correct == 0 || (word->flags & W_TILDEEXP)) &&-
9734 string[sindex+1] == '~')-
9735 word->flags |= W_ITILDE;-
9736#endif-
9737-
9738 /* XXX - bash-4.4/bash-5.0 */-
9739 if (word->flags & W_ASSIGNARG)
word->flags & 0x020000Description
TRUEevaluated 1117 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6531270 times by 1 test
Evaluated by:
  • Self test
1117-6531270
9740 word->flags |= W_ASSIGNRHS; /* affects $@ */
executed 1117 times by 1 test: word->flags |= 0x000800;
Executed by:
  • Self test
1117
9741-
9742 if (isexp == 0 && (word->flags & (W_NOSPLIT|W_NOSPLIT2)) == 0 && isifs (c))
isexp == 0Description
TRUEevaluated 6532353 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 34 times by 1 test
Evaluated by:
  • Self test
(word->flags &...x000040)) == 0Description
TRUEevaluated 7229 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6525124 times by 1 test
Evaluated by:
  • Self test
(ifs_cmap[(uns...har)(c)] != 0)Description
TRUEnever evaluated
FALSEevaluated 7229 times by 1 test
Evaluated by:
  • Self test
0-6532353
9743 {-
9744 has_quoted_ifs++;-
9745 goto add_ifs_character;
never executed: goto add_ifs_character;
0
9746 }-
9747 else-
9748 goto add_character;
executed 6532387 times by 1 test: goto add_character;
Executed by:
  • Self test
6532387
9749-
9750 case ':':
executed 12513070 times by 1 test: case ':':
Executed by:
  • Self test
12513070
9751 if (word->flags & (W_NOTILDE|W_NOASSNTILDE))
word->flags & ...00|0x20000000)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12513066 times by 1 test
Evaluated by:
  • Self test
4-12513066
9752 {-
9753 if (isexp == 0 && (word->flags & (W_NOSPLIT|W_NOSPLIT2)) == 0 && isifs (c))
isexp == 0Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
(word->flags &...x000040)) == 0Description
TRUEnever evaluated
FALSEnever evaluated
(ifs_cmap[(uns...har)(c)] != 0)Description
TRUEnever evaluated
FALSEnever evaluated
0-4
9754 goto add_ifs_character;
never executed: goto add_ifs_character;
0
9755 else-
9756 goto add_character;
executed 4 times by 1 test: goto add_character;
Executed by:
  • Self test
4
9757 }-
9758-
9759 if ((word->flags & (W_ASSIGNMENT|W_ASSIGNRHS|W_TILDEEXP)) &&
(word->flags &...800|0x000080))Description
TRUEevaluated 91 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12512975 times by 1 test
Evaluated by:
  • Self test
91-12512975
9760 string[sindex+1] == '~')
string[sindex+1] == '~'Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 84 times by 1 test
Evaluated by:
  • Self test
7-84
9761 word->flags |= W_ITILDE;
executed 7 times by 1 test: word->flags |= 0x002000;
Executed by:
  • Self test
7
9762-
9763 if (isexp == 0 && (word->flags & (W_NOSPLIT|W_NOSPLIT2)) == 0 && isifs (c))
isexp == 0Description
TRUEevaluated 12513046 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 20 times by 1 test
Evaluated by:
  • Self test
(word->flags &...x000040)) == 0Description
TRUEevaluated 12512933 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 113 times by 1 test
Evaluated by:
  • Self test
(ifs_cmap[(uns...har)(c)] != 0)Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12512920 times by 1 test
Evaluated by:
  • Self test
13-12513046
9764 goto add_ifs_character;
executed 13 times by 1 test: goto add_ifs_character;
Executed by:
  • Self test
13
9765 else-
9766 goto add_character;
executed 12513053 times by 1 test: goto add_character;
Executed by:
  • Self test
12513053
9767-
9768 case '~':
executed 105 times by 1 test: case '~':
Executed by:
  • Self test
105
9769 /* If the word isn't supposed to be tilde expanded, or we're not-
9770 at the start of a word or after an unquoted : or = in an-
9771 assignment statement, we don't do tilde expansion. If we don't want-
9772 tilde expansion when expanding words to be passed to the arithmetic-
9773 evaluator, remove the check for Q_ARITH. Right now, the code-
9774 suppresses tilde expansion when expanding in a pure arithmetic-
9775 context, but allows it when expanding an array subscript. This is-
9776 for backwards compatibility, but I figure nobody's relying on it */-
9777 if ((word->flags & (W_NOTILDE|W_DQUOTE)) ||
(word->flags &...000|0x080000))Description
TRUEnever evaluated
FALSEevaluated 105 times by 1 test
Evaluated by:
  • Self test
0-105
9778 (sindex > 0 && ((word->flags & W_ITILDE) == 0)) ||
sindex > 0Description
TRUEevaluated 52 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 53 times by 1 test
Evaluated by:
  • Self test
((word->flags ...x002000) == 0)Description
TRUEevaluated 37 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 15 times by 1 test
Evaluated by:
  • Self test
15-53
9779 ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) && ((quoted & Q_ARRAYSUB) == 0)))
(quoted & (0x001|0x002))Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 48 times by 1 test
Evaluated by:
  • Self test
((quoted & 0x200) == 0)Description
TRUEevaluated 19 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-48
9780 {-
9781 word->flags &= ~W_ITILDE;-
9782 if (isexp == 0 && (word->flags & (W_NOSPLIT|W_NOSPLIT2)) == 0 && isifs (c) && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) == 0)
isexp == 0Description
TRUEevaluated 39 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 17 times by 1 test
Evaluated by:
  • Self test
(word->flags &...x000040)) == 0Description
TRUEevaluated 38 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
(ifs_cmap[(uns...har)(c)] != 0)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 37 times by 1 test
Evaluated by:
  • Self test
(quoted & (0x001|0x002)) == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-39
9783 goto add_ifs_character;
executed 1 time by 1 test: goto add_ifs_character;
Executed by:
  • Self test
1
9784 else-
9785 goto add_character;
executed 55 times by 1 test: goto add_character;
Executed by:
  • Self test
55
9786 }-
9787-
9788 if (word->flags & W_ASSIGNRHS)
word->flags & 0x000800Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 33 times by 1 test
Evaluated by:
  • Self test
16-33
9789 tflag = 2;
executed 16 times by 1 test: tflag = 2;
Executed by:
  • Self test
16
9790 else if (word->flags & (W_ASSIGNMENT|W_TILDEEXP))
word->flags & ...0004|0x000080)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 31 times by 1 test
Evaluated by:
  • Self test
2-31
9791 tflag = 1;
executed 2 times by 1 test: tflag = 1;
Executed by:
  • Self test
2
9792 else-
9793 tflag = 0;
executed 31 times by 1 test: tflag = 0;
Executed by:
  • Self test
31
9794-
9795 temp = bash_tilde_find_word (string + sindex, tflag, &t_index);-
9796 -
9797 word->flags &= ~W_ITILDE;-
9798-
9799 if (temp && *temp && t_index > 0)
tempDescription
TRUEevaluated 49 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*tempDescription
TRUEevaluated 49 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
t_index > 0Description
TRUEevaluated 46 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
0-49
9800 {-
9801 temp1 = bash_tilde_expand (temp, tflag);-
9802 if (temp1 && *temp1 == '~' && STREQ (temp, temp1))
never executed: __result = (((const unsigned char *) (const char *) ( temp ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( temp1 ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
temp1Description
TRUEevaluated 46 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*temp1 == '~'Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 44 times by 1 test
Evaluated by:
  • Self test
(temp)[0] == (temp1)[0]Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__extension__ ... )))); }) == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-46
9803 {-
9804 FREE (temp);
executed 2 times by 1 test: sh_xfree((temp), "subst.c", 9804);
Executed by:
  • Self test
tempDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
9805 FREE (temp1);
executed 2 times by 1 test: sh_xfree((temp1), "subst.c", 9805);
Executed by:
  • Self test
temp1Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
9806 goto add_character; /* tilde expansion failed */
executed 2 times by 1 test: goto add_character;
Executed by:
  • Self test
2
9807 }-
9808 free (temp);-
9809 temp = temp1;-
9810 sindex += t_index;-
9811 goto add_quoted_string; /* XXX was add_string */
executed 44 times by 1 test: goto add_quoted_string;
Executed by:
  • Self test
44
9812 }-
9813 else-
9814 {-
9815 FREE (temp);
executed 3 times by 1 test: sh_xfree((temp), "subst.c", 9815);
Executed by:
  • Self test
tempDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3
9816 goto add_character;
executed 3 times by 1 test: goto add_character;
Executed by:
  • Self test
3
9817 }-
9818 -
9819 case '$':
executed 109903573 times by 1 test: case '$':
Executed by:
  • Self test
109903573
9820 if (expanded_something)
expanded_somethingDescription
TRUEevaluated 3313109 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 106590464 times by 1 test
Evaluated by:
  • Self test
3313109-106590464
9821 *expanded_something = 1;
executed 3313109 times by 1 test: *expanded_something = 1;
Executed by:
  • Self test
3313109
9822 local_expanded = 1;-
9823-
9824 temp_has_dollar_at = 0;-
9825 pflags = (word->flags & W_NOCOMSUB) ? PF_NOCOMSUB : 0;
(word->flags & 0x000400)Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 109903565 times by 1 test
Evaluated by:
  • Self test
8-109903565
9826 if (word->flags & W_NOSPLIT2)
word->flags & 0x000040Description
TRUEevaluated 40071055 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 69832518 times by 1 test
Evaluated by:
  • Self test
40071055-69832518
9827 pflags |= PF_NOSPLIT2;
executed 40071055 times by 1 test: pflags |= 0x04;
Executed by:
  • Self test
40071055
9828 if (word->flags & W_ASSIGNRHS)
word->flags & 0x000800Description
TRUEevaluated 18303476 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 91600097 times by 1 test
Evaluated by:
  • Self test
18303476-91600097
9829 pflags |= PF_ASSIGNRHS;
executed 18303476 times by 1 test: pflags |= 0x08;
Executed by:
  • Self test
18303476
9830 if (word->flags & W_COMPLETE)
word->flags & 0x8000000Description
TRUEnever evaluated
FALSEevaluated 109903573 times by 1 test
Evaluated by:
  • Self test
0-109903573
9831 pflags |= PF_COMPLETE;
never executed: pflags |= 0x10;
0
9832 tword = param_expand (string, &sindex, quoted, expanded_something,-
9833 &temp_has_dollar_at, &quoted_dollar_at,-
9834 &had_quoted_null, pflags);-
9835 has_dollar_at += temp_has_dollar_at;-
9836 split_on_spaces += (tword->flags & W_SPLITSPACE);-
9837-
9838 if (tword == &expand_wdesc_error || tword == &expand_wdesc_fatal)
tword == &expand_wdesc_errorDescription
TRUEevaluated 224 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 109902738 times by 1 test
Evaluated by:
  • Self test
tword == &expand_wdesc_fatalDescription
TRUEevaluated 53 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 109902685 times by 1 test
Evaluated by:
  • Self test
53-109902738
9839 {-
9840 free (string);-
9841 free (istring);-
9842 return ((tword == &expand_wdesc_error) ? &expand_word_error
executed 277 times by 1 test: return ((tword == &expand_wdesc_error) ? &expand_word_error : &expand_word_fatal);
Executed by:
  • Self test
277
9843 : &expand_word_fatal);
executed 277 times by 1 test: return ((tword == &expand_wdesc_error) ? &expand_word_error : &expand_word_fatal);
Executed by:
  • Self test
277
9844 }-
9845 if (contains_dollar_at && has_dollar_at)
contains_dollar_atDescription
TRUEevaluated 51534094 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 58368591 times by 1 test
Evaluated by:
  • Self test
has_dollar_atDescription
TRUEevaluated 6651 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 51527443 times by 1 test
Evaluated by:
  • Self test
6651-58368591
9846 *contains_dollar_at = 1;
executed 6651 times by 1 test: *contains_dollar_at = 1;
Executed by:
  • Self test
6651
9847-
9848 if (tword && (tword->flags & W_HASQUOTEDNULL))
twordDescription
TRUEevaluated 109902685 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(tword->flags & 0x040000)Description
TRUEevaluated 184 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 109902501 times by 1 test
Evaluated by:
  • Self test
0-109902685
9849 had_quoted_null = 1; /* note for later */
executed 184 times by 1 test: had_quoted_null = 1;
Executed by:
  • Self test
184
9850-
9851 temp = tword ? tword->word : (char *)NULL;
twordDescription
TRUEevaluated 109902685 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-109902685
9852 dispose_word_desc (tword);-
9853-
9854 /* Kill quoted nulls; we will add them back at the end of-
9855 expand_word_internal if nothing else in the string */-
9856 if (had_quoted_null && temp && QUOTED_NULL (temp))
had_quoted_nullDescription
TRUEevaluated 300 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 109902385 times by 1 test
Evaluated by:
  • Self test
tempDescription
TRUEevaluated 132 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 168 times by 1 test
Evaluated by:
  • Self test
(temp)[0] == '\177'Description
TRUEevaluated 87 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 45 times by 1 test
Evaluated by:
  • Self test
(temp)[1] == '\0'Description
TRUEevaluated 87 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-109902385
9857 {-
9858 FREE (temp);
executed 87 times by 1 test: sh_xfree((temp), "subst.c", 9858);
Executed by:
  • Self test
tempDescription
TRUEevaluated 87 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-87
9859 temp = (char *)NULL;-
9860 }
executed 87 times by 1 test: end of block
Executed by:
  • Self test
87
9861-
9862 goto add_string;
executed 109902685 times by 1 test: goto add_string;
Executed by:
  • Self test
109902685
9863 break;
dead code: break;
-
9864-
9865 case '`': /* Backquoted command substitution. */
executed 3231120 times by 1 test: case '`':
Executed by:
  • Self test
3231120
9866 {-
9867 t_index = sindex++;-
9868-
9869 temp = string_extract (string, &sindex, "`", SX_REQMATCH);-
9870 /* The test of sindex against t_index is to allow bare instances of-
9871 ` to pass through, for backwards compatibility. */-
9872 if (temp == &extract_string_error || temp == &extract_string_fatal)
temp == &extract_string_errorDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3231118 times by 1 test
Evaluated by:
  • Self test
temp == &extract_string_fatalDescription
TRUEnever evaluated
FALSEevaluated 3231118 times by 1 test
Evaluated by:
  • Self test
0-3231118
9873 {-
9874 if (sindex - 1 == t_index)
sindex - 1 == t_indexDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-2
9875 {-
9876 sindex = t_index;-
9877 goto add_character;
executed 2 times by 1 test: goto add_character;
Executed by:
  • Self test
2
9878 }-
9879 last_command_exit_value = EXECUTION_FAILURE;-
9880 report_error (_("bad substitution: no closing \"`\" in %s") , string+t_index);-
9881 free (string);-
9882 free (istring);-
9883 return ((temp == &extract_string_error) ? &expand_word_error
never executed: return ((temp == &extract_string_error) ? &expand_word_error : &expand_word_fatal);
0
9884 : &expand_word_fatal);
never executed: return ((temp == &extract_string_error) ? &expand_word_error : &expand_word_fatal);
0
9885 }-
9886 -
9887 if (expanded_something)
expanded_somethingDescription
TRUEevaluated 890 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3230228 times by 1 test
Evaluated by:
  • Self test
890-3230228
9888 *expanded_something = 1;
executed 890 times by 1 test: *expanded_something = 1;
Executed by:
  • Self test
890
9889 local_expanded = 1;-
9890-
9891 if (word->flags & W_NOCOMSUB)
word->flags & 0x000400Description
TRUEnever evaluated
FALSEevaluated 3231118 times by 1 test
Evaluated by:
  • Self test
0-3231118
9892 /* sindex + 1 because string[sindex] == '`' */-
9893 temp1 = substring (string, t_index, sindex + 1);
never executed: temp1 = substring (string, t_index, sindex + 1);
0
9894 else-
9895 {-
9896 de_backslash (temp);-
9897 tword = command_substitute (temp, quoted, 0);-
9898 temp1 = tword ? tword->word : (char *)NULL;
twordDescription
TRUEevaluated 3228715 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3228715
9899 if (tword)
twordDescription
TRUEevaluated 3228715 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3228715
9900 dispose_word_desc (tword);
executed 3228715 times by 1 test: dispose_word_desc (tword);
Executed by:
  • Self test
3228715
9901 }
executed 3228715 times by 1 test: end of block
Executed by:
  • Self test
3228715
9902 FREE (temp);
executed 3228715 times by 1 test: sh_xfree((temp), "subst.c", 9902);
Executed by:
  • Self test
tempDescription
TRUEevaluated 3228715 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3228715
9903 temp = temp1;-
9904 goto dollar_add_string;
executed 3228715 times by 1 test: goto dollar_add_string;
Executed by:
  • Self test
3228715
9905 }-
9906-
9907 case '\\':
executed 7673 times by 1 test: case '\\':
Executed by:
  • Self test
7673
9908 if (string[sindex + 1] == '\n')
string[sindex + 1] == '\n'Description
TRUEnever evaluated
FALSEevaluated 7673 times by 1 test
Evaluated by:
  • Self test
0-7673
9909 {-
9910 sindex += 2;-
9911 continue;
never executed: continue;
0
9912 }-
9913-
9914 c = string[++sindex];-
9915-
9916 if (quoted & Q_HERE_DOCUMENT)
quoted & 0x002Description
TRUEnever evaluated
FALSEevaluated 7673 times by 1 test
Evaluated by:
  • Self test
0-7673
9917 tflag = CBSHDOC;
never executed: tflag = 0x0080;
0
9918 else if (quoted & Q_DOUBLE_QUOTES)
quoted & 0x001Description
TRUEevaluated 2433 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5240 times by 1 test
Evaluated by:
  • Self test
2433-5240
9919 tflag = CBSDQUOTE;
executed 2433 times by 1 test: tflag = 0x0040;
Executed by:
  • Self test
2433
9920 else-
9921 tflag = 0;
executed 5240 times by 1 test: tflag = 0;
Executed by:
  • Self test
5240
9922-
9923 /* From Posix discussion on austin-group list: Backslash escaping-
9924 a } in ${...} is removed. Issue 0000221 */-
9925 if ((quoted & Q_DOLBRACE) && c == RBRACE)
(quoted & 0x080)Description
TRUEevaluated 72 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7601 times by 1 test
Evaluated by:
  • Self test
c == '}'Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 68 times by 1 test
Evaluated by:
  • Self test
4-7601
9926 {-
9927 SCOPY_CHAR_I (twochars, CTLESC, c, string, sindex, string_size);
executed 4 times by 1 test: mblength = 1;
Executed by:
  • Self test
never executed: end of block
never executed: end of block
executed 4 times by 1 test: mblength = (mblength < 1) ? 1 : mblength;
Executed by:
  • Self test
executed 4 times by 1 test: temp[_i + 1] = string[sindex++];
Executed by:
  • Self test
executed 4 times by 1 test: goto add_string;
Executed by:
  • Self test
never executed: end of block
locale_mb_cur_max > 1Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
_iDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
_i < mblengthDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
(mblength < 1)Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
0-4
9928 }
never executed: end of block
0
9929 /* This is the fix for " $@\ " */-
9930 else if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && ((sh_syntaxtab[c] & tflag) == 0) && isexp == 0 && isifs (c))
(quoted & (0x002|0x001))Description
TRUEevaluated 2429 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5240 times by 1 test
Evaluated by:
  • Self test
((sh_syntaxtab...& tflag) == 0)Description
TRUEevaluated 1055 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1374 times by 1 test
Evaluated by:
  • Self test
isexp == 0Description
TRUEevaluated 1012 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 43 times by 1 test
Evaluated by:
  • Self test
(ifs_cmap[(uns...har)(c)] != 0)Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 999 times by 1 test
Evaluated by:
  • Self test
13-5240
9931 {-
9932 RESIZE_MALLOCED_BUFFER (istring, istring_index, 2, istring_size,
never executed: istring_size += (128);
never executed: end of block
(istring_index...= istring_sizeDescription
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
(istring_index...= istring_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0-13
9933 DEFAULT_ARRAY_SIZE);-
9934 istring[istring_index++] = CTLESC;-
9935 istring[istring_index++] = '\\';-
9936 istring[istring_index] = '\0';-
9937-
9938 SCOPY_CHAR_I (twochars, CTLESC, c, string, sindex, string_size);
executed 13 times by 1 test: mblength = 1;
Executed by:
  • Self test
never executed: end of block
never executed: end of block
executed 13 times by 1 test: mblength = (mblength < 1) ? 1 : mblength;
Executed by:
  • Self test
executed 13 times by 1 test: temp[_i + 1] = string[sindex++];
Executed by:
  • Self test
executed 13 times by 1 test: goto add_string;
Executed by:
  • Self test
never executed: end of block
locale_mb_cur_max > 1Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
_iDescription
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
_i < mblengthDescription
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
(mblength < 1)Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test
0-13
9939 }
never executed: end of block
0
9940 else if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && c == 0)
(quoted & (0x002|0x001))Description
TRUEevaluated 2416 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5240 times by 1 test
Evaluated by:
  • Self test
c == 0Description
TRUEnever evaluated
FALSEevaluated 2416 times by 1 test
Evaluated by:
  • Self test
0-5240
9941 {-
9942 RESIZE_MALLOCED_BUFFER (istring, istring_index, 2, istring_size,
never executed: istring_size += (128);
never executed: end of block
(istring_index...= istring_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
(istring_index...= istring_sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
9943 DEFAULT_ARRAY_SIZE);-
9944 istring[istring_index++] = CTLESC;-
9945 istring[istring_index++] = '\\';-
9946 istring[istring_index] = '\0';-
9947 break;
never executed: break;
0
9948 }-
9949 else if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && ((sh_syntaxtab[c] & tflag) == 0))
(quoted & (0x002|0x001))Description
TRUEevaluated 2416 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5240 times by 1 test
Evaluated by:
  • Self test
((sh_syntaxtab...& tflag) == 0)Description
TRUEevaluated 1042 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1374 times by 1 test
Evaluated by:
  • Self test
1042-5240
9950 {-
9951 SCOPY_CHAR_I (twochars, '\\', c, string, sindex, string_size);
executed 394 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 10 times by 1 test: end of block
Executed by:
  • Self test
never executed: end of block
executed 404 times by 1 test: mblength = (mblength < 1) ? 1 : mblength;
Executed by:
  • Self test
executed 404 times by 1 test: temp[_i + 1] = string[sindex++];
Executed by:
  • Self test
executed 404 times by 1 test: goto add_string;
Executed by:
  • Self test
executed 638 times by 1 test: end of block
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 404 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 638 times by 1 test
Evaluated by:
  • Self test
_iDescription
TRUEevaluated 394 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test
_i < mblengthDescription
TRUEevaluated 404 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 404 times by 1 test
Evaluated by:
  • Self test
(mblength < 1)Description
TRUEnever evaluated
FALSEevaluated 404 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 404 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 404 times by 1 test
Evaluated by:
  • Self test
0-638
9952 }
executed 638 times by 1 test: end of block
Executed by:
  • Self test
638
9953 else if (c == 0)
c == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6612 times by 1 test
Evaluated by:
  • Self test
2-6612
9954 {-
9955 c = CTLNUL;-
9956 sindex--; /* add_character: label increments sindex */-
9957 goto add_character;
executed 2 times by 1 test: goto add_character;
Executed by:
  • Self test
2
9958 }-
9959 else-
9960 {-
9961 SCOPY_CHAR_I (twochars, CTLESC, c, string, sindex, string_size);
executed 4942 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 1624 times by 1 test: end of block
Executed by:
  • Self test
never executed: end of block
executed 6566 times by 1 test: mblength = (mblength < 1) ? 1 : mblength;
Executed by:
  • Self test
executed 6566 times by 1 test: temp[_i + 1] = string[sindex++];
Executed by:
  • Self test
executed 6566 times by 1 test: goto add_string;
Executed by:
  • Self test
executed 46 times by 1 test: end of block
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 6566 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 46 times by 1 test
Evaluated by:
  • Self test
_iDescription
TRUEevaluated 4942 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1624 times by 1 test
Evaluated by:
  • Self test
_i < mblengthDescription
TRUEevaluated 6566 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6566 times by 1 test
Evaluated by:
  • Self test
(mblength < 1)Description
TRUEnever evaluated
FALSEevaluated 6566 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 6566 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 6566 times by 1 test
Evaluated by:
  • Self test
0-6566
9962 }
executed 46 times by 1 test: end of block
Executed by:
  • Self test
46
9963-
9964 sindex++;-
9965add_twochars:
code before this statement executed 684 times by 1 test: add_twochars:
Executed by:
  • Self test
684
9966 /* BEFORE jumping here, we need to increment sindex if appropriate */-
9967 RESIZE_MALLOCED_BUFFER (istring, istring_index, 2, istring_size,
executed 1 time by 1 test: istring_size += (128);
Executed by:
  • Self test
executed 1 time by 1 test: end of block
Executed by:
  • Self test
(istring_index...= istring_sizeDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6172 times by 1 test
Evaluated by:
  • Self test
(istring_index...= istring_sizeDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-6172
9968 DEFAULT_ARRAY_SIZE);-
9969 istring[istring_index++] = twochars[0];-
9970 istring[istring_index++] = twochars[1];-
9971 istring[istring_index] = '\0';-
9972-
9973 break;
executed 6173 times by 1 test: break;
Executed by:
  • Self test
6173
9974-
9975 case '"':
executed 26475615 times by 1 test: case '"':
Executed by:
  • Self test
26475615
9976 if ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) && ((quoted & Q_ARITH) == 0))
(quoted & (0x001|0x002))Description
TRUEevaluated 2339 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 26473276 times by 1 test
Evaluated by:
  • Self test
((quoted & 0x100) == 0)Description
TRUEevaluated 559 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1780 times by 1 test
Evaluated by:
  • Self test
559-26473276
9977 goto add_character;
executed 559 times by 1 test: goto add_character;
Executed by:
  • Self test
559
9978-
9979 t_index = ++sindex;-
9980 temp = string_extract_double_quoted (string, &sindex, (word->flags & W_COMPLETE) ? SX_COMPLETE : 0);-
9981-
9982 /* If the quotes surrounded the entire string, then the-
9983 whole word was quoted. */-
9984 quoted_state = (t_index == 1 && string[sindex] == '\0')
t_index == 1Description
TRUEevaluated 26472305 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2751 times by 1 test
Evaluated by:
  • Self test
string[sindex] == '\0'Description
TRUEevaluated 26469472 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2833 times by 1 test
Evaluated by:
  • Self test
2751-26472305
9985 ? WHOLLY_QUOTED-
9986 : PARTIALLY_QUOTED;-
9987-
9988 if (temp && *temp)
tempDescription
TRUEevaluated 26475056 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*tempDescription
TRUEevaluated 26474695 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 361 times by 1 test
Evaluated by:
  • Self test
0-26475056
9989 {-
9990 tword = alloc_word_desc ();-
9991 tword->word = temp;-
9992-
9993 /* XXX - bash-4.4/bash-5.0 */-
9994 if (word->flags & W_ASSIGNARG)
word->flags & 0x020000Description
TRUEevaluated 87 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 26474608 times by 1 test
Evaluated by:
  • Self test
87-26474608
9995 tword->flags |= word->flags & (W_ASSIGNARG|W_ASSIGNRHS); /* affects $@ */
executed 87 times by 1 test: tword->flags |= word->flags & (0x020000|0x000800);
Executed by:
  • Self test
87
9996 if (word->flags & W_COMPLETE)
word->flags & 0x8000000Description
TRUEnever evaluated
FALSEevaluated 26474695 times by 1 test
Evaluated by:
  • Self test
0-26474695
9997 tword->flags |= W_COMPLETE; /* for command substitutions */
never executed: tword->flags |= 0x8000000;
0
9998 if (word->flags & W_NOCOMSUB)
word->flags & 0x000400Description
TRUEnever evaluated
FALSEevaluated 26474695 times by 1 test
Evaluated by:
  • Self test
0-26474695
9999 tword->flags |= W_NOCOMSUB;
never executed: tword->flags |= 0x000400;
0
10000 if (word->flags & W_NOPROCSUB)
word->flags & 0x100000Description
TRUEevaluated 3396 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 26471299 times by 1 test
Evaluated by:
  • Self test
3396-26471299
10001 tword->flags |= W_NOPROCSUB;
executed 3396 times by 1 test: tword->flags |= 0x100000;
Executed by:
  • Self test
3396
10002-
10003 temp = (char *)NULL;-
10004-
10005 temp_has_dollar_at = 0; /* does this quoted (sub)string include $@? */-
10006 /* Need to get W_HASQUOTEDNULL flag through this function. */-
10007 list = expand_word_internal (tword, Q_DOUBLE_QUOTES, 0, &temp_has_dollar_at, (int *)NULL);-
10008 has_dollar_at += temp_has_dollar_at;-
10009-
10010 if (list == &expand_word_error || list == &expand_word_fatal)
list == &expand_word_errorDescription
TRUEevaluated 26 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 26474581 times by 1 test
Evaluated by:
  • Self test
list == &expand_word_fatalDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 26474579 times by 1 test
Evaluated by:
  • Self test
2-26474581
10011 {-
10012 free (istring);-
10013 free (string);-
10014 /* expand_word_internal has already freed temp_word->word-
10015 for us because of the way it prints error messages. */-
10016 tword->word = (char *)NULL;-
10017 dispose_word (tword);-
10018 return list;
executed 28 times by 1 test: return list;
Executed by:
  • Self test
28
10019 }-
10020-
10021 dispose_word (tword);-
10022-
10023 /* "$@" (a double-quoted dollar-at) expands into nothing,-
10024 not even a NULL word, when there are no positional-
10025 parameters. Posix interp 888 says that other parts of the-
10026 word that expand to quoted nulls result in quoted nulls, so-
10027 we can't just throw the entire word away if we have "$@"-
10028 anywhere in it. We use had_quoted_null to keep track */-
10029 if (list == 0 && temp_has_dollar_at) /* XXX - was has_dollar_at */
list == 0Description
TRUEevaluated 3547 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 26471032 times by 1 test
Evaluated by:
  • Self test
temp_has_dollar_atDescription
TRUEevaluated 175 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3372 times by 1 test
Evaluated by:
  • Self test
175-26471032
10030 {-
10031 quoted_dollar_at++;-
10032 break;
executed 175 times by 1 test: break;
Executed by:
  • Self test
175
10033 }-
10034-
10035 /* If this list comes back with a quoted null from expansion,-
10036 we have either "$x" or "$@" with $1 == ''. In either case,-
10037 we need to make sure we add a quoted null argument and-
10038 disable the special handling that "$@" gets. */-
10039 if (list && list->word && list->next == 0 && (list->word->flags & W_HASQUOTEDNULL))
listDescription
TRUEevaluated 26471032 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3372 times by 1 test
Evaluated by:
  • Self test
list->wordDescription
TRUEevaluated 26471032 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
list->next == 0Description
TRUEevaluated 26470560 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 472 times by 1 test
Evaluated by:
  • Self test
(list->word->flags & 0x040000)Description
TRUEevaluated 161 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 26470399 times by 1 test
Evaluated by:
  • Self test
0-26471032
10040 {-
10041 /* If we already saw a quoted null, we don't need to add-
10042 another one */-
10043 if (had_quoted_null && temp_has_dollar_at)
had_quoted_nullDescription
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 140 times by 1 test
Evaluated by:
  • Self test
temp_has_dollar_atDescription
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-140
10044 {-
10045 quoted_dollar_at++;-
10046 break;
executed 21 times by 1 test: break;
Executed by:
  • Self test
21
10047 }-
10048 had_quoted_null = 1; /* XXX */-
10049 }
executed 140 times by 1 test: end of block
Executed by:
  • Self test
140
10050-
10051 /* If we get "$@", we know we have expanded something, so we-
10052 need to remember it for the final split on $IFS. This is-
10053 a special case; it's the only case where a quoted string-
10054 can expand into more than one word. It's going to come back-
10055 from the above call to expand_word_internal as a list with-
10056 a single word, in which all characters are quoted and-
10057 separated by blanks. What we want to do is to turn it back-
10058 into a list for the next piece of code. */-
10059 if (list)
listDescription
TRUEevaluated 26471011 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3372 times by 1 test
Evaluated by:
  • Self test
3372-26471011
10060 dequote_list (list);
executed 26471011 times by 1 test: dequote_list (list);
Executed by:
  • Self test
26471011
10061-
10062 if (temp_has_dollar_at) /* XXX - was has_dollar_at */
temp_has_dollar_atDescription
TRUEevaluated 2071 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 26472312 times by 1 test
Evaluated by:
  • Self test
2071-26472312
10063 {-
10064 quoted_dollar_at++;-
10065 if (contains_dollar_at)
contains_dollar_atDescription
TRUEevaluated 2048 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 23 times by 1 test
Evaluated by:
  • Self test
23-2048
10066 *contains_dollar_at = 1;
executed 2048 times by 1 test: *contains_dollar_at = 1;
Executed by:
  • Self test
2048
10067 if (expanded_something)
expanded_somethingDescription
TRUEevaluated 1225 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 846 times by 1 test
Evaluated by:
  • Self test
846-1225
10068 *expanded_something = 1;
executed 1225 times by 1 test: *expanded_something = 1;
Executed by:
  • Self test
1225
10069 local_expanded = 1;-
10070 }
executed 2071 times by 1 test: end of block
Executed by:
  • Self test
2071
10071 }
executed 26474383 times by 1 test: end of block
Executed by:
  • Self test
26474383
10072 else-
10073 {-
10074 /* What we have is "". This is a minor optimization. */-
10075 FREE (temp);
executed 361 times by 1 test: sh_xfree((temp), "subst.c", 10075);
Executed by:
  • Self test
tempDescription
TRUEevaluated 361 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-361
10076 list = (WORD_LIST *)NULL;-
10077 had_quoted_null = 1; /* note for later */-
10078 }
executed 361 times by 1 test: end of block
Executed by:
  • Self test
361
10079-
10080 /* The code above *might* return a list (consider the case of "$@",-
10081 where it returns "$1", "$2", etc.). We can't throw away the-
10082 rest of the list, and we have to make sure each word gets added-
10083 as quoted. We test on tresult->next: if it is non-NULL, we-
10084 quote the whole list, save it to a string with string_list, and-
10085 add that string. We don't need to quote the results of this-
10086 (and it would be wrong, since that would quote the separators-
10087 as well), so we go directly to add_string. */-
10088 if (list)
listDescription
TRUEevaluated 26471011 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3733 times by 1 test
Evaluated by:
  • Self test
3733-26471011
10089 {-
10090 if (list->next)
list->nextDescription
TRUEevaluated 472 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 26470539 times by 1 test
Evaluated by:
  • Self test
472-26470539
10091 {-
10092 /* Testing quoted_dollar_at makes sure that "$@" is-
10093 split correctly when $IFS does not contain a space. */-
10094 temp = quoted_dollar_at
quoted_dollar_atDescription
TRUEevaluated 472 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-472
10095 ? string_list_dollar_at (list, Q_DOUBLE_QUOTES, 0)-
10096 : string_list (quote_list (list));-
10097 dispose_words (list);-
10098 goto add_string;
executed 472 times by 1 test: goto add_string;
Executed by:
  • Self test
472
10099 }-
10100 else-
10101 {-
10102 temp = savestring (list->word->word);-
10103 tflag = list->word->flags;-
10104 dispose_words (list);-
10105-
10106 /* If the string is not a quoted null string, we want-
10107 to remove any embedded unquoted CTLNUL characters.-
10108 We do not want to turn quoted null strings back into-
10109 the empty string, though. We do this because we-
10110 want to remove any quoted nulls from expansions that-
10111 contain other characters. For example, if we have-
10112 x"$*"y or "x$*y" and there are no positional parameters,-
10113 the $* should expand into nothing. */-
10114 /* We use the W_HASQUOTEDNULL flag to differentiate the-
10115 cases: a quoted null character as above and when-
10116 CTLNUL is contained in the (non-null) expansion-
10117 of some variable. We use the had_quoted_null flag to-
10118 pass the value through this function to its caller. */-
10119 if ((tflag & W_HASQUOTEDNULL) && QUOTED_NULL (temp) == 0)
(tflag & 0x040000)Description
TRUEnever evaluated
FALSEevaluated 26470539 times by 1 test
Evaluated by:
  • Self test
((temp)[0] == ... == '\0') == 0Description
TRUEnever evaluated
FALSEnever evaluated
(temp)[0] == '\177'Description
TRUEnever evaluated
FALSEnever evaluated
(temp)[1] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0-26470539
10120 remove_quoted_nulls (temp); /* XXX */
never executed: remove_quoted_nulls (temp);
0
10121 }
executed 26470539 times by 1 test: end of block
Executed by:
  • Self test
26470539
10122 }-
10123 else-
10124 temp = (char *)NULL;
executed 3733 times by 1 test: temp = (char *) ((void *)0) ;
Executed by:
  • Self test
3733
10125-
10126 /* We do not want to add quoted nulls to strings that are only-
10127 partially quoted; we can throw them away. The exception to-
10128 this is when we are going to be performing word splitting,-
10129 since we have to preserve a null argument if the next character-
10130 will cause word splitting. */-
10131 if (temp == 0 && quoted_state == PARTIALLY_QUOTED && (word->flags & (W_NOSPLIT|W_NOSPLIT2)))
temp == 0Description
TRUEevaluated 3733 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 26470539 times by 1 test
Evaluated by:
  • Self test
quoted_state == 1Description
TRUEevaluated 352 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3381 times by 1 test
Evaluated by:
  • Self test
(word->flags &...010|0x000040))Description
TRUEevaluated 53 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 299 times by 1 test
Evaluated by:
  • Self test
53-26470539
10132 continue;
executed 53 times by 1 test: continue;
Executed by:
  • Self test
53
10133-
10134 add_quoted_string:
code before this statement executed 26474219 times by 1 test: add_quoted_string:
Executed by:
  • Self test
26474219
10135-
10136 if (temp)
tempDescription
TRUEevaluated 36258972 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3680 times by 1 test
Evaluated by:
  • Self test
3680-36258972
10137 {-
10138 temp1 = temp;-
10139 temp = quote_string (temp);-
10140 free (temp1);-
10141 goto add_string;
executed 36258972 times by 1 test: goto add_string;
Executed by:
  • Self test
36258972
10142 }-
10143 else-
10144 {-
10145 /* Add NULL arg. */-
10146 c = CTLNUL;-
10147 sindex--; /* add_character: label increments sindex */-
10148 had_quoted_null = 1; /* note for later */-
10149 goto add_character;
executed 3680 times by 1 test: goto add_character;
Executed by:
  • Self test
3680
10150 }-
10151-
10152 /* break; */-
10153-
10154 case '\'':
executed 18322317 times by 1 test: case '\'':
Executed by:
  • Self test
18322317
10155 if ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)))
(quoted & (0x001|0x002))Description
TRUEevaluated 520 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 18321797 times by 1 test
Evaluated by:
  • Self test
520-18321797
10156 goto add_character;
executed 520 times by 1 test: goto add_character;
Executed by:
  • Self test
520
10157-
10158 t_index = ++sindex;-
10159 temp = string_extract_single_quoted (string, &sindex);-
10160-
10161 /* If the entire STRING was surrounded by single quotes,-
10162 then the string is wholly quoted. */-
10163 quoted_state = (t_index == 1 && string[sindex] == '\0')
t_index == 1Description
TRUEevaluated 18316211 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5586 times by 1 test
Evaluated by:
  • Self test
string[sindex] == '\0'Description
TRUEevaluated 18316088 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 123 times by 1 test
Evaluated by:
  • Self test
123-18316211
10164 ? WHOLLY_QUOTED-
10165 : PARTIALLY_QUOTED;-
10166-
10167 /* If all we had was '', it is a null expansion. */-
10168 if (*temp == '\0')
*temp == '\0'Description
TRUEevaluated 8533408 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9788389 times by 1 test
Evaluated by:
  • Self test
8533408-9788389
10169 {-
10170 free (temp);-
10171 temp = (char *)NULL;-
10172 }
executed 8533408 times by 1 test: end of block
Executed by:
  • Self test
8533408
10173 else-
10174 remove_quoted_escapes (temp); /* ??? */
executed 9788389 times by 1 test: remove_quoted_escapes (temp);
Executed by:
  • Self test
9788389
10175-
10176 if (temp == 0 && quoted_state == PARTIALLY_QUOTED)
temp == 0Description
TRUEevaluated 8533408 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9788389 times by 1 test
Evaluated by:
  • Self test
quoted_state == 1Description
TRUEevaluated 158 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8533250 times by 1 test
Evaluated by:
  • Self test
158-9788389
10177 had_quoted_null = 1; /* note for later */
executed 158 times by 1 test: had_quoted_null = 1;
Executed by:
  • Self test
158
10178-
10179 /* We do not want to add quoted nulls to strings that are only-
10180 partially quoted; such nulls are discarded. See above for the-
10181 exception, which is when the string is going to be split.-
10182 Posix interp 888 */-
10183 if (temp == 0 && (quoted_state == PARTIALLY_QUOTED) && (word->flags & (W_NOSPLIT|W_NOSPLIT2)))
temp == 0Description
TRUEevaluated 8533408 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9788389 times by 1 test
Evaluated by:
  • Self test
(quoted_state == 1)Description
TRUEevaluated 158 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 8533250 times by 1 test
Evaluated by:
  • Self test
(word->flags &...010|0x000040))Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 155 times by 1 test
Evaluated by:
  • Self test
3-9788389
10184 continue;
executed 3 times by 1 test: continue;
Executed by:
  • Self test
3
10185-
10186 /* If we have a quoted null expansion, add a quoted NULL to istring. */-
10187 if (temp == 0)
temp == 0Description
TRUEevaluated 8533405 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9788389 times by 1 test
Evaluated by:
  • Self test
8533405-9788389
10188 {-
10189 c = CTLNUL;-
10190 sindex--; /* add_character: label increments sindex */-
10191 goto add_character;
executed 8533405 times by 1 test: goto add_character;
Executed by:
  • Self test
8533405
10192 }-
10193 else-
10194 goto add_quoted_string;
executed 9788389 times by 1 test: goto add_quoted_string;
Executed by:
  • Self test
9788389
10195-
10196 /* break; */-
10197-
10198 default:
executed 241254219 times by 1 test: default:
Executed by:
  • Self test
241254219
10199 /* This is the fix for " $@ " */-
10200 add_ifs_character:-
10201 if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) || (isexp == 0 && isifs (c) && (word->flags & (W_NOSPLIT|W_NOSPLIT2)) == 0))
(quoted & (0x002|0x001))Description
TRUEevaluated 43728084 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 197526149 times by 1 test
Evaluated by:
  • Self test
isexp == 0Description
TRUEevaluated 197518215 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 7934 times by 1 test
Evaluated by:
  • Self test
(ifs_cmap[(uns...har)(c)] != 0)Description
TRUEevaluated 333100 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 197185115 times by 1 test
Evaluated by:
  • Self test
(word->flags &...x000040)) == 0Description
TRUEevaluated 67 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 333033 times by 1 test
Evaluated by:
  • Self test
67-197526149
10202 {-
10203 if ((quoted&(Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) == 0)
(quoted&(0x002|0x001)) == 0Description
TRUEevaluated 67 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 43728084 times by 1 test
Evaluated by:
  • Self test
67-43728084
10204 has_quoted_ifs++;
executed 67 times by 1 test: has_quoted_ifs++;
Executed by:
  • Self test
67
10205 if (string[sindex]) /* from old goto dollar_add_string */
string[sindex]Description
TRUEevaluated 43728151 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-43728151
10206 sindex++;
executed 43728151 times by 1 test: sindex++;
Executed by:
  • Self test
43728151
10207 if (c == 0)
c == 0Description
TRUEnever evaluated
FALSEevaluated 43728151 times by 1 test
Evaluated by:
  • Self test
0-43728151
10208 {-
10209 c = CTLNUL;-
10210 goto add_character;
never executed: goto add_character;
0
10211 }-
10212 else-
10213 {-
10214#if HANDLE_MULTIBYTE-
10215 /* XXX - should make sure that c is actually multibyte,-
10216 otherwise we can use the twochars branch */-
10217 if (mb_cur_max > 1)
mb_cur_max > 1Description
TRUEevaluated 43722662 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5489 times by 1 test
Evaluated by:
  • Self test
5489-43722662
10218 sindex--;
executed 43722662 times by 1 test: sindex--;
Executed by:
  • Self test
43722662
10219-
10220 if (mb_cur_max > 1)
mb_cur_max > 1Description
TRUEevaluated 43722662 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5489 times by 1 test
Evaluated by:
  • Self test
5489-43722662
10221 {-
10222 SADD_MBQCHAR_BODY(temp, string, sindex, string_size);
executed 43721958 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 704 times by 1 test: end of block
Executed by:
  • Self test
never executed: end of block
never executed: mblength = 1;
executed 43722662 times by 1 test: (temp)[i+1] = (string)[(sindex)++];
Executed by:
  • Self test
executed 43722662 times by 1 test: goto add_string;
Executed by:
  • Self test
mblength < 1Description
TRUEnever evaluated
FALSEevaluated 43722662 times by 1 test
Evaluated by:
  • Self test
iDescription
TRUEevaluated 43721958 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 704 times by 1 test
Evaluated by:
  • Self test
i < mblengthDescription
TRUEevaluated 43722662 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 43722662 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 43722662 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 43722662 times by 1 test
Evaluated by:
  • Self test
0-43722662
10223 }-
10224 else-
10225#endif-
10226 {-
10227 twochars[0] = CTLESC;-
10228 twochars[1] = c;-
10229 goto add_twochars;
executed 5489 times by 1 test: goto add_twochars;
Executed by:
  • Self test
5489
10230 }-
10231 }-
10232 }-
10233-
10234 SADD_MBCHAR (temp, string, sindex, string_size);
executed 196674069 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 98 times by 1 test: end of block
Executed by:
  • Self test
never executed: end of block
never executed: mblength = 1;
executed 196674168 times by 1 test: (temp)[i] = (string)[(sindex)++];
Executed by:
  • Self test
executed 196674167 times by 1 test: goto add_string;
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 196674167 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 851915 times by 1 test
Evaluated by:
  • Self test
mblength < 1Description
TRUEnever evaluated
FALSEevaluated 196674167 times by 1 test
Evaluated by:
  • Self test
iDescription
TRUEevaluated 196674069 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 98 times by 1 test
Evaluated by:
  • Self test
i < mblengthDescription
TRUEevaluated 196674168 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 196674167 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 196674167 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 196674167 times by 1 test
Evaluated by:
  • Self test
0-196674168
10235-
10236 add_character:
code before this statement executed 851915 times by 1 test: add_character:
Executed by:
  • Self test
851915
10237 RESIZE_MALLOCED_BUFFER (istring, istring_index, 1, istring_size,
executed 1 time by 1 test: istring_size += (128);
Executed by:
  • Self test
executed 1 time by 1 test: end of block
Executed by:
  • Self test
(istring_index...= istring_sizeDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 28477226 times by 1 test
Evaluated by:
  • Self test
(istring_index...= istring_sizeDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-28477226
10238 DEFAULT_ARRAY_SIZE);-
10239 istring[istring_index++] = c;-
10240 istring[istring_index] = '\0';-
10241-
10242 /* Next character. */-
10243 sindex++;-
10244 }
executed 28477227 times by 1 test: end of block
Executed by:
  • Self test
28477227
10245 }-
10246-
10247finished_with_string:
code before this statement never executed: finished_with_string:
0
10248 /* OK, we're ready to return. If we have a quoted string, and-
10249 quoted_dollar_at is not set, we do no splitting at all; otherwise-
10250 we split on ' '. The routines that call this will handle what to-
10251 do if nothing has been expanded. */-
10252-
10253 /* Partially and wholly quoted strings which expand to the empty-
10254 string are retained as an empty arguments. Unquoted strings-
10255 which expand to the empty string are discarded. The single-
10256 exception is the case of expanding "$@" when there are no-
10257 positional parameters. In that case, we discard the expansion. */-
10258-
10259 /* Because of how the code that handles "" and '' in partially-
10260 quoted strings works, we need to make ISTRING into a QUOTED_NULL-
10261 if we saw quoting characters, but the expansion was empty.-
10262 "" and '' are tossed away before we get to this point when-
10263 processing partially quoted strings. This makes "" and $xxx""-
10264 equivalent when xxx is unset. We also look to see whether we-
10265 saw a quoted null from a ${} expansion and add one back if we-
10266 need to. */-
10267-
10268 /* If we expand to nothing and there were no single or double quotes-
10269 in the word, we throw it away. Otherwise, we return a NULL word.-
10270 The single exception is for $@ surrounded by double quotes when-
10271 there are no positional parameters. In that case, we also throw-
10272 the word away. */-
10273-
10274 if (*istring == '\0')
*istring == '\0'Description
TRUEevaluated 3389342 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 202757679 times by 1 test
Evaluated by:
  • Self test
3389342-202757679
10275 {-
10276 if (quoted_dollar_at == 0 && (had_quoted_null || quoted_state == PARTIALLY_QUOTED))
quoted_dollar_at == 0Description
TRUEevaluated 3389009 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 333 times by 1 test
Evaluated by:
  • Self test
had_quoted_nullDescription
TRUEevaluated 107 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3388902 times by 1 test
Evaluated by:
  • Self test
quoted_state == 1Description
TRUEnever evaluated
FALSEevaluated 3388902 times by 1 test
Evaluated by:
  • Self test
0-3389009
10277 {-
10278 istring[0] = CTLNUL;-
10279 istring[1] = '\0';-
10280 tword = alloc_word_desc ();-
10281 tword->word = istring;-
10282 istring = 0; /* avoid later free() */-
10283 tword->flags |= W_HASQUOTEDNULL; /* XXX */-
10284 list = make_word_list (tword, (WORD_LIST *)NULL);-
10285 if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
quoted & (0x002|0x001)Description
TRUEevaluated 106 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-106
10286 tword->flags |= W_QUOTED;
executed 106 times by 1 test: tword->flags |= 0x000002;
Executed by:
  • Self test
106
10287 }
executed 107 times by 1 test: end of block
Executed by:
  • Self test
107
10288 /* According to sh, ksh, and Posix.2, if a word expands into nothing-
10289 and a double-quoted "$@" appears anywhere in it, then the entire-
10290 word is removed. */-
10291 /* XXX - exception appears to be that quoted null strings result in-
10292 null arguments */-
10293 else if (quoted_state == UNQUOTED || quoted_dollar_at)
quoted_state == 0Description
TRUEevaluated 3389112 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 123 times by 1 test
Evaluated by:
  • Self test
quoted_dollar_atDescription
TRUEevaluated 123 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3389112
10294 list = (WORD_LIST *)NULL;
executed 3389235 times by 1 test: list = (WORD_LIST *) ((void *)0) ;
Executed by:
  • Self test
3389235
10295 else-
10296 list = (WORD_LIST *)NULL;
never executed: list = (WORD_LIST *) ((void *)0) ;
0
10297 }-
10298 else if (word->flags & W_NOSPLIT)
word->flags & 0x000010Description
TRUEevaluated 6563243 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 196194436 times by 1 test
Evaluated by:
  • Self test
6563243-196194436
10299 {-
10300 tword = alloc_word_desc ();-
10301 tword->word = istring;-
10302 if (had_quoted_null && QUOTED_NULL (istring))
had_quoted_nullDescription
TRUEevaluated 19 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6563224 times by 1 test
Evaluated by:
  • Self test
(istring)[0] == '\177'Description
TRUEnever evaluated
FALSEevaluated 19 times by 1 test
Evaluated by:
  • Self test
(istring)[1] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0-6563224
10303 tword->flags |= W_HASQUOTEDNULL;
never executed: tword->flags |= 0x040000;
0
10304 istring = 0; /* avoid later free() */-
10305 if (word->flags & W_ASSIGNMENT)
word->flags & 0x000004Description
TRUEevaluated 3067 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6560176 times by 1 test
Evaluated by:
  • Self test
3067-6560176
10306 tword->flags |= W_ASSIGNMENT; /* XXX */
executed 3067 times by 1 test: tword->flags |= 0x000004;
Executed by:
  • Self test
3067
10307 if (word->flags & W_COMPASSIGN)
word->flags & 0x008000Description
TRUEnever evaluated
FALSEevaluated 6563243 times by 1 test
Evaluated by:
  • Self test
0-6563243
10308 tword->flags |= W_COMPASSIGN; /* XXX */
never executed: tword->flags |= 0x008000;
0
10309 if (word->flags & W_NOGLOB)
word->flags & 0x000020Description
TRUEevaluated 6558405 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4838 times by 1 test
Evaluated by:
  • Self test
4838-6558405
10310 tword->flags |= W_NOGLOB; /* XXX */
executed 6558405 times by 1 test: tword->flags |= 0x000020;
Executed by:
  • Self test
6558405
10311 if (word->flags & W_NOBRACE)
word->flags & 0x4000000Description
TRUEnever evaluated
FALSEevaluated 6563243 times by 1 test
Evaluated by:
  • Self test
0-6563243
10312 tword->flags |= W_NOBRACE; /* XXX */
never executed: tword->flags |= 0x4000000;
0
10313 if (word->flags & W_NOEXPAND)
word->flags & 0x004000Description
TRUEnever evaluated
FALSEevaluated 6563243 times by 1 test
Evaluated by:
  • Self test
0-6563243
10314 tword->flags |= W_NOEXPAND; /* XXX */
never executed: tword->flags |= 0x004000;
0
10315 if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
quoted & (0x002|0x001)Description
TRUEnever evaluated
FALSEevaluated 6563243 times by 1 test
Evaluated by:
  • Self test
0-6563243
10316 tword->flags |= W_QUOTED;
never executed: tword->flags |= 0x000002;
0
10317 list = make_word_list (tword, (WORD_LIST *)NULL);-
10318 }
executed 6563243 times by 1 test: end of block
Executed by:
  • Self test
6563243
10319 else-
10320 {-
10321 char *ifs_chars;-
10322-
10323 ifs_chars = (quoted_dollar_at || has_dollar_at) ? ifs_value : (char *)NULL;
quoted_dollar_atDescription
TRUEevaluated 5044 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 196189392 times by 1 test
Evaluated by:
  • Self test
has_dollar_atDescription
TRUEevaluated 3452 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 196185940 times by 1 test
Evaluated by:
  • Self test
3452-196189392
10324-
10325 /* If we have $@, we need to split the results no matter what. If-
10326 IFS is unset or NULL, string_list_dollar_at has separated the-
10327 positional parameters with a space, so we split on space (we have-
10328 set ifs_chars to " \t\n" above if ifs is unset). If IFS is set,-
10329 string_list_dollar_at has separated the positional parameters-
10330 with the first character of $IFS, so we split on $IFS. If-
10331 SPLIT_ON_SPACES is set, we expanded $* (unquoted) with IFS either-
10332 unset or null, and we want to make sure that we split on spaces-
10333 regardless of what else has happened to IFS since the expansion,-
10334 or we expanded "$@" with IFS null and we need to split the positional-
10335 parameters into separate words. */-
10336 if (split_on_spaces)
split_on_spacesDescription
TRUEevaluated 413 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 196194023 times by 1 test
Evaluated by:
  • Self test
413-196194023
10337 {-
10338 /* If IFS is not set, and the word is not quoted, we want to split-
10339 the individual words on $' \t\n'. We rely on previous steps to-
10340 quote the portions of the word that should not be split */-
10341 if (ifs_is_set == 0)
ifs_is_set == 0Description
TRUEevaluated 351 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 62 times by 1 test
Evaluated by:
  • Self test
62-351
10342 list = list_string (istring, " \t\n", 1); /* XXX quoted == 1? */
executed 351 times by 1 test: list = list_string (istring, " \t\n", 1);
Executed by:
  • Self test
351
10343 else-
10344 list = list_string (istring, " ", 1); /* XXX quoted == 1? */
executed 62 times by 1 test: list = list_string (istring, " ", 1);
Executed by:
  • Self test
62
10345 }-
10346-
10347 /* If we have $@ (has_dollar_at != 0) and we are in a context where we-
10348 don't want to split the result (W_NOSPLIT2), and we are not quoted,-
10349 we have already separated the arguments with the first character of-
10350 $IFS. In this case, we want to return a list with a single word-
10351 with the separator possibly replaced with a space (it's what other-
10352 shells seem to do).-
10353 quoted_dollar_at is internal to this function and is set if we are-
10354 passed an argument that is unquoted (quoted == 0) but we encounter a-
10355 double-quoted $@ while expanding it. */-
10356 else if (has_dollar_at && quoted_dollar_at == 0 && ifs_chars && quoted == 0 && (word->flags & W_NOSPLIT2))
has_dollar_atDescription
TRUEevaluated 8453 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 196185570 times by 1 test
Evaluated by:
  • Self test
quoted_dollar_at == 0Description
TRUEevaluated 3431 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5022 times by 1 test
Evaluated by:
  • Self test
ifs_charsDescription
TRUEevaluated 3431 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
quoted == 0Description
TRUEevaluated 3431 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
(word->flags & 0x000040)Description
TRUEevaluated 836 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2595 times by 1 test
Evaluated by:
  • Self test
0-196185570
10357 {-
10358 tword = alloc_word_desc ();-
10359 /* Only split and rejoin if we have to */-
10360 if (*ifs_chars && *ifs_chars != ' ')
*ifs_charsDescription
TRUEevaluated 567 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 269 times by 1 test
Evaluated by:
  • Self test
*ifs_chars != ' 'Description
TRUEevaluated 191 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 376 times by 1 test
Evaluated by:
  • Self test
191-567
10361 {-
10362 /* list_string dequotes CTLESCs in the string it's passed, so we-
10363 need it to get the space separation right if space isn't the-
10364 first character in IFS (but is present) and to remove the -
10365 quoting we added back in param_expand(). */-
10366 list = list_string (istring, *ifs_chars ? ifs_chars : " ", 1);-
10367 /* This isn't exactly right in the case where we're expanding-
10368 the RHS of an expansion like ${var-$@} where IFS=: (for-
10369 example). The W_NOSPLIT2 means we do the separation with :;-
10370 the list_string removes the quotes and breaks the string into-
10371 a list, and the string_list rejoins it on spaces. When we-
10372 return, we expect to be able to split the results, but the-
10373 space separation means the right split doesn't happen. */-
10374 tword->word = string_list (list); -
10375 }
executed 191 times by 1 test: end of block
Executed by:
  • Self test
191
10376 else-
10377 tword->word = istring;
executed 645 times by 1 test: tword->word = istring;
Executed by:
  • Self test
645
10378 if (had_quoted_null && QUOTED_NULL (istring))
had_quoted_nullDescription
TRUEnever evaluated
FALSEevaluated 836 times by 1 test
Evaluated by:
  • Self test
(istring)[0] == '\177'Description
TRUEnever evaluated
FALSEnever evaluated
(istring)[1] == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
0-836
10379 tword->flags |= W_HASQUOTEDNULL; /* XXX */
never executed: tword->flags |= 0x040000;
0
10380 if (tword->word != istring)
tword->word != istringDescription
TRUEevaluated 191 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 645 times by 1 test
Evaluated by:
  • Self test
191-645
10381 free (istring);
executed 191 times by 1 test: sh_xfree((istring), "subst.c", 10381);
Executed by:
  • Self test
191
10382 istring = 0; /* avoid later free() */-
10383 goto set_word_flags;
executed 836 times by 1 test: goto set_word_flags;
Executed by:
  • Self test
836
10384 }-
10385 else if (has_dollar_at && ifs_chars)
has_dollar_atDescription
TRUEevaluated 7617 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 196185570 times by 1 test
Evaluated by:
  • Self test
ifs_charsDescription
TRUEevaluated 7617 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-196185570
10386 list = list_string (istring, *ifs_chars ? ifs_chars : " ", 1);
executed 7617 times by 1 test: list = list_string (istring, *ifs_chars ? ifs_chars : " ", 1);
Executed by:
  • Self test
7617
10387 else-
10388 {-
10389 tword = alloc_word_desc ();-
10390 if (expanded_something && *expanded_something == 0 && has_quoted_ifs)
expanded_somethingDescription
TRUEevaluated 57070722 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 139114848 times by 1 test
Evaluated by:
  • Self test
*expanded_something == 0Description
TRUEevaluated 53800088 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3270634 times by 1 test
Evaluated by:
  • Self test
has_quoted_ifsDescription
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 53800073 times by 1 test
Evaluated by:
  • Self test
15-139114848
10391 tword->word = remove_quoted_ifs (istring);
executed 15 times by 1 test: tword->word = remove_quoted_ifs (istring);
Executed by:
  • Self test
15
10392 else-
10393 tword->word = istring;
executed 196185555 times by 1 test: tword->word = istring;
Executed by:
  • Self test
196185555
10394 if (had_quoted_null && QUOTED_NULL (istring))
had_quoted_nullDescription
TRUEevaluated 3872 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 196181698 times by 1 test
Evaluated by:
  • Self test
(istring)[0] == '\177'Description
TRUEevaluated 3606 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 266 times by 1 test
Evaluated by:
  • Self test
(istring)[1] == '\0'Description
TRUEevaluated 3522 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 84 times by 1 test
Evaluated by:
  • Self test
84-196181698
10395 tword->flags |= W_HASQUOTEDNULL; /* XXX */
executed 3522 times by 1 test: tword->flags |= 0x040000;
Executed by:
  • Self test
3522
10396 if (tword->word != istring)
tword->word != istringDescription
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 196185555 times by 1 test
Evaluated by:
  • Self test
15-196185555
10397 free (istring);
executed 15 times by 1 test: sh_xfree((istring), "subst.c", 10397);
Executed by:
  • Self test
15
10398 istring = 0; /* avoid later free() */-
10399set_word_flags:
code before this statement executed 196185570 times by 1 test: set_word_flags:
Executed by:
  • Self test
196185570
10400 if ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) || (quoted_state == WHOLLY_QUOTED))
(quoted & (0x001|0x002))Description
TRUEevaluated 26473760 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 169712646 times by 1 test
Evaluated by:
  • Self test
(quoted_state == 2)Description
TRUEevaluated 44780777 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 124931869 times by 1 test
Evaluated by:
  • Self test
26473760-169712646
10401 tword->flags |= W_QUOTED;
executed 71254537 times by 1 test: tword->flags |= 0x000002;
Executed by:
  • Self test
71254537
10402 if (word->flags & W_ASSIGNMENT)
word->flags & 0x000004Description
TRUEevaluated 4355 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 196182051 times by 1 test
Evaluated by:
  • Self test
4355-196182051
10403 tword->flags |= W_ASSIGNMENT;
executed 4355 times by 1 test: tword->flags |= 0x000004;
Executed by:
  • Self test
4355
10404 if (word->flags & W_COMPASSIGN)
word->flags & 0x008000Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 196186394 times by 1 test
Evaluated by:
  • Self test
12-196186394
10405 tword->flags |= W_COMPASSIGN;
executed 12 times by 1 test: tword->flags |= 0x008000;
Executed by:
  • Self test
12
10406 if (word->flags & W_NOGLOB)
word->flags & 0x000020Description
TRUEevaluated 75 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 196186331 times by 1 test
Evaluated by:
  • Self test
75-196186331
10407 tword->flags |= W_NOGLOB;
executed 75 times by 1 test: tword->flags |= 0x000020;
Executed by:
  • Self test
75
10408 if (word->flags & W_NOBRACE)
word->flags & 0x4000000Description
TRUEnever evaluated
FALSEevaluated 196186406 times by 1 test
Evaluated by:
  • Self test
0-196186406
10409 tword->flags |= W_NOBRACE;
never executed: tword->flags |= 0x4000000;
0
10410 if (word->flags & W_NOEXPAND)
word->flags & 0x004000Description
TRUEnever evaluated
FALSEevaluated 196186406 times by 1 test
Evaluated by:
  • Self test
0-196186406
10411 tword->flags |= W_NOEXPAND;
never executed: tword->flags |= 0x004000;
0
10412 list = make_word_list (tword, (WORD_LIST *)NULL);-
10413 }
executed 196186406 times by 1 test: end of block
Executed by:
  • Self test
196186406
10414 }-
10415-
10416 free (istring);-
10417 return (list);
executed 206147021 times by 1 test: return (list);
Executed by:
  • Self test
206147021
10418}-
10419-
10420/* **************************************************************** */-
10421/* */-
10422/* Functions for Quote Removal */-
10423/* */-
10424/* **************************************************************** */-
10425-
10426/* Perform quote removal on STRING. If QUOTED > 0, assume we are obeying the-
10427 backslash quoting rules for within double quotes or a here document. */-
10428char *-
10429string_quote_removal (string, quoted)-
10430 char *string;-
10431 int quoted;-
10432{-
10433 size_t slen;-
10434 char *r, *result_string, *temp, *send;-
10435 int sindex, tindex, dquote;-
10436 unsigned char c;-
10437 DECLARE_MBSTATE;-
10438-
10439 /* The result can be no longer than the original string. */-
10440 slen = strlen (string);-
10441 send = string + slen;-
10442-
10443 r = result_string = (char *)xmalloc (slen + 1);-
10444-
10445 for (dquote = sindex = 0; c = string[sindex];)
c = string[sindex]Description
TRUEevaluated 6612584 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6505701 times by 1 test
Evaluated by:
  • Self test
6505701-6612584
10446 {-
10447 switch (c)-
10448 {-
10449 case '\\':
executed 335 times by 1 test: case '\\':
Executed by:
  • Self test
335
10450 c = string[++sindex];-
10451 if (c == 0)
c == 0Description
TRUEnever evaluated
FALSEevaluated 335 times by 1 test
Evaluated by:
  • Self test
0-335
10452 {-
10453 *r++ = '\\';-
10454 break;
never executed: break;
0
10455 }-
10456 if (((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) || dquote) && (sh_syntaxtab[c] & CBSDQUOTE) == 0)
(quoted & (0x002|0x001))Description
TRUEnever evaluated
FALSEevaluated 335 times by 1 test
Evaluated by:
  • Self test
dquoteDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 329 times by 1 test
Evaluated by:
  • Self test
(sh_syntaxtab[...& 0x0040) == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test
0-335
10457 *r++ = '\\';
executed 1 time by 1 test: *r++ = '\\';
Executed by:
  • Self test
1
10458 /* FALLTHROUGH */-
10459-
10460 default:
code before this statement executed 335 times by 1 test: default:
Executed by:
  • Self test
executed 107919 times by 1 test: default:
Executed by:
  • Self test
335-107919
10461 SCOPY_CHAR_M (r, string, send, sindex);
executed 107926 times by 1 test: mblength = 1;
Executed by:
  • Self test
executed 6 times by 1 test: end of block
Executed by:
  • Self test
never executed: end of block
executed 107932 times by 1 test: mblength = (mblength < 1) ? 1 : mblength;
Executed by:
  • Self test
executed 107932 times by 1 test: end of block
Executed by:
  • Self test
executed 322 times by 1 test: end of block
Executed by:
  • Self test
locale_mb_cur_max > 1Description
TRUEevaluated 107932 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 322 times by 1 test
Evaluated by:
  • Self test
_iDescription
TRUEevaluated 107926 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
(mblength < 1)Description
TRUEnever evaluated
FALSEevaluated 107932 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 107932 times by 1 test
Evaluated by:
  • Self test
mblength == (size_t)-1Description
TRUEnever evaluated
FALSEevaluated 107932 times by 1 test
Evaluated by:
  • Self test
0-107932
10462 break;
executed 108254 times by 1 test: break;
Executed by:
  • Self test
108254
10463-
10464 case '\'':
executed 6503422 times by 1 test: case '\'':
Executed by:
  • Self test
6503422
10465 if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) || dquote)
(quoted & (0x002|0x001))Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6503418 times by 1 test
Evaluated by:
  • Self test
dquoteDescription
TRUEevaluated 60 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6503358 times by 1 test
Evaluated by:
  • Self test
4-6503418
10466 {-
10467 *r++ = c;-
10468 sindex++;-
10469 break;
executed 64 times by 1 test: break;
Executed by:
  • Self test
64
10470 }-
10471 tindex = sindex + 1;-
10472 temp = string_extract_single_quoted (string, &tindex);-
10473 if (temp)
tempDescription
TRUEevaluated 6503358 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-6503358
10474 {-
10475 strcpy (r, temp);-
10476 r += strlen (r);-
10477 free (temp);-
10478 }
executed 6503358 times by 1 test: end of block
Executed by:
  • Self test
6503358
10479 sindex = tindex;-
10480 break;
executed 6503358 times by 1 test: break;
Executed by:
  • Self test
6503358
10481-
10482 case '"':
executed 908 times by 1 test: case '"':
Executed by:
  • Self test
908
10483 dquote = 1 - dquote;-
10484 sindex++;-
10485 break;
executed 908 times by 1 test: break;
Executed by:
  • Self test
908
10486 }-
10487 }-
10488 *r = '\0';-
10489 return (result_string);
executed 6505701 times by 1 test: return (result_string);
Executed by:
  • Self test
6505701
10490}-
10491-
10492#if 0-
10493/* UNUSED */-
10494/* Perform quote removal on word WORD. This allocates and returns a new-
10495 WORD_DESC *. */-
10496WORD_DESC *-
10497word_quote_removal (word, quoted)-
10498 WORD_DESC *word;-
10499 int quoted;-
10500{-
10501 WORD_DESC *w;-
10502 char *t;-
10503-
10504 t = string_quote_removal (word->word, quoted);-
10505 w = alloc_word_desc ();-
10506 w->word = t ? t : savestring ("");-
10507 return (w);-
10508}-
10509-
10510/* Perform quote removal on all words in LIST. If QUOTED is non-zero,-
10511 the members of the list are treated as if they are surrounded by-
10512 double quotes. Return a new list, or NULL if LIST is NULL. */-
10513WORD_LIST *-
10514word_list_quote_removal (list, quoted)-
10515 WORD_LIST *list;-
10516 int quoted;-
10517{-
10518 WORD_LIST *result, *t, *tresult, *e;-
10519-
10520 for (t = list, result = (WORD_LIST *)NULL; t; t = t->next)-
10521 {-
10522 tresult = make_word_list (word_quote_removal (t->word, quoted), (WORD_LIST *)NULL);-
10523#if 0-
10524 result = (WORD_LIST *) list_append (result, tresult);-
10525#else-
10526 if (result == 0)-
10527 result = e = tresult;-
10528 else-
10529 {-
10530 e->next = tresult;-
10531 while (e->next)-
10532 e = e->next;-
10533 }-
10534#endif-
10535 }-
10536 return (result);-
10537}-
10538#endif-
10539-
10540/*******************************************-
10541 * *-
10542 * Functions to perform word splitting *-
10543 * *-
10544 *******************************************/-
10545-
10546void-
10547setifs (v)-
10548 SHELL_VAR *v;-
10549{-
10550 char *t;-
10551 unsigned char uc;-
10552-
10553 ifs_var = v;-
10554 ifs_value = (v && value_cell (v)) ? value_cell (v) : " \t\n";
vDescription
TRUEevaluated 9452090 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2387 times by 1 test
Evaluated by:
  • Self test
((v)->value)Description
TRUEevaluated 9452086 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test
4-9452090
10555-
10556 ifs_is_set = ifs_var != 0;-
10557 ifs_is_null = ifs_is_set && (*ifs_value == 0);
ifs_is_setDescription
TRUEevaluated 9452090 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 2387 times by 1 test
Evaluated by:
  • Self test
(*ifs_value == 0)Description
TRUEevaluated 1921 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9450169 times by 1 test
Evaluated by:
  • Self test
1921-9452090
10558-
10559 /* Should really merge ifs_cmap with sh_syntaxtab. XXX - doesn't yet-
10560 handle multibyte chars in IFS */-
10561 memset (ifs_cmap, '\0', sizeof (ifs_cmap));-
10562 for (t = ifs_value ; t && *t; t++)
tDescription
TRUEevaluated 24857932 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
*tDescription
TRUEevaluated 15403455 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9454477 times by 1 test
Evaluated by:
  • Self test
0-24857932
10563 {-
10564 uc = *t;-
10565 ifs_cmap[uc] = 1;-
10566 }
executed 15403455 times by 1 test: end of block
Executed by:
  • Self test
15403455
10567-
10568#if defined (HANDLE_MULTIBYTE)-
10569 if (ifs_value == 0)
ifs_value == 0Description
TRUEnever evaluated
FALSEevaluated 9454477 times by 1 test
Evaluated by:
  • Self test
0-9454477
10570 {-
10571 ifs_firstc[0] = '\0'; /* XXX - ? */-
10572 ifs_firstc_len = 1;-
10573 }
never executed: end of block
0
10574 else-
10575 {-
10576 size_t ifs_len;-
10577 ifs_len = strnlen (ifs_value, MB_CUR_MAX);-
10578 ifs_firstc_len = MBLEN (ifs_value, ifs_len);
( (__ctype_get...r_max ()) > 1)Description
TRUEevaluated 9400337 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 54140 times by 1 test
Evaluated by:
  • Self test
54140-9400337
10579 if (ifs_firstc_len == 1 || ifs_firstc_len == 0 || MB_INVALIDCH (ifs_firstc_len))
ifs_firstc_len == 1Description
TRUEevaluated 9452544 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1933 times by 1 test
Evaluated by:
  • Self test
ifs_firstc_len == 0Description
TRUEevaluated 1921 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test
(ifs_firstc_len) == (size_t)-1Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
(ifs_firstc_len) == (size_t)-2Description
TRUEnever evaluated
FALSEevaluated 9 times by 1 test
Evaluated by:
  • Self test
0-9452544
10580 {-
10581 ifs_firstc[0] = ifs_value[0];-
10582 ifs_firstc[1] = '\0';-
10583 ifs_firstc_len = 1;-
10584 }
executed 9454468 times by 1 test: end of block
Executed by:
  • Self test
9454468
10585 else-
10586 memcpy (ifs_firstc, ifs_value, ifs_firstc_len);
executed 9 times by 1 test: memcpy (ifs_firstc, ifs_value, ifs_firstc_len);
Executed by:
  • Self test
9
10587 }-
10588#else-
10589 ifs_firstc = ifs_value ? *ifs_value : 0;-
10590#endif-
10591}-
10592-
10593char *-
10594getifs ()-
10595{-
10596 return ifs_value;
executed 1322793 times by 1 test: return ifs_value;
Executed by:
  • Self test
1322793
10597}-
10598-
10599/* This splits a single word into a WORD LIST on $IFS, but only if the word-
10600 is not quoted. list_string () performs quote removal for us, even if we-
10601 don't do any splitting. */-
10602WORD_LIST *-
10603word_split (w, ifs_chars)-
10604 WORD_DESC *w;-
10605 char *ifs_chars;-
10606{-
10607 WORD_LIST *result;-
10608-
10609 if (w)
wDescription
TRUEevaluated 3286479 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-3286479
10610 {-
10611 char *xifs;-
10612-
10613 xifs = ((w->flags & W_QUOTED) || ifs_chars == 0) ? "" : ifs_chars;
(w->flags & 0x000002)Description
TRUEevaluated 15844 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3270635 times by 1 test
Evaluated by:
  • Self test
ifs_chars == 0Description
TRUEnever evaluated
FALSEevaluated 3270635 times by 1 test
Evaluated by:
  • Self test
0-3270635
10614 result = list_string (w->word, xifs, w->flags & W_QUOTED);-
10615 }
executed 3286479 times by 1 test: end of block
Executed by:
  • Self test
3286479
10616 else-
10617 result = (WORD_LIST *)NULL;
never executed: result = (WORD_LIST *) ((void *)0) ;
0
10618-
10619 return (result);
executed 3286479 times by 1 test: return (result);
Executed by:
  • Self test
3286479
10620}-
10621-
10622/* Perform word splitting on LIST and return the RESULT. It is possible-
10623 to return (WORD_LIST *)NULL. */-
10624static WORD_LIST *-
10625word_list_split (list)-
10626 WORD_LIST *list;-
10627{-
10628 WORD_LIST *result, *t, *tresult, *e;-
10629-
10630 for (t = list, result = (WORD_LIST *)NULL; t; t = t->next)
tDescription
TRUEevaluated 3286479 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3286444 times by 1 test
Evaluated by:
  • Self test
3286444-3286479
10631 {-
10632 tresult = word_split (t->word, ifs_value);-
10633 if (result == 0)
result == 0Description
TRUEevaluated 3281153 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5326 times by 1 test
Evaluated by:
  • Self test
5326-3281153
10634 result = e = tresult;
executed 3281153 times by 1 test: result = e = tresult;
Executed by:
  • Self test
3281153
10635 else-
10636 {-
10637 e->next = tresult;-
10638 while (e->next)
e->nextDescription
TRUEevaluated 5326 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 5326 times by 1 test
Evaluated by:
  • Self test
5326
10639 e = e->next;
executed 5326 times by 1 test: e = e->next;
Executed by:
  • Self test
5326
10640 }
executed 5326 times by 1 test: end of block
Executed by:
  • Self test
5326
10641 }-
10642 return (result);
executed 3286444 times by 1 test: return (result);
Executed by:
  • Self test
3286444
10643}-
10644-
10645/**************************************************-
10646 * *-
10647 * Functions to expand an entire WORD_LIST *-
10648 * *-
10649 **************************************************/-
10650-
10651/* Do any word-expansion-specific cleanup and jump to top_level */-
10652static void-
10653exp_jump_to_top_level (v)-
10654 int v;-
10655{-
10656 set_pipestatus_from_exit (last_command_exit_value);-
10657-
10658 /* Cleanup code goes here. */-
10659 expand_no_split_dollar_star = 0; /* XXX */-
10660 if (expanding_redir)
expanding_redirDescription
TRUEnever evaluated
FALSEevaluated 393 times by 1 test
Evaluated by:
  • Self test
0-393
10661 undo_partial_redirects ();
never executed: undo_partial_redirects ();
0
10662 expanding_redir = 0;-
10663 assigning_in_environment = 0;-
10664-
10665 if (parse_and_execute_level == 0)
parse_and_execute_level == 0Description
TRUEevaluated 348 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 45 times by 1 test
Evaluated by:
  • Self test
45-348
10666 top_level_cleanup (); /* from sig.c */
executed 348 times by 1 test: top_level_cleanup ();
Executed by:
  • Self test
348
10667-
10668 jump_to_top_level (v);-
10669}
never executed: end of block
0
10670-
10671/* Put NLIST (which is a WORD_LIST * of only one element) at the front of-
10672 ELIST, and set ELIST to the new list. */-
10673#define PREPEND_LIST(nlist, elist) \-
10674 do { nlist->next = elist; elist = nlist; } while (0)-
10675-
10676/* Separate out any initial variable assignments from TLIST. If set -k has-
10677 been executed, remove all assignment statements from TLIST. Initial-
10678 variable assignments and other environment assignments are placed-
10679 on SUBST_ASSIGN_VARLIST. */-
10680static WORD_LIST *-
10681separate_out_assignments (tlist)-
10682 WORD_LIST *tlist;-
10683{-
10684 register WORD_LIST *vp, *lp;-
10685-
10686 if (tlist == 0)
tlist == 0Description
TRUEnever evaluated
FALSEevaluated 64686671 times by 1 test
Evaluated by:
  • Self test
0-64686671
10687 return ((WORD_LIST *)NULL);
never executed: return ((WORD_LIST *) ((void *)0) );
0
10688-
10689 if (subst_assign_varlist)
subst_assign_varlistDescription
TRUEevaluated 2538 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 64684133 times by 1 test
Evaluated by:
  • Self test
2538-64684133
10690 dispose_words (subst_assign_varlist); /* Clean up after previous error */
executed 2538 times by 1 test: dispose_words (subst_assign_varlist);
Executed by:
  • Self test
2538
10691-
10692 subst_assign_varlist = (WORD_LIST *)NULL;-
10693 vp = lp = tlist;-
10694-
10695 /* Separate out variable assignments at the start of the command.-
10696 Loop invariant: vp->next == lp-
10697 Loop postcondition:-
10698 lp = list of words left after assignment statements skipped-
10699 tlist = original list of words-
10700 */-
10701 while (lp && (lp->word->flags & W_ASSIGNMENT))
lpDescription
TRUEevaluated 71149194 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 29963585 times by 1 test
Evaluated by:
  • Self test
(lp->word->flags & 0x000004)Description
TRUEevaluated 36426108 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 34723086 times by 1 test
Evaluated by:
  • Self test
29963585-71149194
10702 {-
10703 vp = lp;-
10704 lp = lp->next;-
10705 }
executed 36426108 times by 1 test: end of block
Executed by:
  • Self test
36426108
10706-
10707 /* If lp != tlist, we have some initial assignment statements.-
10708 We make SUBST_ASSIGN_VARLIST point to the list of assignment-
10709 words and TLIST point to the remaining words. */-
10710 if (lp != tlist)
lp != tlistDescription
TRUEevaluated 29965369 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 34721302 times by 1 test
Evaluated by:
  • Self test
29965369-34721302
10711 {-
10712 subst_assign_varlist = tlist;-
10713 /* ASSERT(vp->next == lp); */-
10714 vp->next = (WORD_LIST *)NULL; /* terminate variable list */-
10715 tlist = lp; /* remainder of word list */-
10716 }
executed 29965369 times by 1 test: end of block
Executed by:
  • Self test
29965369
10717-
10718 /* vp == end of variable list */-
10719 /* tlist == remainder of original word list without variable assignments */-
10720 if (!tlist)
!tlistDescription
TRUEevaluated 29963585 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 34723086 times by 1 test
Evaluated by:
  • Self test
29963585-34723086
10721 /* All the words in tlist were assignment statements */-
10722 return ((WORD_LIST *)NULL);
executed 29963585 times by 1 test: return ((WORD_LIST *) ((void *)0) );
Executed by:
  • Self test
29963585
10723-
10724 /* ASSERT(tlist != NULL); */-
10725 /* ASSERT((tlist->word->flags & W_ASSIGNMENT) == 0); */-
10726-
10727 /* If the -k option is in effect, we need to go through the remaining-
10728 words, separate out the assignment words, and place them on-
10729 SUBST_ASSIGN_VARLIST. */-
10730 if (place_keywords_in_env)
place_keywords_in_envDescription
TRUEevaluated 69 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 34723017 times by 1 test
Evaluated by:
  • Self test
69-34723017
10731 {-
10732 WORD_LIST *tp; /* tp == running pointer into tlist */-
10733-
10734 tp = tlist;-
10735 lp = tlist->next;-
10736-
10737 /* Loop Invariant: tp->next == lp */-
10738 /* Loop postcondition: tlist == word list without assignment statements */-
10739 while (lp)
lpDescription
TRUEevaluated 150 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 69 times by 1 test
Evaluated by:
  • Self test
69-150
10740 {-
10741 if (lp->word->flags & W_ASSIGNMENT)
lp->word->flags & 0x000004Description
TRUEevaluated 27 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 123 times by 1 test
Evaluated by:
  • Self test
27-123
10742 {-
10743 /* Found an assignment statement, add this word to end of-
10744 subst_assign_varlist (vp). */-
10745 if (!subst_assign_varlist)
!subst_assign_varlistDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 24 times by 1 test
Evaluated by:
  • Self test
3-24
10746 subst_assign_varlist = vp = lp;
executed 3 times by 1 test: subst_assign_varlist = vp = lp;
Executed by:
  • Self test
3
10747 else-
10748 {-
10749 vp->next = lp;-
10750 vp = lp;-
10751 }
executed 24 times by 1 test: end of block
Executed by:
  • Self test
24
10752-
10753 /* Remove the word pointed to by LP from TLIST. */-
10754 tp->next = lp->next;-
10755 /* ASSERT(vp == lp); */-
10756 lp->next = (WORD_LIST *)NULL;-
10757 lp = tp->next;-
10758 }
executed 27 times by 1 test: end of block
Executed by:
  • Self test
27
10759 else-
10760 {-
10761 tp = lp;-
10762 lp = lp->next;-
10763 }
executed 123 times by 1 test: end of block
Executed by:
  • Self test
123
10764 }-
10765 }
executed 69 times by 1 test: end of block
Executed by:
  • Self test
69
10766 return (tlist);
executed 34723086 times by 1 test: return (tlist);
Executed by:
  • Self test
34723086
10767}-
10768-
10769#define WEXP_VARASSIGN 0x001-
10770#define WEXP_BRACEEXP 0x002-
10771#define WEXP_TILDEEXP 0x004-
10772#define WEXP_PARAMEXP 0x008-
10773#define WEXP_PATHEXP 0x010-
10774-
10775/* All of the expansions, including variable assignments at the start of-
10776 the list. */-
10777#define WEXP_ALL (WEXP_VARASSIGN|WEXP_BRACEEXP|WEXP_TILDEEXP|WEXP_PARAMEXP|WEXP_PATHEXP)-
10778-
10779/* All of the expansions except variable assignments at the start of-
10780 the list. */-
10781#define WEXP_NOVARS (WEXP_BRACEEXP|WEXP_TILDEEXP|WEXP_PARAMEXP|WEXP_PATHEXP)-
10782-
10783/* All of the `shell expansions': brace expansion, tilde expansion, parameter-
10784 expansion, command substitution, arithmetic expansion, word splitting, and-
10785 quote removal. */-
10786#define WEXP_SHELLEXP (WEXP_BRACEEXP|WEXP_TILDEEXP|WEXP_PARAMEXP)-
10787-
10788/* Take the list of words in LIST and do the various substitutions. Return-
10789 a new list of words which is the expanded list, and without things like-
10790 variable assignments. */-
10791-
10792WORD_LIST *-
10793expand_words (list)-
10794 WORD_LIST *list;-
10795{-
10796 return (expand_word_list_internal (list, WEXP_ALL));
executed 64686699 times by 1 test: return (expand_word_list_internal (list, (0x001|0x002|0x004|0x008|0x010)));
Executed by:
  • Self test
64686699
10797}-
10798-
10799/* Same as expand_words (), but doesn't hack variable or environment-
10800 variables. */-
10801WORD_LIST *-
10802expand_words_no_vars (list)-
10803 WORD_LIST *list;-
10804{-
10805 return (expand_word_list_internal (list, WEXP_NOVARS));
executed 9237996 times by 1 test: return (expand_word_list_internal (list, (0x002|0x004|0x008|0x010)));
Executed by:
  • Self test
9237996
10806}-
10807-
10808WORD_LIST *-
10809expand_words_shellexp (list)-
10810 WORD_LIST *list;-
10811{-
10812 return (expand_word_list_internal (list, WEXP_SHELLEXP));
never executed: return (expand_word_list_internal (list, (0x002|0x004|0x008)));
0
10813}-
10814-
10815static WORD_LIST *-
10816glob_expand_word_list (tlist, eflags)-
10817 WORD_LIST *tlist;-
10818 int eflags;-
10819{-
10820 char **glob_array, *temp_string;-
10821 register int glob_index;-
10822 WORD_LIST *glob_list, *output_list, *disposables, *next;-
10823 WORD_DESC *tword;-
10824-
10825 output_list = disposables = (WORD_LIST *)NULL;-
10826 glob_array = (char **)NULL;-
10827 while (tlist)
tlistDescription
TRUEevaluated 68961469 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 43929657 times by 1 test
Evaluated by:
  • Self test
43929657-68961469
10828 {-
10829 /* For each word, either globbing is attempted or the word is-
10830 added to orig_list. If globbing succeeds, the results are-
10831 added to orig_list and the word (tlist) is added to the list-
10832 of disposable words. If globbing fails and failed glob-
10833 expansions are left unchanged (the shell default), the-
10834 original word is added to orig_list. If globbing fails and-
10835 failed glob expansions are removed, the original word is-
10836 added to the list of disposable words. orig_list ends up-
10837 in reverse order and requires a call to REVERSE_LIST to-
10838 be set right. After all words are examined, the disposable-
10839 words are freed. */-
10840 next = tlist->next;-
10841-
10842 /* If the word isn't an assignment and contains an unquoted-
10843 pattern matching character, then glob it. */-
10844 if ((tlist->word->flags & W_NOGLOB) == 0 &&
(tlist->word->...0x000020) == 0Description
TRUEevaluated 62402989 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 6558480 times by 1 test
Evaluated by:
  • Self test
6558480-62402989
10845 unquoted_glob_pattern_p (tlist->word->word))
unquoted_glob_...t->word->word)Description
TRUEevaluated 805 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 62402184 times by 1 test
Evaluated by:
  • Self test
805-62402184
10846 {-
10847 glob_array = shell_glob_filename (tlist->word->word);-
10848-
10849 /* Handle error cases.-
10850 I don't think we should report errors like "No such file-
10851 or directory". However, I would like to report errors-
10852 like "Read failed". */-
10853-
10854 if (glob_array == 0 || GLOB_FAILED (glob_array))
glob_array == 0Description
TRUEnever evaluated
FALSEevaluated 805 times by 1 test
Evaluated by:
  • Self test
(glob_array) =...b_error_returnDescription
TRUEevaluated 695 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 110 times by 1 test
Evaluated by:
  • Self test
0-805
10855 {-
10856 glob_array = (char **)xmalloc (sizeof (char *));-
10857 glob_array[0] = (char *)NULL;-
10858 }
executed 695 times by 1 test: end of block
Executed by:
  • Self test
695
10859-
10860 /* Dequote the current word in case we have to use it. */-
10861 if (glob_array[0] == NULL)
glob_array[0] == ((void *)0)Description
TRUEevaluated 695 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 110 times by 1 test
Evaluated by:
  • Self test
110-695
10862 {-
10863 temp_string = dequote_string (tlist->word->word);-
10864 free (tlist->word->word);-
10865 tlist->word->word = temp_string;-
10866 }
executed 695 times by 1 test: end of block
Executed by:
  • Self test
695
10867-
10868 /* Make the array into a word list. */-
10869 glob_list = (WORD_LIST *)NULL;-
10870 for (glob_index = 0; glob_array[glob_index]; glob_index++)
glob_array[glob_index]Description
TRUEevaluated 1400 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 805 times by 1 test
Evaluated by:
  • Self test
805-1400
10871 {-
10872 tword = make_bare_word (glob_array[glob_index]);-
10873 glob_list = make_word_list (tword, glob_list);-
10874 }
executed 1400 times by 1 test: end of block
Executed by:
  • Self test
1400
10875-
10876 if (glob_list)
glob_listDescription
TRUEevaluated 110 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 695 times by 1 test
Evaluated by:
  • Self test
110-695
10877 {-
10878 output_list = (WORD_LIST *)list_append (glob_list, output_list);-
10879 PREPEND_LIST (tlist, disposables);-
10880 }
executed 110 times by 1 test: end of block
Executed by:
  • Self test
110
10881 else if (fail_glob_expansion != 0)
fail_glob_expansion != 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 694 times by 1 test
Evaluated by:
  • Self test
1-694
10882 {-
10883 last_command_exit_value = EXECUTION_FAILURE;-
10884 report_error (_("no match: %s"), tlist->word->word);-
10885 exp_jump_to_top_level (DISCARD);-
10886 }
never executed: end of block
0
10887 else if (allow_null_glob_expansion == 0)
allow_null_glob_expansion == 0Description
TRUEevaluated 691 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test
3-691
10888 {-
10889 /* Failed glob expressions are left unchanged. */-
10890 PREPEND_LIST (tlist, output_list);-
10891 }
executed 691 times by 1 test: end of block
Executed by:
  • Self test
691
10892 else-
10893 {-
10894 /* Failed glob expressions are removed. */-
10895 PREPEND_LIST (tlist, disposables);-
10896 }
executed 3 times by 1 test: end of block
Executed by:
  • Self test
3
10897 }-
10898 else-
10899 {-
10900 /* Dequote the string. */-
10901 temp_string = dequote_string (tlist->word->word);-
10902 free (tlist->word->word);-
10903 tlist->word->word = temp_string;-
10904 PREPEND_LIST (tlist, output_list);-
10905 }
executed 68960664 times by 1 test: end of block
Executed by:
  • Self test
68960664
10906-
10907 strvec_dispose (glob_array);-
10908 glob_array = (char **)NULL;-
10909-
10910 tlist = next;-
10911 }
executed 68961468 times by 1 test: end of block
Executed by:
  • Self test
68961468
10912-
10913 if (disposables)
disposablesDescription
TRUEevaluated 109 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 43929548 times by 1 test
Evaluated by:
  • Self test
109-43929548
10914 dispose_words (disposables);
executed 109 times by 1 test: dispose_words (disposables);
Executed by:
  • Self test
109
10915-
10916 if (output_list)
output_listDescription
TRUEevaluated 43929657 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-43929657
10917 output_list = REVERSE_LIST (output_list, WORD_LIST *);
executed 43929657 times by 1 test: output_list = ((output_list && output_list->next) ? (WORD_LIST *)list_reverse ((GENERIC_LIST *)output_list) : (WORD_LIST *)(output_list));
Executed by:
  • Self test
output_listDescription
TRUEevaluated 43929657 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
output_list->nextDescription
TRUEevaluated 9648934 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 34280723 times by 1 test
Evaluated by:
  • Self test
0-43929657
10918-
10919 return (output_list);
executed 43929657 times by 1 test: return (output_list);
Executed by:
  • Self test
43929657
10920}-
10921-
10922#if defined (BRACE_EXPANSION)-
10923static WORD_LIST *-
10924brace_expand_word_list (tlist, eflags)-
10925 WORD_LIST *tlist;-
10926 int eflags;-
10927{-
10928 register char **expansions;-
10929 char *temp_string;-
10930 WORD_LIST *disposables, *output_list, *next;-
10931 WORD_DESC *w;-
10932 int eindex;-
10933-
10934 for (disposables = output_list = (WORD_LIST *)NULL; tlist; tlist = next)
tlistDescription
TRUEevaluated 63633200 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 43961081 times by 1 test
Evaluated by:
  • Self test
43961081-63633200
10935 {-
10936 next = tlist->next;-
10937-
10938 if (tlist->word->flags & W_NOBRACE)
tlist->word->flags & 0x4000000Description
TRUEnever evaluated
FALSEevaluated 63633200 times by 1 test
Evaluated by:
  • Self test
0-63633200
10939 {-
10940/*itrace("brace_expand_word_list: %s: W_NOBRACE", tlist->word->word);*/-
10941 PREPEND_LIST (tlist, output_list);-
10942 continue;
never executed: continue;
0
10943 }-
10944-
10945 if ((tlist->word->flags & (W_COMPASSIGN|W_ASSIGNARG)) == (W_COMPASSIGN|W_ASSIGNARG))
(tlist->word->...8000|0x020000)Description
TRUEevaluated 80 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 63633120 times by 1 test
Evaluated by:
  • Self test
80-63633120
10946 {-
10947/*itrace("brace_expand_word_list: %s: W_COMPASSIGN|W_ASSIGNARG", tlist->word->word);*/-
10948 PREPEND_LIST (tlist, output_list);-
10949 continue;
executed 80 times by 1 test: continue;
Executed by:
  • Self test
80
10950 }-
10951-
10952 /* Only do brace expansion if the word has a brace character. If-
10953 not, just add the word list element to BRACES and continue. In-
10954 the common case, at least when running shell scripts, this will-
10955 degenerate to a bunch of calls to `mbschr', and then what is-
10956 basically a reversal of TLIST into BRACES, which is corrected-
10957 by a call to REVERSE_LIST () on BRACES when the end of TLIST-
10958 is reached. */-
10959 if (mbschr (tlist->word->word, LBRACE))
mbschr (tlist-...rd->word, '{')Description
TRUEevaluated 39107 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 63594013 times by 1 test
Evaluated by:
  • Self test
39107-63594013
10960 {-
10961 expansions = brace_expand (tlist->word->word);-
10962-
10963 for (eindex = 0; temp_string = expansions[eindex]; eindex++)
temp_string = ...nsions[eindex]Description
TRUEevaluated 49572 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 39107 times by 1 test
Evaluated by:
  • Self test
39107-49572
10964 {-
10965 w = alloc_word_desc ();-
10966 w->word = temp_string;-
10967-
10968 /* If brace expansion didn't change the word, preserve-
10969 the flags. We may want to preserve the flags-
10970 unconditionally someday -- XXX */-
10971 if (STREQ (temp_string, tlist->word->word))
never executed: __result = (((const unsigned char *) (const char *) ( temp_string ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( tlist->word->word ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
(temp_string)[...word->word)[0]Description
TRUEevaluated 39161 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10411 times by 1 test
Evaluated by:
  • Self test
__extension__ ... )))); }) == 0Description
TRUEevaluated 39021 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 140 times by 1 test
Evaluated by:
  • Self test
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-39161
10972 w->flags = tlist->word->flags;
executed 39021 times by 1 test: w->flags = tlist->word->flags;
Executed by:
  • Self test
39021
10973 else-
10974 w = make_word_flags (w, temp_string);
executed 10551 times by 1 test: w = make_word_flags (w, temp_string);
Executed by:
  • Self test
10551
10975-
10976 output_list = make_word_list (w, output_list);-
10977 }
executed 49572 times by 1 test: end of block
Executed by:
  • Self test
49572
10978 free (expansions);-
10979-
10980 /* Add TLIST to the list of words to be freed after brace-
10981 expansion has been performed. */-
10982 PREPEND_LIST (tlist, disposables);-
10983 }
executed 39107 times by 1 test: end of block
Executed by:
  • Self test
39107
10984 else-
10985 PREPEND_LIST (tlist, output_list);
executed 63594013 times by 1 test: end of block
Executed by:
  • Self test
63594013
10986 }-
10987-
10988 if (disposables)
disposablesDescription
TRUEevaluated 29527 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 43931554 times by 1 test
Evaluated by:
  • Self test
29527-43931554
10989 dispose_words (disposables);
executed 29527 times by 1 test: dispose_words (disposables);
Executed by:
  • Self test
29527
10990-
10991 if (output_list)
output_listDescription
TRUEevaluated 43961081 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-43961081
10992 output_list = REVERSE_LIST (output_list, WORD_LIST *);
executed 43961081 times by 1 test: output_list = ((output_list && output_list->next) ? (WORD_LIST *)list_reverse ((GENERIC_LIST *)output_list) : (WORD_LIST *)(output_list));
Executed by:
  • Self test
output_listDescription
TRUEevaluated 43961081 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
output_list->nextDescription
TRUEevaluated 9678582 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 34282499 times by 1 test
Evaluated by:
  • Self test
0-43961081
10993-
10994 return (output_list);
executed 43961081 times by 1 test: return (output_list);
Executed by:
  • Self test
43961081
10995}-
10996#endif-
10997-
10998#if defined (ARRAY_VARS)-
10999/* Take WORD, a compound associative array assignment, and internally run-
11000 'declare -A w', where W is the variable name portion of WORD. */-
11001static int-
11002make_internal_declare (word, option, cmd)-
11003 char *word;-
11004 char *option;-
11005 char *cmd;-
11006{-
11007 int t, r;-
11008 WORD_LIST *wl;-
11009 WORD_DESC *w;-
11010-
11011 w = make_word (word);-
11012-
11013 t = assignment (w->word, 0);-
11014 if (w->word[t] == '=')
w->word[t] == '='Description
TRUEevaluated 79 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-79
11015 {-
11016 w->word[t] = '\0';-
11017 if (w->word[t - 1] == '+') /* cut off any append op */
w->word[t - 1] == '+'Description
TRUEnever evaluated
FALSEevaluated 79 times by 1 test
Evaluated by:
  • Self test
0-79
11018 w->word[t - 1] = '\0';
never executed: w->word[t - 1] = '\0';
0
11019 }
executed 79 times by 1 test: end of block
Executed by:
  • Self test
79
11020-
11021 wl = make_word_list (w, (WORD_LIST *)NULL);-
11022 wl = make_word_list (make_word (option), wl);-
11023-
11024 r = declare_builtin (wl);-
11025-
11026 dispose_words (wl);-
11027 return r;
executed 79 times by 1 test: return r;
Executed by:
  • Self test
79
11028} -
11029#endif-
11030-
11031static WORD_LIST *-
11032shell_expand_word_list (tlist, eflags)-
11033 WORD_LIST *tlist;-
11034 int eflags;-
11035{-
11036 WORD_LIST *expanded, *orig_list, *new_list, *next, *temp_list, *wcmd;-
11037 int expanded_something, has_dollar_at;-
11038-
11039 /* We do tilde expansion all the time. This is what 1003.2 says. */-
11040 new_list = (WORD_LIST *)NULL;-
11041 for (wcmd = tlist; wcmd; wcmd = wcmd->next)
wcmdDescription
TRUEevaluated 63641343 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 43959750 times by 1 test
Evaluated by:
  • Self test
43959750-63641343
11042 if (wcmd->word->flags & W_ASSNBLTIN)
wcmd->word->flags & 0x010000Description
TRUEevaluated 1331 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 63640012 times by 1 test
Evaluated by:
  • Self test
1331-63640012
11043 break;
executed 1331 times by 1 test: break;
Executed by:
  • Self test
1331
11044-
11045 for (orig_list = tlist; tlist; tlist = next)
tlistDescription
TRUEevaluated 63643650 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 43958925 times by 1 test
Evaluated by:
  • Self test
43958925-63643650
11046 {-
11047 next = tlist->next;-
11048-
11049#if defined (ARRAY_VARS)-
11050 /* If this is a compound array assignment to a builtin that accepts-
11051 such assignments (e.g., `declare'), take the assignment and perform-
11052 it separately, handling the semantics of declarations inside shell-
11053 functions. This avoids the double-evaluation of such arguments,-
11054 because `declare' does some evaluation of compound assignments on-
11055 its own. */-
11056 if ((tlist->word->flags & (W_COMPASSIGN|W_ASSIGNARG)) == (W_COMPASSIGN|W_ASSIGNARG))
(tlist->word->...8000|0x020000)Description
TRUEevaluated 80 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 63643570 times by 1 test
Evaluated by:
  • Self test
80-63643570
11057 {-
11058 int t;-
11059 char opts[16];-
11060 int opti;-
11061-
11062 opti = 0;-
11063 if (tlist->word->flags & (W_ASSIGNASSOC|W_ASSNGLOBAL|W_CHKLOCAL|W_ASSIGNARRAY))
tlist->word->f...0000|0x800000)Description
TRUEevaluated 79 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-79
11064 opts[opti++] = '-';
executed 79 times by 1 test: opts[opti++] = '-';
Executed by:
  • Self test
79
11065-
11066 if ((tlist->word->flags & (W_ASSIGNASSOC|W_ASSNGLOBAL)) == (W_ASSIGNASSOC|W_ASSNGLOBAL))
(tlist->word->...000|0x2000000)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 76 times by 1 test
Evaluated by:
  • Self test
4-76
11067 {-
11068 opts[opti++] = 'g';-
11069 opts[opti++] = 'A';-
11070 }
executed 4 times by 1 test: end of block
Executed by:
  • Self test
4
11071 else if (tlist->word->flags & W_ASSIGNASSOC)
tlist->word->flags & 0x400000Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 63 times by 1 test
Evaluated by:
  • Self test
13-63
11072 opts[opti++] = 'A';
executed 13 times by 1 test: opts[opti++] = 'A';
Executed by:
  • Self test
13
11073 else if ((tlist->word->flags & (W_ASSIGNARRAY|W_ASSNGLOBAL)) == (W_ASSIGNARRAY|W_ASSNGLOBAL))
(tlist->word->...000|0x2000000)Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 47 times by 1 test
Evaluated by:
  • Self test
16-47
11074 {-
11075 opts[opti++] = 'g';-
11076 opts[opti++] = 'a';-
11077 }
executed 16 times by 1 test: end of block
Executed by:
  • Self test
16
11078 else if (tlist->word->flags & W_ASSIGNARRAY)
tlist->word->flags & 0x800000Description
TRUEevaluated 36 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 11 times by 1 test
Evaluated by:
  • Self test
11-36
11079 opts[opti++] = 'a';
executed 36 times by 1 test: opts[opti++] = 'a';
Executed by:
  • Self test
36
11080 else if (tlist->word->flags & W_ASSNGLOBAL)
tlist->word->flags & 0x2000000Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-10
11081 opts[opti++] = 'g';
executed 10 times by 1 test: opts[opti++] = 'g';
Executed by:
  • Self test
10
11082-
11083 if (tlist->word->flags & W_CHKLOCAL)
tlist->word->f...s & 0x10000000Description
TRUEevaluated 16 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 64 times by 1 test
Evaluated by:
  • Self test
16-64
11084 opts[opti++] = 'G';
executed 16 times by 1 test: opts[opti++] = 'G';
Executed by:
  • Self test
16
11085-
11086 /* If we have special handling note the integer attribute and others-
11087 that transform the value upon assignment. What we do is take all-
11088 of the option arguments and scan through them looking for options-
11089 that cause such transformations, and add them to the `opts' array. */-
11090/* if (opti > 0) */-
11091 {-
11092 char omap[128];-
11093 int oind;-
11094 WORD_LIST *l;-
11095-
11096 memset (omap, '\0', sizeof (omap));-
11097 for (l = orig_list->next; l != tlist; l = l->next)
l != tlistDescription
TRUEevaluated 76 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 80 times by 1 test
Evaluated by:
  • Self test
76-80
11098 {-
11099 if (l->word->word[0] != '-')
l->word->word[0] != '-'Description
TRUEnever evaluated
FALSEevaluated 76 times by 1 test
Evaluated by:
  • Self test
0-76
11100 break; /* non-option argument */
never executed: break;
0
11101 if (l->word->word[0] == '-' && l->word->word[1] == '-' && l->word->word[2] == 0)
l->word->word[0] == '-'Description
TRUEevaluated 76 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
l->word->word[1] == '-'Description
TRUEnever evaluated
FALSEevaluated 76 times by 1 test
Evaluated by:
  • Self test
l->word->word[2] == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-76
11102 break; /* -- signals end of options */
never executed: break;
0
11103 for (oind = 1; l->word->word[oind]; oind++)
l->word->word[oind]Description
TRUEevaluated 91 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 76 times by 1 test
Evaluated by:
  • Self test
76-91
11104 switch (l->word->word[oind])-
11105 {-
11106 case 'i':
executed 4 times by 1 test: case 'i':
Executed by:
  • Self test
4
11107 case 'l':
executed 2 times by 1 test: case 'l':
Executed by:
  • Self test
2
11108 case 'u':
never executed: case 'u':
0
11109 case 'c':
never executed: case 'c':
0
11110 omap[l->word->word[oind]] = 1;-
11111 if (opti == 0)
opti == 0Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test
0-6
11112 opts[opti++] = '-';
never executed: opts[opti++] = '-';
0
11113 break;
executed 6 times by 1 test: break;
Executed by:
  • Self test
6
11114 default:
executed 85 times by 1 test: default:
Executed by:
  • Self test
85
11115 break;
executed 85 times by 1 test: break;
Executed by:
  • Self test
85
11116 }-
11117 }
executed 76 times by 1 test: end of block
Executed by:
  • Self test
76
11118-
11119 for (oind = 0; oind < sizeof (omap); oind++)
oind < sizeof (omap)Description
TRUEevaluated 10240 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 80 times by 1 test
Evaluated by:
  • Self test
80-10240
11120 if (omap[oind])
omap[oind]Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 10234 times by 1 test
Evaluated by:
  • Self test
6-10234
11121 opts[opti++] = oind;
executed 6 times by 1 test: opts[opti++] = oind;
Executed by:
  • Self test
6
11122 }-
11123-
11124 opts[opti] = '\0';-
11125 if (opti > 0)
opti > 0Description
TRUEevaluated 79 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
1-79
11126 {-
11127 t = make_internal_declare (tlist->word->word, opts, wcmd ? wcmd->word->word : (char *)0);-
11128 if (t != EXECUTION_SUCCESS)
t != 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 78 times by 1 test
Evaluated by:
  • Self test
1-78
11129 {-
11130 last_command_exit_value = t;-
11131 exp_jump_to_top_level (DISCARD);-
11132 }
never executed: end of block
0
11133 }
executed 78 times by 1 test: end of block
Executed by:
  • Self test
78
11134-
11135 t = do_word_assignment (tlist->word, 0);-
11136 if (t == 0)
t == 0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 75 times by 1 test
Evaluated by:
  • Self test
4-75
11137 {-
11138 last_command_exit_value = EXECUTION_FAILURE;-
11139 exp_jump_to_top_level (DISCARD);-
11140 }
never executed: end of block
0
11141-
11142 /* Now transform the word as ksh93 appears to do and go on */-
11143 t = assignment (tlist->word->word, 0);-
11144 tlist->word->word[t] = '\0';-
11145 if (tlist->word->word[t - 1] == '+')
tlist->word->w...[t - 1] == '+'Description
TRUEnever evaluated
FALSEevaluated 75 times by 1 test
Evaluated by:
  • Self test
0-75
11146 tlist->word->word[t - 1] = '\0'; /* cut off append op */
never executed: tlist->word->word[t - 1] = '\0';
0
11147 tlist->word->flags &= ~(W_ASSIGNMENT|W_NOSPLIT|W_COMPASSIGN|W_ASSIGNARG|W_ASSIGNASSOC|W_ASSIGNARRAY);-
11148 }
executed 75 times by 1 test: end of block
Executed by:
  • Self test
75
11149#endif-
11150-
11151 expanded_something = 0;-
11152 expanded = expand_word_internal-
11153 (tlist->word, 0, 0, &has_dollar_at, &expanded_something);-
11154-
11155 if (expanded == &expand_word_error || expanded == &expand_word_fatal)
expanded == &expand_word_errorDescription
TRUEevaluated 213 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 63641544 times by 1 test
Evaluated by:
  • Self test
expanded == &expand_word_fatalDescription
TRUEevaluated 50 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 63641494 times by 1 test
Evaluated by:
  • Self test
50-63641544
11156 {-
11157 /* By convention, each time this error is returned,-
11158 tlist->word->word has already been freed. */-
11159 tlist->word->word = (char *)NULL;-
11160-
11161 /* Dispose our copy of the original list. */-
11162 dispose_words (orig_list);-
11163 /* Dispose the new list we're building. */-
11164 dispose_words (new_list);-
11165-
11166 last_command_exit_value = EXECUTION_FAILURE;-
11167 if (expanded == &expand_word_error)
expanded == &expand_word_errorDescription
TRUEevaluated 213 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 50 times by 1 test
Evaluated by:
  • Self test
50-213
11168 exp_jump_to_top_level (DISCARD);
executed 213 times by 1 test: exp_jump_to_top_level (2);
Executed by:
  • Self test
213
11169 else-
11170 exp_jump_to_top_level (FORCE_EOF);
executed 50 times by 1 test: exp_jump_to_top_level (1);
Executed by:
  • Self test
50
11171 }-
11172-
11173 /* Don't split words marked W_NOSPLIT. */-
11174 if (expanded_something && (tlist->word->flags & W_NOSPLIT) == 0)
expanded_somethingDescription
TRUEevaluated 3312063 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 60329431 times by 1 test
Evaluated by:
  • Self test
(tlist->word->...0x000010) == 0Description
TRUEevaluated 3282857 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 29206 times by 1 test
Evaluated by:
  • Self test
29206-60329431
11175 {-
11176 temp_list = word_list_split (expanded);-
11177 dispose_words (expanded);-
11178 }
executed 3282857 times by 1 test: end of block
Executed by:
  • Self test
3282857
11179 else-
11180 {-
11181 /* If no parameter expansion, command substitution, process-
11182 substitution, or arithmetic substitution took place, then-
11183 do not do word splitting. We still have to remove quoted-
11184 null characters from the result. */-
11185 word_list_remove_quoted_nulls (expanded);-
11186 temp_list = expanded;-
11187 }
executed 60358637 times by 1 test: end of block
Executed by:
  • Self test
60358637
11188-
11189 expanded = REVERSE_LIST (temp_list, WORD_LIST *);
temp_listDescription
TRUEevaluated 63631662 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9832 times by 1 test
Evaluated by:
  • Self test
temp_list->nextDescription
TRUEevaluated 3093548 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 60538114 times by 1 test
Evaluated by:
  • Self test
9832-63631662
11190 new_list = (WORD_LIST *)list_append (expanded, new_list);-
11191 }
executed 63641494 times by 1 test: end of block
Executed by:
  • Self test
63641494
11192-
11193 if (orig_list)
orig_listDescription
TRUEevaluated 43958925 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-43958925
11194 dispose_words (orig_list);
executed 43958925 times by 1 test: dispose_words (orig_list);
Executed by:
  • Self test
43958925
11195-
11196 if (new_list)
new_listDescription
TRUEevaluated 43958865 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 60 times by 1 test
Evaluated by:
  • Self test
60-43958865
11197 new_list = REVERSE_LIST (new_list, WORD_LIST *);
executed 43958865 times by 1 test: new_list = ((new_list && new_list->next) ? (WORD_LIST *)list_reverse ((GENERIC_LIST *)new_list) : (WORD_LIST *)(new_list));
Executed by:
  • Self test
new_listDescription
TRUEevaluated 43958865 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
new_list->nextDescription
TRUEevaluated 9677567 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 34281298 times by 1 test
Evaluated by:
  • Self test
0-43958865
11198-
11199 return (new_list);
executed 43958925 times by 1 test: return (new_list);
Executed by:
  • Self test
43958925
11200}-
11201-
11202/* The workhorse for expand_words () and expand_words_no_vars ().-
11203 First arg is LIST, a WORD_LIST of words.-
11204 Second arg EFLAGS is a flags word controlling which expansions are-
11205 performed.-
11206-
11207 This does all of the substitutions: brace expansion, tilde expansion,-
11208 parameter expansion, command substitution, arithmetic expansion,-
11209 process substitution, word splitting, and pathname expansion, according-
11210 to the bits set in EFLAGS. Words with the W_QUOTED or W_NOSPLIT bits-
11211 set, or for which no expansion is done, do not undergo word splitting.-
11212 Words with the W_NOGLOB bit set do not undergo pathname expansion; words-
11213 with W_NOBRACE set do not undergo brace expansion (see-
11214 brace_expand_word_list above). */-
11215static WORD_LIST *-
11216expand_word_list_internal (list, eflags)-
11217 WORD_LIST *list;-
11218 int eflags;-
11219{-
11220 WORD_LIST *new_list, *temp_list;-
11221 int tint;-
11222 char *savecmd;-
11223-
11224 tempenv_assign_error = 0;-
11225 if (list == 0)
list == 0Description
TRUEevaluated 29 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 73924666 times by 1 test
Evaluated by:
  • Self test
29-73924666
11226 return ((WORD_LIST *)NULL);
executed 29 times by 1 test: return ((WORD_LIST *) ((void *)0) );
Executed by:
  • Self test
29
11227-
11228 garglist = new_list = copy_word_list (list);-
11229 if (eflags & WEXP_VARASSIGN)
eflags & 0x001Description
TRUEevaluated 64686671 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9237995 times by 1 test
Evaluated by:
  • Self test
9237995-64686671
11230 {-
11231 garglist = new_list = separate_out_assignments (new_list);-
11232 if (new_list == 0)
new_list == 0Description
TRUEevaluated 29963585 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 34723086 times by 1 test
Evaluated by:
  • Self test
29963585-34723086
11233 {-
11234 if (subst_assign_varlist)
subst_assign_varlistDescription
TRUEevaluated 29963585 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-29963585
11235 {-
11236 /* All the words were variable assignments, so they are placed-
11237 into the shell's environment. */-
11238 for (temp_list = subst_assign_varlist; temp_list; temp_list = temp_list->next)
temp_listDescription
TRUEevaluated 36424249 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 29960997 times by 1 test
Evaluated by:
  • Self test
29960997-36424249
11239 {-
11240 savecmd = this_command_name;-
11241 this_command_name = (char *)NULL; /* no arithmetic errors */-
11242 tint = do_word_assignment (temp_list->word, 0);-
11243 this_command_name = savecmd;-
11244 /* Variable assignment errors in non-interactive shells-
11245 running in Posix.2 mode cause the shell to exit, unless-
11246 they are being run by the `command' builtin. */-
11247 if (tint == 0)
tint == 0Description
TRUEevaluated 107 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 36421661 times by 1 test
Evaluated by:
  • Self test
107-36421661
11248 {-
11249 last_command_exit_value = EXECUTION_FAILURE;-
11250 if (interactive_shell == 0 && posixly_correct && executing_command_builtin == 0)
interactive_shell == 0Description
TRUEevaluated 107 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
posixly_correctDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 106 times by 1 test
Evaluated by:
  • Self test
executing_command_builtin == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-107
11251 exp_jump_to_top_level (FORCE_EOF);
executed 1 time by 1 test: exp_jump_to_top_level (1);
Executed by:
  • Self test
1
11252 else-
11253 exp_jump_to_top_level (DISCARD);
executed 106 times by 1 test: exp_jump_to_top_level (2);
Executed by:
  • Self test
106
11254 }-
11255 }
executed 36421661 times by 1 test: end of block
Executed by:
  • Self test
36421661
11256 dispose_words (subst_assign_varlist);-
11257 subst_assign_varlist = (WORD_LIST *)NULL;-
11258 }
executed 29960997 times by 1 test: end of block
Executed by:
  • Self test
29960997
11259 return ((WORD_LIST *)NULL);
executed 29960997 times by 1 test: return ((WORD_LIST *) ((void *)0) );
Executed by:
  • Self test
29960997
11260 }-
11261 }
executed 34723086 times by 1 test: end of block
Executed by:
  • Self test
34723086
11262-
11263 /* Begin expanding the words that remain. The expansions take place on-
11264 things that aren't really variable assignments. */-
11265-
11266#if defined (BRACE_EXPANSION)-
11267 /* Do brace expansion on this word if there are any brace characters-
11268 in the string. */-
11269 if ((eflags & WEXP_BRACEEXP) && brace_expansion && new_list)
(eflags & 0x002)Description
TRUEevaluated 43961081 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
brace_expansionDescription
TRUEevaluated 43961081 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
new_listDescription
TRUEevaluated 43961081 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
0-43961081
11270 new_list = brace_expand_word_list (new_list, eflags);
executed 43961081 times by 1 test: new_list = brace_expand_word_list (new_list, eflags);
Executed by:
  • Self test
43961081
11271#endif /* BRACE_EXPANSION */-
11272-
11273 /* Perform the `normal' shell expansions: tilde expansion, parameter and-
11274 variable substitution, command substitution, arithmetic expansion,-
11275 and word splitting. */-
11276 new_list = shell_expand_word_list (new_list, eflags);-
11277-
11278 /* Okay, we're almost done. Now let's just do some filename-
11279 globbing. */-
11280 if (new_list)
new_listDescription
TRUEevaluated 43958865 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 60 times by 1 test
Evaluated by:
  • Self test
60-43958865
11281 {-
11282 if ((eflags & WEXP_PATHEXP) && disallow_filename_globbing == 0)
(eflags & 0x010)Description
TRUEevaluated 43958865 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
disallow_filen..._globbing == 0Description
TRUEevaluated 43929658 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 29207 times by 1 test
Evaluated by:
  • Self test
0-43958865
11283 /* Glob expand the word list unless globbing has been disabled. */-
11284 new_list = glob_expand_word_list (new_list, eflags);
executed 43929658 times by 1 test: new_list = glob_expand_word_list (new_list, eflags);
Executed by:
  • Self test
43929658
11285 else-
11286 /* Dequote the words, because we're not performing globbing. */-
11287 new_list = dequote_list (new_list);
executed 29207 times by 1 test: new_list = dequote_list (new_list);
Executed by:
  • Self test
29207
11288 }-
11289-
11290 if ((eflags & WEXP_VARASSIGN) && subst_assign_varlist)
(eflags & 0x001)Description
TRUEevaluated 34722515 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 9236409 times by 1 test
Evaluated by:
  • Self test
subst_assign_varlistDescription
TRUEevaluated 1786 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 34720729 times by 1 test
Evaluated by:
  • Self test
1786-34722515
11291 {-
11292 sh_wassign_func_t *assign_func;-
11293 int is_special_builtin, is_builtin_or_func;-
11294-
11295 /* If the remainder of the words expand to nothing, Posix.2 requires-
11296 that the variable and environment assignments affect the shell's-
11297 environment. */-
11298 assign_func = new_list ? assign_in_env : do_word_assignment;
new_listDescription
TRUEevaluated 1772 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test
14-1772
11299 tempenv_assign_error = 0;-
11300-
11301 is_builtin_or_func = (new_list && new_list->word && (find_shell_builtin (new_list->word->word) || find_function (new_list->word->word)));
new_listDescription
TRUEevaluated 1772 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test
new_list->wordDescription
TRUEevaluated 1772 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
find_shell_bui...t->word->word)Description
TRUEevaluated 1675 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 97 times by 1 test
Evaluated by:
  • Self test
find_function ...t->word->word)Description
TRUEevaluated 54 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 43 times by 1 test
Evaluated by:
  • Self test
0-1772
11302 /* Posix says that special builtins exit if a variable assignment error-
11303 occurs in an assignment preceding it. */-
11304 is_special_builtin = (posixly_correct && new_list && new_list->word && find_special_builtin (new_list->word->word));
posixly_correctDescription
TRUEevaluated 42 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1744 times by 1 test
Evaluated by:
  • Self test
new_listDescription
TRUEevaluated 41 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
new_list->wordDescription
TRUEevaluated 41 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
find_special_b...t->word->word)Description
TRUEevaluated 29 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test
0-1744
11305 -
11306 for (temp_list = subst_assign_varlist; temp_list; temp_list = temp_list->next)
temp_listDescription
TRUEevaluated 1885 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1783 times by 1 test
Evaluated by:
  • Self test
1783-1885
11307 {-
11308 savecmd = this_command_name;-
11309 this_command_name = (char *)NULL;-
11310 assigning_in_environment = (assign_func == assign_in_env);-
11311 tint = (*assign_func) (temp_list->word, is_builtin_or_func);-
11312 assigning_in_environment = 0;-
11313 this_command_name = savecmd;-
11314 /* Variable assignment errors in non-interactive shells running-
11315 in Posix.2 mode cause the shell to exit. */-
11316 if (tint == 0)
tint == 0Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1864 times by 1 test
Evaluated by:
  • Self test
21-1864
11317 {-
11318 if (assign_func == do_word_assignment)
assign_func ==...ord_assignmentDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEevaluated 19 times by 1 test
Evaluated by:
  • Self test
2-19
11319 {-
11320 last_command_exit_value = EXECUTION_FAILURE;-
11321 if (interactive_shell == 0 && posixly_correct)
interactive_shell == 0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
posixly_correctDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test
0-2
11322 exp_jump_to_top_level (FORCE_EOF);
executed 1 time by 1 test: exp_jump_to_top_level (1);
Executed by:
  • Self test
1
11323 else-
11324 exp_jump_to_top_level (DISCARD);
executed 1 time by 1 test: exp_jump_to_top_level (2);
Executed by:
  • Self test
1
11325 }-
11326 else if (interactive_shell == 0 && is_special_builtin)
interactive_shell == 0Description
TRUEevaluated 19 times by 1 test
Evaluated by:
  • Self test
FALSEnever evaluated
is_special_builtinDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test
FALSEevaluated 18 times by 1 test
Evaluated by:
  • Self test
0-19
11327 {-
11328 last_command_exit_value = EXECUTION_FAILURE;-
11329 exp_jump_to_top_level (FORCE_EOF);-
11330 }
never executed: end of block
0
11331 else-
11332 tempenv_assign_error++;
executed 18 times by 1 test: tempenv_assign_error++;
Executed by:
  • Self test
18
11333 }-
11334 }
executed 1882 times by 1 test: end of block
Executed by:
  • Self test
1882
11335-
11336 dispose_words (subst_assign_varlist);-
11337 subst_assign_varlist = (WORD_LIST *)NULL;-
11338 }
executed 1783 times by 1 test: end of block
Executed by:
  • Self test
1783
11339-
11340 return (new_list);
executed 43958921 times by 1 test: return (new_list);
Executed by:
  • Self test
43958921
11341}-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.1.2