@@ -142,34 +142,34 @@ count_chars(const char *restrict s, const char c)
142
142
size_t
143
143
count_words (size_t * start_word , size_t * full_word )
144
144
{
145
- size_t words = 0 , w = 0 , first_non_space = 0 ;
146
- char q = 0 ;
145
+ size_t words = 0 , i = 0 , first_non_space = 0 ;
146
+ char quote = 0 ;
147
147
char * b = rl_line_buffer ;
148
148
149
- for (; b [w ]; w ++ ) {
149
+ for (; b [i ]; i ++ ) {
150
150
/* Keep track of open quotes. */
151
- if (b [w ] == '\'' || b [w ] == '"' )
152
- q = q == b [w ] ? 0 : b [w ];
151
+ if (b [i ] == '\'' || b [i ] == '"' )
152
+ quote = quote == b [i ] ? 0 : b [i ];
153
153
154
- if (! first_non_space && b [w ] != ' ' ) {
154
+ if (first_non_space == 0 && b [i ] != ' ' ) {
155
155
words = 1 ;
156
- * start_word = w ;
156
+ * start_word = i ;
157
157
first_non_space = 1 ;
158
158
continue ;
159
159
}
160
160
161
- if (w > 0 && b [w ] == ' ' && b [w - 1 ] != '\\' ) {
162
- if (!* full_word && b [w - 1 ] != '|'
163
- && b [w - 1 ] != ';' && b [w - 1 ] != '&' )
164
- * full_word = w ; /* Index of the end of the first full word (cmd). */
165
- if (b [w + 1 ] && b [w + 1 ] != ' ' )
161
+ if (i > 0 && b [i ] == ' ' && b [i - 1 ] != '\\' ) {
162
+ if (!* full_word && b [i - 1 ] != '|'
163
+ && b [i - 1 ] != ';' && b [i - 1 ] != '&' )
164
+ * full_word = i ; /* Index of the end of the first full word (cmd). */
165
+ if (b [i + 1 ] && b [i + 1 ] != ' ' )
166
166
words ++ ;
167
167
}
168
168
169
169
/* If a process separator char is found, reset variables so that we
170
170
* can start counting again for the new command. */
171
- if (! q && cur_color != hq_c && w > 0 && b [w - 1 ] != '\\'
172
- && ((b [w ] == '&' && b [w - 1 ] == '&' ) || b [w ] == '|' || b [w ] == ';' ))
171
+ if (quote == 0 && cur_color != hq_c && i > 0 && b [i - 1 ] != '\\'
172
+ && ((b [i ] == '&' && b [i - 1 ] == '&' ) || b [i ] == '|' || b [i ] == ';' ))
173
173
words = first_non_space = * full_word = 0 ;
174
174
}
175
175
@@ -227,11 +227,9 @@ xstrcasechr(char *s, char c)
227
227
228
228
const char uc = (char )TOUPPER (c );
229
229
while (* s ) {
230
- if (TOUPPER (* s ) != uc ) {
231
- s ++ ;
232
- continue ;
233
- }
234
- return s ;
230
+ if (TOUPPER (* s ) == uc )
231
+ return s ;
232
+ s ++ ;
235
233
}
236
234
237
235
return (char * )NULL ;
0 commit comments