CharLowerW does the right thing. But I still need Windows.h to use it :)<br><br><div class="gmail_quote">On Mon, Oct 3, 2011 at 8:43 PM, Bryce Cogswell <span dir="ltr"><<a href="mailto:bryceco@gmail.com">bryceco@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div style="word-wrap:break-word"><div>Locale-specific is not what we want, but I don't believe Windows exposes an alternative API that does what we want. (Does CharLower give a different answer than tolower?)</div>
<div><br></div><div>However, looking over the FileManager code a little more I'm not even sure using the path is the best solution, it seems it would be better to use inode like the unix code does. Windows doesn't support inode (the s_ino field in stat), but it does have nFileIndexHigh/nFileIndexLow which are exposed via ::GetFileInformationByHandle and is basically the same thing. This would require refactoring FileSystemStatCache to use a new structure in place of stat that could be shared between Windows and Unix. This would be a lot of small changes but seems like it would be fairly straightforward.</div>
<div><br></div><br><div><div><div></div><div class="h5"><div>On Oct 3, 2011, at 9:21 AM, Nikola Smiljanic wrote:</div><br></div></div><blockquote type="cite"><div><div></div><div class="h5">towlower doesn't seem to work with my test string in Cyrillic. This function does locale-specific conversion, is this what we want?<div>
<br></div><div>Here's the whole thing, with all the calls to ::stat replaced with llvm::sys::fs::Stat.<br>
<br><div class="gmail_quote">On Fri, Sep 30, 2011 at 8:04 PM, Bryce Cogswell <span dir="ltr"><<a href="mailto:bryceco@gmail.com" target="_blank">bryceco@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div>You can use _iswupper and _towlower instead of CharLowerBuffW. They don't require windows.h and work with /Za.</div><div><div></div><div><br><div><div>On Sep 30, 2011, at 12:24 AM, Nikola Smiljanic wrote:</div>
<br><blockquote type="cite">I tried to do the conversion to lowercase inside GetFullPath by adding an additional bool parameter to this function. It's not perfect but seems much better than repeating the whole UTF8 to UTF16 and UTF16 to UTF8 conversion again. The problem I have is with access to CharLowerBuffW. I need Windows.h for this function but when I try to include it I get a bunch of errors because Language Extensions are disabled, /Za switch. Do I just enable them and include Windows.h inside and #ifdef section?<br>
<br><div class="gmail_quote">On Thu, Sep 29, 2011 at 7:57 AM, Bryce Cogswell <span dir="ltr"><<a href="mailto:bryceco@gmail.com" target="_blank">bryceco@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div>I agree they are broken on all platforms. However, FileManager.cpp already contains an #if WIN32 conditional around the code calling LowercaseString, so you can use MultiByteToWideChar and CharLowerBuffW directly there, and not call the LowercaseString function. I don't think there are any other places where LowercaseString is called with non-ascii data, so you can punt on fixing it for now.</div>
<div><div></div><div><div><br></div><div><div>On Sep 28, 2011, at 10:11 PM, Nikola Smiljanic wrote:</div><br><blockquote type="cite">I have a problem with Lowercase and Uppercase functions. These are broken on all platforms, not only Window, so I can't just #ifdef and use <span style="color:rgb(34, 34, 34);font-family:arial, sans-serif;font-size:13px;background-color:rgb(255, 255, 255)">CharLowerBuffW. I</span> need a portable way to convert from UTF8 to UTF16. There is set of functions inside clang/Basic/ConvertUTF, but LLVM can't depend on this. What do I do?<br>
<br><div class="gmail_quote">On Tue, Sep 27, 2011 at 5:09 AM, Bryce Cogswell <span dir="ltr"><<a href="mailto:bryceco@yahoo.com" target="_blank">bryceco@yahoo.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204, 204, 204);border-left-style:solid;padding-left:1ex">
<div style="word-wrap:break-word"><div>I think the assert you have for _stat64i32 is fine. It is a constant expression so should compile to nothing, and the chance of the definition changing is pretty much zero.</div><div>
<br></div><div>LowercaseString appears to be used by ASM printers where the output is expected to be ASCII, and then some WIN32-conditioned code in FileManager.cpp. I hate to say it but you'll probably need to convert the UTF-8 paths to wide char, lower case it using CharLowerBuffW (since it needs to match the casing rules used by NTFS), and then convert back to UTF-8. </div>
<div><br></div><div>If you need to be pedantic about recognizing whether two paths are the same on Windows you also need to call GetFullPathName in order to expand any 8.3 path components, but this is an expensive function so I wouldn't do it unless absolutely necessary.</div>
<div><br></div><div>There is also a call to _fullpath in there that needs to be changed to _wfullpath.</div><div><br></div><div>The rest of the patch looks good.</div><br><div><div><div></div><div><div>On Sep 23, 2011, at 9:57 AM, Nikola Smiljanic wrote:</div>
<br></div></div><blockquote type="cite"><div><div></div><div>Here's a new patch that fixes all the issues mentioned before. Note that this isn't final, I didn't want to replace all calls to ::stat so that it's easier to review.<div>
<br></div><div>I have only one more questions:</div>
<div><br></div><div>1. _wopen accepts _stat64i32 instead of stat structure. These two are exactly the same, the only difference is that stat uses time_t and _stat64i32 uses __time64_t (time_t is a typedef for __time64_t but this depends on one more macro). I check to see that size of these two structures is the same, but is there something more that I could do? I'd also like to use some kind of static assert instead of runtime assert.</div>
<div><br></div><div>I've also noticed that function LowercaseString (the same applies to UppercaseString) doesn't work with UTF8 input. It's calling isupper and tolower and these functions can't handle UTF8. This should get a new issue probably?<br>
<br><div class="gmail_quote">On Wed, Sep 21, 2011 at 1:41 AM, Aaron Ballman <span dir="ltr"><<a href="mailto:aaron@aaronballman.com" target="_blank">aaron@aaronballman.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>On Tue, Sep 20, 2011 at 4:15 PM, Nikola Smiljanic <<a href="mailto:popizdeh@gmail.com" target="_blank">popizdeh@gmail.com</a>> wrote:<br>
> OK since this approach makes sense I'll shoot with my questions :)<br>
> 1. Where should get_utf8_argv go and is the name of this function OK? Right<br>
> now the function is inside llvm::sys::fs namespace because I need access to<br>
> Windows.h, should I leave it there.<br>
<br>
</div>I don't think it belongs there as it has nothing to do with the file<br>
system. However, I'm not familiar enough to know of a better place<br>
for it either. Hopefully someone else can chime in with an idea.<br>
<div><br>
> 2. get_utf8_argv allocates new char** representing utf8 argv, should I<br>
> deallocate this inside driver.cpp, use std::vector<std::string> instead or<br>
> ignore the allocation completely?<br>
<br>
</div>Perhaps some SmallVectors would make sense here? An inner one to hold<br>
the arg data, and an outer one to hold the list of inner vectors.<br>
Then you can do the cleanup within the call.<br>
<div><br>
> 3. There is an #ifdef inside driver.cpp right now that I don't like.<br>
> get_utf8_argv works for windows only, but I could change the function to<br>
> accept argv and return it as vector of utf8 strings. It would convert char*<br>
> to std::string on unix and use GetCommandLine + utf8 conversion on windows.<br>
<br>
</div>I have no concrete opinion one way or the other on this.<br>
<div><br>
> 4. Should I wrap functions like ::fstat and ::close for consistency even<br>
> though they don't work with paths?<br>
<br>
</div>I don't believe so.<br>
<div><br>
> I'll fix everything that is formatting related. You're right, current patch<br>
> has Open only for windows but I'll add the other one as well.<br>
<br>
</div>Thanks for the help!<br>
<font color="#888888"><br>
~Aaron<br>
</font></blockquote></div><br></div>
</div></div><span><clang.patch></span><span><llvm.patch></span></blockquote></div><br></div></blockquote></div><br>
</blockquote></div><br></div></div></div></blockquote></div><br>
</blockquote></div><br></div></div></div></blockquote></div><br></div>
</div></div><span><clang.patch></span><span><llvm.patch></span></blockquote></div><br></div></blockquote></div><br>