<div dir="ltr">Thanks for commenting.<br><div class="gmail_extra"><br><div class="gmail_quote">2014-10-21 0:20 GMT+08:00 Nikolay Sivov <span dir="ltr"><<a href="mailto:bunglehead@gmail.com" target="_blank">bunglehead@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000"><span>
    <div>On 10/20/2014 19:58, Shuai Meng wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">Thank you very much for commenting on this patch.<br>
        <div class="gmail_extra"><br>
          <div class="gmail_quote">2014-10-20 0:06 GMT+08:00 Nikolay
            Sivov <span dir="ltr"><<a href="mailto:bunglehead@gmail.com" target="_blank">bunglehead@gmail.com</a>></span>:<br>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
              <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
                +    str = SysAllocStringLen(NULL, 1023);<br>
                +    newstr = SysAllocStringLen(NULL, 1023);<br>
              </blockquote>
              Where this length comes from?<br>
              Well, I tested String on windows xp, and found that 1023
              was the limit, when given a number bigger than that, the
              output kept the length of 1023.<br>
            </blockquote>
          </div>
        </div>
      </div>
    </blockquote></span>
    Can you add this too as a test? In some compact way if possible.</div></blockquote><div>I tried again and I found that maybe you were right. The number of 1023 was got like this: I wrote vbscript with a common text editor on xp, and save it as xx.vbs, then double clicked it. I used this method and found that MsgBox String(1024, 65) only printed "a...(the length is 1023)....a".</div><div>Tragedy is today I write MsgBox Len(String(1024, 65)), and it prints 1024! It's the same with the other numbers greater than 1023!   So I  was cheated yesterday. The true limit may be 32768 * 16384 * 1.25, but I am not sure. I need to know the exact limit of the length of the string subtype, however experiments show difference with the documents of microsoft which claims the limit is about 2 billion.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><span><br>
    <blockquote type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">
            <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
              <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
                +    switch(V_VT(arg + 1)) {<br>
                +    case VT_NULL:<br>
                +        return MAKE_VBSERROR(VBSE_ILLEGAL_NULL_USE);<br>
                +    case VT_BSTR:<br>
                +        str = V_BSTR(arg + 1);<br>
                +        break;<br>
                +    case  VT_ARRAY|VT_BYREF|VT_VARIANT:<br>
                +        return DISP_E_TYPEMISMATCH;<br>
                +    default:<br>
                +        hres = to_short(arg + 1, &tmp);<br>
                +        if(FAILED(hres))<br>
                +            return hres;<br>
                +        str[0] = (char)tmp;<br>
                +        break;<br>
                +    }<br>
              </blockquote>
              You only need first character, right? Then why do you need
              a full BSTR pointer in VT_BSTR case? And assigning it<br>
              to 'str' you leak a previously allocated buffer. </blockquote>
            <div>So how do I get the first character of (arg + 1)?  How
              about this: str[0] = * V_BSTR(arg + 1)</div>
            <div>In fact I don't quite understand how SysAllocStringLen
              work, but I see it is used in the former function, so I
              think maybe it is necessary.</div>
          </div>
        </div>
      </div>
    </blockquote></span>
    What I don't get is why do you allocate 'str' at all, it should be
    just 'WCHAR ch;' variable.</div></blockquote><div>Yes, you are right. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><span><br>
    <blockquote type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">
            <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Why
              cast to (char)tmp?<br>
            </blockquote>
            <div>I think the type of str[0] is WCHAR, and tmp is an
              integer, shouldn't we make a cast? <br>
            </div>
          </div>
        </div>
      </div>
    </blockquote></span>
    WCHAR is 'unsigned short'. And it feels like it needs more tests for
    other variant types.</div></blockquote><div>Yes, such as VT_DATE, but problem is it can't be tested. Until now, '#' is still not supported in wine. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><span><br>
    <blockquote type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">
            <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><br>
              <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
                +    else if(len == 0)<br>
                +        newstr = '\0';<br>
              </blockquote>
              Same way you're losing pointer to allocated buffer.<br>
              <br>
              <br>
            </blockquote>
          </div>
          <br>
        </div>
      </div>
    </blockquote>
    <br>
  </span></div>

</blockquote></div><br></div></div>