Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cmdline fix #96

Merged
merged 3 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ if not "%MAKE%" == "" goto skip_make
if "%COMPILER%" == "TC2" set MAKE=%TC2_BASE%\make -f
if "%COMPILER%" == "TURBOCPP" set MAKE=%TP1_BASE%\bin\make -f
if "%COMPILER%" == "BC5" set MAKE=%BC5_BASE%\bin\make -f
if "%COMPILER%" == "WATCOM" set MAKE=wmake /ms /h /f
if "%COMPILER%" == "WATCOM" set MAKE=wmake -ms -h -f

echo Make is %MAKE%.

Expand All @@ -97,10 +97,10 @@ echo Checking SUPPL library
cd suppl
if exist skip goto endSuppl
echo Building SUPPL library
%MAKE%suppl.mak all
%MAKE% suppl.mak all
if errorlevel 1 goto ende
cd src
%MAKE%suppl.mak all
%MAKE% suppl.mak all
if errorlevel 1 goto ende
cd ..
:endSuppl
Expand All @@ -110,50 +110,50 @@ echo.
echo Making basic utilities for build process
echo.
cd utils
%MAKE%utils.mak all
%MAKE% utils.mak all
if errorlevel 1 goto ende
cd ..

echo.
echo Making STRINGS resource
echo.
cd strings
%MAKE%strings.mak all
%MAKE% strings.mak all
if errorlevel 1 goto ende
cd strings
%MAKE%strings.mak all
%MAKE% strings.mak all
if errorlevel 1 goto ende
cd ..\..

echo.
echo Making CRITER resource
echo.
cd criter
%MAKE%criter.mak all
%MAKE% criter.mak all
if errorlevel 1 goto ende
cd ..

echo.
echo Making misc library
echo.
cd lib
%MAKE%lib.mak all
%MAKE% lib.mak all
if errorlevel 1 goto ende
cd ..

echo.
echo Making commands library
echo.
cd cmd
%MAKE%cmd.mak all
%MAKE% cmd.mak all
if errorlevel 1 goto ende
cd ..

echo.
echo Making COMMAND.COM
echo.
cd shell
%MAKE%command.mak all
%MAKE% command.mak all
if errorlevel 1 goto ende
cd ..

Expand All @@ -172,7 +172,7 @@ cd tools
type tools.m1 >tools.mak
..\utils\mktools.exe >>tools.mak
type tools.m2 >>tools.mak
%MAKE%tools.mak all
%MAKE% tools.mak all
if errorlevel 1 goto ende
cd ..

Expand Down
115 changes: 58 additions & 57 deletions lib/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

#if defined(__WATCOMC__) || defined(__GNUC__)
struct fcb {
char bytes[0x25];
char bytes[0x25];
};

#ifdef __WATCOMC__
Expand All @@ -93,24 +93,24 @@ char *parsfnm(const char *cmdline, struct fcb far *fcbptr, int option);
#else /* __GNUC__ */
static char *parsfnm(const char *cmdline, struct fcb far *fcbptr, int option)
{
char *ret;
unsigned char opt = option;
asm volatile("int $0x21" :
"=S"(ret), "+Ral"(opt) :
"Rah"((unsigned char)0x29), "e"(FP_SEG(fcbptr)), "D"(FP_OFF(fcbptr)),
"Rds"(FP_SEG(cmdline)), "0"(cmdline) :
"cc", "memory");
return opt == 0xff ? NULL : ret;
char *ret;
unsigned char opt = option;
asm volatile("int $0x21" :
"=S"(ret), "+Ral"(opt) :
"Rah"((unsigned char)0x29), "e"(FP_SEG(fcbptr)), "D"(FP_OFF(fcbptr)),
"Rds"(FP_SEG(cmdline)), "0"(cmdline) :
"cc", "memory");
return opt == 0xff ? NULL : ret;
}
#endif
#endif

struct ExecBlock
{
word segOfEnv;
char far *cmdLine;
struct fcb far *fcb1;
struct fcb far *fcb2;
word segOfEnv;
char far *cmdLine;
struct fcb far *fcb1;
struct fcb far *fcb2;
};

#include "algndflt.h"
Expand All @@ -123,43 +123,44 @@ int exec(const char *cmd, char *cmdLine, const unsigned segOfEnv)
# define buf dosCMDTAIL
# define memcpy _fmemcpy
#else
unsigned char buf[MAX_EXTERNAL_COMMAND_SIZE+2]; /* 128 bytes is max size in PSP, 2 bytes for size and terminator */
unsigned char buf[MAX_EXTERNAL_COMMAND_SIZE+2]; /* 128 bytes is max size in PSP, 2 bytes for size and terminator */
#endif
struct fcb fcb1,
fcb2;
struct ExecBlock execBlock;
int retval;
int cmdLen;


assert(cmd);
assert(cmdLine);

invalidateNLSbuf();

/* generate Pascal string from the command line */
/* we assume passed in c string (ASCIIZ) */
cmdLen = strlen(cmdLine);
if (cmdLen > MAX_EXTERNAL_COMMAND_SIZE) {
/* we assume CMDLINE environment variable already set with full cmdLine */
/* so we simply truncate passed command line to max size, terminated by \r, no \0 for callee */
/* for maximum compatibility set size to 127 (0x7f) */
buf[0] = (unsigned char)(MAX_EXTERNAL_COMMAND_SIZE+1);
memcpy(&buf[1], cmdLine, MAX_EXTERNAL_COMMAND_SIZE);
/* terminate with just carriage return \r */
memcpy(&buf[1] + buf[0], "\xd", 1);
} else {
/* set size of actual command line and copy to buffer */
memcpy(&buf[1], cmdLine, buf[0] = strlen(cmdLine));
/* ensure terminated with \r\0 */
memcpy(&buf[1] + buf[0], "\xd", 2);
}

/* fill FCBs */
if ((cmdLine = parsfnm(cmdLine, &fcb1, 1)) != 0)
parsfnm(cmdLine, &fcb2, 1);

saveSession();
struct fcb fcb1, fcb2;
struct ExecBlock execBlock;
int retval;
int cmdLen;

assert(cmd);
assert(cmdLine);

invalidateNLSbuf();

/* generate Pascal string from the command line */
/* we assume passed in c string (ASCIIZ) */
cmdLen = strlen(cmdLine);
if (cmdLen > MAX_EXTERNAL_COMMAND_SIZE) {
/* we assume CMDLINE environment variable already set with full cmdLine */
/* so we simply truncate passed command line to max size, terminated by \r, no \0 for callee */
/* for maximum compatibility set size to 127 (0x7f) */
buf[0] = (unsigned char)(MAX_EXTERNAL_COMMAND_SIZE+1);
memcpy(&buf[1], cmdLine, MAX_EXTERNAL_COMMAND_SIZE);
/* terminate with just carriage return \r */
buf[MAX_EXTERNAL_COMMAND_SIZE+1] = '\x0d';
} else {
/* set size of actual command line and copy to buffer */
buf[0] = (unsigned char)cmdLen;
memcpy(&buf[1], cmdLine, cmdLen);
/* ensure terminated with \r\0, if less then 126 characters
or \r, if exactly 126 characters */
memcpy(&buf[1] + cmdLen, "\x0d", (cmdLen < MAX_EXTERNAL_COMMAND_SIZE) ? 2 : 1);
}

/* fill FCBs */
if ((cmdLine = parsfnm(cmdLine, &fcb1, 1)) != 0) {
parsfnm(cmdLine, &fcb2, 1);
}

saveSession();

#ifdef FEATURE_XMS_SWAP
if(XMSisactive() && swapOnExec == TRUE) {
Expand All @@ -174,16 +175,16 @@ int exec(const char *cmd, char *cmdLine, const unsigned segOfEnv)
} else
#endif
{
/* fill execute structure */
execBlock.segOfEnv = segOfEnv;
execBlock.cmdLine = (char far *)buf;
execBlock.fcb1 = (struct fcb far *)&fcb1;
execBlock.fcb2 = (struct fcb far *)&fcb2;
/* fill execute structure */
execBlock.segOfEnv = segOfEnv;
execBlock.cmdLine = (char far *)buf;
execBlock.fcb1 = (struct fcb far *)&fcb1;
execBlock.fcb2 = (struct fcb far *)&fcb2;

retval = lowLevelExec((char far*)cmd, (struct ExecBlock far*)&execBlock);
retval = lowLevelExec((char far*)cmd, (struct ExecBlock far*)&execBlock);
}

restoreSession();
restoreSession();

return retval;
return retval;
}