]> granicus.if.org Git - postgresql/commitdiff
Make size-output fixed length in pg_basebackup verbose mode
authorMagnus Hagander <magnus@hagander.net>
Thu, 17 Jan 2013 13:43:33 +0000 (14:43 +0100)
committerMagnus Hagander <magnus@hagander.net>
Thu, 17 Jan 2013 13:43:33 +0000 (14:43 +0100)
This way the line doesn't shift right as the amount of data processed
increases.

src/bin/pg_basebackup/pg_basebackup.c

index 36f825e95c8730b73bceb9f5a6cc936715bce201..f77b9f68e2922f6cd7683a1a89a84b7880b2365e 100644 (file)
@@ -432,9 +432,10 @@ progress_report(int tablespacenum, const char *filename)
                         * call)
                         */
                        fprintf(stderr,
-                                       ngettext("%s/%s kB (100%%), %d/%d tablespace %*s",
-                                                        "%s/%s kB (100%%), %d/%d tablespaces %*s",
+                                       ngettext("%*s/%s kB (100%%), %d/%d tablespace %*s",
+                                                        "%*s/%s kB (100%%), %d/%d tablespaces %*s",
                                                         tablespacecount),
+                                       strlen(totalsize_str),
                                        totaldone_str, totalsize_str,
                                        tablespacenum, tablespacecount,
                                        VERBOSE_FILENAME_LENGTH + 5, "");
@@ -443,9 +444,10 @@ progress_report(int tablespacenum, const char *filename)
                        bool truncate = (strlen(filename) > VERBOSE_FILENAME_LENGTH);
 
                        fprintf(stderr,
-                                       ngettext("%s/%s kB (%d%%), %d/%d tablespace (%s%-*.*s)",
-                                                        "%s/%s kB (%d%%), %d/%d tablespaces (%s%-*.*s)",
+                                       ngettext("%*s/%s kB (%d%%), %d/%d tablespace (%s%-*.*s)",
+                                                        "%*s/%s kB (%d%%), %d/%d tablespaces (%s%-*.*s)",
                                                         tablespacecount),
+                                       strlen(totalsize_str),
                                        totaldone_str, totalsize_str, percent,
                                        tablespacenum, tablespacecount,
                                        /* Prefix with "..." if we do leading truncation */
@@ -458,9 +460,10 @@ progress_report(int tablespacenum, const char *filename)
        }
        else
                fprintf(stderr,
-                               ngettext("%s/%s kB (%d%%), %d/%d tablespace",
-                                                "%s/%s kB (%d%%), %d/%d tablespaces",
+                               ngettext("%*s/%s kB (%d%%), %d/%d tablespace",
+                                                "%*s/%s kB (%d%%), %d/%d tablespaces",
                                                 tablespacecount),
+                               strlen(totalsize_str),
                                totaldone_str, totalsize_str, percent,
                                tablespacenum, tablespacecount);