#ifdef HAVE_CONFIG_H # include "config.h" #endif /* HAVE_CONFIG_H */ #ifdef HAVE_LIBGEN_H # include #endif /* HAVE_LIBGEN_H */ #include #include /* extract the basename of a file */ char * tcc_basename(const char *name) { #ifdef HAVE_LIBGEN_H return (basename((char *)name)); #else char *p; p = strchr(name, 0); while (p > name && !IS_DIRSEP(p[-1])) { --p; } return (p); #endif /* HAVE_LIBGEN_H */ } /* extract extension part of a file * * (if no extension, return pointer to end-of-string) */ char * tcc_fileextension(const char *name) { const char *b; char *e; b = tcc_basename(name); e = strrchr(tcc_basename(name), '.'); if (e) { return (e); } return (strchr(b, 0)); }