Commit 71d1681
authored
patch: improve validation of normal diffs (briandfoy#952)
* patch: improve validation of normal diffs
* A normal diff can contain (a)dd, (c)hange and (d)elete commands
* For the Add command, a single target address is expected to be prefixed before "a"
* Diff utils output data in form of XaY,Z and not X,YaZ (so in practice the error condition should not happen)
* GNU diffutils manual described and Add command as "LaR", where L is a single line number and R is a range (e.g. 3,4) [1]
* Make this version of patch reject malformed Add commands
* Print the offending input data and line number
* Calling $patch->reject() is needed for setting the correct exit code
* When the exit code will indicate failure, avoid printing "done" message after preceding error messages
* I created an invalid input file manually to test this
1. https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Normal.html
* previous commit missed loop construct for c and d diff commands1 parent de00a20 commit 71d1681
1 file changed
+12
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
203 | | - | |
| 203 | + | |
204 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
205 | 213 | | |
206 | 214 | | |
207 | 215 | | |
| |||
278 | 286 | | |
279 | 287 | | |
280 | 288 | | |
| 289 | + | |
281 | 290 | | |
282 | | - | |
| 291 | + | |
283 | 292 | | |
284 | 293 | | |
285 | 294 | | |
| |||
0 commit comments