* Possible Bug ???
@ 2011-11-01 23:37 Leon Vanderploeg
2011-11-02 8:47 ` Csaba Raduly
0 siblings, 1 reply; 2+ messages in thread
From: Leon Vanderploeg @ 2011-11-01 23:37 UTC (permalink / raw)
To: cygwin
Greetings,
This issue is making my head flat from pounding it against the wall. It appears to be a bug in Cygwin 1.7, but I can't say with any certainty. I've been down too many dead end trails already...
With cygwin 1.7.5, file name with a special characters such as ñ (n with tidle above it) fail be properly extracted from a WIN32_FIND_DATA structure with findFirstFile (or findNextFile).
To set up a simple test scenario, I created a file in C:\Testing named Mañana.docx. I compiled the code at the end of this message on Cygwin 1.7.9 with GCC version 3.4.4.
On the Cygwin 1.7.9 machine, it returns:
$ ./winfilestat3.exe
hFind filename is ***Ma▒ana.docx***
hFind file name stat return code is: -1
character 0 is M
character 0 is signed int 77, hex 4d
character 1 is a
character 1 is signed int 97, hex 61
character 2 is ▒
character 2 is signed int -15, hex fffffff1
character 3 is a
character 3 is signed int 97, hex 61
character 4 is n
character 4 is signed int 110, hex 6e
character 5 is a
character 5 is signed int 97, hex 61
character 6 is .
character 6 is signed int 46, hex 2e
character 7 is d
character 7 is signed int 100, hex 64
character 8 is o
character 8 is signed int 111, hex 6f
character 9 is c
character 9 is signed int 99, hex 63
NOTE that the ñ is interpreted as ▒, and the stat fails.
I moved the compiled program to another PC running Cygwin 1.5.25. It CORRECTLY returns:
bash-3.2$ ./winfilestat3.exe
hFind filename is ***Mañana.docx***
hFind file name stat return code is: 0
character 0 is M
character 0 is signed int 77, hex 4d
character 1 is a
character 1 is signed int 97, hex 61
character 2 is ñ
character 2 is signed int -15, hex fffffff1
character 3 is a
character 3 is signed int 97, hex 61
character 4 is n
character 4 is signed int 110, hex 6e
character 5 is a
character 5 is signed int 97, hex 61
character 6 is .
character 6 is signed int 46, hex 2e
bash-3.2$
Note the ñ is correct, and the stat succeeds.
Is this a bug, or do I need to set something up special on Cygwin 1.7 to get it to work the way it used to?
Thanks in advance,
Leon
**start of code****************************
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
#include <winbase.h>
#include <sys/types.h>
#include <fcntl.h>
#include <dirent.h>
#include <curl/curl.h>
#include <pthread.h>
#include <wctype.h>
#include <sys/wait.h>
#include <cygwin/wait.h>
struct stat fileStat;
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
int main(int argc, char **argv)
{
char filename[100];
int rtn, i;
char chr;
/*
if(argc != 2)
{
printf("arg1 is required\n");
return(1);
}
*/
/*
//hard coded cyg
wcscpy(filename, "/cygdrive/c/Testing/Mañana.docx");
printf("Hard coded cyg filename is ***%s***\n",filename);
rtn = wstat(filename,&fileStat);
printf("hard coded cyg file name stat return code is: %d\n", rtn);
for ( i = 0 ; i < wcslen(filename) ; i++ )
{
printf("character %d is %c\n", i, filename[i] );
printf("character %d is signed int %d, hex %x \n", i, filename[i], filename[i] );
}
//hard coded Win
wcscpy(filename, "C:\\Testing\\Mañana.docx");
printf("Hard coded win filename is ***%s***\n",filename);
rtn = wstat(filename,&fileStat);
printf("hard coded win file name stat return code is: %d\n", rtn);
for ( i = 0 ; i < wcslen(filename) ; i++ )
{
printf("character %d is %c\n", i, filename[i] );
printf("character %d is signed int %d, hex %x \n", i, filename[i], filename[i] );
}
*/
/*
//from argv[1]
strcpy(filename, argv[1]);
printf("argv[1] is\n%s\n", filename);
rtn = stat(filename,&fileStat);
printf("argv[1] stat return code is: %d\n", rtn);
for ( i = 0 ; i < wcslen(filename) ; i++ )
{
printf("character %d is %c\n", i, filename[i] );
printf("character %d is signed int %d, hex %x \n", i, filename[i], filename[i] );
}
printf("arg1 is ***%s***\n", argv[1]);
rtn = stat(argv[1],&fileStat);
printf("exit code is: %d\n", rtn);
*/
//find file
char pathSearch[300];
sprintf(pathSearch, "C:\\Testing\\*.docx");
hFind = FindFirstFile(pathSearch, &FindFileData);
if (hFind == INVALID_HANDLE_VALUE)
{
printf("Warning: No .docx file found in the directory. Exiting.\n");
return(1);
}
strcpy(filename, FindFileData.cFileName);
printf("hFind filename is ***%s***\n",filename);
rtn = stat(filename,&fileStat);
printf("hFind file name stat return code is: %d\n", rtn);
for ( i = 0 ; i < wcslen(filename) ; i++ )
{
printf("character %d is %c\n", i, filename[i] );
printf("character %d is signed int %d, hex %x \n", i, filename[i], filename[i] );
}
return(0);
}
**end of code****************************
Leon Vanderploeg
Cell 303-877-9654
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Possible Bug ???
2011-11-01 23:37 Possible Bug ??? Leon Vanderploeg
@ 2011-11-02 8:47 ` Csaba Raduly
0 siblings, 0 replies; 2+ messages in thread
From: Csaba Raduly @ 2011-11-02 8:47 UTC (permalink / raw)
To: cygwin, leonv
Hi,
On Wed, Nov 2, 2011 at 12:36 AM, Leon Vanderploeg wrote:
> Greetings,
>
> This issue is making my head flat from pounding it against the wall. It appears to be a bug in Cygwin 1.7, but I can't say with any certainty. I've been down too many dead end trails already...
>
> With cygwin 1.7.5, file name with a special characters such as ñ (n with tidle above it) fail be properly extracted from a WIN32_FIND_DATA structure with findFirstFile (or findNextFile).
>
> To set up a simple test scenario, I created a file in C:\Testing named Mañana.docx. I compiled the code at the end of this message on Cygwin 1.7.9 with GCC version 3.4.4.
Your program does not compile:
$ gcc-3 t.cc
In file included from t.cc:12:
/usr/include/curl/curl.h:126: error: `SOCKET' does not name a type
/usr/include/curl/curl.h:228: error: `curl_socket_t' has not been declared
/usr/include/curl/curl.h:242: error: typedef `curl_socket_t' is
initialized (use __typeof__ instead)
/usr/include/curl/curl.h:242: error: `curl_opensocket_callback' was
not declared in this scope
/usr/include/curl/curl.h:242: error: expected `,' or `;' before '(' token
t.cc: In function `int main(int, char**)':
t.cc:111: error: `wcslen' undeclared (first use this function)
t.cc:111: error: (Each undeclared identifier is reported only once for
each function it appears in.)
$ gcc-3 -mno-cygwin t.cc
t.cc:12:23: curl/curl.h: No such file or directory
t.cc:16:22: sys/wait.h: No such file or directory
t.cc:17:25: cygwin/wait.h: No such file or directory
t.cc: In function `int main(int, char**)':
t.cc:111: error: cannot convert `char*' to `const wchar_t*' for
argument `1' to `size_t wcslen(const wchar_t*)'
You are mixing narrow and wide strings. This will not work.
Csaba
--
GCS a+ e++ d- C++ ULS$ L+$ !E- W++ P+++$ w++$ tv+ b++ DI D++ 5++
The Tao of math: The numbers you can count are not the real numbers.
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-11-02 8:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-01 23:37 Possible Bug ??? Leon Vanderploeg
2011-11-02 8:47 ` Csaba Raduly
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).