delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/09/23/11:52:06

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Thu, 23 Sep 2004 11:51:37 -0400 (EDT)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: =?iso-8859-1?Q?Mikael_=C5sberg?= <mikas493 AT student DOT liu DOT se>
cc: cygwin AT cygwin DOT com
Subject: Re: Same code, same script, different results
In-Reply-To: <007501c4a172$a96aa9e0$b200a8c0@mindcooler>
Message-ID: <Pine.GSO.4.61.0409231148470.29444@slinky.cs.nyu.edu>
References: <007501c4a172$a96aa9e0$b200a8c0 AT mindcooler>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.39

---559023410-684387517-1095954697=:29444
Content-Type: TEXT/PLAIN; charset=iso-8859-1
Content-Transfer-Encoding: 8BIT

On Thu, 23 Sep 2004, Mikael Åsberg wrote:

> Hello, I am using the latest Cygwin with all packages updated (running
> Windows XP Professional SP2) and I'm having a problem with a simple C++
> program that uses the Win32 API to scan a directory (recursively or
> non-recursively, depending on user input). The code is as follows:
>
> [snip]
>      if(strcmp(argv[2], "--non-recursive") == 0) {
>         recursive = false;
>         cout << "Will perform a non-recursive scan of directory "
>              << argv[1] << "." << endl;
>      } else {
>         cerr << "Ignoring unknown option " << argv[2] << "." << endl;
>      }
> [snip]

Yours was by far not a minimal testcase.  The above would have sufficed.

> If I test this program with the following bash script:
> #!/bin/bash
> echo "Performing a scan without using recursion"
> ./directory_scanner.exe c:\\coding\\cygwin\\c++\\ --non-recursive

Does your bash script have DOS line endings?  Try "d2u bashscript".

> the output is:
> Performing a scan without using recursion
> Ignoring unknown option --non-recursive.
> [Recursive listing snipped]
>
> If I compile the exactly the same code under MSVC++ 7.1 and invoke the
> executable it produces with the exactly the same script, the output is:
> Performing a scan without using recursion
> Will perform a non-recursive scan of directory c:\coding\cygwin\c++\.
> [Non-recursive listing snipped]
>
> What's going on here? Why doesn't strcmp() return 0 if compiled with g++
> with the input given above?

Apparently MSVCRT's startup code considers \r to be whitespace, and
Cygwin's doesn't.  Use Unix line endings, or put the script on a text
mount.
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor AT watson DOT ibm DOT com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"Happiness lies in being privileged to work hard for long hours in doing
whatever you think is worth doing."  -- Dr. Jubal Harshaw

---559023410-684387517-1095954697=:29444
Content-Type: text/plain; charset=us-ascii

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/
---559023410-684387517-1095954697=:29444--

- Raw text -


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