diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-04-08 15:30:34 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-04-08 15:30:34 +0200 |
commit | d82e94307f1e073a0ccddb506ba5fff3da042b42 (patch) | |
tree | e87abfb6173c79b48a0e044db2ed581f4040bfeb /sal/textenc | |
parent | 641a823ce72c9fe761d56403be562bc8f03a88f4 (diff) |
tdf#88169: Do not return ..._INFO_SRCBUFFERTOSMALL when ..._FLAGS_FLUSH
...in accordance with
<http://www.openoffice.org/udk/cpp/man/spec/textconversion.html>
Change-Id: I62013f89c421722770123db8a5794e63d3572e6b
Diffstat (limited to 'sal/textenc')
-rw-r--r-- | sal/textenc/tcvtmb.cxx | 163 |
1 files changed, 84 insertions, 79 deletions
diff --git a/sal/textenc/tcvtmb.cxx b/sal/textenc/tcvtmb.cxx index acf02cc44401..6d0534bf37f3 100644 --- a/sal/textenc/tcvtmb.cxx +++ b/sal/textenc/tcvtmb.cxx @@ -87,113 +87,118 @@ sal_Size ImplDBCSToUnicode( const void* pData, SAL_UNUSED_PARAMETER void*, /* Source buffer to small */ if ( pSrcBuf +1 == pEndSrcBuf ) { - *pInfo |= RTL_TEXTTOUNICODE_INFO_ERROR | RTL_TEXTTOUNICODE_INFO_SRCBUFFERTOSMALL; - break; + if ( (nFlags & RTL_TEXTTOUNICODE_FLAGS_FLUSH) == 0 ) + { + *pInfo |= RTL_TEXTTOUNICODE_INFO_ERROR | RTL_TEXTTOUNICODE_INFO_SRCBUFFERTOSMALL; + break; + } } - - pSrcBuf++; - cTrail = (unsigned char)*pSrcBuf; - if ( (cTrail >= pLeadEntry->mnTrailStart) && (cTrail <= pLeadEntry->mnTrailEnd) ) - cConv = pLeadEntry->mpToUniTrailTab[cTrail-pLeadEntry->mnTrailStart]; else - cConv = 0; - - if ( !cConv ) { - /* EUDC Ranges */ - sal_uInt16 i; - const ImplDBCSEUDCData* pEUDCTab = pConvertData->mpEUDCTab; - for ( i = 0; i < pConvertData->mnEUDCCount; i++ ) + pSrcBuf++; + cTrail = (unsigned char)*pSrcBuf; + if ( (cTrail >= pLeadEntry->mnTrailStart) && (cTrail <= pLeadEntry->mnTrailEnd) ) + cConv = pLeadEntry->mpToUniTrailTab[cTrail-pLeadEntry->mnTrailStart]; + else + cConv = 0; + + if ( !cConv ) { - if ( (cLead >= pEUDCTab->mnLeadStart) && - (cLead <= pEUDCTab->mnLeadEnd) ) + /* EUDC Ranges */ + sal_uInt16 i; + const ImplDBCSEUDCData* pEUDCTab = pConvertData->mpEUDCTab; + for ( i = 0; i < pConvertData->mnEUDCCount; i++ ) { - if ( (cTrail >= pEUDCTab->mnTrail1Start) && - (cTrail <= pEUDCTab->mnTrail1End) ) + if ( (cLead >= pEUDCTab->mnLeadStart) && + (cLead <= pEUDCTab->mnLeadEnd) ) { - cConv = pEUDCTab->mnUniStart+ - ((cLead-pEUDCTab->mnLeadStart)*pEUDCTab->mnTrailRangeCount)+ - (cTrail-pEUDCTab->mnTrail1Start); - break; - } - else - { - sal_uInt16 nTrailCount = pEUDCTab->mnTrail1End-pEUDCTab->mnTrail1Start+1; - if ( (pEUDCTab->mnTrailCount >= 2) && - (cTrail >= pEUDCTab->mnTrail2Start) && - (cTrail <= pEUDCTab->mnTrail2End) ) + if ( (cTrail >= pEUDCTab->mnTrail1Start) && + (cTrail <= pEUDCTab->mnTrail1End) ) { cConv = pEUDCTab->mnUniStart+ - ((cLead-pEUDCTab->mnLeadStart)*pEUDCTab->mnTrailRangeCount)+ - nTrailCount+ - (cTrail-pEUDCTab->mnTrail2Start); + ((cLead-pEUDCTab->mnLeadStart)*pEUDCTab->mnTrailRangeCount)+ + (cTrail-pEUDCTab->mnTrail1Start); break; } else { - nTrailCount = pEUDCTab->mnTrail2End-pEUDCTab->mnTrail2Start+1; - if ( (pEUDCTab->mnTrailCount >= 3) && - (cTrail >= pEUDCTab->mnTrail3Start) && - (cTrail <= pEUDCTab->mnTrail3End) ) + sal_uInt16 nTrailCount = pEUDCTab->mnTrail1End-pEUDCTab->mnTrail1Start+1; + if ( (pEUDCTab->mnTrailCount >= 2) && + (cTrail >= pEUDCTab->mnTrail2Start) && + (cTrail <= pEUDCTab->mnTrail2End) ) { cConv = pEUDCTab->mnUniStart+ + ((cLead-pEUDCTab->mnLeadStart)*pEUDCTab->mnTrailRangeCount)+ + nTrailCount+ + (cTrail-pEUDCTab->mnTrail2Start); + break; + } + else + { + nTrailCount = pEUDCTab->mnTrail2End-pEUDCTab->mnTrail2Start+1; + if ( (pEUDCTab->mnTrailCount >= 3) && + (cTrail >= pEUDCTab->mnTrail3Start) && + (cTrail <= pEUDCTab->mnTrail3End) ) + { + cConv = pEUDCTab->mnUniStart+ ((cLead-pEUDCTab->mnLeadStart)*pEUDCTab->mnTrailRangeCount)+ nTrailCount+ (cTrail-pEUDCTab->mnTrail3Start); - break; + break; + } } } } - } - pEUDCTab++; - } - - if ( !cConv ) - { - /* We compare the full range of the trail we defined, */ - /* which can often be greater than the limit. We do this */ - /* so that extensions that don't consider encodings */ - /* correctly treat double-byte characters as a single */ - /* character as much as possible. */ - - if (cLead < pConvertData->mnLeadStart - || cLead > pConvertData->mnLeadEnd - || cTrail < pConvertData->mnTrailStart - || cTrail > pConvertData->mnTrailEnd) - { - *pInfo |= RTL_TEXTTOUNICODE_INFO_INVALID; - if ( (nFlags & RTL_TEXTTOUNICODE_FLAGS_INVALID_MASK) == RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR ) - { - *pInfo |= RTL_TEXTTOUNICODE_INFO_ERROR; - break; - } - else if ( (nFlags & RTL_TEXTTOUNICODE_FLAGS_INVALID_MASK) == RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE ) - { - pSrcBuf++; - continue; - } - else - cConv = RTL_TEXTENC_UNICODE_REPLACEMENT_CHARACTER; + pEUDCTab++; } - else + + if ( !cConv ) { - *pInfo |= RTL_TEXTTOUNICODE_INFO_MBUNDEFINED; - if ( (nFlags & RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_MASK) == RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR ) - { - *pInfo |= RTL_TEXTTOUNICODE_INFO_ERROR; - break; - } - else if ( (nFlags & RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_MASK) == RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_IGNORE ) + /* We compare the full range of the trail we defined, */ + /* which can often be greater than the limit. We do this */ + /* so that extensions that don't consider encodings */ + /* correctly treat double-byte characters as a single */ + /* character as much as possible. */ + + if (cLead < pConvertData->mnLeadStart + || cLead > pConvertData->mnLeadEnd + || cTrail < pConvertData->mnTrailStart + || cTrail > pConvertData->mnTrailEnd) { - pSrcBuf++; - continue; + *pInfo |= RTL_TEXTTOUNICODE_INFO_INVALID; + if ( (nFlags & RTL_TEXTTOUNICODE_FLAGS_INVALID_MASK) == RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR ) + { + *pInfo |= RTL_TEXTTOUNICODE_INFO_ERROR; + break; + } + else if ( (nFlags & RTL_TEXTTOUNICODE_FLAGS_INVALID_MASK) == RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE ) + { + pSrcBuf++; + continue; + } + else + cConv = RTL_TEXTENC_UNICODE_REPLACEMENT_CHARACTER; } - else - cConv = RTL_TEXTENC_UNICODE_REPLACEMENT_CHARACTER; } } } + if ( !cConv ) + { + *pInfo |= RTL_TEXTTOUNICODE_INFO_MBUNDEFINED; + if ( (nFlags & RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_MASK) == RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR ) + { + *pInfo |= RTL_TEXTTOUNICODE_INFO_ERROR; + break; + } + else if ( (nFlags & RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_MASK) == RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_IGNORE ) + { + pSrcBuf++; + continue; + } + else + cConv = RTL_TEXTENC_UNICODE_REPLACEMENT_CHARACTER; + } } if ( pDestBuf == pEndDestBuf ) |