[comp.lang.c] Bug in MSC 4.0 small/medium libraries?

creps@silver.bacs.indiana.edu (Steve Creps) (10/23/88)

   There seems to be a bug in or related to the intdosx() routine in
MSC 4.0, in the SMALL and MEDIUM models.
   Given the following code:

<>#include <stdio.h>
<>#include <sys/dta.h>
<>#include <doslib.h>
<>main(argc, argv)
<>int argc;
<>char *argv[];
<>{
<>	DTA *dta;
<>	printf("filespec: %s\n", argv[1]);
<>	if (findfirst(argv[1], (unsigned)0)) { /* this is the important line */
<>		do {
<>			dta = getDTA();
<>			printf("\t%s\n", dta->dta_filename);
<>		} while (findnext());
<>	} else {
<>		fprintf(stderr, "No match.\n");
<>	}
<>	return;
<>
<>int
<>findfirst(filespec, attr)
<>char *filespec;
<>unsigned int attr;
<>{
<>	regs.h.ah = 0x4e;
<>	regs.x.cx = attr;
<>	regs.x.dx = FP_OFF(filespec);
<>	sregs.ds = FP_SEG(filespec);
<>	intdosx(&regs, &regs, &sregs);
<>	return !regs.x.cflag;
<>}

   ..., the program normally should print a list of files in the current
directory when passed "*.*" as an argument. It does so using the large
and compact models. However, with the small and medium models the first
call to findfirst() always fails, whether the program is passed "*.*" or
what-have-you. Checking the ax register after the call to intdosx() from
findfirst() reveals an error code of 3, "path not found." Normally this
code should be 2 , "file not found," or 18, "no more files."
   Again, the only difference in the program working properly, or not
working properly, is whether it is compiled L/C or M/S.
   Is this a known bug, or have I found a new one? Also, does anyone have
a patch or replacement routine to correct whatever library routine is buggy?

-	-	-	-	-	-	-	-	-	-
Steve Creps, Indiana University, Bloomington, home of the "Hoosiers"
	creps@silver.bacs.indiana.edu (129.79.1.6)
	{inuxc,rutgers,pyramid,pur-ee}!iuvax!silver!creps
	creps@iubacs.bitnet (forwarded)