www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/10/27/11:36:51

From: "Graeme Fenwick" <gfenwick AT BYESPAMprimex DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: /? command line args being altered by DJGPP
Date: Tue, 27 Oct 1998 16:23:07 -0000
Lines: 38
X-Newsreader: Microsoft Outlook Express 4.72.2106.4
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4
NNTP-Posting-Host: ppp47-43.dial.nildram.co.uk
Message-ID: <3635f355.0@scooby.nildram.co.uk>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi all!

At first I thought this was 99% certain to be a DOS issue. Now that I've
recompiled the program with "lcc", and not recieved the same effect, it now
seems more likely to be DJGPP specific.

Put simply, I've written (part of a) program to parse command line
arguments, and it's running into trouble when I try to read the arguments
"/?", "/??", "/???" and so on. For some reason, the argument is sometimes
being converted into what seems like a directory name(!), so the program
itself isn't reading the argument as "/?".

I've written a test program to illustrate the point-

            #include <stdio.h>

            int main(int argc, char **argv)
            {
               printf("%s\n", argv[1]);
               return 0;
            }

If the program is compiled like so-
            gcc -Wall -ansi -o test test.c
then typing
            "test /?" gives the output "/a"
            "test /??" gives the output "/??" (correct, this time)
            "test /???" gives the output "/ati"
and so on....

Like I said, it looks like an OS issue at first, but the lcc-compiled
version doesn't do this..! Any ideas?...

--
Graeme Fenwick - gfenwick AT BYESPAMprimex DOT co DOT uk
  (Remove "BYESPAM" spam filter when replying by mail)


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019