summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGianluca Guida <glguida@gmail.com>2005-01-31 16:06:19 +0000
committerGianluca Guida <glguida@gmail.com>2005-01-31 16:06:19 +0000
commit023b8ad08b52ce938ab84db8052b4ce940cd0e8a (patch)
tree8087ba217d0988eba4b518e1c7a363295736947d
parent11a61b22dd0a0a0cc80b3c8594c85fecbb5e679a (diff)
Handle --stow argument with missing / correctly.
-rw-r--r--ChangeLog5
-rw-r--r--stow.c23
2 files changed, 28 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index e19585a..e9ff7a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2005-01-31 Gianluca Guida <glguida@gmail.com>
+ * stow.c (stow_diradd): Handle --stow argument with missing /
+ correctly.
+
+2005-01-31 Gianluca Guida <glguida@gmail.com>
+
* pattern.c: New file.
* stow.c: Likewise.
* pattern.h: Likewise.
diff --git a/stow.c b/stow.c
index 9089444..fc30206 100644
--- a/stow.c
+++ b/stow.c
@@ -124,6 +124,29 @@ stow_diradd (char *dir, int flags, struct patternlist *patternlist, int remove)
.flags = flags,
.remove = remove
};
+ int dir_len;
+
+ dir_len = strlen(dir);
+ if (dir_len == 0)
+ {
+ error (EXIT_FAILURE, ARGP_ERR_UNKNOWN, "stow_diradd");
+ }
+
+ if (dir[dir_len - 1 ] != '/')
+ {
+ char *tmp;
+
+ tmp = (char *) malloc (dir_len + 1);
+
+ if (tmp == NULL)
+ error (EXIT_FAILURE, ENOMEM, "stow_diradd");
+
+ strncpy (tmp, dir, dir_len);
+
+ tmp[dir_len] = '/';
+
+ dir = tmp;
+ }
err = for_each_subdir_priv (dir, _stow_scanstowentry, (void *)&mypriv);