From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: BUG: DJGPP, argc and * Date: Wed, 11 Jun 1997 20:03:48 +0000 Organization: Two pounds of chaos and a pinch of salt Lines: 35 Message-ID: <339F04A4.2AA1@cs.com> References: <199706110609 DOT JAA19858 AT andromeda DOT delta DOT edu DOT gr> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp108.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Kappas Ioannis wrote: > > I think I've found a bug in DJGPP. When an argument in the command line is > the character * the argc is 108 instead of 2. > consider this program: > main(int argc, char *argv[]) > { > printf("%d\n", argc); > return 0; > } > > when we call the program with the asterisk, e.g. "a *" the argc is returning > 109 instead of 2. Is this normal or is this a bug?? You undoubtedly have 107 files in the directory from which you run your program. '*' on the command line is automatically wildcard-expanded to the names of all files in the directory. (This is also true in DOS, btw - "dir *" gives all files; "dir *." gives all files w/o extensions.) DJGPP programs use the Unix (POSIX) style of command line globbing, and the function responsible for this is part of the startup code. The FAQ has instructions on disabling it in chapter 8.15; also look up __crt0_glob_function() in the libc documentation. A workaround would be to enclose the * in quotes; i.e., foo "*". hth -- --------------------------------------------------------------------- | John M. Aldrich | "Be wary of strong drink. It can | | aka Fighteer I | make you shoot at tax collectors-- | | mailto:fighteer AT cs DOT com | and miss." | | http://www.cs.com/fighteer | - Lazarus Long | ---------------------------------------------------------------------