-
-
Notifications
You must be signed in to change notification settings - Fork 706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for Issue 7648. #3138
Fix for Issue 7648. #3138
Conversation
|
Can you add a unittest for this situation? |
|
I loaded master.phobos and compiled phobos.lib. I try to compile with new phobos.lib. In case of execution I receive an error. Windows 7 (32), cp1251. This error is and in 65 and 66 and 67 versions dmd. I correct this error the following patch in stdio.d |
|
Added a simple unit test. |
|
@mgwasus so you are saying that this patch does NOT fix your issue? |
|
to mgwasus: WideCharToMultiByte convert to local code page. So this may fail on windows with cp1251: In any case, I think that your patch for "fopen" makes sense. Because now we can not use "fopen" on windows, if the file name contains non-ASCII characters. |
|
I think mgwasus offered an alternative solution. |
|
I'm going to defer to others on this regarding whether this fixes the issue, as language support is not my forte, but the implementation seems sound to me. |
|
This PR is the implementation of @CyberShadow -s suggestion, from 7648 thread:
Maybe he could check? |
|
Woops. Based on unittest in std\stdio.d:1219 fopen opens the file in FILE_SHARE_READ + FILE_SHARE_WRITE. I will fix it. |
|
Hi,
About this patch:
|
|
I'll be ready for the second round on Monday. |
|
The functions that are explicitely mapped from Unicode back to the bad multibyte versions by the DMC runtime are CreateFile, DeleteFile, MoveFile, GetFileAttributes, SetFileAttributes, CreateDirectory, RemoveDirectory, FindFirstFile, FindNextFile, GetCurrentDirectory, SetCurrentDirectory, CreateProcess, GetCommandLine and GetModuleFileName. So there are quite a few other C runtime functions other than fopen that fail to work with non-ascii characters. |
|
I think DMC still supports MS-DOS, but as D supports XP and up, maybe @WalterBright would be OK with a DM libc branch/fork for D. |
|
The DOS versions would not be affected, but some early Windows version might. For full compatibility a runtime check for availability of the W-Versions could be added, too. |
|
If you have time to handle this, I think you should email Walter Bright and get the code. |
|
Actually I've got it a few years ago as part of the commercial compiler version, but never tried to build it. I'll have a look... |
|
I have loaded function _wfopen () from msvcrt.dll using functions LoadLibrary and GetProcAddress. This loaded dynamically function fine works with wide lines and creates files with any names. Thus, precisely mistake in _wfopen from dmc. It is strange, why such serious mistake is not corrected till now. |
|
Yeah, by now it's not a secret that DM libc's "wide" functions simply convert the wide strings down to ANSI (and not even doing any sort of Unicode/codepage conversion, but simply by casting each wchar_t to a char). |
|
The dmc lib does a WideCharToMultiByte conversion, but that only works for characters in the current code page. |
…indows GUI application
|
Unicode winapi is supported on win9x through MSLU |
Cent-ify std.traits.
fix Issue 14422 - std.process: Pipes do not append to files on Win64
…s-14408 fix Issue 14408 - std.process: Can't start interactive process from Wind...
|
As I understand it, we waiting for a reply Walter Bright. |
|
Ping @rainers |
|
Sorry, I didn't hear back from @WalterBright regarding my second version. I don't know if it is ignored or accepted. |
|
Sorry, I'd overlooked it. Will check it out. |
|
dmd does not support Windows versions prior to XP (and not sure if we officially dumped XP or not). Hence, there is no need to deal with MSLU. There never was anyway - prior versions of Phobos handled Win95 correctly, but this support was removed. I.e. just go ahead and call the Windows 'W' functions. dmc does need to support Win95, but it'd be better to just work around it in Phobos. |
I'm not sure we can implement this completely in Phobos. We need to basically completely reimplement |
|
"a+" implemented by FILE_APPEND_DATA | GENERIC_READ flags. |
Nice, didn't know that. I don't see this documented on MSDN anywhere. |
On MSDN CreateFile i found comment
In any case, on vanilla dmd(v2.067.1) and ldc(0.15.2-beta1) read+write with "a+" also does not working. My testcase Can't check result on DPaste because ldc result: I do not correctly understand the mode "a+"? |
|
Mmm... I checked with tutorialspoint's DMD64 v2.066. Got: Apparently, it is a problem only on windows. |
Walter has built a new version of snn.lib with the patches, it is already in the dmc package found here http://www.digitalmars.com/download/freecompiler.html. This should fix _wfopen, _wunlink, _wrename, _wmkdir, _wrmdir and a few more. |
|
Thank you. I looked at the name of the archive dm857c.zip, rather than the content. And I did not notice the update. |
|
With the new DMC everything is working fine on the master branch (and on 2.067.1 to). Thanks to the preparatory steps in #788. I close this PR. And opened a new one to perform the cleanup doc's info about Issue 7648. |
Which link on that page includes the new |
|
Hmm... That is, the link to the old version again. Although previously it was new. |
|
http://ftp.digitalmars.com/snn.lib - new version of snn.lib. |
|
Would be nice to have permanent links to specific versions... I guess I'll just nab it from recent DMD zip files. |
This fixes Issue 7648 - std.stdio expects file names to be encoded in CP_ACP on Windows instead of UTF-8.