Skip to content

fix: buffer too short should fail#32

Merged
adrienaury merged 2 commits intomainfrom
fix-eof-with-short-line-does-not-clean-buffer
May 14, 2025
Merged

fix: buffer too short should fail#32
adrienaury merged 2 commits intomainfrom
fix-eof-with-short-line-does-not-clean-buffer

Conversation

@adrienaury
Copy link
Member

No description provided.

@adrienaury adrienaury linked an issue May 14, 2025 that may be closed by this pull request
@adrienaury adrienaury requested a review from Copilot May 14, 2025 09:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request fixes an issue where a buffer that is too short now correctly triggers a failure. The key changes include:

  • Adding a new error variable (ErrIncompleteBuffer) and updating the buffer growth function to detect incomplete buffers.
  • Tweaking error messages in the unfold command for improved clarity.
  • Refactoring the fold command to delegate the execution loop into a new helper function (execUntilEOF) to better handle EOF and error propagation.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
pkg/posimap/core/buffer/buffer.go Added a new error for incomplete buffers and updated growTo for stricter read length checks.
internal/appli/command/unfold.go Updated error messages for buffer preparation for consistency.
internal/appli/command/fold.go Refactored the record handling loop into execUntilEOF and updated error handling.
Comments suppressed due to low confidence (1)

internal/appli/command/fold.go:85

  • [nitpick] Consider using a consistent variable name for the record object; currently, the call uses 'record' while the execUntilEOF function defines the parameter as 'rcrd'.
if err := f.execUntilEOF(cfg, reader, writer, record); err != nil {

@adrienaury adrienaury merged commit 545113b into main May 14, 2025
1 check passed
@adrienaury adrienaury deleted the fix-eof-with-short-line-does-not-clean-buffer branch May 14, 2025 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: eof with short line does not clean buffer

2 participants