]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
- avoid using basename() to fix systems with that already defined
authorAndrew Tridgell <tridge@samba.org>
Thu, 25 Sep 2003 06:11:28 +0000 (08:11 +0200)
committerAndrew Tridgell <tridge@samba.org>
Thu, 25 Sep 2003 06:11:28 +0000 (08:11 +0200)
- add EINTR handling in lock_fd()

- make sure we prototype asprintf on systems that don't have it

ccache.c
ccache.h
cleanup.c
execute.c
util.c

index c4d3f695b7fa95f116c5d3a694ac2d2ee29b2f72..03e205e817f7ed7fb55c9ca8bb478bce2eac4993 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -335,7 +335,7 @@ static void find_hash(ARGS *args)
           limit the basename to 10
           characters in order to cope with filesystem with small
           maximum filename length limits */
-       input_base = basename(input_file);
+       input_base = str_basename(input_file);
        tmp = strchr(input_base, '.');
        if (tmp != NULL) {
                *tmp = 0;
@@ -547,7 +547,7 @@ static void find_compiler(int argc, char **argv)
 
        orig_args = args_init(argc, argv);
 
-       base = basename(argv[0]);
+       base = str_basename(argv[0]);
 
        /* we might be being invoked like "ccache gcc -c foo.c" */
        if (strcmp(base, MYNAME) == 0) {
@@ -557,7 +557,7 @@ static void find_compiler(int argc, char **argv)
                        /* a full path was given */
                        return;
                }
-               base = basename(argv[1]);
+               base = str_basename(argv[1]);
        }
 
        /* support user override of the compiler */
index 6eddf768c0e3e79bb7e2c0a4729e040e8ef665eb..20038a45a308b10ebfcc565fd356f584bb6a4a74 100644 (file)
--- a/ccache.h
+++ b/ccache.h
@@ -83,7 +83,7 @@ char *x_strdup(const char *s);
 void *x_realloc(void *ptr, size_t size);
 void *x_malloc(size_t size);
 void traverse(const char *dir, void (*fn)(const char *, struct stat *));
-char *basename(const char *s);
+char *str_basename(const char *s);
 char *dirname(char *s);
 int lock_fd(int fd);
 size_t file_size(struct stat *st);
@@ -107,6 +107,9 @@ int unify_hash(const char *fname);
 #ifndef HAVE_VASPRINTF
 int vasprintf(char **, const char *, va_list );
 #endif
+#ifndef HAVE_ASPRINTF
+int asprintf(char **ptr, const char *format, ...);
+#endif
 
 #ifndef HAVE_SNPRINTF
 int snprintf(char *,size_t ,const char *, ...);
index 1e886427b7fdd36f6af181f9d84421186f9bd296..99312283ebccf1df1ed581e88b01605795eb21b7 100644 (file)
--- a/cleanup.c
+++ b/cleanup.c
@@ -52,7 +52,7 @@ static void traverse_fn(const char *fname, struct stat *st)
 
        if (!S_ISREG(st->st_mode)) return;
 
-       p = basename(fname);
+       p = str_basename(fname);
        if (strcmp(p, "stats") == 0) {
                free(p);
                return;
@@ -165,7 +165,7 @@ static void wipe_fn(const char *fname, struct stat *st)
 
        if (!S_ISREG(st->st_mode)) return;
 
-       p = basename(fname);
+       p = str_basename(fname);
        if (strcmp(p, "stats") == 0) {
                free(p);
                return;
index 97a29c1a7f1fb7136afb0051faa174753464b0d7..f55fbdda54f65923c489dc9c082b3b26a819c1bf 100644 (file)
--- a/execute.c
+++ b/execute.c
@@ -102,7 +102,7 @@ char *find_executable(const char *name, const char *exclude_name)
                        if (S_ISLNK(st1.st_mode)) {
                                char *buf = x_realpath(fname);
                                if (buf) {
-                                       char *p = basename(buf);
+                                       char *p = str_basename(buf);
                                        if (strcmp(p, exclude_name) == 0) {
                                                /* its a link to "ccache" ! */
                                                free(p);
diff --git a/util.c b/util.c
index b5661bb77cb6076ff7cb24202bd94583305fe9b2..6bab50d91007787730e052866fcd0a112603d578 100644 (file)
--- a/util.c
+++ b/util.c
@@ -242,7 +242,7 @@ void traverse(const char *dir, void (*fn)(const char *, struct stat *))
 
 
 /* return the base name of a file - caller frees */
-char *basename(const char *s)
+char *str_basename(const char *s)
 {
        char *p = strrchr(s, '/');
        if (p) {
@@ -267,6 +267,7 @@ char *dirname(char *s)
 int lock_fd(int fd)
 {
        struct flock fl;
+       int ret;
 
        fl.l_type = F_WRLCK;
        fl.l_whence = SEEK_SET;
@@ -274,7 +275,12 @@ int lock_fd(int fd)
        fl.l_len = 1;
        fl.l_pid = 0;
 
-       return fcntl(fd, F_SETLKW, &fl);
+       /* not sure why we would be getting a signal here,
+          but one user claimed it is possible */
+       do {
+               ret = fcntl(fd, F_SETLKW, &fl);
+       } while (ret == -1 && errno == EINTR);
+       return ret;
 }
 
 /* return size on disk of a file */