diff options
author | peter <peter@FreeBSD.org> | 1999-03-18 09:21:42 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1999-03-18 09:21:42 +0000 |
commit | 308b60f66831aa65a459a7b347ea6ca14b6e4799 (patch) | |
tree | 1b2cd3bad90a2dd8ccb449f73ddfb9e295c0737d /contrib/cvs/src/filesubr.c | |
parent | 0c111e2b51cac7eead56494b30c5977e4ec9a8ea (diff) | |
download | FreeBSD-src-308b60f66831aa65a459a7b347ea6ca14b6e4799.zip FreeBSD-src-308b60f66831aa65a459a7b347ea6ca14b6e4799.tar.gz |
Import cvs-1.10 onto vendor branch. Merge to follow shortly.
Obtained from: cyclic.com
Diffstat (limited to 'contrib/cvs/src/filesubr.c')
-rw-r--r-- | contrib/cvs/src/filesubr.c | 42 |
1 files changed, 12 insertions, 30 deletions
diff --git a/contrib/cvs/src/filesubr.c b/contrib/cvs/src/filesubr.c index 0ccc3df..1c24b2f 100644 --- a/contrib/cvs/src/filesubr.c +++ b/contrib/cvs/src/filesubr.c @@ -415,29 +415,6 @@ rename_file (from, to) } /* - * link a file, if possible. Warning: the Windows NT version of this - * function just copies the file, so only use this function in ways - * that can deal with either a link or a copy. - */ -int -link_file (from, to) - const char *from; - const char *to; -{ - if (trace) -#ifdef SERVER_SUPPORT - (void) fprintf (stderr, "%c-> link(%s,%s)\n", - (server_active) ? 'S' : ' ', from, to); -#else - (void) fprintf (stderr, "-> link(%s,%s)\n", from, to); -#endif - if (noexec) - return (0); - - return (link (from, to)); -} - -/* * unlink a file, if possible. */ int @@ -770,7 +747,9 @@ xreadlink (link) const char *link; { char *file = NULL; - int buflen = BUFSIZ; + char *tfile; + int buflen = 128; + int link_name_len; if (!islink (link)) return NULL; @@ -781,18 +760,21 @@ xreadlink (link) do { file = xrealloc (file, buflen); - errno = 0; - readlink (link, file, buflen); + link_name_len = readlink (link, file, buflen - 1); buflen *= 2; } - while (errno == ENAMETOOLONG); + while (link_name_len < 0 && errno == ENAMETOOLONG); - if (errno) + if (link_name_len < 0) error (1, errno, "cannot readlink %s", link); - return file; -} + file[link_name_len] = '\0'; + tfile = xstrdup (file); + free (file); + + return tfile; +} /* Return a pointer into PATH's last component. */ |