delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/09/23/12:19:47

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
Message-ID: <002201c4a189$1b126b80$b200a8c0@mindcooler>
From: =?iso-8859-1?Q?Mikael_=C5sberg?= <mikas493 AT student DOT liu DOT se>
To: <cygwin AT cygwin DOT com>
References: <007501c4a172$a96aa9e0$b200a8c0 AT mindcooler> <Pine DOT GSO DOT 4 DOT 61 DOT 0409231148470 DOT 29444 AT slinky DOT cs DOT nyu DOT edu>
Subject: Re: Same code, same script, different results
Date: Thu, 23 Sep 2004 18:19:28 +0200
MIME-Version: 1.0

> 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
>

Lol, you're right, Igor, that test case was far from minimal. Should've cut 
it down, of course. On the other hand, I often see people cutting away what 
they think is unrelated code or whatnot, when, in fact, they are cutting 
away the cause of their problems when posting questions.

Anyway, it's working as expected now. But to tell the truth I don't know 
exactly what the problem was. I tinkered some with the script, did a make 
clean ; make (again), and, voila, it works. I'm glad that it works, but it's 
a bit annoying not understanding what the problem and the rememdy was.

Thanks for on-list replies and private emails

/ Mikael

PS. I remember once having the cygwin mailing list in "usenet style format" 
in outlook express, but I can't for the life of me remember what I did. 
Anyone knows what I'm talking about? DS. 



--
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/

- Raw text -


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