Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!killer!ames!lll-tis!lll-winken!uunet!mcvax!philmds!leo From: leo@philmds.UUCP (Leo de Wit) Newsgroups: comp.sys.atari.st Subject: Re: A ghost in the house Message-ID: <557@philmds.UUCP> Date: 8 Jul 88 11:45:06 GMT References: <511@stag.UUCP> Reply-To: leo@philmds.UUCP (Leo de Wit) Organization: Philips I&E DTS Eindhoven Lines: 46 In article <511@stag.UUCP> stdnet@stag.UUCP writes: >From: thelake!steve@stag.UUCP (Steve Yelvington) > > >I compiled a directory lister with Mark Johnson C, version 2.0. >It works just fine, but at the end of the directory, it prints out a >message on the console: "(no more files)". > >This message is nowhere to be found in my program or in the MJC library. >So I figure that either it is coming from GEMdos, or I have a friendly ghost. >I want it to go away. > >One of the local programmers (John Osawa, author of the Schizo desk >accessory) tried my code with Mark Williams C and got no such message. >He suggested that MJC's startup code may throw a switch, and mentioned >something about Perror. I thumbed through "Atari ST Application >Programming" (Pollack and Weber), but found no references to Perror. >It's not in osbind.h. I found nothing like it in the MJC startup routines, >either. > >So: What is Perror? How do I shut off this message? In Unix the function perror() prints out its string argument, followed by a colon and an error message. This error message is from an array (something like char *sys_errlist[]; but you don't have to declare it) and is indexed into by the global int errno, which contains the last O.S. error encountered. Probably your Perror behaves just like this - maybe it is in the startup code with which MJC C binaries are linked and activated when the last error encountered is non-zero (just guessing). Most likely the GEMDOS calls Fsfirst and Fsnext are used to scan a directory; when Fsnext fails at last - no more files that satisfy the spec - it returns -49. I suggest you check the global ints like errno (maybe there's also an oserr), print them out after the directory scan. One of them will most likely contain -49. To shut off this message you have two options: just set errno to 0 before exiting (or the global int that is 'responsible') or if you dislike the 'automatic' Perror (I would) you could patch the startup code with NOP's on the relevant place(s). extern int errno; errno = 0; /* and then leave main() or do exit() */ Hope this helps... Leo.