2013-10-23 10:14:47 +02:00
|
|
|
--- timezone-2013g/zic.c
|
|
|
|
+++ timezone-2013g/zic.c 2013-10-14 14:23:08.450235811 +0000
|
2013-10-02 13:34:00 +02:00
|
|
|
@@ -120,7 +120,7 @@ static int addtype(zic_t gmtoff, const c
|
2012-10-29 20:13:44 +01:00
|
|
|
static void leapadd(zic_t t, int positive, int rolling, int count);
|
|
|
|
static void adjleap(void);
|
|
|
|
static void associate(void);
|
2012-08-26 11:35:33 +02:00
|
|
|
-static void dolink(const char * fromfield, const char * tofield);
|
|
|
|
+static void dolink(const char * fromfield, const char * tofield, int defaultsymlink);
|
2012-10-29 20:13:44 +01:00
|
|
|
static char ** getfields(char * buf);
|
2013-07-16 16:24:47 +02:00
|
|
|
static zic_t gethms(const char * string, const char * errstrng,
|
|
|
|
int signable);
|
2013-10-02 13:34:00 +02:00
|
|
|
@@ -575,7 +575,7 @@ _("%s: More than one -L option specified
|
2012-08-26 11:35:33 +02:00
|
|
|
*/
|
|
|
|
for (i = 0; i < nlinks; ++i) {
|
|
|
|
eat(links[i].l_filename, links[i].l_linenum);
|
|
|
|
- dolink(links[i].l_from, links[i].l_to);
|
|
|
|
+ dolink(links[i].l_from, links[i].l_to, FALSE);
|
|
|
|
if (noise)
|
|
|
|
for (j = 0; j < nlinks; ++j)
|
|
|
|
if (strcmp(links[i].l_to,
|
2013-10-23 10:14:47 +02:00
|
|
|
@@ -584,18 +584,19 @@ _("%s: More than one -L option specified
|
2012-08-26 11:35:33 +02:00
|
|
|
}
|
|
|
|
if (lcltime != NULL) {
|
|
|
|
eat("command line", 1);
|
|
|
|
- dolink(lcltime, TZDEFAULT);
|
2012-10-29 20:13:44 +01:00
|
|
|
+ dolink(lcltime, TZDEFAULT, TRUE);
|
2012-08-26 11:35:33 +02:00
|
|
|
}
|
|
|
|
if (psxrules != NULL) {
|
|
|
|
eat("command line", 1);
|
|
|
|
- dolink(psxrules, TZDEFRULES);
|
2012-10-29 20:13:44 +01:00
|
|
|
+ dolink(psxrules, TZDEFRULES, FALSE);
|
2012-08-26 11:35:33 +02:00
|
|
|
}
|
|
|
|
return (errors == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-10-29 20:13:44 +01:00
|
|
|
-dolink(const char *const fromfield, const char *const tofield)
|
|
|
|
+dolink(const char *const fromfield, const char *const tofield, int defaultsymlink)
|
2012-08-26 11:35:33 +02:00
|
|
|
{
|
2013-10-23 10:14:47 +02:00
|
|
|
+ struct stat st;
|
2012-08-26 11:35:33 +02:00
|
|
|
register char * fromname;
|
|
|
|
register char * toname;
|
2013-10-23 10:14:47 +02:00
|
|
|
|
|
|
|
@@ -606,6 +607,10 @@ dolink(const char *const fromfield, cons
|
|
|
|
fromname = ecatalloc(fromname, "/");
|
|
|
|
fromname = ecatalloc(fromname, fromfield);
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ if (lstat(fromname, &st) == 0 && S_ISLNK(st.st_mode))
|
|
|
|
+ defaultsymlink = TRUE;
|
|
|
|
+
|
|
|
|
if (tofield[0] == '/')
|
|
|
|
toname = ecpyalloc(tofield);
|
|
|
|
else {
|
|
|
|
@@ -619,15 +624,16 @@ dolink(const char *const fromfield, cons
|
2012-08-26 11:35:33 +02:00
|
|
|
*/
|
|
|
|
if (!itsdir(toname))
|
|
|
|
(void) remove(toname);
|
2013-10-02 13:34:00 +02:00
|
|
|
- if (link(fromname, toname) != 0
|
|
|
|
+ if (defaultsymlink || link(fromname, toname) != 0
|
|
|
|
&& access(fromname, F_OK) == 0 && !itsdir(fromname)) {
|
2012-08-26 11:35:33 +02:00
|
|
|
int result;
|
|
|
|
|
|
|
|
if (mkdirs(toname) != 0)
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
|
|
|
- result = link(fromname, toname);
|
2013-10-02 13:34:00 +02:00
|
|
|
- if (result != 0) {
|
|
|
|
+ if (!defaultsymlink) result = link(fromname, toname);
|
|
|
|
+
|
|
|
|
+ if ((defaultsymlink || (!defaultsymlink && result != 0))) {
|
2013-10-23 10:14:47 +02:00
|
|
|
const char *s = fromname;
|
2013-10-02 13:34:00 +02:00
|
|
|
const char *t;
|
|
|
|
register char * symlinkcontents = NULL;
|