fixed a bug in the glob expansion code (pointed out by
authorAndrew Tridgell <tridge@samba.org>
Mon, 18 May 1998 14:00:24 +0000 (14:00 +0000)
committerAndrew Tridgell <tridge@samba.org>
Mon, 18 May 1998 14:00:24 +0000 (14:00 +0000)
hazard.bsn@blkseanet.net.eu.org)

main.c
util.c

diff --git a/main.c b/main.c
index bcc292b..67ece95 100644 (file)
--- a/main.c
+++ b/main.c
@@ -43,6 +43,8 @@ static void report(int f)
 
        if (!verbose) return;
 
+       if (am_server && !am_sender) return;
+
        if (am_server && am_sender) {
                write_longint(f,read_total());
                write_longint(f,write_total());
@@ -235,7 +237,6 @@ static int do_recv(int f_in,int f_out,struct file_list *flist,char *local_name)
        int status=0;
        int recv_pipe[2];
        extern int preserve_hard_links;
-       extern int am_server;
 
        if (preserve_hard_links)
                init_hard_links(flist);
@@ -252,8 +253,7 @@ static int do_recv(int f_in,int f_out,struct file_list *flist,char *local_name)
                if (f_in != f_out) close(f_out);
 
                recv_files(f_in,flist,local_name,recv_pipe[1]);
-               if (!am_server)
-                       report(f_in);
+               report(f_in);
 
                if (verbose > 3)
                        rprintf(FINFO,"do_recv waiting on %d\n",pid);
diff --git a/util.c b/util.c
index 5b16fc4..89bc75b 100644 (file)
--- a/util.c
+++ b/util.c
@@ -558,10 +558,11 @@ static void glob_expand_one(char *s, char **argv, int *argc, int maxargs)
 #endif
 }
 
-void glob_expand(char *base, char **argv, int *argc, int maxargs)
+void glob_expand(char *base1, char **argv, int *argc, int maxargs)
 {
        char *s = argv[*argc];
        char *p, *q;
+       char *base = base1;
 
        if (!s || !*s) return;
 
@@ -572,21 +573,23 @@ void glob_expand(char *base, char **argv, int *argc, int maxargs)
        s = strdup(s);
        if (!s) out_of_memory("glob_expand");
 
+       base = (char *)malloc(strlen(base1)+3);
+       if (!base) out_of_memory("glob_expand");
+
+       sprintf(base," %s/", base1);
+
        q = s;
        while ((p = strstr(q,base)) && ((*argc) < maxargs)) {
-               if (p != q && *(p-1) == ' ' && p[strlen(base)] == '/') {
-                       /* split it at this point */
-                       *(p-1) = 0;
-                       glob_expand_one(q, argv, argc, maxargs);
-                       q = p+strlen(base)+1;
-               } else {
-                       q++;
-               }
+               /* split it at this point */
+               *p = 0;
+               glob_expand_one(q, argv, argc, maxargs);
+               q = p+strlen(base);
        }
 
        if (*q && (*argc < maxargs)) glob_expand_one(q, argv, argc, maxargs);
 
        free(s);
+       free(base);
 }
 
 /*******************************************************************