add some debug messages, use master_env even if no SET= in config.sys, cosmetic changes to sys

git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1077 6ac86273-5f31-0410-b378-82cca8765d1b
This commit is contained in:
Kenneth J Davis 2004-12-22 12:11:00 +00:00
parent d3482e2c86
commit 47137fde93
3 changed files with 80 additions and 8 deletions

View File

@ -129,6 +129,10 @@ struct config Config = {
/* unsigned ebda2move; */ 0, /* value for SWITCHES=/E:nnnn */
};
/* master_env copied over command line area in
DOS_PSP, thus its size limited to 128 bytes */
static char master_env[128] = "PATH=.";
STATIC seg_t base_seg BSS_INIT(0);
STATIC seg_t umb_base_seg BSS_INIT(0);
VFP lpTop BSS_INIT(0);
@ -293,6 +297,9 @@ void PreConfig(void)
#ifdef DEBUG
printf("Preliminary allocation completed: top at %p\n", lpTop);
#endif
/* initialize environment */
fmemcpy(MK_PTR(char, DOS_PSP + 8, 0), master_env, sizeof(master_env));
}
static void KernelAllocSFT(sfttbl FAR *p, unsigned files, int high)
@ -2066,8 +2073,8 @@ STATIC void _CmdInstall(PCStr p, int mode)
if (len > sizeof args.ctBuffer - 2)
len = sizeof args.ctBuffer - 2; /* trim too long line */
args.ctCount = (UBYTE)len;
args.ctBuffer[len] = '\r';
args.ctBuffer[len+1] = 0;
args.ctBuffer[len-2] = '\r';
args.ctBuffer[len-1] = '\0';
memcpy(args.ctBuffer, p, len);
set_strategy(mode);
@ -2109,7 +2116,7 @@ VOID DoInstall(void)
/* master_env copied over command line area in
DOS_PSP, thus its size limited to 128 bytes */
static char master_env[128] = "PATH=.";
/* static char master_env[128] = "PATH=."; */
/* !!! dirty hack: because bug in old FreeCOM, which wrongly
process empty environment in MS-DOS style, garbage empty

View File

@ -136,7 +136,7 @@ STATIC int ChildEnv(seg_t env_seg, seg_t *penv_seg, const char far *path)
{
seg_t dst_seg = *penv_seg + 1;
/* enviornment contains:
/* environment contains:
- 0 or more ASCIIZ strings (with variable definitions);
- empty ASCIIZ string (one null character);
- 16-bit counter (usually 1);
@ -151,6 +151,45 @@ STATIC int ChildEnv(seg_t env_seg, seg_t *penv_seg, const char far *path)
*MK_PTR(UWORD, dst_seg, env_sz + 2) = 1;
fstrcpy(MK_PTR(char, dst_seg, env_sz + 4), PriPathName);
}
#if DEBUG
{
seg_t dst_seg = *penv_seg + 1;
int i;
printf("ChildEnv. env seg=0x%02x\n", dst_seg);
if (dst_seg)
{
const char FAR*p = MK_PTR(const char, dst_seg, 0);
/* loop through ASCIIZ env variables */
if (*p)
while (*p)
{
printf("[");
for (; *p; p++)
if (*p == ' ') printf("<space>");
else printf("%c", *p);
printf("]\n");
p++;
}
else
p++; /* even empty env must have 1 ("") ASCIIZ string */
/* may be followed by empty string (just \0), 16bit count, ASCIIZ argv[0] */
printf("End of Env marker = 0x%02x (should be 0)\n", *p);
printf("argv[0] present = %u\n", *MK_PTR(UWORD, dst_seg, env_sz + 2));
p+=3; /* skip 16bit count and point to argv[0] */
if (*p)
{
for (i = 0; p[i] && (i < 127); i++)
printf("%c", p[i]);
printf("\n");
}
else
printf("No program name (argv[0]) supplied\n");
}
}
#endif
return SUCCESS;
}
@ -292,6 +331,32 @@ static void load_transfer(seg_t ds, exec_blk *ep, int mode)
fcbcode = (get_cds1(p->ps_fcb1.fcb_drive) ? 0 : 0xff) |
(get_cds1(p->ps_fcb2.fcb_drive) ? 0 : 0xff00);
#ifdef DEBUG
{
int i, ctCount=ep->exec.cmd_line->ctCount;
/* display full command line */
if (ctCount > 127)
{
printf("load_transfer. CommantTail=%d count exceeds 127\n", ctCount);
ctCount = 127;
}
printf("load_transfer. CommandTail is:\n");
/* use loop in case tail not '\0' terminated */
if (ctCount)
{
for (i=0; i < ctCount; i++)
if (ep->exec.cmd_line->ctBuffer[i] == ' ')
printf("<space>");
else
printf("%c", ep->exec.cmd_line->ctBuffer[i]);
printf("\n");
}
else
printf("<empty>\n");
}
#endif
/* Transfer control to the executable */
if (mode == LOADNGO)
{

View File

@ -660,7 +660,7 @@ void initOptions(int argc, char *argv[], SYSOptions *opts)
char *comspec = getenv("COMSPEC");
if (opts->fnCmd || (comspec == NULL) || stat(comspec, &fstatbuf))
{
printf("%s: failed to find command interpreter (shell) file %s\n", pgm, (opts->fnCmd)?opts->fnCmd:"COMMAND.COM");
printf("%s: failed to find command interpreter (shell) file %s\n", pgm, srcFile);
exit(1);
}
}
@ -711,7 +711,7 @@ int main(int argc, char **argv)
{
char *comspec = getenv("COMSPEC");
if (!opts.fnCmd && (comspec != NULL))
printf("%s: Trying shell from %COMSPEC%=\"%s\"\n", pgm, comspec);
printf("%s: Trying shell from %%COMSPEC%%=\"%s\"\n", pgm, comspec);
if (opts.fnCmd || (comspec == NULL) || !copy(comspec, opts.dstDrive, "COMMAND.COM"))
{
printf("\n%s: failed to find command interpreter (shell) file %s\n", pgm, (opts.fnCmd)?opts.fnCmd:"COMMAND.COM");
@ -1443,7 +1443,7 @@ BOOL copy(const BYTE *source, COUNT drive, const BYTE * filename)
open(dest, O_RDWR | O_TRUNC | O_CREAT | O_BINARY,
S_IREAD | S_IWRITE)) < 0)
{
printf(" %s: can't create\"%s\"\nDOS errnum %d", pgm, dest, errno);
printf(" %s: can't create\"%s\"\nDOS errnum %d\n", pgm, dest, errno);
close(fdin);
return FALSE;
}
@ -1486,7 +1486,7 @@ BOOL copy(const BYTE *source, COUNT drive, const BYTE * filename)
};
#endif
printf("%lu Bytes transferred", copied);
printf("%lu Bytes transferred\n", copied);
return TRUE;
} /* copy */