Skip to content

Commit bb8b581

Browse files
committed
add some comments and debug prints
1 parent 93add63 commit bb8b581

File tree

2 files changed

+25
-20
lines changed

2 files changed

+25
-20
lines changed

kernel/newstuff.c

+1-14
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,9 @@
2525
/* Cambridge, MA 02139, USA. */
2626
/****************************************************************/
2727

28-
#ifdef VERSION_STRINGS
29-
static BYTE *mainRcsId =
30-
"$Id: newstuff.c 1479 2009-07-07 13:33:24Z bartoldeman $";
31-
#endif
32-
3328
#include "portab.h"
3429
#include "globals.h"
30+
#include "debug.h"
3531

3632
/*
3733
TE-TODO: if called repeatedly by same process,
@@ -104,9 +100,6 @@ long DosMkTmp(BYTE FAR * pathname, UWORD attr)
104100
return rc;
105101
}
106102

107-
#ifdef DEBUG
108-
#define DEBUG_TRUENAME
109-
#endif
110103

111104
#define drLetterToNr(dr) ((unsigned char)((dr) - 'A'))
112105
/* Convert an uppercased drive letter into the drive index */
@@ -236,12 +229,6 @@ long DosMkTmp(BYTE FAR * pathname, UWORD attr)
236229
237230
*/
238231

239-
#ifdef DEBUG_TRUENAME
240-
#define tn_printf(x) printf x
241-
#else
242-
#define tn_printf(x)
243-
#endif
244-
245232
#define PNE_WILDCARD 1
246233
#define PNE_DOT 2
247234

kernel/task.c

+24-6
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,9 @@
2828

2929
#include "portab.h"
3030
#include "globals.h"
31+
#include "debug.h"
32+
3133

32-
#ifdef VERSION_STRINGS
33-
static BYTE *RcsId =
34-
"$Id: task.c 1563 2011-04-08 16:04:24Z bartoldeman $";
35-
#endif
3634

3735
#define toupper(c) ((c) >= 'a' && (c) <= 'z' ? (c) + ('A' - 'a') : (c))
3836

@@ -130,6 +128,9 @@ STATIC UWORD SetverGetVersion(BYTE FAR *table, BYTE FAR *name)
130128
return 0;
131129
}
132130

131+
/* allocate memory for and copy current process env to child environment
132+
returns segment of env MCB (not env block itself) in pChildEnvSeg
133+
*/
133134
STATIC COUNT ChildEnv(exec_blk * exp, UWORD * pChildEnvSeg, char far * pathname)
134135
{
135136
BYTE FAR *pSrc;
@@ -167,18 +168,27 @@ STATIC COUNT ChildEnv(exec_blk * exp, UWORD * pChildEnvSeg, char far * pathname)
167168
if (nEnvSize >= MAXENV - ENV_KEEPFREE)
168169
return DE_INVLDENV;
169170

171+
/* loop until first double terminator '\0\0' found */
170172
if (*(UWORD FAR *) (pSrc + nEnvSize) == 0)
171173
break;
172174
}
173175
nEnvSize += 2; /* account for trailing \0\0 */
174176
}
175177

176-
/* allocate enough space for env + path */
178+
/* allocate enough space for env + path (rounding up to nearest para)
179+
Note: we must allocate at least 1 paragraph (16 bytes) for empty environment
180+
+ ENV_KEEPFREE for argv[0] (program name)
181+
*/
182+
DebugPrintf(("PriPathName is %lu bytes\n", sizeof(PriPathName)));
183+
assert(sizeof(PriPathName)+3==ENV_KEEPFREE);
177184
if ((RetCode = DosMemAlloc((nEnvSize + ENV_KEEPFREE + 15)/16,
178185
mem_access_mode, pChildEnvSeg,
179186
NULL /*(UWORD FAR *) MaxEnvSize ska */ )) < 0)
187+
{
188+
DebugPrintf(("Error alloc Env space\n"));
180189
return RetCode;
181-
pDest = MK_FP(*pChildEnvSeg + 1, 0);
190+
}
191+
pDest = MK_FP(*pChildEnvSeg + 1, 0); /* skip past MCB and set pDest to start of env block */
182192

183193
/* fill the new env and inform the process of its */
184194
/* location throught the psp */
@@ -199,8 +209,10 @@ STATIC COUNT ChildEnv(exec_blk * exp, UWORD * pChildEnvSeg, char far * pathname)
199209
/* copy complete pathname */
200210
if ((RetCode = truename(pathname, PriPathName, CDS_MODE_SKIP_PHYSICAL)) < SUCCESS)
201211
{
212+
DebugPrintf(("Failed to get truename for env argv0\n"));
202213
return RetCode;
203214
}
215+
DebugPrintf(("ChildEnv for [%s]\n", PriPathName));
204216
fstrcpy(pDest, PriPathName);
205217

206218
/* Theoretically one could either:
@@ -472,6 +484,9 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd)
472484
}
473485

474486
rc = ChildEnv(exp, &env, namep);
487+
#if DEBUG
488+
if (rc != SUCCESS) DebugPrintf(("Failed to create ChildEnv\n"));
489+
#endif
475490

476491
/* COMFILES will always be loaded in largest area. is that true TE */
477492
/* yes, see RBIL, int21/ah=48 -- Bart */
@@ -652,6 +667,9 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd)
652667
}
653668

654669
rc = ChildEnv(exp, &env, namep);
670+
#if DEBUG
671+
if (rc != SUCCESS) DebugPrintf(("Failed to create ChildEnv\n"));
672+
#endif
655673

656674
if (rc == SUCCESS)
657675
/* Now find out how many paragraphs are available */

0 commit comments

Comments
 (0)