1
0
Fork 0
Commit graph

309 commits

Author SHA1 Message Date
Patryk Obara
e3559f98ee Update program name in shell startup messages 2020-04-04 04:20:28 +02:00
Patryk Obara
a956f14de1 Inject newlines before displaying DOS prompt
In an earlier change, I removed appending newline outside of batch mode
in DOS shell code - that made DOSBox behave less like MS-DOS and more
like modern shells, that do not try to compensate for buggy
applications.

However, we should recognize that DOSBox (unlike e.g. FreeDOS) is designed
to run legacy applications, which might make assumptions about DOS
implementation. Some examples:

- PC Player Benchmark assumes, that help commands are displayed exactly
  at 80x25 terminal and formats the output to fill the whole screen
  (scrolling past DOS4GW messages).
- Quake and other ID games print shareware information on exit, but do
  it via a direct memory dump (not interrupts to print DOS text), and
  follow up with setting cursor exactly at line 22 (which is partly
  written already), expecting shell to inject newline.
- PCC Compiler prints status message on exit without newline, depending
  on MS-DOS shell behaviour.
- TEXTUTIL set of external commands do not print nothing to standard
  output, and are designed to clear the screen, therefore writing a
  newline after .COM commands would be a mistake.

Therefore we want to inject this newline, but not in every case.

New implementation reuses a static variable used by Program base class
(for purpose of translating UNIX newlines to DOS newlines) for detection
if it's appropriate to inject an additional newline or not.

Injecting the newline happens in function displaying the DOS prompt (so
we don't need to write additonal logic for separately handling batch
mode). When starting a non-COM, non-internal command the static variable
is set to the state indicating that next DOS prompt should inject the
newline.

Fixes: #208
2020-03-12 20:54:33 +01:00
Joshua Fern
f2029d71d8 Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
Patryk Obara
e2196a77e2 Silence buffer overflow false-positives
Coverity reports a number of buffer overflows here.

The code was written in a way, that effectively made it hard for static
analysis to prove the buffer overflow does not happen, but the code
itself was safe.

Update it to avoid repetition and use snprintf, that guarantees no
buffer overflow will happen, and buffer will always be zero-delimited.
2020-02-26 11:08:28 +01:00
Patryk Obara
b58ad366fc Silence few false-positive buffer overflow issues 2020-02-26 11:08:28 +01:00
Patryk Obara
dc55ccb21f Fix buffer overflow in CMD_PATH
This buffer overflow was easy to trigger by just running:

  Z:\> path <very-long-string>

We avoid the problem by using snprintf, which will trim input to
the length passed as second parameter.
2020-02-26 11:08:28 +01:00
VileRancour
ffe3c5ab7f Add cga_mono machine
Emulates the user using a CGA card with a monochrome monitor.
Monochrome monitor options are: green, amber, white or paperwhite.
The color can be changed at runtime with F11.

Include paperwhite color by Basic <basic@vogons.org>
https://www.vogons.org/viewtopic.php?p=587382#p587382

Vogons thread: https://www.vogons.org/viewtopic.php?f=41&t=29101

Signed-off-by: Michael Zijlstra <mzijlstra@gmail.com>
Signed-off-by: Patryk Obara <dreamer.tan@gmail.com>

Imported-from: https://www.vogons.org/viewtopic.php?p=238045#p238045
2020-01-29 13:46:23 +01:00
krcroft
878959a0aa Formatting and review fixes 2020-01-22 09:40:00 +01:00
krcroft
3391651323 Fix NULL issues in shell code 2020-01-22 09:40:00 +01:00
Patryk Obara
2159cb9aec Use correct type for printf field size specifier
Formatting options for printf family of functions use int as a type
for formatting a field size.
2020-01-04 08:26:22 +01:00
Patryk Obara
c4dba16740 Move drives.h to common include dir
Judging by the usage, this header belongs in there instead of being
limited to dos module only.  This change makes it easier to reuse code
for new features related to drives mounting/unmounting.
2020-01-04 08:26:22 +01:00
Patryk Obara
8da42c5983 Remove false friend declarations
The single use from friended class is in public interface. Removal of
friend designators allows Clang to pinpoint few additional unused
private fields.
2020-01-04 08:26:22 +01:00
Patryk Obara
6ed2396a2e Print a newline after 'path' command 2019-12-29 08:12:28 +01:00
Patryk Obara
5c1c653098 Print a newline after user makes a choice
Previously, this command expected newline to be injected by the shell
(which was incorrect behaviour, as shell was skipping it in batch
files).
2019-12-29 08:12:28 +01:00
Patryk Obara
1bdb67b2c3 Add an assert in 'choice' command
Static analyzer indicates that in this context `rem` can be NULL,
therefore should not be passed to strchr, but in this context `rem`
cannot be NULL becasuse `args` is not NULL (even after StripSpaces).
2019-12-29 08:12:28 +01:00
Patryk Obara
bb2088eb72 Fix a number of effc++ warnings in shell code 2019-12-27 07:34:48 +01:00
Patryk Obara
08a7f47c2b Fix output of 'dir /w /p' and edge cases
Previous implementation avoided invocation of 'pause' in many edge
cases, e.g.: when pause should be invoked between summary lines.

Avoid displaying '.' and '..' in root directory of mounted drive (just
like other dir implementations do).

Use C++11 for-each loop for iterating over directory entries.

Split code inside the loop by option, resulting in more readable
implementation.

Use "%*s" to inject empty whitespace of calculated size instead of
outputting spaces in a loop.

Leave some TODO notes describing further improvements.
2019-12-27 07:34:48 +01:00
Patryk Obara
64949a6e8c Print volume/drive label in 'dir' cmd
This is in line with any other implementation of 'dir' command. It's
also very useful for identifying e.g. which floppy is currently mounted.

MS-DOS and cmd.exe display Volume Serial Number, but it emulating it in
DOSBox doesn't seem to be very useful.
2019-12-27 07:34:48 +01:00
Patryk Obara
3eaabb41c1 Fix output formatting of 'dir' command
Adapt to 'pause' command working correctly (assuming the terminal height
is 25, this will need further adjustments for supporting 80x50 and
different modes).

Adjust "intro" by 1 space to make formatting the same as MS-DOS 'dir'
command - this makes intro not "merge" visually with the files listed.

Adjust placing of files and directories counters, to make it resemble
most 'dir' implementations.

Count intro lines for purpose of correct pagination with 'dir /p'.

Skip counting not printed lines with 'dir /b /p'.

Output of 'dir /w /p' is still broken, but fixing it will require more
invasive changes.

Fixes: #75
2019-12-23 21:52:37 +01:00
Patryk Obara
e68a64aade Adjust 'help /all' to fixed 'pause' 2019-12-23 21:52:37 +01:00
Patryk Obara
b0cdfa5161 Do not print newline after every command
This newline is already ommitted from batch files and noecho commands,
this change makes the behaviour consistent in interactive mode.

Additional newline is a behaviour inherited from MS-DOS, and even still
visible in Windows cmd.exe, but all modern DOS implementations,
PowerShell, unix terminals, etc - they all prefer consistent behaviour
over addtional newline. Also, there's no point in wasting 4% of screen
estate just to show empty line.

This fixes CLS command, which is now able to properly clean the screen
and place prompt in the first line.
2019-12-23 21:52:37 +01:00
Patryk Obara
c20579a835 Display newline after key was pressed in 'pause' cmd
Move newline from the string message to the WriteOut in command itself.
This makes the PAUSE command behave like the original, which is
important for commands like DIR /P.
2019-12-23 21:52:37 +01:00
Patryk Obara
5f9ac5eeab Remove code ifdefed for OS/2
Cleanup before replacing SDL1.2 with SDL2.

OS/2 support was introduced in DOSBox in March 2006.  OS/2 reached EOL
in December 2006.

As of 2019, OS/2 is being continued by proprietary 32-bit only ArcaOS,
although there is no official SDL2 support, despite pledges from SDL2
maintainers.
2019-12-09 16:27:11 +01:00
Patryk Obara
59edc4d9b5 Change the length of version field in infobox
Otherwise, infobox looks broken when version string has more
than 8 characters.
2019-11-29 06:27:14 +01:00
Patryk Obara
64671a888c Avoid passing null to strcat
Static analysis indicated an issue, when line was being passed as 2nd
argument to strcat:

Null pointer passed as an argument to a 'nonnull' parameter

Replace repeated strcat with creating a formatted string and use
the opportunity to do a small format cleanup.
2019-11-24 17:14:32 +01:00
Patryk Obara
a4a6bed5c1 Merge branch 'svn/trunk' 2019-10-01 18:11:50 +02:00
Peter Veenstra
a919e33aec Pick some lowhanging fruit. (some memory leaks and unused variables)
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4264
2019-10-01 12:11:09 +00:00
Patryk Obara
b62a637157 Import svn:ignore props to .gitignore files 2019-09-15 20:34:57 +02:00
Sjoerd van der Berg
53666d5f27 Extra DIR sorting options patch by Saga Musix
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4255
2019-09-08 12:25:41 +00:00
Peter Veenstra
bec0e79890 Don't remove bytes from autoexec.bat when changing settings from autoexec.bat, but replace them instead. This way the location stays valid.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4212
2019-04-20 13:55:35 +00:00
Peter Veenstra
eb26b9a58e Change first_shell to be DOS_Shell instead of Program. Makes future manipulations easier.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4211
2019-04-20 13:48:55 +00:00
Peter Veenstra
111fa1d45b Check lengths before adding C style strings together. Fixes #498
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4202
2019-04-03 10:31:52 +00:00
Peter Veenstra
1fbaff47fc Update year and address of FSF
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4183
2019-01-25 14:09:58 +00:00
ripsaw8080
31d7e74eac It is more compatible with DOS to not insert carriage returns in the console device.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4114
2018-06-12 20:04:10 +00:00
Peter Veenstra
5bb10db88b Time keeps on ticking
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4109
2018-05-29 12:58:58 +00:00
Peter Veenstra
4bcbd35104 Fix ExpandDot not caring about the size of the buffer. (vogons topic 59658)
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4108
2018-05-29 09:27:16 +00:00
Peter Veenstra
80740117b9 Take length in consideration before moving the echo off upwards.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4106
2018-05-24 18:09:21 +00:00
Peter Veenstra
85789a06da Fix echo off being written twice. Attempt to make the line endings in the generated autoexec.bat all DOS style line endings.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4105
2018-05-22 15:18:45 +00:00
Peter Veenstra
6485a80102 Silence a warning
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4070
2018-01-30 15:57:27 +00:00
Peter Veenstra
6cf39c1fc6 Years update
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4021
2017-05-30 11:35:08 +00:00
Peter Veenstra
a3345eed24 Spaces in LOG_MSG and some at the end of the line.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3999
2016-10-02 14:12:32 +00:00
ripsaw8080
4555aa279d Implement INT 2E -- fixes Gold of the Aztecs and a few other games. Also, stop writing uninitialized junk into first shell's command tail at startup.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3979
2016-04-05 05:48:00 +00:00
Peter Veenstra
3000bd2feb Be a bit more flexible. Parse ver set 3.2 correctly as well.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3964
2016-02-10 09:42:32 +00:00
Peter Veenstra
2a1ae6fb9c Improve rename support for when renaming files (in a folder) on a drive different from the current one.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3947
2015-10-08 19:51:01 +00:00
Peter Veenstra
c8a128d733 Rework the parsing of arguments into the FCBs:
- We now first split the line into arguments using space,tab,;,=,',' as separators.
- Next we convert /Hello into H ello 
- Lastly we feed the arguments 1 and 2 to the FCB_Parsename function
(- It got messy, but the results are better )

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3942
2015-10-02 20:23:14 +00:00
Peter Veenstra
cb28976df6 More robust parsing, so that dosbox -fullscreen A.EXE works
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3934
2015-09-08 13:46:26 +00:00
ripsaw8080
5a748e5cbb Display a simple startup message for sub-shells instead of the welcome banner.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3930
2015-08-17 15:06:28 +00:00
ripsaw8080
59c9ae1d60 Fix shell PAUSE command when reading extended keys, and make TYPE command more compatible by stopping at EOF byte.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3927
2015-08-05 14:56:36 +00:00
Peter Veenstra
acd7b73c8a Ignore/remove single % in batchfiles. (Fixes B13Demo batchfiles on pcgamer coverdisc 1995-08)
Remove magic constants.
Add some boundary checks.

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3925
2015-07-15 16:31:35 +00:00
Peter Veenstra
e4b97eb62e Handle "copy H*.txt file.txt" correctly
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3907
2015-03-18 14:38:24 +00:00