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/ |\ _,,,---,,_ [EMAIL PROTECTED] ZZZzz /,`.-'`' -. ;-;;,_ [EMAIL PROTECTED] |,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
-- 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/