Skip to content

Commit

Permalink
Simplified str_ends_in
Browse files Browse the repository at this point in the history
  • Loading branch information
sol-prog committed Jun 10, 2019
1 parent 1b36677 commit 4e8127d
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions utils.h
Expand Up @@ -16,8 +16,6 @@ do { \

// Check if a string "str" ends with a substring "ends"
static inline bool str_ends_in(const char *str, const char *ends) {
size_t str_len = strlen(str);
size_t ends_len = strlen(ends);
char *pos = strstr(str, ends);
return (pos != NULL) && (pos + ends_len == str + str_len);
char *pos = strrchr(str, '.');
return !strcmp(pos, ends);
}

0 comments on commit 4e8127d

Please sign in to comment.