free software resistance
the cost of computing freedom is eternal vigilance
### fdif.fig
*originally posted:* aug 2024
openbsd doesnt have a -y option for diff, and often i only need to know if lines are found in the other file. generally i have a simple utility for this, and just as often the openbsd version of diff is sufficient.
today i really wanted to compare text side by side like diff -y, but writing a real diff utility is a bit beyond my needs or- without learning a lot more- my ability. so this is a simplified version of diff -y, and since it suits my purposes, i made it do 140 character width plus 5 characters for the comparison in the middle.
unlike similar utilities, which are made for the gui- this does not try to line up matching lines. it only shows a "1" to the right of lines from the first file that are found in the second- and a "1" to the left of each line from the second file when it is found in the first.
thus a "1 1" means both lines are found in both files, it doesnt mean the lines next to each other match.
usage:
./fdif.fig.py file1 file2
```
# 2024 by mn
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
proginf = "fdif, aug 2024 mn"
pad " " times 70
p command left 2
p1 p mid 1 1
p2 p mid 2 1
lineone arropen p1
linetwo arropen p2
c1 lineone len
c2 linetwo len
ifmore c2 c1
count c2
else
count c1
next
for each 1 count 1
buf1 lineone mid each 1
buf2 linetwo mid each 1
findone instr linetwo buf1 sgn str
findtwo instr lineone buf2 sgn str
ifmore each c1
buf1 ""
findone "0"
next
ifmore each c2
buf2 ""
findtwo "0"
next
now buf1 plus pad left 70 plus " " plus findone plus " " plus findtwo plus " " plus buf2 left 145 print
next
```
license: 0-clause bsd
```
# 2018, 2019, 2020, 2021, 2022, 2023, 2024
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
```
=> https://freesoftwareresistance.neocities.org