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(®s, ®s, &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)
jbvb@ftp.COM (James Van Bokkelen) (10/25/88)
In article <2509@silver.bacs.indiana.edu>, creps@silver.bacs.indiana.edu (Steve Creps) writes: > > 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: > .... > <>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); Look carefully at the definitions of FP_SEG & FP_OFF in DOS.H. They assume the pointer they are working on is 32 bits long, which is only true in the "large data" models. If you need one routine which works in all models, the simplest fix is probably to put in an explicit cast to "char far *" and continue to use FP_OFF & FP_SEG. Intel. Segments. Ennnnhhhh....... James VanBokkelen FTP Software Inc.