VirtualBox

Changeset 104773 in vbox for trunk/src/VBox


Ignore:
Timestamp:
May 24, 2024 12:56:32 PM (6 months ago)
Author:
vboxsync
Message:

Shared Clipboard: Make ShClUtf16LFLenUtf8 to provide proper length in characters for LF -> CRLF conversion, bugref:10694.

Also rename the function into ShClUtf16CalcNormalizedEolToCRLFLength and update documentation.

Location:
trunk/src/VBox
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/darwin/VBoxClient/VBoxClientClipboardGuestToHost.cpp

    r100108 r104773  
    234234
    235235    size_t cwcTmp; /* (includes a schwarzenegger character) */
    236     int rc = ShClUtf16LFLenUtf8(pwszData, cbData / sizeof(RTUTF16), &cwcTmp);
     236    int rc = ShClUtf16CalcNormalizedEolToCRLFLength(pwszData, cbData / sizeof(RTUTF16), &cwcTmp);
    237237    AssertRCReturn(rc, rc);
    238238
  • trunk/src/VBox/GuestHost/SharedClipboard/clipboard-common.cpp

    r104762 r104773  
    668668    size_t   cchDst;
    669669
    670     int rc = ShClUtf16LFLenUtf8(pcwszSrc, cwcSrc, &cchDst);
     670    int rc = ShClUtf16CalcNormalizedEolToCRLFLength(pcwszSrc, cwcSrc, &cchDst);
    671671    if (RT_SUCCESS(rc))
    672672    {
     
    838838}
    839839
    840 int ShClUtf16LFLenUtf8(PCRTUTF16 pcwszSrc, size_t cwSrc, size_t *pchLen)
     840int ShClUtf16CalcNormalizedEolToCRLFLength(PCRTUTF16 pcwszSrc, size_t cwSrc, size_t *pchLen)
    841841{
    842842    AssertPtrReturn(pcwszSrc, VERR_INVALID_POINTER);
     
    856856    {
    857857        /* Check for a single line feed */
    858         if (pcwszSrc[i] == VBOX_SHCL_LINEFEED)
     858        if (   pcwszSrc[i] == VBOX_SHCL_LINEFEED
     859            && (i == 0 || pcwszSrc[i - 1] != VBOX_SHCL_CARRIAGERETURN))
     860        {
    859861            ++cLen;
     862        }
    860863#ifdef RT_OS_DARWIN
    861864        /* Check for a single carriage return (MacOS) */
    862         if (pcwszSrc[i] == VBOX_SHCL_CARRIAGERETURN)
     865        if (   pcwszSrc[i] == VBOX_SHCL_CARRIAGERETURN
     866            && (i + 1 >= cwcSrc || pcwszSrc[i + 1] != VBOX_SHCL_LINEFEED))
     867        {
    863868            ++cLen;
     869        }
    864870#endif
    865871        if (pcwszSrc[i] == 0)
  • trunk/src/VBox/HostServices/SharedClipboard/darwin-pasteboard.cpp

    r103148 r104773  
    313313                Assert(cwcSrc == RTUtf16Len(pwszSrc));
    314314                size_t cwcDst = 0;
    315                 rc = ShClUtf16LFLenUtf8(pwszSrc, cwcSrc, &cwcDst);
     315                rc = ShClUtf16CalcNormalizedEolToCRLFLength(pwszSrc, cwcSrc, &cwcDst);
    316316                if (RT_SUCCESS(rc))
    317317                {
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette