Reposition the call to setup_iconv() so that it gets called only once
authorWayne Davison <wayned@samba.org>
Sun, 7 Oct 2007 20:43:49 +0000 (20:43 +0000)
committerWayne Davison <wayned@samba.org>
Sun, 7 Oct 2007 20:43:49 +0000 (20:43 +0000)
is a local_server copy, and so that arg-parsing code doesn't interfere
with the sending of a remote charset value.

main.c
options.c
pipe.c

diff --git a/main.c b/main.c
index 4b67f2a..df0b6e8 100644 (file)
--- a/main.c
+++ b/main.c
@@ -448,13 +448,16 @@ static pid_t do_cmd(char *cmd, char *machine, char *user, char **remote_argv, in
                *f_out_p = from_gen_pipe[1];
                *f_in_p = batch_fd;
                ret = -1; /* no child pid */
+               setup_iconv();
        } else if (local_server) {
                /* If the user didn't request --[no-]whole-file, force
                 * it on, but only if we're not batch processing. */
                if (whole_file < 0 && !write_batch)
                        whole_file = 1;
                ret = local_child(argc, args, f_in_p, f_out_p, child_main);
+               setup_iconv();
        } else {
+               setup_iconv();
                if (protect_args) {
                        int fd;
 #ifdef ICONV_OPTION
@@ -1476,7 +1479,9 @@ int main(int argc,char *argv[])
        if (write_batch < 0)
                dry_run = 1;
 
-       if (am_daemon && !am_server)
+       if (am_server)
+               setup_iconv();
+       else if (am_daemon)
                return daemon_main();
 
        if (am_server && protect_args) {
index 61d2a90..f7ef675 100644 (file)
--- a/options.c
+++ b/options.c
@@ -1249,7 +1249,6 @@ int parse_arguments(int *argc_p, const char ***argv_p, int frommain)
                else
                        need_unsorted_flist = 1;
        }
-       setup_iconv();
 #endif
 
        if (protect_args == 1) {
diff --git a/pipe.c b/pipe.c
index 50c78c4..f3cea83 100644 (file)
--- a/pipe.c
+++ b/pipe.c
@@ -144,6 +144,7 @@ pid_t local_child(int argc, char **argv, int *f_in, int *f_out,
                        close(to_child_pipe[0]);
                if (from_child_pipe[1] != STDOUT_FILENO)
                        close(from_child_pipe[1]);
+               setup_iconv();
                child_main(argc, argv);
        }