|
Lines 164-171
WORD_LIST *subst_assign_varlist = (WORD_
Link Here
|
| 164 |
without any leading variable assignments. */ |
164 |
without any leading variable assignments. */ |
| 165 |
static WORD_LIST *garglist = (WORD_LIST *)NULL; |
165 |
static WORD_LIST *garglist = (WORD_LIST *)NULL; |
| 166 |
|
166 |
|
|
|
167 |
#ifdef INCLUDE_UNUSED |
| 167 |
static char *quoted_substring __P((char *, int, int)); |
168 |
static char *quoted_substring __P((char *, int, int)); |
| 168 |
static int quoted_strlen __P((char *)); |
169 |
static int quoted_strlen __P((char *)); |
|
|
170 |
#endif |
| 169 |
static char *quoted_strchr __P((char *, int, int)); |
171 |
static char *quoted_strchr __P((char *, int, int)); |
| 170 |
|
172 |
|
| 171 |
static char *expand_string_if_necessary __P((char *, int, EXPFUNC *)); |
173 |
static char *expand_string_if_necessary __P((char *, int, EXPFUNC *)); |
|
Lines 204-210
static int match_pattern_char __P((char
Link Here
|
| 204 |
static int match_pattern __P((char *, char *, int, char **, char **)); |
206 |
static int match_pattern __P((char *, char *, int, char **, char **)); |
| 205 |
static int getpatspec __P((int, char *)); |
207 |
static int getpatspec __P((int, char *)); |
| 206 |
static char *getpattern __P((char *, int, int)); |
208 |
static char *getpattern __P((char *, int, int)); |
|
|
209 |
#ifdef INCLUDE_UNUSED |
| 207 |
static char *variable_remove_pattern __P((char *, char *, int, int)); |
210 |
static char *variable_remove_pattern __P((char *, char *, int, int)); |
|
|
211 |
#endif |
| 208 |
static char *list_remove_pattern __P((WORD_LIST *, char *, int, int, int)); |
212 |
static char *list_remove_pattern __P((WORD_LIST *, char *, int, int, int)); |
| 209 |
static char *parameter_list_remove_pattern __P((int, char *, int, int)); |
213 |
static char *parameter_list_remove_pattern __P((int, char *, int, int)); |
| 210 |
#ifdef ARRAY_VARS |
214 |
#ifdef ARRAY_VARS |
|
Lines 366-372
unquoted_member (character, string)
Link Here
|
| 366 |
|
370 |
|
| 367 |
slen = strlen (string); |
371 |
slen = strlen (string); |
| 368 |
sindex = 0; |
372 |
sindex = 0; |
| 369 |
while (c = string[sindex]) |
373 |
while ((c = string[sindex])) |
| 370 |
{ |
374 |
{ |
| 371 |
if (c == character) |
375 |
if (c == character) |
| 372 |
return (1); |
376 |
return (1); |
|
Lines 409-415
unquoted_substring (substr, string)
Link Here
|
| 409 |
|
413 |
|
| 410 |
slen = strlen (string); |
414 |
slen = strlen (string); |
| 411 |
sublen = strlen (substr); |
415 |
sublen = strlen (substr); |
| 412 |
for (sindex = 0; c = string[sindex]; ) |
416 |
for (sindex = 0; (c = string[sindex]); ) |
| 413 |
{ |
417 |
{ |
| 414 |
if (STREQN (string + sindex, substr, sublen)) |
418 |
if (STREQN (string + sindex, substr, sublen)) |
| 415 |
return (1); |
419 |
return (1); |
|
Lines 516-522
string_extract (string, sindex, charlist
Link Here
|
| 516 |
|
520 |
|
| 517 |
slen = strlen (string + *sindex) + *sindex; |
521 |
slen = strlen (string + *sindex) + *sindex; |
| 518 |
i = *sindex; |
522 |
i = *sindex; |
| 519 |
while (c = string[i]) |
523 |
while ((c = string[i])) |
| 520 |
{ |
524 |
{ |
| 521 |
if (c == '\\') |
525 |
if (c == '\\') |
| 522 |
{ |
526 |
{ |
|
Lines 575-581
string_extract_double_quoted (string, si
Link Here
|
| 575 |
|
579 |
|
| 576 |
j = 0; |
580 |
j = 0; |
| 577 |
i = *sindex; |
581 |
i = *sindex; |
| 578 |
while (c = string[i]) |
582 |
while ((c = string[i])) |
| 579 |
{ |
583 |
{ |
| 580 |
/* Process a character that was quoted by a backslash. */ |
584 |
/* Process a character that was quoted by a backslash. */ |
| 581 |
if (pass_next) |
585 |
if (pass_next) |
|
Lines 704-710
skip_double_quoted (string, slen, sind)
Link Here
|
| 704 |
|
708 |
|
| 705 |
pass_next = backquote = 0; |
709 |
pass_next = backquote = 0; |
| 706 |
i = sind; |
710 |
i = sind; |
| 707 |
while (c = string[i]) |
711 |
while ((c = string[i])) |
| 708 |
{ |
712 |
{ |
| 709 |
if (pass_next) |
713 |
if (pass_next) |
| 710 |
{ |
714 |
{ |
|
Lines 822-828
string_extract_verbatim (string, sindex,
Link Here
|
| 822 |
return temp; |
826 |
return temp; |
| 823 |
} |
827 |
} |
| 824 |
|
828 |
|
| 825 |
for (i = *sindex; c = string[i]; i++) |
829 |
for (i = *sindex; (c = string[i]); i++) |
| 826 |
{ |
830 |
{ |
| 827 |
if (c == CTLESC) |
831 |
if (c == CTLESC) |
| 828 |
{ |
832 |
{ |
|
Lines 1034-1040
extract_dollar_brace_string (string, sin
Link Here
|
| 1034 |
slen = strlen (string + *sindex) + *sindex; |
1038 |
slen = strlen (string + *sindex) + *sindex; |
| 1035 |
|
1039 |
|
| 1036 |
i = *sindex; |
1040 |
i = *sindex; |
| 1037 |
while (c = string[i]) |
1041 |
while ((c = string[i])) |
| 1038 |
{ |
1042 |
{ |
| 1039 |
if (pass_character) |
1043 |
if (pass_character) |
| 1040 |
{ |
1044 |
{ |
|
Lines 1295-1301
skip_to_delim (string, start, delims)
Link Here
|
| 1295 |
no_longjmp_on_fatal_error = 1; |
1299 |
no_longjmp_on_fatal_error = 1; |
| 1296 |
i = start; |
1300 |
i = start; |
| 1297 |
pass_next = backq = 0; |
1301 |
pass_next = backq = 0; |
| 1298 |
while (c = string[i]) |
1302 |
while ((c = string[i])) |
| 1299 |
{ |
1303 |
{ |
| 1300 |
if (pass_next) |
1304 |
if (pass_next) |
| 1301 |
{ |
1305 |
{ |
|
Lines 1973-1979
do_assignment_internal (string, expand)
Link Here
|
| 1973 |
#define ASSIGN_RETURN(r) do { FREE (value); free (name); return (r); } while (0) |
1977 |
#define ASSIGN_RETURN(r) do { FREE (value); free (name); return (r); } while (0) |
| 1974 |
|
1978 |
|
| 1975 |
#if defined (ARRAY_VARS) |
1979 |
#if defined (ARRAY_VARS) |
| 1976 |
if (t = xstrchr (name, '[')) /*]*/ |
1980 |
if ((t = xstrchr (name, '['))) /*]*/ |
| 1977 |
{ |
1981 |
{ |
| 1978 |
if (assign_list) |
1982 |
if (assign_list) |
| 1979 |
{ |
1983 |
{ |
|
Lines 2891-2897
match_pattern_char (pat, string)
Link Here
|
| 2891 |
if (*string == 0) |
2895 |
if (*string == 0) |
| 2892 |
return (0); |
2896 |
return (0); |
| 2893 |
|
2897 |
|
| 2894 |
switch (c = *pat++) |
2898 |
switch ((c = *pat++)) |
| 2895 |
{ |
2899 |
{ |
| 2896 |
default: |
2900 |
default: |
| 2897 |
return (*string == c); |
2901 |
return (*string == c); |
|
Lines 3011-3017
getpattern (value, quoted, expandpat)
Link Here
|
| 3011 |
{ |
3015 |
{ |
| 3012 |
char *pat, *tword; |
3016 |
char *pat, *tword; |
| 3013 |
WORD_LIST *l; |
3017 |
WORD_LIST *l; |
| 3014 |
int i; |
|
|
| 3015 |
|
3018 |
|
| 3016 |
tword = xstrchr (value, '~') ? bash_tilde_expand (value, 0) : savestring (value); |
3019 |
tword = xstrchr (value, '~') ? bash_tilde_expand (value, 0) : savestring (value); |
| 3017 |
|
3020 |
|
|
Lines 3023-3029
getpattern (value, quoted, expandpat)
Link Here
|
| 3023 |
#if 0 |
3026 |
#if 0 |
| 3024 |
if (expandpat && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && *tword) |
3027 |
if (expandpat && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && *tword) |
| 3025 |
{ |
3028 |
{ |
| 3026 |
i = 0; |
3029 |
int i = 0; |
| 3027 |
pat = string_extract_double_quoted (tword, &i, 1); |
3030 |
pat = string_extract_double_quoted (tword, &i, 1); |
| 3028 |
free (tword); |
3031 |
free (tword); |
| 3029 |
tword = pat; |
3032 |
tword = pat; |
|
Lines 3626-3631
read_comsub (fd, quoted)
Link Here
|
| 3626 |
|
3629 |
|
| 3627 |
istring = (char *)NULL; |
3630 |
istring = (char *)NULL; |
| 3628 |
istring_index = istring_size = bufn = 0; |
3631 |
istring_index = istring_size = bufn = 0; |
|
|
3632 |
bufp = buf; /* redundant */ |
| 3629 |
|
3633 |
|
| 3630 |
#ifdef __CYGWIN__ |
3634 |
#ifdef __CYGWIN__ |
| 3631 |
setmode (fd, O_TEXT); /* we don't want CR/LF, we want Unix-style */ |
3635 |
setmode (fd, O_TEXT); /* we don't want CR/LF, we want Unix-style */ |
|
Lines 4007-4013
parameter_brace_expand_word (name, var_i
Link Here
|
| 4007 |
temp = quote_escapes (temp); |
4011 |
temp = quote_escapes (temp); |
| 4008 |
} |
4012 |
} |
| 4009 |
#endif |
4013 |
#endif |
| 4010 |
else if (var = find_variable (name)) |
4014 |
else if ((var = find_variable (name))) |
| 4011 |
{ |
4015 |
{ |
| 4012 |
if (var_isset (var) && invisible_p (var) == 0) |
4016 |
if (var_isset (var) && invisible_p (var) == 0) |
| 4013 |
{ |
4017 |
{ |
|
Lines 4185-4190
parameter_brace_expand_length (name)
Link Here
|
| 4185 |
SHELL_VAR *var; |
4189 |
SHELL_VAR *var; |
| 4186 |
#endif |
4190 |
#endif |
| 4187 |
|
4191 |
|
|
|
4192 |
t = NULL; |
| 4188 |
if (name[1] == '\0') /* ${#} */ |
4193 |
if (name[1] == '\0') /* ${#} */ |
| 4189 |
number = number_of_args (); |
4194 |
number = number_of_args (); |
| 4190 |
else if ((name[1] == '@' || name[1] == '*') && name[2] == '\0') /* ${#@}, ${#*} */ |
4195 |
else if ((name[1] == '@' || name[1] == '*') && name[2] == '\0') /* ${#@}, ${#*} */ |
|
Lines 4489-4494
parameter_brace_substring (varname, valu
Link Here
|
| 4489 |
if (r <= 0) |
4494 |
if (r <= 0) |
| 4490 |
return ((r == 0) ? &expand_param_error : (char *)NULL); |
4495 |
return ((r == 0) ? &expand_param_error : (char *)NULL); |
| 4491 |
|
4496 |
|
|
|
4497 |
temp = NULL; |
| 4492 |
switch (vtype) |
4498 |
switch (vtype) |
| 4493 |
{ |
4499 |
{ |
| 4494 |
case VT_VARIABLE: |
4500 |
case VT_VARIABLE: |
|
Lines 4576-4582
pat_subst (string, pat, rep, mflags)
Link Here
|
| 4576 |
ret = (char *)xmalloc (rsize = 64); |
4582 |
ret = (char *)xmalloc (rsize = 64); |
| 4577 |
ret[0] = '\0'; |
4583 |
ret[0] = '\0'; |
| 4578 |
|
4584 |
|
| 4579 |
for (replen = STRLEN (rep), rptr = 0, str = string;;) |
4585 |
for (replen = STRLEN (rep), rptr = 0, (str = string);;) |
| 4580 |
{ |
4586 |
{ |
| 4581 |
if (match_pattern (str, pat, mtype, &s, &e) == 0) |
4587 |
if (match_pattern (str, pat, mtype, &s, &e) == 0) |
| 4582 |
break; |
4588 |
break; |
|
Lines 4624-4630
pos_params_pat_subst (string, pat, rep,
Link Here
|
| 4624 |
{ |
4630 |
{ |
| 4625 |
WORD_LIST *save, *params; |
4631 |
WORD_LIST *save, *params; |
| 4626 |
WORD_DESC *w; |
4632 |
WORD_DESC *w; |
| 4627 |
char *ret, *tt; |
4633 |
char *ret; |
| 4628 |
|
4634 |
|
| 4629 |
save = params = list_rest_of_args (); |
4635 |
save = params = list_rest_of_args (); |
| 4630 |
if (save == 0) |
4636 |
if (save == 0) |
|
Lines 4681-4687
parameter_brace_patsub (varname, value,
Link Here
|
| 4681 |
if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) |
4687 |
if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) |
| 4682 |
mflags |= MATCH_QUOTED; |
4688 |
mflags |= MATCH_QUOTED; |
| 4683 |
|
4689 |
|
| 4684 |
if (rep = quoted_strchr (lpatsub, '/', ST_BACKSL)) |
4690 |
if ((rep = quoted_strchr (lpatsub, '/', ST_BACKSL))) |
| 4685 |
*rep++ = '\0'; |
4691 |
*rep++ = '\0'; |
| 4686 |
else |
4692 |
else |
| 4687 |
rep = (char *)NULL; |
4693 |
rep = (char *)NULL; |
|
Lines 4727-4732
parameter_brace_patsub (varname, value,
Link Here
|
| 4727 |
other cases if QUOTED == 0, since the posparams and arrays |
4733 |
other cases if QUOTED == 0, since the posparams and arrays |
| 4728 |
indexed by * or @ do special things when QUOTED != 0. */ |
4734 |
indexed by * or @ do special things when QUOTED != 0. */ |
| 4729 |
|
4735 |
|
|
|
4736 |
temp = 0; |
| 4730 |
switch (vtype) |
4737 |
switch (vtype) |
| 4731 |
{ |
4738 |
{ |
| 4732 |
case VT_VARIABLE: |
4739 |
case VT_VARIABLE: |
|
Lines 4828-4834
parameter_brace_expand (string, indexp,
Link Here
|
| 4828 |
|
4835 |
|
| 4829 |
/* Find out what character ended the variable name. Then |
4836 |
/* Find out what character ended the variable name. Then |
| 4830 |
do the appropriate thing. */ |
4837 |
do the appropriate thing. */ |
| 4831 |
if (c = string[sindex]) |
4838 |
if ((c = string[sindex])) |
| 4832 |
sindex++; |
4839 |
sindex++; |
| 4833 |
|
4840 |
|
| 4834 |
/* If c is followed by one of the valid parameter expansion |
4841 |
/* If c is followed by one of the valid parameter expansion |
|
Lines 4838-4844
parameter_brace_expand (string, indexp,
Link Here
|
| 4838 |
if (c == ':' && VALID_PARAM_EXPAND_CHAR (string[sindex])) |
4845 |
if (c == ':' && VALID_PARAM_EXPAND_CHAR (string[sindex])) |
| 4839 |
{ |
4846 |
{ |
| 4840 |
check_nullness++; |
4847 |
check_nullness++; |
| 4841 |
if (c = string[sindex]) |
4848 |
if ((c = string[sindex])) |
| 4842 |
sindex++; |
4849 |
sindex++; |
| 4843 |
} |
4850 |
} |
| 4844 |
else if (c == ':' && string[sindex] != RBRACE) |
4851 |
else if (c == ':' && string[sindex] != RBRACE) |
|
Lines 6068-6074
string_quote_removal (string, quoted)
Link Here
|
| 6068 |
|
6075 |
|
| 6069 |
r = result_string = (char *)xmalloc (slen + 1); |
6076 |
r = result_string = (char *)xmalloc (slen + 1); |
| 6070 |
|
6077 |
|
| 6071 |
for (dquote = sindex = 0; c = string[sindex];) |
6078 |
for (dquote = sindex = 0; (c = string[sindex]);) |
| 6072 |
{ |
6079 |
{ |
| 6073 |
switch (c) |
6080 |
switch (c) |
| 6074 |
{ |
6081 |
{ |
|
Lines 6498-6504
brace_expand_word_list (tlist, eflags)
Link Here
|
| 6498 |
{ |
6505 |
{ |
| 6499 |
expansions = brace_expand (tlist->word->word); |
6506 |
expansions = brace_expand (tlist->word->word); |
| 6500 |
|
6507 |
|
| 6501 |
for (eindex = 0; temp_string = expansions[eindex]; eindex++) |
6508 |
for (eindex = 0; (temp_string = expansions[eindex]); eindex++) |
| 6502 |
{ |
6509 |
{ |
| 6503 |
w = make_word (temp_string); |
6510 |
w = make_word (temp_string); |
| 6504 |
/* If brace expansion didn't change the word, preserve |
6511 |
/* If brace expansion didn't change the word, preserve |