Today I discovered the cause of a long-time frustration I've had trying to modify NETSRV.MAC to add services.
I've been trying to add an RSH server listener to NETSRV. But every time I would edit the file with VI (my Elvis V2.0 1996 port), the resulting NETSRV executable would fail to RECEIVE for all services. Always. ALWAYS ALWAYS ALWAYS. Reverting back to the original untouched (ca. 2006 NETSRV.MAC from the Panda distribution) source and compiling, the resulting NETSRV.EXE would run just fine. Changing ANYTHING and recompiling would result in the failure.
Comparing the untouched and a file created by simply saving a new copy from within the editor, there was a one-byte-off count to the file sizes.
Running the ported UNIX diff on those files showed the following:
$diff -u ns4.mac ns4a.mac
--- ns4.mac Fri Jan 21 14:52:51 2022
+++ ns4a.mac Fri Jan 21 15:45:37 2022
@@ -1602,7 +1602,7 @@
MOVX T3,^D10 ; in decimal
NOUT% ; output local port number
- HRROI T2,[ASCIZ/#;PERSIST:30/] ; wait 30 seconds for synchronize
+ HRROI T2,[ASCIZ/#;PERSIST:30/] ; wait 30 seconds for synchronize
MOVX T1,GJ%SHT ; GTJFN% flags
No difference show. There must be an embedded control character. But when I load NS4.MAC into vi, the line is as-shown.
I started to look at the binary contents of the file:
$cmp -l ns4.mac ns4a.mac | head -10
47946 26 43
47947 43 73
47948 73 120
47949 120 105
47950 105 122
47951 122 123
47952 123 111
47953 111 123
47954 123 124
47955 124 72
Aha. There's a CTRL-V (Octal 026) in NS4.MAC that isn't in NS4A.MAC.
The other characters shown are:
43 Hash/Pound sign (#)
73 Semicolon (;)
120 105 122 123 111 123 124 Octal codes for ASCII: PERSIST
So there's an embedded CTRL-V at the beginning of the ASCIZ string in the HRROI line.
Elvis is dropping that character when loading the file for editing!
I found the offending Elvis code in io.c:
/* maybe strip control characters */
if (beautify && nread > 0)
for (i = j = 0; i < nread; i++)
if (iobuf[i] >= ' ' || iobuf[i] == '\t' || iobuf[i] == '\n' || iobuf[i] == '\f')
iobuf[j++] = iobuf[i];
nread = j;
So it is the Elvis beautify setting causing the character drop. I never use the beautify setting. But it is inexplicably set in my elvis.rc file.
This isn't what the beautify setting does in BSD vi or the VIM clone.
Regardless, removing the set beautify in my elvis.rc and I'm good now.