- /*
- * Look for our extension
- */
- for (ptr = extensions; *ptr;)
- {
- /*
- * Is it the current extension?
- */
- if ( strncmp ( extension, extensions, len ) == 0 )
- return 1 ;
-
- /*
- * No, go find the next extension. They are separated from each other by one or more blank spaces.
- */
- ptr = strchr ( ptr + len, ' ' ) ;
-
- /*
- * If we ran off the end of the "extensions" character string, we didn't find it. Return failure.
- */
- if ( !ptr ) return 0 ;
-
- while ( *ptr == ' ' )
- ptr++ ;
+ while (1) {
+ const char *p = strstr(extensions, extension);
+ if (!p)
+ return 0; /* not found */
+ /* check that the match isn't a super string */
+ if ((p == start || p[-1] == ' ') && (p[len] == ' ' || p[len] == 0))
+ return 1;
+ /* skip the false match and continue */
+ extensions = p + len;