From: Joel Rosdahl Date: Sun, 21 Feb 2010 20:14:51 +0000 (+0100) Subject: Add .o suffix to stored object files for consistency X-Git-Tag: v3.0pre0~67 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=694fdd67753169cae984fc5eec85d3122c7a67c4;p=thirdparty%2Fccache.git Add .o suffix to stored object files for consistency --- diff --git a/ccache.c b/ccache.c index e79fa67ce..8ef65b4bf 100644 --- a/ccache.c +++ b/ccache.c @@ -76,7 +76,7 @@ static struct file_hash *object_hash; /* * Full path to the file containing the cached object code - * (cachedir/a/b/cdef[...]-size). + * (cachedir/a/b/cdef[...]-size.o). */ static char *cached_obj; @@ -847,7 +847,7 @@ static int find_hash(ARGS *args, enum findhash_call_mode mode) } object_name = format_file_hash(object_hash); - cached_obj = get_path_in_cache(object_name, "", nlevels); + cached_obj = get_path_in_cache(object_name, ".o", nlevels); cached_stderr = get_path_in_cache(object_name, ".stderr", nlevels); cached_dep = get_path_in_cache(object_name, ".d", nlevels); x_asprintf(&stats_file, "%s/%c/stats", cache_dir, object_name[0]); diff --git a/cleanup.c b/cleanup.c index ba8914aa8..af6e9137e 100644 --- a/cleanup.c +++ b/cleanup.c @@ -51,8 +51,20 @@ static size_t object_files_threshold; static int is_object_file(const char *fname) { int i; + int len; - for (i = strlen(fname) - 1; i >= 0; i--) { + len = strlen(fname); + if (len < 2) { + return 0; + } + + /* ccache 3.0 and later: */ + if (len >= 2 && fname[len - 2] == '.' && fname[len - 1] == 'o') { + return 1; + } + + /* ccache 2.4 and earlier: */ + for (i = len - 1; i >= 0; i--) { if (fname[i] == '.') { return 0; } else if (fname[i] == '-') {