Document the new --partial-dir option.
[rsync/rsync.git] / util.c
diff --git a/util.c b/util.c
index 8d05771..13987b9 100644 (file)
--- a/util.c
+++ b/util.c
@@ -900,6 +900,30 @@ int pop_dir(char *dir)
        return 1;
 }
 
+/**
+ * Return the filename, turning any newlines into '?'s.  This ensures that
+ * outputting it on a line of its own cannot generate an empty line.  This
+ * function can handle only 2 names at a time!
+ **/
+const char *safe_fname(const char *fname)
+{
+       static char fbuf1[MAXPATHLEN], fbuf2[MAXPATHLEN];
+       static char *fbuf = fbuf2;
+       char *nl = strchr(fname, '\n');
+
+       if (!nl)
+               return fname;
+
+       fbuf = fbuf == fbuf1 ? fbuf2 : fbuf1;
+       strlcpy(fbuf, fname, MAXPATHLEN);
+       nl = fbuf + (nl - (char *)fname);
+       do {
+               *nl = '?';
+       } while ((nl = strchr(nl+1, '\n')) != NULL);
+
+       return fbuf;
+}
+
 /**
  * Return a quoted string with the full pathname of the indicated filename.
  * The string " (in MODNAME)" may also be appended.  The returned pointer
@@ -914,6 +938,7 @@ char *full_fname(const char *fn)
        if (result)
                free(result);
 
+       fn = safe_fname(fn);
        if (*fn == '/')
                p1 = p2 = "";
        else {