@@ -102,7 +102,7 @@ get_select_ex_ranges(struct sequence* sequ, struct command_list* select, struct
102102static int _pass_select_pat (const char * name , struct command * sc );
103103
104104int
105- pass_select (char * name , struct command * sc )
105+ pass_select (const char * name , struct command * sc )
106106 /* checks name against class (if element) and pattern that may
107107 (but need not) be contained in command sc;
108108 0: does not pass, 1: passes */
@@ -122,18 +122,12 @@ pass_select_el(struct element* el, struct command* sc)
122122{
123123 struct name_list * nl = sc -> par_names ;
124124 struct command_parameter_list * pl = sc -> par ;
125- int pos , in = 0 , any = 0 ;
126- char * class , * pattern ;
127-
128- pos = name_list_pos ("class" , nl );
125+ int pos = name_list_pos ("class" , nl );
129126 if (pos > -1 && nl -> inform [pos ]) /* parameter has been read */
130127 {
131- if (el != NULL )
132- {
133- class = pl -> parameters [pos ]-> string ;
134- in = belongs_to_class (el , class );
135- if (in == 0 ) return 0 ;
136- }
128+ char * class = pl -> parameters [pos ]-> string ;
129+ if (!belongs_to_class (el , class ))
130+ return 0 ;
137131 }
138132 return _pass_select_pat (el -> name , sc );
139133}
@@ -144,11 +138,8 @@ int pass_select_str(const char* name, struct command* sc)
144138 (but need not) be contained in command sc;
145139 considers only SELECT commands *without CLASS*!
146140 0: does not pass, 1: passes */
147- struct name_list * nl = sc -> par_names ;
148- int pos ;
149141 // if the command has CLASS attribute, it is supposed to match elements:
150- pos = name_list_pos ("class" , nl );
151- if (pos > -1 && nl -> inform [pos ]) /* parameter has been read */
142+ if (par_present ("class" , sc , NULL )) /* parameter has been read */
152143 return 0 ;
153144 return _pass_select_pat (name , sc );
154145}
@@ -158,19 +149,13 @@ int _pass_select_pat(const char* name, struct command* sc)
158149 /* used internally. */
159150 struct name_list * nl = sc -> par_names ;
160151 struct command_parameter_list * pl = sc -> par ;
161- int pos , in = 0 , any = 0 ;
162- char * pattern ;
163-
164- any = in = 0 ;
165- pos = name_list_pos ("pattern" , nl );
152+ int pos = name_list_pos ("pattern" , nl );
166153 if (pos > -1 && nl -> inform [pos ]) /* parameter has been read */
167154 {
168- any = 1 ;
169- pattern = stolower (pl -> parameters [pos ]-> string );
170- if (myregex (pattern , strip (name )) == 0 ) in = 1 ;
155+ char * pattern = stolower (pl -> parameters [pos ]-> string );
156+ return myregex (pattern , strip (name )) == 0 ;
171157 }
172- if (any == 0 ) return 1 ;
173- else return in ;
158+ return 1 ;
174159}
175160
176161int
@@ -191,13 +176,11 @@ pass_select_list_el(struct element* el, struct command_list* cl)
191176 /* Should use this function in favor of `pass_select_list` where possible. It
192177 works for all elements and is faster if knowing the element in advance. */
193178{
194- int i , ret = 0 ;
195- if (cl -> curr == 0 ) return 1 ;
196- for (i = 0 ; i < cl -> curr ; i ++ )
197- {
198- if ((ret = pass_select_el (el , cl -> commands [i ]))) break ;
179+ for (int i = 0 ; i < cl -> curr ; i ++ ) {
180+ if (pass_select_el (el , cl -> commands [i ]))
181+ return 1 ;
199182 }
200- return ret ;
183+ return cl -> curr == 0 ;
201184}
202185
203186int
0 commit comments