This reads OK to me. Does anyone else want to comment on this? Else I'll commit this in a couple of days.
martijn@ On 02/25/18 22:05, Tim Chase wrote: >> Synopsis: ed(1) doesn't set modifed flag reading into an empty file >> Category: user >> Environment: > System : OpenBSD 6.2 > Details : OpenBSD 6.2-stable (GENERIC) #2: Sat Dec 23 07:40:47 CST > 2017 > > [email protected]:/usr/src/sys/arch/macppc/compile/GENERIC > > Architecture: OpenBSD.macppc > Machine : macppc >> Description: > > Reading a file into an empty ed(1) buffer doesn't set the modified flag. > > As defined in POSIX > http://pubs.opengroup.org/onlinepubs/009604599/utilities/ed.html > "If the buffer has changed since the last time the entire buffer was written, > the user shall be warned" > Reading a file changes the buffer. > >> How-To-Repeat: > > Current behavior: > > $ ed > r !ls > q > $ > > Expected behavior > > $ ed > r !ls > q > ? > q > $ > > Should be analogous to appending/inserting in an empty file which > does work as expected: > > $ ed > a > x > . > q > ? > q > $ > >> Fix: > > As best I can tell, this diff against /usr/src/bin/ed/main.c (or > something like it) should fix it: > > --- main.c Sun Feb 25 14:42:21 2018 > +++ main_modified.c Sun Feb 25 14:43:03 2018 > @@ -723,7 +723,7 @@ > if ((addr = read_file(*fnp ? fnp : old_filename, > second_addr)) < 0) > return ERR; > - else if (addr && addr != addr_last) > + else if (addr != addr_last) > modified = 1; > break; > case 's': > > because "addr" is zero when this is an empty file. > > dmesg: > OpenBSD 6.2-stable (GENERIC) #2: Sat Dec 23 07:40:47 CST 2017 > [email protected]:/usr/src/sys/arch/macppc/compile/GENERIC > real mem = 1610612736 (1536MB) > avail mem = 1546530816 (1474MB) > mpath0 at root > scsibus0 at mpath0: 256 targets > mainbus0 at root: model PowerBook6,7 > cpu0 at mainbus0: 7447A (Revision 0x105): 1333 MHz: 512KB L2 cache > mem0 at mainbus0 > spdmem0 at mem0: no EEPROM found > spdmem1 at mem0: 1GB DDR SDRAM non-parity PC2700CL2.5 > memc0 at mainbus0: uni-n rev 0xd2 > "hw-clock" at memc0 not configured > kiic0 at memc0 offset 0xf8001000 > iic0 at kiic0 > adt0 at iic0 addr 0x2e: adt7467 rev 0x71 > asms0 at iic0 addr 0x58: rev 1.34, version 0.1 > mpcpcibr0 at mainbus0 pci: uni-north > pci0 at mpcpcibr0 bus 0 > pchb0 at pci0 dev 11 function 0 "Apple UniNorth AGP" rev 0x00 > agp at pchb0 not configured > radeondrm0 at pci0 dev 16 function 0 "ATI Radeon Mobility 9550" rev 0x80 > drm0 at radeondrm0 > radeondrm0: irq 48 > mpcpcibr1 at mainbus0 pci: uni-north > pci1 at mpcpcibr1 bus 0 > macobio0 at pci1 dev 23 function 0 "Apple Intrepid" rev 0x00 > openpic0 at macobio0 offset 0x40000: version 0x4614 feature 3f0302 LE > macgpio0 at macobio0 offset 0x50 > "modem-reset" at macgpio0 offset 0x1d not configured > "modem-power" at macgpio0 offset 0x1c not configured > "accelerometer-1" at macgpio0 offset 0x13 not configured > "accelerometer-2" at macgpio0 offset 0x14 not configured > "headphone-mute" at macgpio0 offset 0x1f not configured > "amp-mute" at macgpio0 offset 0x20 not configured > "hw-reset" at macgpio0 offset 0x25 not configured > "headphone-detect" at macgpio0 offset 0x17 not configured > macgpio1 at macgpio0 offset 0x9: irq 47 > "programmer-switch" at macgpio0 offset 0x11 not configured > dfs0 at macgpio0 offset 0x6b: speeds: 1333, 666 MHz > "gpio4" at macgpio0 offset 0x1e not configured > "escc-legacy" at macobio0 offset 0x12000 not configured > zs0 at macobio0 offset 0x13000: irq 22,23 > zstty0 at zs0 channel 0 > zstty1 at zs0 channel 1 > snapper0 at macobio0 offset 0x0: irq 30,1,2 > "timer" at macobio0 offset 0x15000 not configured > adb0 at macobio0 offset 0x16000: irq 25, via-pmu, 2 targets > apm0 at adb0: battery flags 0x5, 99% charged > piic0 at adb0 > iic1 at piic0 > akbd0 at adb0 addr 2: PowerBook G4 keyboard (Inverted T) > wskbd0 at akbd0: console keyboard > abtn0 at adb0 addr 7: brightness/volume/eject buttons > "battery" at macobio0 offset 0x0 not configured > "backlight" at macobio0 offset 0xf300 not configured > kiic1 at macobio0 offset 0x18000 > iic2 at kiic1 > wdc0 at macobio0 offset 0x20000 irq 24: DMA > atapiscsi0 at wdc0 channel 0 drive 0 > scsibus1 at atapiscsi0: 2 targets > cd0 at scsibus1 targ 0 lun 0: <MATSHITA, CD-RW CW-8124, DB0D> ATAPI 5/cdrom > removable > cd0(wdc0:0:0): using BIOS timings, DMA mode 2 > audio0 at snapper0 > bwi0 at pci1 dev 18 function 0 "Broadcom BCM4318" rev 0x02: irq 52, address > 00:11:24:c6:9f:5b > ohci0 at pci1 dev 26 function 0 "Apple Intrepid USB" rev 0x00: irq 29, > version 1.0, legacy support > ohci1 at pci1 dev 27 function 0 "NEC USB" rev 0x43: irq 63, version 1.0 > ohci2 at pci1 dev 27 function 1 "NEC USB" rev 0x43: irq 63, version 1.0 > ehci0 at pci1 dev 27 function 2 "NEC USB" rev 0x04: irq 63 > usb0 at ehci0: USB revision 2.0 > uhub0 at usb0 configuration 1 interface 0 "NEC EHCI root hub" rev 2.00/1.00 > addr 1 > usb1 at ohci0: USB revision 1.0 > uhub1 at usb1 configuration 1 interface 0 "Apple OHCI root hub" rev 1.00/1.00 > addr 1 > usb2 at ohci1: USB revision 1.0 > uhub2 at usb2 configuration 1 interface 0 "NEC OHCI root hub" rev 1.00/1.00 > addr 1 > usb3 at ohci2: USB revision 1.0 > uhub3 at usb3 configuration 1 interface 0 "NEC OHCI root hub" rev 1.00/1.00 > addr 1 > mpcpcibr2 at mainbus0 pci: uni-north > pci2 at mpcpcibr2 bus 0 > kauaiata0 at pci2 dev 13 function 0 "Apple Intrepid ATA" rev 0x00 > wdc1 at kauaiata0 irq 39: DMA > wd0 at wdc1 channel 0 drive 0: <FUJITSU MHV2040AT> > wd0: 16-sector PIO, LBA48, 38154MB, 78140160 sectors > wd0(wdc1:0:0): using PIO mode 4, DMA mode 2, Ultra-DMA mode 5 > "Apple UniNorth Firewire" rev 0x81 at pci2 dev 14 function 0 not configured > gem0 at pci2 dev 15 function 0 "Apple Uni-N2 GMAC" rev 0x80: irq 41, address > 00:11:24:de:65:2a > bmtphy0 at gem0 phy 0: BCM5221 100baseTX PHY, rev. 4 > uhidev0 at uhub1 port 1 configuration 1 interface 0 "Apple Computer > HID-proxy" rev 2.00/19.65 addr 2 > uhidev0: iclass 3/1 > ukbd0 at uhidev0: 8 variable keys, 6 key codes > wskbd1 at ukbd0 mux 1 > uhidev1 at uhub1 port 1 configuration 1 interface 1 "Apple Computer > HID-proxy" rev 2.00/19.65 addr 2 > uhidev1: iclass 3/1 > ums0 at uhidev1: 5 buttons > wsmouse0 at ums0 mux 0 > uhidev2 at uhub1 port 2 configuration 1 interface 0 "Apple Computer Apple > Internal Trackpad" rev 2.00/0.80 addr 3 > uhidev2: iclass 3/1 > utpms0 at uhidev2: Geyser Trackpad > wsmouse1 at utpms0 mux 0 > vscsi0 at root > scsibus2 at vscsi0: 256 targets > softraid0 at root > scsibus3 at softraid0: 256 targets > bootpath: /pci@f4000000/ata-6@d/disk@0:/bsd > root on wd0a (07e687822af716b1.a) swap on wd0b dump on wd0b > WARNING: / was not properly unmounted > error: [drm:pid0:radeon_get_bios] *ERROR* Unable to locate a BIOS ROM > error: [drm:pid0:radeon_agp_init] *ERROR* Unable to acquire AGP: 22 > radeondrm0: 1024x768, 8bpp > wsdisplay0 at radeondrm0 mux 1: console (std, vt100 emulation), using wskbd0 > wskbd1: connecting to wsdisplay0 > wsdisplay0: screen 1-5 added (std, vt100 emulation) > > usbdevs: > Controller /dev/usb0: > addr 1: high speed, self powered, config 1, EHCI root hub(0x0000), > NEC(0x1033), rev 1.00 > port 1 powered > port 2 powered > port 3 powered > port 4 powered > port 5 powered > Controller /dev/usb1: > addr 1: full speed, self powered, config 1, OHCI root hub(0x0000), > Apple(0x106b), rev 1.00 > port 1 addr 2: full speed, self powered, config 1, HID-proxy(0x1000), Apple > Computer(0x05ac), rev 19.65 > port 2 addr 3: full speed, power 40 mA, config 1, Apple Internal > Trackpad(0x030b), Apple Computer(0x05ac), rev 0.80 > Controller /dev/usb2: > addr 1: full speed, self powered, config 1, OHCI root hub(0x0000), > NEC(0x1033), rev 1.00 > port 1 powered > port 2 powered > port 3 powered > Controller /dev/usb3: > addr 1: full speed, self powered, config 1, OHCI root hub(0x0000), > NEC(0x1033), rev 1.00 > port 1 powered > port 2 powered >
