Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow --print-stats --null-output #649

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

gperciva
Copy link
Member

No description provided.

@@ -163,21 +163,21 @@ chunks_delete_printstats(FILE * stream, CHUNKS_D * C, const char * name,
name = "This archive";

/* Print header. */
if (chunks_stats_printheader(stream, csv))
if (chunks_stats_printheader(stream, csv, 0))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we wanted to allow tarsnap -d --null-output -f archivename, then we'd hook it in here.

A small part of me thinks "hey, why not allow --null-output everywhere!". But a larger part of me points out that it's not needed for the GUI, and I struggle to think of any scenario where -d --null-output would really be useful.

@@ -284,21 +284,21 @@ chunks_write_printstats(FILE * stream, CHUNKS_W * C, int csv)
{

/* Print header. */
if (chunks_stats_printheader(stream, csv))
if (chunks_stats_printheader(stream, csv, 0))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same argument for -c --null-output; if we wanted to enable it, this is where we'd start.

@@ -8,6 +8,6 @@
* Print ${separator} to ${stream} if ${print_nulls} is zero; otherwise,
* print ${num_nulls} '\0'.
*/
int print_separator(FILE *, char *, int, int);
int print_separator(FILE *, const char *, int, int);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad. In #643, I was so fixated on whether we'd allow #define print_sep that I missed that the API should take const.

goto err0;
}
if (fprintf(stream, ",") < 0)
goto err0;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally we'd have

...) {
        warnp("fprintf");
        goto err0;
}

here, but we don't need the warnp when we switch to print_separator() in the following commit.

I normally try to have a "perfect" refactoring before changing code, but in this specific case I think it's worth skipping the warning in order to reduce the number of changed lines in the diff.

This commit does not change any program behaviour.

Separating the printing of these fields makes the upcoming
`--print-stats --null-output` easier to implement.

This commit also adds 'const' to print_separator(), which should have been in:
    2025-02-17 lib/util/print_separator: add
    9b9f0e7
These changes were made automatically via scripts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant