diff --git a/src/ChangeLog b/src/ChangeLog index 46fc9befa..ef110fd37 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -5,6 +5,7 @@ handling out of get_byte. * view.c: Cleaned up the code. Added error handling for the growing buffer case. + * util.c (extension): Simplified the code. 2004-12-02 Andrew V. Samoilov diff --git a/src/util.c b/src/util.c index 1ae8096c8..baeddc50d 100644 --- a/src/util.c +++ b/src/util.c @@ -591,17 +591,8 @@ int regexp_match (const char *pattern, const char *string, int match_type) const char *extension (const char *filename) { - const char *d; - - if (!(*filename)) - return ""; - - d = filename + strlen (filename) - 1; - for (;d >= filename; d--){ - if (*d == '.') - return d+1; - } - return ""; + const char *d = strrchr (filename, '.'); + return (d != NULL) ? d + 1 : ""; } int get_int (const char *file, const char *key, int def)