|
@@ -908,8 +908,6 @@ chdir_count (void)
|
|
int
|
|
int
|
|
chdir_arg (char const *dir)
|
|
chdir_arg (char const *dir)
|
|
{
|
|
{
|
|
- char *absdir;
|
|
|
|
-
|
|
|
|
if (wd_count == wd_alloc)
|
|
if (wd_count == wd_alloc)
|
|
{
|
|
{
|
|
if (wd_alloc == 0)
|
|
if (wd_alloc == 0)
|
|
@@ -919,9 +917,7 @@ chdir_arg (char const *dir)
|
|
if (! wd_count)
|
|
if (! wd_count)
|
|
{
|
|
{
|
|
wd[wd_count].name = ".";
|
|
wd[wd_count].name = ".";
|
|
- wd[wd_count].abspath = xgetcwd ();
|
|
|
|
- if (!wd[wd_count].abspath)
|
|
|
|
- call_arg_fatal ("getcwd", ".");
|
|
|
|
|
|
+ wd[wd_count].abspath = NULL;
|
|
wd[wd_count].fd = AT_FDCWD;
|
|
wd[wd_count].fd = AT_FDCWD;
|
|
wd_count++;
|
|
wd_count++;
|
|
}
|
|
}
|
|
@@ -938,22 +934,8 @@ chdir_arg (char const *dir)
|
|
return wd_count - 1;
|
|
return wd_count - 1;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
- /* If the given name is absolute, use it to represent this directory;
|
|
|
|
- otherwise, construct a name based on the previous -C option. */
|
|
|
|
- if (IS_ABSOLUTE_FILE_NAME (dir))
|
|
|
|
- absdir = xstrdup (dir);
|
|
|
|
- else if (wd[wd_count - 1].abspath)
|
|
|
|
- {
|
|
|
|
- namebuf_t nbuf = namebuf_create (wd[wd_count - 1].abspath);
|
|
|
|
- namebuf_add_dir (nbuf, dir);
|
|
|
|
- absdir = namebuf_finish (nbuf);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- absdir = 0;
|
|
|
|
-
|
|
|
|
wd[wd_count].name = dir;
|
|
wd[wd_count].name = dir;
|
|
- wd[wd_count].abspath = absdir;
|
|
|
|
|
|
+ wd[wd_count].abspath = NULL;
|
|
wd[wd_count].fd = 0;
|
|
wd[wd_count].fd = 0;
|
|
return wd_count++;
|
|
return wd_count++;
|
|
}
|
|
}
|
|
@@ -1054,6 +1036,40 @@ tar_getcdpath (int idx)
|
|
}
|
|
}
|
|
return cwd;
|
|
return cwd;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (!wd[idx].abspath)
|
|
|
|
+ {
|
|
|
|
+ int i;
|
|
|
|
+ int save_cwdi = chdir_current;
|
|
|
|
+
|
|
|
|
+ for (i = idx; i >= 0; i--)
|
|
|
|
+ if (wd[i].abspath)
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ while (++i <= idx)
|
|
|
|
+ {
|
|
|
|
+ chdir_do (i);
|
|
|
|
+ if (i == 0)
|
|
|
|
+ {
|
|
|
|
+ if ((wd[i].abspath = xgetcwd ()) == NULL)
|
|
|
|
+ call_arg_fatal ("getcwd", ".");
|
|
|
|
+ }
|
|
|
|
+ else if (IS_ABSOLUTE_FILE_NAME (wd[i].name))
|
|
|
|
+ /* If the given name is absolute, use it to represent this
|
|
|
|
+ directory; otherwise, construct a name based on the
|
|
|
|
+ previous -C option. */
|
|
|
|
+ wd[i].abspath = xstrdup (wd[i].name);
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ namebuf_t nbuf = namebuf_create (wd[i - 1].abspath);
|
|
|
|
+ namebuf_add_dir (nbuf, wd[i].name);
|
|
|
|
+ wd[i].abspath = namebuf_finish (nbuf);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ chdir_do (save_cwdi);
|
|
|
|
+ }
|
|
|
|
+
|
|
return wd[idx].abspath;
|
|
return wd[idx].abspath;
|
|
}
|
|
}
|
|
|
|
|