Skip to content

Conversation

mknos
Copy link
Contributor

@mknos mknos commented Jan 4, 2025

  • This version of patch first attempts to process an ed diff by running an external ed command, then falls back to processing the ed commands directly
  • I noticed the external ed code was always failing but I didn't debug it until now
  • Problem1: SIGCHLD happens normally when ed exits but it was being treated as an error (removing signal handlers fixes it)
  • Problem2: write command sent to ed was not terminated by a newline, so ed would never run the command
  • Problem3: after writing to o_file, the offset of filehandle $out was at byte 26, so the test line comparison wasn't correct
  • With this patch I can process a simple ed diff on Linux without the code reaching PLAN_J
%cat ab.diff # change a.c into b.c
9,14d
%cp a.c acopy.c
%perl patch -e acopy.c ab.diff
Hmm...  Looks like an ed diff to me...
Patching file acopy.c using Plan A...
Hunk #1 succeeded at 1.
done
%cmp acopy.c b.c
%cmp acopy.c a.c
acopy.c a.c differ: byte 84, line 9

* This version of patch first attempts to process an ed diff by running an external ed command, then falls back to processing the ed commands directly
* I noticed the external ed code was always failing but I didn't debug it until now
* Problem1: SIGCHLD happens normally when ed exits but it was being treated as an error (removing signal handlers fixes it)
* Problem2: write command sent to ed was not terminated by a newline, so ed would never run the command
* Problem3: after writing to o_file, the offset of filehandle $out was at byte 26, so the test line comparison wasn't correct
* With this patch I can process a simple ed diff on Linux without the code reaching PLAN_J
@github-actions github-actions bot added Type: enhancement improve a feature that already exists Priority: low get to this whenever Program: patch The patch program labels Jan 4, 2025
@mknos mknos temporarily deployed to automated_testing January 4, 2025 05:55 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 4, 2025 05:55 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 4, 2025 05:55 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 4, 2025 05:55 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 4, 2025 05:55 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 4, 2025 05:55 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 4, 2025 05:55 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 4, 2025 05:55 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 4, 2025 05:55 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 4, 2025 05:55 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 4, 2025 05:55 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 4, 2025 05:56 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 4, 2025 05:56 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 4, 2025 05:56 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 4, 2025 05:56 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 4, 2025 05:56 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 4, 2025 05:56 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 4, 2025 05:56 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 4, 2025 05:56 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 4, 2025 05:56 — with GitHub Actions Inactive
@briandfoy briandfoy self-assigned this Jan 4, 2025
bin/patch Outdated
local $SIG{CHLD} = sub { die 'Bad child...' };
open ED, '|-', qw(ed - -s), $self->{i_file} or die "Couldn't fork ed: $!";
my $cmd = 'ed -s ' . $self->{'i_file'};
open ED, '|-', $cmd or die "Couldn't fork ed: $!";
Copy link
Owner

Choose a reason for hiding this comment

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

Was there a problem with the list form of the pipe? That should be safer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well spotted. I added a commit to convert the ed arguments back to a list and repeated the original test.

@briandfoy briandfoy added Status: changes requested adjust the pull request as noted in comments Type: bug an existing feature does not work and removed Type: enhancement improve a feature that already exists labels Jan 4, 2025
@mknos mknos temporarily deployed to automated_testing January 6, 2025 02:56 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 6, 2025 02:56 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 6, 2025 02:56 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 6, 2025 02:56 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 6, 2025 02:56 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 6, 2025 02:56 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 6, 2025 02:56 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 6, 2025 02:56 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 6, 2025 02:56 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 6, 2025 02:56 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 6, 2025 02:56 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 6, 2025 02:56 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 6, 2025 02:56 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 6, 2025 02:56 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 6, 2025 02:56 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 6, 2025 02:56 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 6, 2025 02:56 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 6, 2025 02:56 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 6, 2025 02:56 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing January 6, 2025 02:56 — with GitHub Actions Inactive
@briandfoy briandfoy removed the Status: changes requested adjust the pull request as noted in comments label Jan 6, 2025
@briandfoy briandfoy merged commit 74cc47e into briandfoy:master Jan 6, 2025
22 checks passed
@briandfoy briandfoy added Status: accepted The fix is accepted and removed Priority: low get to this whenever labels Jan 6, 2025
@briandfoy briandfoy added Status: released there is a new release with this fix and removed Status: accepted The fix is accepted labels Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Program: patch The patch program Status: released there is a new release with this fix Type: bug an existing feature does not work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants