Some superficial code tweaks.
[rsync/rsync.git] / util.c
diff --git a/util.c b/util.c
index a474c9b..a01a38d 100644 (file)
--- a/util.c
+++ b/util.c
@@ -28,6 +28,9 @@
 #include "rsync.h"
 
 extern int verbose;
+extern int dry_run;
+extern int module_id;
+extern int modify_window;
 extern struct exclude_list_struct server_exclude_list;
 
 int sanitize_paths = 0;
@@ -126,7 +129,6 @@ void overflow(char *str)
 
 int set_modtime(char *fname, time_t modtime)
 {
-       extern int dry_run;
        if (dry_run)
                return 0;
 
@@ -502,7 +504,6 @@ static void glob_expand_one(char *s, char **argv, int *argc, int maxargs)
        exclude_server_path(s);
        (*argc)++;
 #else
-       extern int sanitize_paths;
        glob_t globbuf;
        int i;
 
@@ -706,9 +707,12 @@ void sanitize_path(char *p, char *reldir)
        int allowdotdot = 0;
 
        if (reldir) {
-               depth++;
+               int new_component = 1;
                while (*reldir) {
-                       if (*reldir++ == '/') {
+                       if (*reldir++ == '/')
+                               new_component = 1;
+                       else if (new_component) {
+                               new_component = 0;
                                depth++;
                        }
                }
@@ -884,9 +888,8 @@ int pop_dir(char *dir)
  * The string " (in MODNAME)" may also be appended.  The returned pointer
  * remains valid until the next time full_fname() is called.
  **/
-char *full_fname(char *fn)
+char *full_fname(const char *fn)
 {
-       extern int module_id;
        static char *result = NULL;
        char *m1, *m2, *m3;
        char *p1, *p2;
@@ -1039,7 +1042,6 @@ int msleep(int t)
        struct timeval tval, t1, t2;
 
        gettimeofday(&t1, NULL);
-       gettimeofday(&t2, NULL);
 
        while (tdiff < t) {
                tval.tv_sec = (t-tdiff)/1000;
@@ -1070,13 +1072,13 @@ int msleep(int t)
  **/
 int cmp_modtime(time_t file1, time_t file2)
 {
-       extern int modify_window;
-
        if (file2 > file1) {
-               if (file2 - file1 <= modify_window) return 0;
+               if (file2 - file1 <= modify_window)
+                       return 0;
                return -1;
        }
-       if (file1 - file2 <= modify_window) return 0;
+       if (file1 - file2 <= modify_window)
+               return 0;
        return 1;
 }