- Fix printf() warnings (format should be long, not int)
- Signed/unsigned mismatch, size_t for array indexing
- Comment out the unused trim() function.
In sim_instr(), the effective address is computed; for the case of TAG
(index register addressing), the contents of the specified index register
is added to the effective address, but the result is not masked to 16
bits as per the hardware functionality.
Adding a a 16 bit mask operation fixes the issue.
Also synchronize Window Event pump and command input thread startup
before counting on their use.
Previously the Windows GUI startup happened too early (in the power on
device reset of all DEVICES) and it didn't consistently stabilize before
proceeding. A quick exit after the RegisterSanityCheck activity would
sometimes hang and builds would never complete.
- Initialize local state variable to 0. Likely non functional changes due
to lack of depth in static analysis scan. Coverity detects real problems
like this.
- Migrate use of strncpy to strlcpy to assure safe buffer operations
This avoids a potential invalid pointer dereference when formatting
the return value from sim_instr() if it is < SCPE_BASE but greater
than the previously defined static array size.sizeof
Update simh.doc to reflect this generic change.
Cleaned up a couple of things here. Specifically:
1) scp_reading is only set when CmdThread is actually reading.
2) Avoid calling ResetEvent(hCmdReadEvent) since it has no effect.
3) Calling ReadFile directly rather than calling read_line which ultimately
calls fgets(stdin) and that ultimately calls ReadFile.
4) Added a cleanup mechanism to shutdown the CmdThread
and related open handles to Events and Thread when the program exits.
Remaining potential problems:
1) A user might have type a partial command (scp_reading) but not
completed it by hitting Enter, and then they perform some GUI
interaction which does other things. Some strange output will be
produced on top of the partially entered command line.
2) Whether or not a complete command has been entered, the original
CmdThread will have a read posted on stdin throughout any activity
initiated by GUI activities. It is not clear that the simulator’s console
will coherently be able to change the console’s mode from the line
oriented mode that SCP uses to the character oriented mode used
while instructions are executing with read pending on the input side.