File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -189,13 +189,20 @@ static char *file_read(const char *path, size_t *len) {
189189// MARK: -
190190
191191static bool check_line (const char * current , const char * begin_with , const char * end_with ) {
192- char * found1 = NULL ;
193- char * found2 = NULL ;
192+ // find the end of the current line
193+ if (strlen (begin_with ) > strlen (current )) return false;
194+ const char * line_end = strchr (current + strlen (begin_with ), '\n' );
195+ if (!line_end ) line_end = current + strlen (current ); // No newline, use end of string
194196
195- found1 = strstr (current , begin_with );
196- if (found1 ) found2 = strstr (current , end_with );
197+ // search for begin_with within the line
198+ const char * found1 = strstr (current , begin_with );
199+ if (!found1 || found1 > line_end ) return false;
197200
198- return ((found1 != NULL ) && (found2 != NULL ));
201+ // search for end_with after found1 but within the line
202+ const char * found2 = strstr (found1 + strlen (begin_with ), end_with );
203+ if (!found2 || found2 > line_end ) return false;
204+
205+ return true;
199206}
200207
201208static char * match_copy (const char * str , const char match ) {
You can’t perform that action at this time.
0 commit comments