//----------------------------------------------------------------------------- // Peek size of sting to come, check memory bound //----------------------------------------------------------------------------- int CUtlBufferEditor::PeekStringLength() { if ( !IsValid() ) return 0; // Eat preceeding whitespace int nOffset = 0; if ( IsText() ) { nOffset = PeekWhiteSpace( nOffset ); } int nStartingOffset = nOffset; do { int nPeekAmount = 128; // NOTE: Add 1 for the terminating zero! if ( !CheckArbitraryPeekGet( nOffset, nPeekAmount ) ) { if ( nOffset == nStartingOffset ) return 0; return nOffset - nStartingOffset + 1; } const char *pTest = (const char *)PeekGet( nOffset ); if ( !IsText() ) { for ( int i = 0; i < nPeekAmount; ++i ) { // The +1 here is so we eat the terminating 0 if ( pTest[i] == 0 ) return (i + nOffset - nStartingOffset + 1); } } else { for ( int i = 0; i < nPeekAmount; ++i ) { // The +1 here is so we eat the terminating 0 if ( isspace((unsigned char)pTest[i]) || (pTest[i] == 0) ) return (i + nOffset - nStartingOffset + 1); } } nOffset += nPeekAmount; } while ( true ); }
//----------------------------------------------------------------------------- // Reads a null-terminated string //----------------------------------------------------------------------------- void CUtlBufferEditor::GetString( char* pString, int nMaxChars ) { if (!IsValid()) { *pString = 0; return; } if ( nMaxChars == 0 ) { nMaxChars = INT_MAX; } // Remember, this *includes* the null character // It will be 0, however, if the buffer is empty. int nLen = PeekStringLength(); if ( IsText() ) { EatWhiteSpace(); } if ( nLen == 0 ) { *pString = 0; m_Error |= GET_OVERFLOW; return; } // Strip off the terminating NULL if ( nLen <= nMaxChars ) { Get( pString, nLen - 1 ); pString[ nLen - 1 ] = 0; } else { Get( pString, nMaxChars - 1 ); pString[ nMaxChars - 1 ] = 0; SeekGet( SEEK_CURRENT, nLen - 1 - nMaxChars ); } // Read the terminating NULL in binary formats if ( !IsText() ) { VerifyEquals( GetChar(), 0 ); } }
void CUtlBufferEditor::PutDelimitedString( CUtlCharConversion *pConv, const char *pString ) { if ( !IsText() || !pConv ) { PutString( pString ); return; } if ( WasLastCharacterCR() ) { PutTabs(); } Put( pConv->GetDelimiter(), pConv->GetDelimiterLength() ); int nLen = pString ? Q_strlen( pString ) : 0; for ( int i = 0; i < nLen; ++i ) { PutDelimitedCharInternal( pConv, pString[i] ); } if ( WasLastCharacterCR() ) { PutTabs(); } Put( pConv->GetDelimiter(), pConv->GetDelimiterLength() ); }
BOOL CMyBCGPProp::TextToVar(const CString& strText) { BOOL bRet = CBCGPProp::TextToVar(strText); if (bRet) { if ((m_dwFlags & PROP_HAS_SPIN) && m_varValue.vt == VT_INT) { if (m_varValue.intVal < m_nMinValue) { m_varValue.intVal = m_nMinValue; } if (m_varValue.intVal > m_nMaxValue) { m_varValue.intVal = m_nMaxValue; } } else if (IsText()) { if (strText.Find('-') != -1) { CString strNewText(strText); strNewText.Replace('-', '_'); m_varValue = (LPCTSTR)strNewText; } } } return bRet; }
void TSorterListItem::Init() { // Set DataType based on entry_ref BFile theFile; if ( theFile.SetTo(&m_EntryRef, B_READ_WRITE) == B_OK ) { // Create node BNodeInfo nodeInfo(&theFile); if (nodeInfo.InitCheck() == B_NO_ERROR) { if (IsAudio(nodeInfo)) m_DataType = kAudioType; else if (IsImage(nodeInfo)) m_DataType = kPictureType; else if (IsText(nodeInfo)) m_DataType = kTextType; else if (IsVideo(nodeInfo)) m_DataType = kVideoType; } else { m_DataType = kUnknownType; } theFile.Unset(); } }
bool CUtlInplaceBuffer::InplaceGetLinePtr( char **ppszInBufferPtr, int *pnLineLength ) { Assert( IsText() && !ContainsCRLF() ); int nLineLen = PeekLineLength(); if ( nLineLen <= 1 ) { SeekGet( SEEK_TAIL, 0 ); return false; } -- nLineLen; // because it accounts for putting a terminating null-character char *pszLine = ( char * ) const_cast< void * >( PeekGet() ); SeekGet( SEEK_CURRENT, nLineLen ); // Set the out args if ( ppszInBufferPtr ) *ppszInBufferPtr = pszLine; if ( pnLineLength ) *pnLineLength = nLineLen; return true; }
PRBool nsAccUtils::IsTextInterfaceSupportCorrect(nsIAccessible *aAccessible) { PRBool foundText = PR_FALSE; nsCOMPtr<nsIAccessibleDocument> accDoc = do_QueryInterface(aAccessible); if (accDoc) { // Don't test for accessible docs, it makes us create accessibles too // early and fire mutation events before we need to return PR_TRUE; } nsCOMPtr<nsIAccessible> child, nextSibling; aAccessible->GetFirstChild(getter_AddRefs(child)); while (child) { if (IsText(child)) { foundText = PR_TRUE; break; } child->GetNextSibling(getter_AddRefs(nextSibling)); child.swap(nextSibling); } if (foundText) { // found text child node nsCOMPtr<nsIAccessibleText> text = do_QueryInterface(aAccessible); if (!text) return PR_FALSE; } return PR_TRUE; }
PRInt32 nsAccUtils::TextLength(nsIAccessible *aAccessible) { if (!IsText(aAccessible)) return 1; nsRefPtr<nsAccessNode> accNode = nsAccUtils::QueryAccessNode(aAccessible); nsIFrame *frame = accNode->GetFrame(); if (frame && frame->GetType() == nsAccessibilityAtoms::textFrame) { // Ensure that correct text length is calculated (with non-rendered // whitespace chars not counted). nsIContent *content = frame->GetContent(); if (content) { PRUint32 length; nsresult rv = nsHyperTextAccessible:: ContentToRenderedOffset(frame, content->TextLength(), &length); return NS_SUCCEEDED(rv) ? static_cast<PRInt32>(length) : -1; } } // For list bullets (or anything other accessible which would compute its own // text. They don't have their own frame. // XXX In the future, list bullets may have frame and anon content, so // we should be able to remove this at that point nsRefPtr<nsAccessible> acc(nsAccUtils::QueryAccessible(aAccessible)); nsAutoString text; acc->AppendTextTo(text, 0, PR_UINT32_MAX); // Get all the text return text.Length(); }
PRBool nsAccUtils::IsTextInterfaceSupportCorrect(nsAccessible *aAccessible) { PRBool foundText = PR_FALSE; nsCOMPtr<nsIAccessibleDocument> accDoc = do_QueryObject(aAccessible); if (accDoc) { // Don't test for accessible docs, it makes us create accessibles too // early and fire mutation events before we need to return PR_TRUE; } PRInt32 childCount = aAccessible->GetChildCount(); for (PRint32 childIdx = 0; childIdx < childCount; childIdx++) { nsAccessible *child = GetChildAt(childIdx); if (IsText(child)) { foundText = PR_TRUE; break; } } if (foundText) { // found text child node nsCOMPtr<nsIAccessibleText> text = do_QueryObject(aAccessible); if (!text) return PR_FALSE; } return PR_TRUE; }
//----------------------------------------------------------------------------- // This version of PeekStringLength converts \" to \\ and " to \, etc. // It also reads a " at the beginning and end of the string //----------------------------------------------------------------------------- int CUtlBufferEditor::PeekDelimitedStringLength( CUtlCharConversion *pConv, bool bActualSize ) { if ( !IsText() || !pConv ) return PeekStringLength(); // Eat preceeding whitespace int nOffset = 0; if ( IsText() ) { nOffset = PeekWhiteSpace( nOffset ); } if ( !PeekStringMatch( nOffset, pConv->GetDelimiter(), pConv->GetDelimiterLength() ) ) return 0; // Try to read ending ", but don't accept \" int nActualStart = nOffset; nOffset += pConv->GetDelimiterLength(); int nLen = 1; // Starts at 1 for the '\0' termination do { if ( PeekStringMatch( nOffset, pConv->GetDelimiter(), pConv->GetDelimiterLength() ) ) break; if ( !CheckPeekGet( nOffset, 1 ) ) break; char c = *(const char*)PeekGet( nOffset ); ++nLen; ++nOffset; if ( c == pConv->GetEscapeChar() ) { int nLength = pConv->MaxConversionLength(); if ( !CheckArbitraryPeekGet( nOffset, nLength ) ) break; pConv->FindConversion( (const char*)PeekGet(nOffset), &nLength ); nOffset += nLength; } } while (true); return bActualSize ? nLen : nOffset - nActualStart + pConv->GetDelimiterLength() + 1; }
void CUtlBufferEditor::PutDelimitedChar( CUtlCharConversion *pConv, char c ) { if ( !IsText() || !pConv ) { PutChar( c ); return; } PutDelimitedCharInternal( pConv, c ); }
// reparse point is an address within html that we can // can feed to HtmlPullParser() to start parsing from that point const char *HtmlToken::GetReparsePoint() const { if (IsStartTag() || IsEmptyElementEndTag()) return s - 1; if (IsEndTag()) return s - 2; if (IsText()) return s; CrashIf(true); // don't call us on error tokens return NULL; }
void CMyBCGPProp::OnClickButton(CPoint point) { CBCGPProp::OnClickButton(point); if (IsText()) { ASSERT_VALID(this); ASSERT_VALID(m_pWndList); ASSERT_VALID(m_pWndInPlace); ASSERT(::IsWindow(m_pWndInPlace->GetSafeHwnd())); m_bButtonIsDown = TRUE; m_bButtonIsHighlighted = FALSE; Redraw(); CString strPath = (LPCTSTR)(_bstr_t)m_varValue; BOOL bUpdate = FALSE; CMulTextEditDlg dlg; dlg.SetText(strPath); if (dlg.DoModal() == IDOK) { bUpdate = TRUE; strPath = dlg.GetText(); } if (bUpdate) { if (strPath.Find('-') != -1) { strPath.Replace('-', '_'); } if (m_pWndInPlace != NULL) { m_pWndInPlace->SetWindowText(strPath); } m_varValue = (LPCTSTR)strPath; } m_bButtonIsDown = FALSE; Redraw(); if (m_pWndInPlace != NULL) { m_pWndInPlace->SetFocus(); } else { m_pWndList->SetFocus(); } } }
//----------------------------------------------------------------------------- // Eats whitespace //----------------------------------------------------------------------------- void CUtlBufferEditor::EatWhiteSpace() { if ( IsText() && IsValid() ) { while ( CheckGet( sizeof(char) ) ) { if ( !isspace( *(const unsigned char*)PeekGet() ) ) break; m_Get += sizeof(char); } } }
//----------------------------------------------------------------------------- // Writes a null-terminated string //----------------------------------------------------------------------------- void CUtlBufferEditor::PutString( const char* pString ) { if (!IsText()) { if ( pString ) { // Not text? append a null at the end. size_t nLen = Q_strlen( pString ) + 1; Put( pString, nLen * sizeof(char) ); return; } else { PutTypeBin<char>( 0 ); } } else if (pString) { int nTabCount = ( m_Flags & AUTO_TABS_DISABLED ) ? 0 : m_nTab; if ( nTabCount > 0 ) { if ( WasLastCharacterCR() ) { if ( !IsDirectiveLine( pString ) ) PutTabs(); } const char* pEndl = strchr( pString, '\n' ); while ( pEndl ) { size_t nSize = (size_t)pEndl - (size_t)pString + sizeof(char); Put( pString, nSize ); pString = pEndl + 1; if ( *pString ) { if ( !IsDirectiveLine( pString ) ) PutTabs(); pEndl = strchr( pString, '\n' ); } else { pEndl = NULL; } } } size_t nLen = Q_strlen( pString ); if ( nLen ) { Put( pString, nLen * sizeof(char) ); } } }
//----------------------------------------------------------------------------- // Peeks how much whitespace to eat //----------------------------------------------------------------------------- int CUtlBufferEditor::PeekWhiteSpace( int nOffset ) { if ( !IsText() || !IsValid() ) return 0; while ( CheckPeekGet( nOffset, sizeof(char) ) ) { if ( !isspace( *(unsigned char*)PeekGet( nOffset ) ) ) break; nOffset += sizeof(char); } return nOffset; }
void CUtlBufferEditor::GetDelimitedString( CUtlCharConversion *pConv, char *pString, int nMaxChars ) { if ( !IsText() || !pConv ) { GetString( pString, nMaxChars ); return; } if (!IsValid()) { *pString = 0; return; } if ( nMaxChars == 0 ) { nMaxChars = INT_MAX; } EatWhiteSpace(); if ( !PeekStringMatch( 0, pConv->GetDelimiter(), pConv->GetDelimiterLength() ) ) return; // Pull off the starting delimiter SeekGet( SEEK_CURRENT, pConv->GetDelimiterLength() ); int nRead = 0; while ( IsValid() ) { if ( PeekStringMatch( 0, pConv->GetDelimiter(), pConv->GetDelimiterLength() ) ) { SeekGet( SEEK_CURRENT, pConv->GetDelimiterLength() ); break; } char c = GetDelimitedCharInternal( pConv ); if ( nRead < nMaxChars ) { pString[nRead] = c; ++nRead; } } if ( nRead >= nMaxChars ) { nRead = nMaxChars - 1; } pString[nRead] = '\0'; }
BOOL HSCurKeyInfo::IsBlock() { if( IsText() ) { return FALSE; } if( MakeMarket(m_cCode.m_cCodeType) == STOCK_MARKET && MakeMainMarket(m_cCode.m_cCodeType) > (STOCK_MARKET|SZ_BOURSE) ) { return TRUE; } return FALSE; }
//--------------------------------------------------------------------------- // void NFTM::Variable::Dump(NFTM::OutputStream *os) { if (os) { //os->Write("****** Variable::Dump is BROKEN *****\n"); os->Write("\t\tvar %s is %s%s\n", Name(), IsNull() ? "null " : "", Kind()); if (!IsNull() && IsText()) { char minibuf[64 + 1]; NFTM::StrCopy(minibuf, u.text->text, 64); char *s = minibuf; while (*s && *s != '\n') { s++; } *s = 0; os->Write("\t\t\t%s\n", minibuf); } } }
void CMyBCGPProp::GetResultShort(CString& strValue) { if (m_lstShortOptions.GetCount() == 0) { return; } CString strShort; if (IsList()) { POSITION pos = m_lstShortOptions.FindIndex(GetSelectedOption()); if (pos == NULL) { ASSERT(FALSE); return; } strShort = m_lstShortOptions.GetAt(pos); } else { strShort = m_lstShortOptions.GetHead(); } if (!strShort.IsEmpty()) { CString strFormatProperty = FormatProperty(); if (IsText()) { if (!strFormatProperty.IsEmpty()) { strValue += STR_SHORT_PREFIX + strShort + STR_SHORT_TEXT_FALG + strFormatProperty; } } else { strValue += STR_SHORT_PREFIX + strShort + (IsList() ? _T("") : FormatProperty()); } if (m_pBuddyProp) { strValue += m_pBuddyProp->FormatProperty(); } } }
PRUint32 nsAccUtils::TextLength(nsAccessible *aAccessible) { if (!IsText(aAccessible)) return 1; nsTextAccessible* textLeaf = aAccessible->AsTextLeaf(); if (textLeaf) return textLeaf->Text().Length(); // For list bullets (or anything other accessible which would compute its own // text. They don't have their own frame. // XXX In the future, list bullets may have frame and anon content, so // we should be able to remove this at that point nsAutoString text; aAccessible->AppendTextTo(text); // Get all the text return text.Length(); }
//----------------------------------------------------------------------------- // Modifies the buffer to be binary or text; Blows away the buffer and the CONTAINS_CRLF value. //----------------------------------------------------------------------------- void CUtlBufferEditor::SetBufferType( bool bIsText, bool bContainsCRLF ) { #ifdef _DEBUG // If the buffer is empty, there is no opportunity for this stuff to fail if ( TellMaxPut() != 0 ) { if ( IsText() ) { if ( bIsText ) { Assert( ContainsCRLF() == bContainsCRLF ); } else { Assert( ContainsCRLF() ); } } else { if ( bIsText ) { Assert( bContainsCRLF ); } } } #endif if ( bIsText ) { m_Flags |= TEXT_BUFFER; } else { m_Flags &= ~TEXT_BUFFER; } if ( bContainsCRLF ) { m_Flags |= CONTAINS_CRLF; } else { m_Flags &= ~CONTAINS_CRLF; } }
//----------------------------------------------------------------------------- // Eats C++ style comments //----------------------------------------------------------------------------- bool CUtlBufferEditor::EatCPPComment() { if ( IsText() && IsValid() ) { // If we don't have a a c++ style comment next, we're done const char *pPeek = (const char *)PeekGet( 2 * sizeof(char), 0 ); if ( !pPeek || ( pPeek[0] != '/' ) || ( pPeek[1] != '/' ) ) return false; // Deal with c++ style comments m_Get += 2; // read complete line for ( char c = GetChar(); IsValid(); c = GetChar() ) { if ( c == '\n' ) break; } return true; } return false; }
//----------------------------------------------------------------------------- // Reads up to and including the first \n //----------------------------------------------------------------------------- void CUtlBufferEditor::GetLine( char* pLine, int nMaxChars ) { Assert( IsText() && !ContainsCRLF() ); if ( !IsValid() ) { *pLine = 0; return; } if ( nMaxChars == 0 ) { nMaxChars = INT_MAX; } // Remember, this *includes* the null character // It will be 0, however, if the buffer is empty. int nLen = PeekLineLength(); if ( nLen == 0 ) { *pLine = 0; m_Error |= GET_OVERFLOW; return; } // Strip off the terminating NULL if ( nLen <= nMaxChars ) { Get( pLine, nLen - 1 ); pLine[ nLen - 1 ] = 0; } else { Get( pLine, nMaxChars - 1 ); pLine[ nMaxChars - 1 ] = 0; SeekGet( SEEK_CURRENT, nLen - 1 - nMaxChars ); } }
int CUtlBufferEditor::VaScanf( const char* pFmt, va_list list ) { Assert( pFmt ); if ( m_Error || !IsText() ) return 0; int numScanned = 0; int nLength; char c; char* pEnd; while ( c = *pFmt++ ) { // Stop if we hit the end of the buffer if ( m_Get >= TellMaxPut() ) { m_Error |= GET_OVERFLOW; break; } switch (c) { case ' ': // eat all whitespace EatWhiteSpace(); break; case '%': { // Conversion character... try to convert baby! char type = *pFmt++; if (type == 0) return numScanned; switch(type) { case 'c': { char* ch = va_arg( list, char * ); if ( CheckPeekGet( 0, sizeof(char) ) ) { *ch = *(const char*)PeekGet(); ++m_Get; } else { *ch = 0; return numScanned; } } break; case 'i': case 'd': { int* i = va_arg( list, int * ); // NOTE: This is not bullet-proof; it assumes numbers are < 128 characters nLength = 128; if ( !CheckArbitraryPeekGet( 0, nLength ) ) { *i = 0; return numScanned; } *i = strtol( (char*)PeekGet(), &pEnd, 10 ); int nBytesRead = (int)( pEnd - (char*)PeekGet() ); if ( nBytesRead == 0 ) return numScanned; m_Get += nBytesRead; } break; case 'x': { int* i = va_arg( list, int * ); // NOTE: This is not bullet-proof; it assumes numbers are < 128 characters nLength = 128; if ( !CheckArbitraryPeekGet( 0, nLength ) ) { *i = 0; return numScanned; } *i = strtol( (char*)PeekGet(), &pEnd, 16 ); int nBytesRead = (int)( pEnd - (char*)PeekGet() ); if ( nBytesRead == 0 ) return numScanned; m_Get += nBytesRead; } break; case 'u': { unsigned int* u = va_arg( list, unsigned int *); // NOTE: This is not bullet-proof; it assumes numbers are < 128 characters nLength = 128; if ( !CheckArbitraryPeekGet( 0, nLength ) ) { *u = 0; return numScanned; } *u = strtoul( (char*)PeekGet(), &pEnd, 10 ); int nBytesRead = (int)( pEnd - (char*)PeekGet() ); if ( nBytesRead == 0 ) return numScanned; m_Get += nBytesRead; } break; case 'f': { float* f = va_arg( list, float *); // NOTE: This is not bullet-proof; it assumes numbers are < 128 characters nLength = 128; if ( !CheckArbitraryPeekGet( 0, nLength ) ) { *f = 0.0f; return numScanned; } *f = (float)strtod( (char*)PeekGet(), &pEnd ); int nBytesRead = (int)( pEnd - (char*)PeekGet() ); if ( nBytesRead == 0 ) return numScanned; m_Get += nBytesRead; } break; case 's': { char* s = va_arg( list, char * ); GetString( s ); } break; default: { // unimplemented scanf type Assert(0); return numScanned; } break; } ++numScanned; } break; default: { // Here we have to match the format string character // against what's in the buffer or we're done. if ( !CheckPeekGet( 0, sizeof(char) ) ) return numScanned; if ( c != *(const char*)PeekGet() ) return numScanned; ++m_Get; } } } return numScanned; }
bool ON_Annotation::IsDimension() const { if( IsText() || IsLeader()) return FALSE; return TRUE; }
bool TRefFilter::Filter(const entry_ref *theRef, BNode *theNode, struct stat_beos *theStat, const char *mimetype) { // Create BEntry and traverse to get source ref BEntry entry(theRef, true); if (entry.InitCheck() != B_OK) { ERROR("TRefFilter::Filter() - Error creating BEntry -\n"); return false; } // Create a node from ref BNode localNode(theRef); if (localNode.InitCheck() != B_OK) { ERROR("TRefFilter::Filter() - Error creating BNode -\n"); return false; } // Get node info BNodeInfo nodeInfo(&localNode); if (nodeInfo.InitCheck() != B_OK) { ERROR("TRefFilter::Filter() - Error getting BNodeInfo -\n"); return false; } // Get stat info struct stat st; if (entry.GetStat(&st) != B_OK) { ERROR("TRefFilter::Filter() - Error getting stat info -\n"); return false; } switch(m_FilterType) { case kAudioFilter: { // Allow directories if (S_ISDIR(st.st_mode)) return true; // Allow audio if (IsAudio(nodeInfo)) return true; } break; case kAudioAiffFilter: { // Allow directories if (S_ISDIR(st.st_mode)) return true; // Allow audio if (IsAudioAiff(nodeInfo)) return true; } break; case kImageFilter: { // Allow directories if (S_ISDIR(st.st_mode)) return true; // Allow images if (IsImage(nodeInfo)) return true; } break; case kTextFilter: { // Allow directories if (S_ISDIR(st.st_mode)) return true; // Allow text if (IsText(nodeInfo)) return true; } break; case kVideoFilter: { // Allow directories if (S_ISDIR(st.st_mode)) return true; // Allow video if (IsVideo(nodeInfo)) return true; } break; case kCueSheetFilter: { // Allow directories if (S_ISDIR(st.st_mode)) return true; // Allow CueSheets if (IsCueSheet(nodeInfo)) return true; } break; case kDirectoryFilter: { // Allow directories if (S_ISDIR(st.st_mode)) return true; } break; default: return true; } // Fail if we get here return false; }
char CUtlBufferEditor::GetDelimitedChar( CUtlCharConversion *pConv ) { if ( !IsText() || !pConv ) return GetChar( ); return GetDelimitedCharInternal( pConv ); }
bool ON_Annotation::IsDimension() const { if( IsText() || IsLeader()) return false; return true; }
//----------------------------------------------------------------------------- // Converts a buffer from a CRLF buffer to a CR buffer (and back) // Returns false if no conversion was necessary (and outBuf is left untouched) // If the conversion occurs, outBuf will be cleared. //----------------------------------------------------------------------------- bool CUtlBufferEditor::ConvertCRLF( CUtlBufferEditor &outBuf ) { if ( !IsText() || !outBuf.IsText() ) return false; if ( ContainsCRLF() == outBuf.ContainsCRLF() ) return false; int nInCount = TellMaxPut(); outBuf.Purge(); outBuf.EnsureCapacity( nInCount ); bool bFromCRLF = ContainsCRLF(); // Start reading from the beginning int nGet = TellGet(); int nPut = TellPut(); int nGetDelta = 0; int nPutDelta = 0; const char *pBase = (const char*)Base(); int nCurrGet = 0; while ( nCurrGet < nInCount ) { const char *pCurr = &pBase[nCurrGet]; if ( bFromCRLF ) { const char *pNext = Q_strnistr( pCurr, "\r\n", nInCount - nCurrGet ); if ( !pNext ) { outBuf.Put( pCurr, nInCount - nCurrGet ); break; } int nBytes = (size_t)pNext - (size_t)pCurr; outBuf.Put( pCurr, nBytes ); outBuf.PutChar( '\n' ); nCurrGet += nBytes + 2; if ( nGet >= nCurrGet - 1 ) { --nGetDelta; } if ( nPut >= nCurrGet - 1 ) { --nPutDelta; } } else { const char *pNext = Q_strnchr( pCurr, '\n', nInCount - nCurrGet ); if ( !pNext ) { outBuf.Put( pCurr, nInCount - nCurrGet ); break; } int nBytes = (size_t)pNext - (size_t)pCurr; outBuf.Put( pCurr, nBytes ); outBuf.PutChar( '\r' ); outBuf.PutChar( '\n' ); nCurrGet += nBytes + 1; if ( nGet >= nCurrGet ) { ++nGetDelta; } if ( nPut >= nCurrGet ) { ++nPutDelta; } } } Assert( nPut + nPutDelta <= outBuf.TellMaxPut() ); outBuf.SeekGet( SEEK_HEAD, nGet + nGetDelta ); outBuf.SeekPut( SEEK_HEAD, nPut + nPutDelta ); return true; }