Don't intermix rprint with printf.
authorWayne Davison <wayne@opencoder.net>
Fri, 9 Sep 2022 20:10:58 +0000 (13:10 -0700)
committerWayne Davison <wayne@opencoder.net>
Fri, 9 Sep 2022 20:10:58 +0000 (13:10 -0700)
json-version.diff

index 08e80439e9a1c4d403c1b07ef530629614c9bbc0..b8fd010ef0702e95900026581a285548bcb31dc3 100644 (file)
@@ -7,7 +7,7 @@ To use this patch, run these commands for a successful build:
     ./configure                               (optional if already run)
     make
 
-based-on: 24174f9a96b191bff8f9420573de468a769c2ed9
+based-on: 1f12b196fd049058e1d12bdf8e9b01dd05f656f0
 diff --git a/options.c b/options.c
 --- a/options.c
 +++ b/options.c
@@ -44,7 +44,7 @@ diff --git a/usage.c b/usage.c
        int line_len, j;
        char *info_flags[] = {
  
-@@ -161,10 +162,12 @@ static void print_info_flags(enum logcode f)
+@@ -161,49 +162,105 @@ static void print_info_flags(enum logcode f)
  
                NULL
        };
@@ -57,8 +57,13 @@ diff --git a/usage.c b/usage.c
 +              int str_len = str && *str != '*' ? strlen(str) + (as_json ? 2 : 0) : 1000;
                int need_comma = next_nfo && *next_nfo != '*' ? 1 : 0;
                if (line_len && line_len + 1 + str_len + need_comma >= (int)sizeof line_buf) {
-                       rprintf(f, "   %s\n", line_buf);
-@@ -173,37 +176,88 @@ static void print_info_flags(enum logcode f)
+-                      rprintf(f, "   %s\n", line_buf);
++                      if (as_json)
++                              printf("   %s\n", line_buf);
++                      else
++                              rprintf(f, "   %s\n", line_buf);
+                       line_len = 0;
+               }
                if (!str)
                        break;
                if (*str == '*') {
@@ -161,7 +166,7 @@ diff --git a/usage.c b/usage.c
  
  #ifdef MAINTAINER_MODE
        rprintf(f, "Panic Action: \"%s\"\n", get_panic_action());
-@@ -226,7 +280,7 @@ void print_rsync_version(enum logcode f)
+@@ -226,7 +283,7 @@ void print_rsync_version(enum logcode f)
  
  void usage(enum logcode F)
  {
@@ -170,7 +175,7 @@ diff --git a/usage.c b/usage.c
  
    rprintf(F,"\n");
    rprintf(F,"rsync is a file transfer program capable of efficient remote update\n");
-@@ -253,7 +307,7 @@ void usage(enum logcode F)
+@@ -253,7 +310,7 @@ void usage(enum logcode F)
  
  void daemon_usage(enum logcode F)
  {