1 /* histexpand.c -- history expansion. */
3 /* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
5 This file contains the GNU History Library (the Library), a set of
6 routines for managing the text of previously typed lines.
8 The Library is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 1, or (at your option)
13 The Library is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 The GNU General Public License is often shipped with GNU software, and
19 is generally kept in a file called COPYING or LICENSE. If you do not
20 have a copy of the license, write to the Free Software Foundation,
21 675 Mass Ave, Cambridge, MA 02139, USA. */
23 #define READLINE_LIBRARY
25 #if defined (HAVE_CONFIG_H)
31 #if defined (HAVE_STDLIB_H)
34 # include "ansi_stdlib.h"
35 #endif /* HAVE_STDLIB_H */
37 #if defined (HAVE_UNISTD_H)
41 #if defined (HAVE_STRING_H)
45 #endif /* !HAVE_STRING_H */
50 static char error_pointer;
52 static char *subst_lhs;
53 static char *subst_rhs;
54 static int subst_lhs_len;
55 static int subst_rhs_len;
57 static char *get_history_word_specifier ();
58 static char *history_find_word ();
60 extern int history_offset;
62 extern char *single_quote ();
63 static char *quote_breaks ();
65 extern char *xmalloc (), *xrealloc ();
67 /* Variables exported by this file. */
68 /* The character that represents the start of a history expansion
69 request. This is usually `!'. */
70 char history_expansion_char = '!';
72 /* The character that invokes word substitution if found at the start of
73 a line. This is usually `^'. */
74 char history_subst_char = '^';
76 /* During tokenization, if this character is seen as the first character
77 of a word, then it, and all subsequent characters upto a newline are
78 ignored. For a Bourne shell, this should be '#'. Bash special cases
79 the interactive comment character to not be a comment delimiter. */
80 char history_comment_char = '\0';
82 /* The list of characters which inhibit the expansion of text if found
83 immediately following history_expansion_char. */
84 char *history_no_expand_chars = " \t\n\r=";
86 /* If set to a non-zero value, single quotes inhibit history expansion.
88 int history_quotes_inhibit_expansion = 0;
90 /* If set, this points to a function that is called to verify that a
91 particular history expansion should be performed. */
92 Function *history_inhibit_expansion_function;
94 /* **************************************************************** */
96 /* History Expansion */
98 /* **************************************************************** */
100 /* Hairy history expansion on text, not tokens. This is of general
101 use, and thus belongs in this library. */
103 /* The last string searched for by a !?string? search. */
104 static char *search_string;
106 /* The last string matched by a !?string? search. */
107 static char *search_match;
109 /* Return the event specified at TEXT + OFFSET modifying OFFSET to
110 point to after the event specifier. Just a pointer to the history
111 line is returned; NULL is returned in the event of a bad specifier.
112 You pass STRING with *INDEX equal to the history_expansion_char that
113 begins this specification.
114 DELIMITING_QUOTE is a character that is allowed to end the string
115 specification for what to search for in addition to the normal
116 characters `:', ` ', `\t', `\n', and sometimes `?'.
117 So you might call this function like:
118 line = get_history_event ("!echo:p", &index, 0); */
120 get_history_event (string, caller_index, delimiting_quote)
123 int delimiting_quote;
128 int which, sign, local_index, substring_okay;
129 Function *search_func;
132 /* The event can be specified in a number of ways.
134 !! the previous command
136 !-n current command-line minus N
137 !str the most recent command starting with STR
139 the most recent command containing STR
141 All values N are determined via HISTORY_BASE. */
145 if (string[i] != history_expansion_char)
146 return ((char *)NULL);
148 /* Move on to the specification. */
154 #define RETURN_ENTRY(e, w) \
155 return ((e = history_get (w)) ? e->line : (char *)NULL)
157 /* Handle !! case. */
158 if (string[i] == history_expansion_char)
161 which = history_base + (history_length - 1);
163 RETURN_ENTRY (entry, which);
166 /* Hack case of numeric line specification. */
167 if (string[i] == '-')
173 if (_rl_digit_p (string[i]))
175 /* Get the extent of the digits and compute the value. */
176 for (which = 0; _rl_digit_p (string[i]); i++)
177 which = (which * 10) + _rl_digit_value (string[i]);
182 which = (history_length + history_base) - which;
184 RETURN_ENTRY (entry, which);
187 /* This must be something to search for. If the spec begins with
188 a '?', then the string may be anywhere on the line. Otherwise,
189 the string must be found at the start of a line. */
190 if (string[i] == '?')
196 /* Only a closing `?' or a newline delimit a substring search string. */
197 for (local_index = i; c = string[i]; i++)
198 if ((!substring_okay && (whitespace (c) || c == ':' ||
199 (history_search_delimiter_chars && member (c, history_search_delimiter_chars)) ||
200 string[i] == delimiting_quote)) ||
202 (substring_okay && string[i] == '?'))
205 which = i - local_index;
206 temp = xmalloc (1 + which);
208 strncpy (temp, string + local_index, which);
211 if (substring_okay && string[i] == '?')
216 #define FAIL_SEARCH() \
218 history_offset = history_length; free (temp) ; return (char *)NULL; \
221 /* If there is no search string, try to use the previous search string,
222 if one exists. If not, fail immediately. */
223 if (*temp == '\0' && substring_okay)
228 temp = savestring (search_string);
234 search_func = substring_okay ? history_search : history_search_prefix;
237 local_index = (*search_func) (temp, -1);
242 if (local_index == 0 || substring_okay)
244 entry = current_history ();
245 history_offset = history_length;
247 /* If this was a substring search, then remember the
248 string that we matched for word substitution. */
251 FREE (search_string);
252 search_string = temp;
255 search_match = history_find_word (entry->line, local_index);
260 return (entry->line);
272 /* Function for extracting single-quoted strings. Used for inhibiting
273 history expansion within single quotes. */
275 /* Extract the contents of STRING as if it is enclosed in single quotes.
276 SINDEX, when passed in, is the offset of the character immediately
277 following the opening single quote; on exit, SINDEX is left pointing
278 to the closing single quote. */
280 hist_string_extract_single_quoted (string, sindex)
286 for (i = *sindex; string[i] && string[i] != '\''; i++)
296 register char *p, *r;
300 for (p = s; p && *p; p++, len++)
304 else if (whitespace (*p) || *p == '\n')
308 r = ret = xmalloc (len);
310 for (p = s; p && *p; )
320 else if (whitespace (*p) || *p == '\n')
335 hist_error(s, start, current, errtype)
337 int start, current, errtype;
342 ll = current - start;
346 case EVENT_NOT_FOUND:
347 emsg = "event not found";
351 emsg = "bad word specifier";
355 emsg = "substitution failed";
359 emsg = "unrecognized history modifier";
363 emsg = "unknown expansion error";
368 temp = xmalloc (ll + elen + 3);
369 strncpy (temp, s + start, ll);
372 strcpy (temp + ll + 2, emsg);
376 /* Get a history substitution string from STR starting at *IPTR
377 and return it. The length is returned in LENPTR.
379 A backslash can quote the delimiter. If the string is the
380 empty string, the previous pattern is used. If there is
381 no previous pattern for the lhs, the last history search
384 If IS_RHS is 1, we ignore empty strings and set the pattern
385 to "" anyway. subst_lhs is not changed if the lhs is empty;
386 subst_rhs is allowed to be set to the empty string. */
389 get_subst_pattern (str, iptr, delimiter, is_rhs, lenptr)
391 int *iptr, delimiter, is_rhs, *lenptr;
393 register int si, i, j, k;
394 char *s = (char *) NULL;
398 for (si = i; str[si] && str[si] != delimiter; si++)
399 if (str[si] == '\\' && str[si + 1] == delimiter)
402 if (si > i || is_rhs)
404 s = xmalloc (si - i + 1);
405 for (j = 0, k = i; k < si; j++, k++)
407 /* Remove a backslash quoting the search string delimiter. */
408 if (str[k] == '\\' && str[k + 1] == delimiter)
426 postproc_subst_rhs ()
431 new = xmalloc (new_size = subst_rhs_len + subst_lhs_len);
432 for (i = j = 0; i < subst_rhs_len; i++)
434 if (subst_rhs[i] == '&')
436 if (j + subst_lhs_len >= new_size)
437 new = xrealloc (new, (new_size = new_size * 2 + subst_lhs_len));
438 strcpy (new + j, subst_lhs);
443 /* a single backslash protects the `&' from lhs interpolation */
444 if (subst_rhs[i] == '\\' && subst_rhs[i + 1] == '&')
447 new = xrealloc (new, new_size *= 2);
448 new[j++] = subst_rhs[i];
457 /* Expand the bulk of a history specifier starting at STRING[START].
458 Returns 0 if everything is OK, -1 if an error occurred, and 1
459 if the `p' modifier was supplied and the caller should just print
460 the returned string. Returns the new index into string in
461 *END_INDEX_PTR, and the expanded specifier in *RET_STRING. */
463 history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
465 int start, *end_index_ptr;
467 char *current_line; /* for !# */
469 int i, n, starting_index;
470 int substitute_globally, want_quotes, print_only;
471 char *event, *temp, *result, *tstr, *t, c, *word_spec;
474 result = xmalloc (result_len = 128);
478 /* If it is followed by something that starts a word specifier,
479 then !! is implied as the event specifier. */
481 if (member (string[i + 1], ":$*%^"))
486 fake_s[0] = fake_s[1] = history_expansion_char;
488 event = get_history_event (fake_s, &fake_i, 0);
490 else if (string[i + 1] == '#')
493 event = current_line;
497 int quoted_search_delimiter = 0;
499 /* If the character before this `!' is a double or single
500 quote, then this expansion takes place inside of the
501 quoted string. If we have to search for some text ("!foo"),
502 allow the delimiter to end the search string. */
503 if (i && (string[i - 1] == '\'' || string[i - 1] == '"'))
504 quoted_search_delimiter = string[i - 1];
505 event = get_history_event (string, &i, quoted_search_delimiter);
510 *ret_string = hist_error (string, start, i, EVENT_NOT_FOUND);
515 /* If a word specifier is found, then do what that requires. */
517 word_spec = get_history_word_specifier (string, event, &i);
519 /* There is no such thing as a `malformed word specifier'. However,
520 it is possible for a specifier that has no match. In that case,
522 if (word_spec == (char *)&error_pointer)
524 *ret_string = hist_error (string, starting_index, i, BAD_WORD_SPEC);
529 /* If no word specifier, than the thing of interest was the event. */
530 temp = word_spec ? savestring (word_spec) : savestring (event);
533 /* Perhaps there are other modifiers involved. Do what they say. */
534 want_quotes = substitute_globally = print_only = 0;
537 while (string[i] == ':')
543 substitute_globally = 1;
551 *ret_string = hist_error (string, i+1, i+2, BAD_MODIFIER);
564 /* :p means make this the last executed line. So we
565 return an error state after adding this line to the
571 /* :t discards all but the last part of the pathname. */
573 tstr = strrchr (temp, '/');
577 t = savestring (tstr);
583 /* :h discards the last part of a pathname. */
585 tstr = strrchr (temp, '/');
590 /* :r discards the suffix. */
592 tstr = strrchr (temp, '.');
597 /* :e discards everything but the suffix. */
599 tstr = strrchr (temp, '.');
602 t = savestring (tstr);
608 /* :s/this/that substitutes `that' for the first
609 occurrence of `this'. :gs/this/that substitutes `that'
610 for each occurrence of `this'. :& repeats the last
611 substitution. :g& repeats the last substitution
618 int delimiter, failed, si, l_temp;
622 if (i + 2 < (int)strlen (string))
623 delimiter = string[i + 2];
625 break; /* no search delimiter */
629 t = get_subst_pattern (string, &i, delimiter, 0, &subst_lhs_len);
630 /* An empty substitution lhs with no previous substitution
631 uses the last search string as the lhs. */
639 if (search_string && *search_string)
641 subst_lhs = savestring (search_string);
642 subst_lhs_len = strlen (subst_lhs);
646 subst_lhs = (char *) NULL;
651 /* If there is no lhs, the substitution can't succeed. */
652 if (subst_lhs_len == 0)
654 *ret_string = hist_error (string, starting_index, i, SUBST_FAILED);
661 subst_rhs = get_subst_pattern (string, &i, delimiter, 1, &subst_rhs_len);
663 /* If `&' appears in the rhs, it's supposed to be replaced
665 if (member ('&', subst_rhs))
666 postproc_subst_rhs ();
671 l_temp = strlen (temp);
672 /* Ignore impossible cases. */
673 if (subst_lhs_len > l_temp)
675 *ret_string = hist_error (string, starting_index, i, SUBST_FAILED);
681 /* Find the first occurrence of THIS in TEMP. */
683 for (failed = 1; (si + subst_lhs_len) <= l_temp; si++)
684 if (STREQN (temp+si, subst_lhs, subst_lhs_len))
686 int len = subst_rhs_len - subst_lhs_len + l_temp;
687 new_event = xmalloc (1 + len);
688 strncpy (new_event, temp, si);
689 strncpy (new_event + si, subst_rhs, subst_rhs_len);
690 strncpy (new_event + si + subst_rhs_len,
691 temp + si + subst_lhs_len,
692 l_temp - (si + subst_lhs_len));
693 new_event[len] = '\0';
699 if (substitute_globally)
702 l_temp = strlen (temp);
703 substitute_globally++;
710 if (substitute_globally > 1)
712 substitute_globally = 0;
713 continue; /* don't want to increment i */
717 continue; /* don't want to increment i */
719 *ret_string = hist_error (string, starting_index, i, SUBST_FAILED);
727 /* Done with modfiers. */
728 /* Believe it or not, we have to back the pointer up by one. */
735 if (want_quotes == 'q')
736 x = single_quote (temp);
737 else if (want_quotes == 'x')
738 x = quote_breaks (temp);
740 x = savestring (temp);
748 result = xrealloc (result, n + 2);
749 strcpy (result, temp);
753 *ret_string = result;
757 /* Expand the string STRING, placing the result into OUTPUT, a pointer
758 to a string. Returns:
760 -1) If there was an error in expansion.
761 0) If no expansions took place (or, if the only change in
762 the text was the de-slashifying of the history expansion
764 1) If expansions did take place
765 2) If the `p' modifier was given and the caller should print the result
767 If an error ocurred in expansion, then OUTPUT contains a descriptive
770 #define ADD_STRING(s) \
773 int sl = strlen (s); \
775 if (j >= result_len) \
777 while (j >= result_len) \
779 result = xrealloc (result, result_len); \
781 strcpy (result + j - sl, s); \
785 #define ADD_CHAR(c) \
788 if (j >= result_len - 1) \
789 result = xrealloc (result, result_len += 64); \
796 history_expand (hstring, output)
801 int i, r, l, passc, cc, modified, eindex, only_printing;
804 /* The output string, and its length. */
808 /* Used when adding the string. */
811 /* Setting the history expansion character to 0 inhibits all
812 history expansion. */
813 if (history_expansion_char == 0)
815 *output = savestring (hstring);
819 /* Prepare the buffer for printing error messages. */
820 result = xmalloc (result_len = 256);
823 only_printing = modified = 0;
824 l = strlen (hstring);
826 /* Grovel the string. Only backslash can quote the history escape
827 character. We also handle arg specifiers. */
829 /* Before we grovel forever, see if the history_expansion_char appears
830 anywhere within the text. */
832 /* The quick substitution character is a history expansion all right. That
833 is to say, "^this^that^" is equivalent to "!!:s^this^that^", and in fact,
834 that is the substitution that we do. */
835 if (hstring[0] == history_subst_char)
837 string = xmalloc (l + 5);
839 string[0] = string[1] = history_expansion_char;
842 strcpy (string + 4, hstring);
848 /* If not quick substitution, still maybe have to do expansion. */
850 /* `!' followed by one of the characters in history_no_expand_chars
851 is NOT an expansion. */
852 for (i = 0; string[i]; i++)
855 if (string[i] == history_expansion_char)
857 if (!cc || member (cc, history_no_expand_chars))
859 /* If the calling application has set
860 history_inhibit_expansion_function to a function that checks
861 for special cases that should not be history expanded,
862 call the function and skip the expansion if it returns a
864 else if (history_inhibit_expansion_function &&
865 (*history_inhibit_expansion_function) (string, i))
870 else if (history_quotes_inhibit_expansion && string[i] == '\'')
872 /* If this is bash, single quotes inhibit history expansion. */
874 hist_string_extract_single_quoted (string, &i);
876 else if (history_quotes_inhibit_expansion && string[i] == '\\')
878 /* If this is bash, allow backslashes to quote single
879 quotes and the history expansion character. */
880 if (cc == '\'' || cc == history_expansion_char)
885 if (string[i] != history_expansion_char)
888 *output = savestring (string);
893 /* Extract and perform the substitution. */
894 for (passc = i = j = 0; i < l; i++)
896 int tchar = string[i];
905 if (tchar == history_expansion_char)
911 ADD_CHAR (string[i]);
921 /* If history_quotes_inhibit_expansion is set, single quotes
922 inhibit history expansion. */
923 if (history_quotes_inhibit_expansion)
928 hist_string_extract_single_quoted (string, &i);
930 slen = i - quote + 2;
931 temp = xmalloc (slen);
932 strncpy (temp, string + quote, slen);
933 temp[slen - 1] = '\0';
938 ADD_CHAR (string[i]);
942 case -3: /* history_expansion_char */
945 /* If the history_expansion_char is followed by one of the
946 characters in history_no_expand_chars, then it is not a
947 candidate for expansion of any kind. */
948 if (member (cc, history_no_expand_chars))
950 ADD_CHAR (string[i]);
954 #if defined (NO_BANG_HASH_MODIFIERS)
955 /* There is something that is listed as a `word specifier' in csh
956 documentation which means `the expanded text to this point'.
957 That is not a word specifier, it is an event specifier. If we
958 don't want to allow modifiers with `!#', just stick the current
959 output line in again. */
964 temp = xmalloc (1 + strlen (result));
965 strcpy (temp, result);
974 r = history_expand_internal (string, i, &eindex, &temp, result);
979 if (string != hstring)
992 only_printing = r == 1;
1000 if (string != hstring)
1005 add_history (result);
1009 return (modified != 0);
1012 /* Return a consed string which is the word specified in SPEC, and found
1013 in FROM. NULL is returned if there is no spec. The address of
1014 ERROR_POINTER is returned if the word specified cannot be found.
1015 CALLER_INDEX is the offset in SPEC to start looking; it is updated
1016 to point to just after the last character parsed. */
1018 get_history_word_specifier (spec, from, caller_index)
1022 register int i = *caller_index;
1024 int expecting_word_spec = 0;
1027 /* The range of words to return doesn't exist yet. */
1029 result = (char *)NULL;
1031 /* If we found a colon, then this *must* be a word specification. If
1032 it isn't, then it is an error. */
1036 expecting_word_spec++;
1039 /* Handle special cases first. */
1041 /* `%' is the word last searched for. */
1044 *caller_index = i + 1;
1045 return (search_match ? savestring (search_match) : savestring (""));
1048 /* `*' matches all of the arguments, but not the command. */
1051 *caller_index = i + 1;
1052 result = history_arg_extract (1, '$', from);
1053 return (result ? result : savestring (""));
1056 /* `$' is last arg. */
1059 *caller_index = i + 1;
1060 return (history_arg_extract ('$', '$', from));
1063 /* Try to get FIRST and LAST figured out. */
1067 else if (spec[i] == '^')
1069 else if (_rl_digit_p (spec[i]) && expecting_word_spec)
1071 for (first = 0; _rl_digit_p (spec[i]); i++)
1072 first = (first * 10) + _rl_digit_value (spec[i]);
1075 return ((char *)NULL); /* no valid `first' for word specifier */
1077 if (spec[i] == '^' || spec[i] == '*')
1079 last = (spec[i] == '^') ? 1 : '$'; /* x* abbreviates x-$ */
1082 else if (spec[i] != '-')
1088 if (_rl_digit_p (spec[i]))
1090 for (last = 0; _rl_digit_p (spec[i]); i++)
1091 last = (last * 10) + _rl_digit_value (spec[i]);
1093 else if (spec[i] == '$')
1098 else if (!spec[i] || spec[i] == ':') /* could be modifier separator */
1099 last = -1; /* x- abbreviates x-$ omitting word `$' */
1104 if (last >= first || last == '$' || last < 0)
1105 result = history_arg_extract (first, last, from);
1107 return (result ? result : (char *)&error_pointer);
1110 /* Extract the args specified, starting at FIRST, and ending at LAST.
1111 The args are taken from STRING. If either FIRST or LAST is < 0,
1112 then make that arg count from the right (subtract from the number of
1113 tokens, so that FIRST = -1 means the next to last token on the line).
1114 If LAST is `$' the last arg from STRING is used. */
1116 history_arg_extract (first, last, string)
1120 register int i, len;
1125 /* XXX - think about making history_tokenize return a struct array,
1126 each struct in array being a string and a length to avoid the
1127 calls to strlen below. */
1128 if ((list = history_tokenize (string)) == NULL)
1129 return ((char *)NULL);
1131 for (len = 0; list[len]; len++)
1135 last = len + last - 1;
1138 first = len + first - 1;
1148 if (first >= len || last > len || first < 0 || last < 0 || first > last)
1149 result = ((char *)NULL);
1152 for (size = 0, i = first; i < last; i++)
1153 size += strlen (list[i]) + 1;
1154 result = xmalloc (size + 1);
1157 for (i = first, offset = 0; i < last; i++)
1159 strcpy (result + offset, list[i]);
1160 offset += strlen (list[i]);
1163 result[offset++] = ' ';
1169 for (i = 0; i < len; i++)
1176 #define slashify_in_quotes "\\`\"$"
1178 /* Parse STRING into tokens and return an array of strings. If WIND is
1179 not -1 and INDP is not null, we also want the word surrounding index
1180 WIND. The position in the returned array of strings is returned in
1183 history_tokenize_internal (string, wind, indp)
1188 register int i, start, result_index, size;
1191 /* Get a token, and stuff it into RESULT. The tokens are split
1192 exactly where the shell would split them. */
1193 for (i = result_index = size = 0, result = (char **)NULL; string[i]; )
1197 /* Skip leading whitespace. */
1198 for (; string[i] && whitespace (string[i]); i++)
1200 if (string[i] == 0 || string[i] == history_comment_char)
1205 if (member (string[i], "()\n"))
1211 if (member (string[i], "<>;&|$"))
1213 int peek = string[i + 1];
1215 if (peek == string[i] && peek != '$')
1217 if (peek == '<' && string[i + 2] == '-')
1224 if ((peek == '&' && (string[i] == '>' || string[i] == '<')) ||
1225 ((peek == '>') && (string[i] == '&')) ||
1226 ((peek == '(') && (string[i] == '$')))
1232 if (string[i] != '$')
1239 /* Get word from string + i; */
1241 if (member (string[i], "\"'`"))
1242 delimiter = string[i++];
1244 for (; string[i]; i++)
1246 if (string[i] == '\\' && string[i + 1] == '\n')
1252 if (string[i] == '\\' && delimiter != '\'' &&
1253 (delimiter != '"' || member (string[i], slashify_in_quotes)))
1259 if (delimiter && string[i] == delimiter)
1265 if (!delimiter && (member (string[i], " \t\n;&()|<>")))
1268 if (!delimiter && member (string[i], "\"'`"))
1269 delimiter = string[i];
1274 /* If we are looking for the word in which the character at a
1275 particular index falls, remember it. */
1276 if (indp && wind != -1 && wind >= start && wind < i)
1277 *indp = result_index;
1280 if (result_index + 2 >= size)
1281 result = (char **)xrealloc (result, ((size += 10) * sizeof (char *)));
1282 result[result_index] = xmalloc (1 + len);
1283 strncpy (result[result_index], string + start, len);
1284 result[result_index][len] = '\0';
1285 result[++result_index] = (char *)NULL;
1291 /* Return an array of tokens, much as the shell might. The tokens are
1292 parsed out of STRING. */
1294 history_tokenize (string)
1297 return (history_tokenize_internal (string, -1, (int *)NULL));
1300 /* Find and return the word which contains the character at index IND
1301 in the history line LINE. Used to save the word matched by the
1302 last history !?string? search. */
1304 history_find_word (line, ind)
1311 words = history_tokenize_internal (line, ind, &wind);
1313 return ((char *)NULL);
1315 for (i = 0; i < wind; i++)
1317 for (i = wind + 1; words[i]; i++)