php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81381 Wrong line number on empty sides of diffs
Submitted: 2021-08-24 19:42 UTC Modified: -
From: gingko at gingko dot ovh Assigned:
Status: Open Package: xdiff (PECL)
PHP Version: 7.3.29 OS: Linux Debian 10
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: gingko at gingko dot ovh
New email:
PHP Version: OS:

 

 [2021-08-24 19:42 UTC] gingko at gingko dot ovh
Description:
------------
When comparing two strings using xdiff_string_diff, on any added line groups (one side with new lines, one side empty), the line number for the empty side is one less than what it should do.

This caused me some headaches in working on a PHP web page where I was trying to parse and use these line number values for extracting lines which are common to both sides.

I will likely need to workaround this by adding one to the line number if the corresponding length is zero.

Using xdiff-2.1.0.


Test script:
---------------
echo
  xdiff_string_diff(
    "A\nA\nA\nB\nB\nB\nB\nC\nC\nC\nC\n",
    "A\nA\nA\nC\nC\nC\nC\n",
    0);

Expected result:
----------------
@@ -4,4 +4,0 @@
-B
-B
-B
-B


Actual result:
--------------
@@ -4,4 +3,0 @@
-B
-B
-B
-B


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Dec 06 07:03:36 2021 UTC