Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/modules/packages/packages.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ bool ffPrintPackages(FFPackagesOptions* options) {
FF_PRINT_PACKAGE(xbps)

assert(output.length >= 2); // counts.all > 0 guarantees that at least one package count was printed, which guarantees that ", " was appended at least once
ffStrbufSubstrBefore(&output, output.length - 1);
output.chars[output.length - 1] = '\n';
ffStrbufSubstrBefore(&output, output.length - 2);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚪ LOW RISK

Suggestion: The implementation changes the output from 'package,\n' to 'package\n' (removing the comma). While this is likely an improvement, it contradicts the 'identical behavior' claim in the PR description. Ensure this change in output format is intended for the packages module.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a bot misread. The original code performed two operations:

  1. ffStrbufSubstrBefore(&output, output.length - 1) — truncates, removing the trailing space
  2. output.chars[output.length - 1] = '\n' — overwrites what is now the last char (the ,) with \n

Both the comma and space were removed; output never ended with a comma. The new code produces byte-for-byte identical output via ffStrbufSubstrBefore(&output, output.length - 2) + ffStrbufAppendC(&output, '\n').

ffStrbufAppendC(&output, '\n');
ffStrbufWriteTo(&output, stdout);
} else {
FF_PRINT_FORMAT_CHECKED(FF_PACKAGES_MODULE_NAME,
Expand Down
Loading